diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/_meta.json b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/_meta.json index c521420e8823..55e8f9377b0b 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/_meta.json +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "commit": "1be09531e4c6edeafde41d6562371566d39669e8", + "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.7", + "@autorest/modelerfour@4.24.3" ], - "commit": "50ed15bd61ac79f2368d769df0c207a00b9e099f", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/redhatopenshift/resource-manager/readme.md --multiapi --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/redhatopenshift/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.7 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/redhatopenshift/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/__init__.py index 580098c41dd4..bd784676913d 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/__init__.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/__init__.py @@ -14,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/_azure_red_hat_open_shift_client.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/_azure_red_hat_open_shift_client.py index 23b5f929e52b..822788f54ca7 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/_azure_red_hat_open_shift_client.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/_azure_red_hat_open_shift_client.py @@ -9,20 +9,17 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING - -from msrest import Deserializer, Serializer +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin from ._configuration import AzureRedHatOpenShiftClientConfiguration +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential class _SDKClient(object): @@ -43,9 +40,9 @@ class AzureRedHatOpenShiftClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :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 api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -56,7 +53,7 @@ class AzureRedHatOpenShiftClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2022-04-01' + DEFAULT_API_VERSION = '2022-09-04' _PROFILE_TAG = "azure.mgmt.redhatopenshift.AzureRedHatOpenShiftClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -67,12 +64,12 @@ class AzureRedHatOpenShiftClient(MultiApiClientMixin, _SDKClient): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - api_version=None, # type: Optional[str] - base_url="https://management.azure.com", # type: str - profile=KnownProfiles.default, # type: KnownProfiles - **kwargs # type: Any + credential: "TokenCredential", + subscription_id: str, + api_version: Optional[str]=None, + base_url: str = "https://management.azure.com", + profile: KnownProfiles=KnownProfiles.default, + **kwargs: Any ): self._config = AzureRedHatOpenShiftClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -92,6 +89,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2020-04-30: :mod:`v2020_04_30.models` * 2021-09-01-preview: :mod:`v2021_09_01_preview.models` * 2022-04-01: :mod:`v2022_04_01.models` + * 2022-09-04: :mod:`v2022_09_04.models` """ if api_version == '2020-04-30': from .v2020_04_30 import models @@ -102,8 +100,25 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-04-01': from .v2022_04_01 import models return models + elif api_version == '2022-09-04': + from .v2022_09_04 import models + return models raise ValueError("API version {} is not available".format(api_version)) + @property + def machine_pools(self): + """Instance depends on the API version: + + * 2022-09-04: :class:`MachinePoolsOperations` + """ + api_version = self._get_api_version('machine_pools') + if api_version == '2022-09-04': + from .v2022_09_04.operations import MachinePoolsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'machine_pools'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property def open_shift_clusters(self): """Instance depends on the API version: @@ -111,6 +126,7 @@ def open_shift_clusters(self): * 2020-04-30: :class:`OpenShiftClustersOperations` * 2021-09-01-preview: :class:`OpenShiftClustersOperations` * 2022-04-01: :class:`OpenShiftClustersOperations` + * 2022-09-04: :class:`OpenShiftClustersOperations` """ api_version = self._get_api_version('open_shift_clusters') if api_version == '2020-04-30': @@ -119,8 +135,25 @@ def open_shift_clusters(self): from .v2021_09_01_preview.operations import OpenShiftClustersOperations as OperationClass elif api_version == '2022-04-01': from .v2022_04_01.operations import OpenShiftClustersOperations as OperationClass + elif api_version == '2022-09-04': + from .v2022_09_04.operations import OpenShiftClustersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'open_shift_clusters'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def open_shift_versions(self): + """Instance depends on the API version: + + * 2022-09-04: :class:`OpenShiftVersionsOperations` + """ + api_version = self._get_api_version('open_shift_versions') + if api_version == '2022-09-04': + from .v2022_09_04.operations import OpenShiftVersionsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'open_shift_versions'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -130,6 +163,7 @@ def operations(self): * 2020-04-30: :class:`Operations` * 2021-09-01-preview: :class:`Operations` * 2022-04-01: :class:`Operations` + * 2022-09-04: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2020-04-30': @@ -138,8 +172,53 @@ def operations(self): from .v2021_09_01_preview.operations import Operations as OperationClass elif api_version == '2022-04-01': from .v2022_04_01.operations import Operations as OperationClass + elif api_version == '2022-09-04': + from .v2022_09_04.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def secrets(self): + """Instance depends on the API version: + + * 2022-09-04: :class:`SecretsOperations` + """ + api_version = self._get_api_version('secrets') + if api_version == '2022-09-04': + from .v2022_09_04.operations import SecretsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'secrets'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def sync_identity_providers(self): + """Instance depends on the API version: + + * 2022-09-04: :class:`SyncIdentityProvidersOperations` + """ + api_version = self._get_api_version('sync_identity_providers') + if api_version == '2022-09-04': + from .v2022_09_04.operations import SyncIdentityProvidersOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'sync_identity_providers'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def sync_sets(self): + """Instance depends on the API version: + + * 2022-09-04: :class:`SyncSetsOperations` + """ + api_version = self._get_api_version('sync_sets') + if api_version == '2022-09-04': + from .v2022_09_04.operations import SyncSetsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'sync_sets'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) def close(self): diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/_configuration.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/_configuration.py index 33bbccb96e67..6b5c810cdd62 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/_configuration.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/_configuration.py @@ -8,7 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies @@ -18,8 +18,6 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential class AzureRedHatOpenShiftClientConfiguration(Configuration): @@ -28,19 +26,18 @@ class AzureRedHatOpenShiftClientConfiguration(Configuration): 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 """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any ): - # type: (...) -> None if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -55,9 +52,8 @@ def __init__( def _configure( self, - **kwargs # type: Any + **kwargs: 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) diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/_serialization.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/_serialization.py new file mode 100644 index 000000000000..2c170e28dbca --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/_serialization.py @@ -0,0 +1,1967 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import Optional, Union, AnyStr, IO, Mapping + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore + +from typing import Dict, Any, cast + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # 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: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str + unicode_str = str + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset # type: ignore +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? 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) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) # type: ignore + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = unicode_str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError: + 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 = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_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): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :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) # type: ignore + return result + except ValueError: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_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 # type: ignore + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name # type: ignore + raise_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) # type: ignore + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_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): # type: ignore + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # 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)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) # type: ignore + 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) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_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): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) # type: ignore + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_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() # type: ignore + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_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) # type: ignore + 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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/aio/_azure_red_hat_open_shift_client.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/aio/_azure_red_hat_open_shift_client.py index 11ba3a9e93ec..cf447e486d14 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/aio/_azure_red_hat_open_shift_client.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/aio/_azure_red_hat_open_shift_client.py @@ -11,17 +11,15 @@ from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin +from .._serialization import Deserializer, Serializer from ._configuration import AzureRedHatOpenShiftClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -42,9 +40,9 @@ class AzureRedHatOpenShiftClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :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 api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -55,7 +53,7 @@ class AzureRedHatOpenShiftClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2022-04-01' + DEFAULT_API_VERSION = '2022-09-04' _PROFILE_TAG = "azure.mgmt.redhatopenshift.AzureRedHatOpenShiftClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -71,7 +69,7 @@ def __init__( api_version: Optional[str] = None, base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, - **kwargs # type: Any + **kwargs: Any ) -> None: self._config = AzureRedHatOpenShiftClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -91,6 +89,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2020-04-30: :mod:`v2020_04_30.models` * 2021-09-01-preview: :mod:`v2021_09_01_preview.models` * 2022-04-01: :mod:`v2022_04_01.models` + * 2022-09-04: :mod:`v2022_09_04.models` """ if api_version == '2020-04-30': from ..v2020_04_30 import models @@ -101,8 +100,25 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-04-01': from ..v2022_04_01 import models return models + elif api_version == '2022-09-04': + from ..v2022_09_04 import models + return models raise ValueError("API version {} is not available".format(api_version)) + @property + def machine_pools(self): + """Instance depends on the API version: + + * 2022-09-04: :class:`MachinePoolsOperations` + """ + api_version = self._get_api_version('machine_pools') + if api_version == '2022-09-04': + from ..v2022_09_04.aio.operations import MachinePoolsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'machine_pools'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property def open_shift_clusters(self): """Instance depends on the API version: @@ -110,6 +126,7 @@ def open_shift_clusters(self): * 2020-04-30: :class:`OpenShiftClustersOperations` * 2021-09-01-preview: :class:`OpenShiftClustersOperations` * 2022-04-01: :class:`OpenShiftClustersOperations` + * 2022-09-04: :class:`OpenShiftClustersOperations` """ api_version = self._get_api_version('open_shift_clusters') if api_version == '2020-04-30': @@ -118,8 +135,25 @@ def open_shift_clusters(self): from ..v2021_09_01_preview.aio.operations import OpenShiftClustersOperations as OperationClass elif api_version == '2022-04-01': from ..v2022_04_01.aio.operations import OpenShiftClustersOperations as OperationClass + elif api_version == '2022-09-04': + from ..v2022_09_04.aio.operations import OpenShiftClustersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'open_shift_clusters'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def open_shift_versions(self): + """Instance depends on the API version: + + * 2022-09-04: :class:`OpenShiftVersionsOperations` + """ + api_version = self._get_api_version('open_shift_versions') + if api_version == '2022-09-04': + from ..v2022_09_04.aio.operations import OpenShiftVersionsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'open_shift_versions'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -129,6 +163,7 @@ def operations(self): * 2020-04-30: :class:`Operations` * 2021-09-01-preview: :class:`Operations` * 2022-04-01: :class:`Operations` + * 2022-09-04: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2020-04-30': @@ -137,8 +172,53 @@ def operations(self): from ..v2021_09_01_preview.aio.operations import Operations as OperationClass elif api_version == '2022-04-01': from ..v2022_04_01.aio.operations import Operations as OperationClass + elif api_version == '2022-09-04': + from ..v2022_09_04.aio.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def secrets(self): + """Instance depends on the API version: + + * 2022-09-04: :class:`SecretsOperations` + """ + api_version = self._get_api_version('secrets') + if api_version == '2022-09-04': + from ..v2022_09_04.aio.operations import SecretsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'secrets'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def sync_identity_providers(self): + """Instance depends on the API version: + + * 2022-09-04: :class:`SyncIdentityProvidersOperations` + """ + api_version = self._get_api_version('sync_identity_providers') + if api_version == '2022-09-04': + from ..v2022_09_04.aio.operations import SyncIdentityProvidersOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'sync_identity_providers'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def sync_sets(self): + """Instance depends on the API version: + + * 2022-09-04: :class:`SyncSetsOperations` + """ + api_version = self._get_api_version('sync_sets') + if api_version == '2022-09-04': + from ..v2022_09_04.aio.operations import SyncSetsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'sync_sets'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) async def close(self): diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/aio/_configuration.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/aio/_configuration.py index 42e2e0d943f3..b93a5f8df98e 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/aio/_configuration.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/aio/_configuration.py @@ -26,9 +26,9 @@ class AzureRedHatOpenShiftClientConfiguration(Configuration): 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 """ @@ -36,7 +36,7 @@ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - **kwargs # type: Any + **kwargs: Any ) -> None: if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/models.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/models.py index 7d9f8183c1a9..2ffd6312570d 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/models.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/models.py @@ -4,4 +4,4 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from .v2022_04_01.models import * +from .v2022_09_04.models import * diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/__init__.py index a3faaf238d96..04ebd4beb61a 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/__init__.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AzureRedHatOpenShift4Client'] -# `._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 * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AzureRedHatOpenShift4Client", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_azure_red_hat_open_shift4_client.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_azure_red_hat_open_shift4_client.py index 8104e033c8fd..ff16686e0b58 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_azure_red_hat_open_shift4_client.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_azure_red_hat_open_shift4_client.py @@ -9,12 +9,11 @@ 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 . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import AzureRedHatOpenShift4ClientConfiguration from .operations import OpenShiftClustersOperations, Operations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class AzureRedHatOpenShift4Client: + +class AzureRedHatOpenShift4Client: # pylint: disable=client-accepts-api-version-keyword """Rest API for Azure Red Hat OpenShift 4. :ivar operations: Operations operations @@ -30,9 +30,9 @@ class AzureRedHatOpenShift4Client: :ivar open_shift_clusters: OpenShiftClustersOperations operations :vartype open_shift_clusters: azure.mgmt.redhatopenshift.v2020_04_30.operations.OpenShiftClustersOperations - :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 @@ -50,22 +50,21 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AzureRedHatOpenShift4ClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AzureRedHatOpenShift4ClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.open_shift_clusters = OpenShiftClustersOperations(self._client, self._config, self._serialize, self._deserialize) - + self.open_shift_clusters = OpenShiftClustersOperations( + 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 @@ -74,7 +73,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 @@ -87,15 +86,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> AzureRedHatOpenShift4Client + def __enter__(self) -> "AzureRedHatOpenShift4Client": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_configuration.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_configuration.py index 62f655748855..42190ab1bbdd 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_configuration.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_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 AzureRedHatOpenShift4ClientConfiguration(Configuration): # pylint: disabl 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 "2020-04-30". 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(AzureRedHatOpenShift4ClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-04-30") # type: str + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", "2020-04-30") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +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-redhatopenshift/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-redhatopenshift/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs # type: Any - ): - # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_metadata.json b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_metadata.json index c36c43a96eca..fb6106d7a3e3 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_metadata.json +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureRedHatOpenShift4ClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureRedHatOpenShift4ClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureRedHatOpenShift4ClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureRedHatOpenShift4ClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -100,4 +100,4 @@ "operations": "Operations", "open_shift_clusters": "OpenShiftClustersOperations" } -} \ No newline at end of file +} diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_patch.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_vendor.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_vendor.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,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 +23,5 @@ 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) diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_version.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_version.py index 59deb8c7263b..e5754a47ce68 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_version.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/__init__.py index eccb1597054c..796011f698f4 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/__init__.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._azure_red_hat_open_shift4_client import AzureRedHatOpenShift4Client -__all__ = ['AzureRedHatOpenShift4Client'] -# `._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 * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AzureRedHatOpenShift4Client", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/_azure_red_hat_open_shift4_client.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/_azure_red_hat_open_shift4_client.py index faebbdd00c5b..ebd3b893d9c4 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/_azure_red_hat_open_shift4_client.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/_azure_red_hat_open_shift4_client.py @@ -9,12 +9,11 @@ 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 .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import AzureRedHatOpenShift4ClientConfiguration from .operations import OpenShiftClustersOperations, Operations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class AzureRedHatOpenShift4Client: + +class AzureRedHatOpenShift4Client: # pylint: disable=client-accepts-api-version-keyword """Rest API for Azure Red Hat OpenShift 4. :ivar operations: Operations operations @@ -30,9 +30,9 @@ class AzureRedHatOpenShift4Client: :ivar open_shift_clusters: OpenShiftClustersOperations operations :vartype open_shift_clusters: azure.mgmt.redhatopenshift.v2020_04_30.aio.operations.OpenShiftClustersOperations - :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 @@ -50,22 +50,21 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AzureRedHatOpenShift4ClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AzureRedHatOpenShift4ClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.open_shift_clusters = OpenShiftClustersOperations(self._client, self._config, self._serialize, self._deserialize) - + self.open_shift_clusters = OpenShiftClustersOperations( + 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 @@ -74,7 +73,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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/_configuration.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/_configuration.py index c40446cd2aca..b01055c0259a 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/_configuration.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/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 AzureRedHatOpenShift4ClientConfiguration(Configuration): # pylint: disabl 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 "2020-04-30". 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(AzureRedHatOpenShift4ClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-04-30") # type: str + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", "2020-04-30") 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-redhatopenshift/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-redhatopenshift/{}".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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/_patch.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/operations/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/operations/__init__.py index 7ffcf7895ee8..70ea64711791 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/operations/__init__.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import Operations from ._open_shift_clusters_operations import OpenShiftClustersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'OpenShiftClustersOperations', + "Operations", + "OpenShiftClustersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/operations/_open_shift_clusters_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/operations/_open_shift_clusters_operations.py index 27db914f96ca..b4ad904b93cc 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/operations/_open_shift_clusters_operations.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/operations/_open_shift_clusters_operations.py @@ -6,87 +6,119 @@ # 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._open_shift_clusters_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_credentials_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._open_shift_clusters_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_credentials_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OpenShiftClustersOperations: - """OpenShiftClustersOperations 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 OpenShiftClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.redhatopenshift.v2020_04_30.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.redhatopenshift.v2020_04_30.aio.AzureRedHatOpenShift4Client`'s + :attr:`open_shift_clusters` 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.OpenShiftClusterList"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.OpenShiftCluster"]: """Lists OpenShift clusters in the specified subscription. The operation returns properties of each OpenShift cluster. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OpenShiftClusterList or the result of - cls(response) + :return: An iterator like instance of either OpenShiftCluster or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftClusterList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-04-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + cls: ClsType[_models.OpenShiftClusterList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterList"] 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) 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) @@ -97,16 +129,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OpenShiftClusterList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -116,57 +146,67 @@ 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.RedHatOpenShift/openShiftClusters"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters"} @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.OpenShiftClusterList"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.OpenShiftCluster"]: """Lists OpenShift clusters in the specified subscription and resource group. The operation returns properties of each OpenShift cluster. :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 OpenShiftClusterList or the result of - cls(response) + :return: An iterator like instance of either OpenShiftCluster or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftClusterList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-04-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + cls: ClsType[_models.OpenShiftClusterList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterList"] 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) 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) @@ -177,16 +217,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OpenShiftClusterList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -196,107 +234,124 @@ 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.RedHatOpenShift/openShiftClusters"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.OpenShiftCluster": + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.OpenShiftCluster: """Gets a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenShiftCluster, or the result of cls(response) + :return: OpenShiftCluster or the result of cls(response) :rtype: ~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftCluster"] 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', "2020-04-30") # type: str + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftCluster", + parameters: Union[_models.OpenShiftCluster, IO], **kwargs: Any - ) -> "_models.OpenShiftCluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftCluster"] + ) -> _models.OpenShiftCluster: 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', "2020-04-30") # 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(parameters, 'OpenShiftCluster') + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OpenShiftCluster") + + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -304,38 +359,124 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.OpenShiftCluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster + :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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftCluster", + parameters: Union[_models.OpenShiftCluster, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.OpenShiftCluster"]: + ) -> AsyncLROPoller[_models.OpenShiftCluster]: """Creates or updates a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str - :param parameters: The OpenShift cluster resource. - :type parameters: ~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster + :param parameters: The OpenShift cluster resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster 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 @@ -348,17 +489,17 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-04-30") # 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.OpenShiftCluster"] - 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: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, @@ -366,63 +507,71 @@ async def begin_create_or_update( parameters=parameters, 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('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", 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: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any + self, resource_group_name: str, resource_name: str, **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', "2020-04-30") # 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: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -432,23 +581,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns nothing. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -460,80 +606,100 @@ 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', "2020-04-30") # 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: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_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): + 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, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } async def _update_initial( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftClusterUpdate", + parameters: Union[_models.OpenShiftClusterUpdate, IO], **kwargs: Any - ) -> "_models.OpenShiftCluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftCluster"] + ) -> _models.OpenShiftCluster: 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', "2020-04-30") # 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(parameters, 'OpenShiftClusterUpdate') + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OpenShiftClusterUpdate") + + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -541,38 +707,124 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.OpenShiftClusterUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftClusterUpdate + :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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + The operation returns properties of a OpenShift cluster. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftClusterUpdate", + parameters: Union[_models.OpenShiftClusterUpdate, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.OpenShiftCluster"]: + ) -> AsyncLROPoller[_models.OpenShiftCluster]: """Creates or updates a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str - :param parameters: The OpenShift cluster resource. - :type parameters: ~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftClusterUpdate + :param parameters: The OpenShift cluster resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftClusterUpdate 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 @@ -585,17 +837,17 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-04-30") # 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.OpenShiftCluster"] - 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: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -603,90 +855,100 @@ async def begin_update( parameters=parameters, 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('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", 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: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } @distributed_trace_async async def list_credentials( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.OpenShiftClusterCredentials": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.OpenShiftClusterCredentials: """Lists credentials of an OpenShift cluster with the specified subscription, resource group and resource name. The operation returns the credentials. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenShiftClusterCredentials, or the result of cls(response) + :return: OpenShiftClusterCredentials or the result of cls(response) :rtype: ~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftClusterCredentials - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterCredentials"] 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', "2020-04-30") # type: str + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + cls: ClsType[_models.OpenShiftClusterCredentials] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OpenShiftClusterCredentials', pipeline_response) + deserialized = self._deserialize("OpenShiftClusterCredentials", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials"} # type: ignore - + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials" + } diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/operations/_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/operations/_operations.py index cbd2db4e6bf5..7a5bf80903ce 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/operations/_operations.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/operations/_operations.py @@ -6,81 +6,107 @@ # 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') + +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.redhatopenshift.v2020_04_30.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.redhatopenshift.v2020_04_30.aio.AzureRedHatOpenShift4Client`'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.OperationList"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available RP operations. The operation returns the RP operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationList or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2020_04_30.models.OperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2020_04_30.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-04-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] 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) 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) @@ -91,16 +117,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -110,8 +134,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.RedHatOpenShift/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.RedHatOpenShift/operations"} diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/operations/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/models/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/models/__init__.py index 9a3b9a2f511e..0ac56ca3b505 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/models/__init__.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/models/__init__.py @@ -25,33 +25,35 @@ from ._models_py3 import TrackedResource from ._models_py3 import WorkerProfile - -from ._azure_red_hat_open_shift4_client_enums import ( - ProvisioningState, - VMSize, - Visibility, -) +from ._azure_red_hat_open_shift4_client_enums import ProvisioningState +from ._azure_red_hat_open_shift4_client_enums import VMSize +from ._azure_red_hat_open_shift4_client_enums import Visibility +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'APIServerProfile', - 'CloudErrorBody', - 'ClusterProfile', - 'ConsoleProfile', - 'Display', - 'IngressProfile', - 'MasterProfile', - 'NetworkProfile', - 'OpenShiftCluster', - 'OpenShiftClusterCredentials', - 'OpenShiftClusterList', - 'OpenShiftClusterUpdate', - 'Operation', - 'OperationList', - 'Resource', - 'ServicePrincipalProfile', - 'TrackedResource', - 'WorkerProfile', - 'ProvisioningState', - 'VMSize', - 'Visibility', + "APIServerProfile", + "CloudErrorBody", + "ClusterProfile", + "ConsoleProfile", + "Display", + "IngressProfile", + "MasterProfile", + "NetworkProfile", + "OpenShiftCluster", + "OpenShiftClusterCredentials", + "OpenShiftClusterList", + "OpenShiftClusterUpdate", + "Operation", + "OperationList", + "Resource", + "ServicePrincipalProfile", + "TrackedResource", + "WorkerProfile", + "ProvisioningState", + "VMSize", + "Visibility", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/models/_azure_red_hat_open_shift4_client_enums.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/models/_azure_red_hat_open_shift4_client_enums.py index d88062dfc108..f5808017d0a0 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/models/_azure_red_hat_open_shift4_client_enums.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/models/_azure_red_hat_open_shift4_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """ProvisioningState represents a provisioning state. - """ +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ProvisioningState represents a provisioning state.""" ADMIN_UPDATING = "AdminUpdating" CREATING = "Creating" @@ -22,16 +20,16 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -class Visibility(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Visibility represents visibility. - """ + +class Visibility(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Visibility represents visibility.""" PRIVATE = "Private" PUBLIC = "Public" -class VMSize(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """VMSize represents a VM size. - """ + +class VMSize(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """VMSize represents a VM size.""" STANDARD_D2_S_V3 = "Standard_D2s_v3" STANDARD_D4_S_V3 = "Standard_D4s_v3" diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/models/_models_py3.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/models/_models_py3.py index 372d1a7b4e5d..bea3c975f780 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/models/_models_py3.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/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. @@ -6,18 +7,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._azure_red_hat_open_shift4_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class APIServerProfile(msrest.serialization.Model): +class APIServerProfile(_serialization.Model): """APIServerProfile represents an API server profile. - :ivar visibility: API server visibility (immutable). Possible values include: "Private", - "Public". + :ivar visibility: API server visibility (immutable). Known values are: "Private" and "Public". :vartype visibility: str or ~azure.mgmt.redhatopenshift.v2020_04_30.models.Visibility :ivar url: The URL to access the cluster API server (immutable). :vartype url: str @@ -26,21 +28,21 @@ class APIServerProfile(msrest.serialization.Model): """ _attribute_map = { - 'visibility': {'key': 'visibility', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, - 'ip': {'key': 'ip', 'type': 'str'}, + "visibility": {"key": "visibility", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "ip": {"key": "ip", "type": "str"}, } def __init__( self, *, - visibility: Optional[Union[str, "Visibility"]] = None, + visibility: Optional[Union[str, "_models.Visibility"]] = None, url: Optional[str] = None, ip: Optional[str] = None, **kwargs ): """ - :keyword visibility: API server visibility (immutable). Possible values include: "Private", + :keyword visibility: API server visibility (immutable). Known values are: "Private" and "Public". :paramtype visibility: str or ~azure.mgmt.redhatopenshift.v2020_04_30.models.Visibility :keyword url: The URL to access the cluster API server (immutable). @@ -48,13 +50,13 @@ def __init__( :keyword ip: The IP of the cluster API server (immutable). :paramtype ip: str """ - super(APIServerProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.visibility = visibility self.url = url self.ip = ip -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """CloudErrorBody represents the body of a cloud error. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -71,10 +73,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -83,7 +85,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -99,14 +101,14 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.redhatopenshift.v2020_04_30.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class ClusterProfile(msrest.serialization.Model): +class ClusterProfile(_serialization.Model): """ClusterProfile represents a cluster profile. :ivar pull_secret: The pull secret for the cluster (immutable). @@ -120,10 +122,10 @@ class ClusterProfile(msrest.serialization.Model): """ _attribute_map = { - 'pull_secret': {'key': 'pullSecret', 'type': 'str'}, - 'domain': {'key': 'domain', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'resource_group_id': {'key': 'resourceGroupId', 'type': 'str'}, + "pull_secret": {"key": "pullSecret", "type": "str"}, + "domain": {"key": "domain", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "resource_group_id": {"key": "resourceGroupId", "type": "str"}, } def __init__( @@ -145,14 +147,14 @@ def __init__( :keyword resource_group_id: The ID of the cluster resource group (immutable). :paramtype resource_group_id: str """ - super(ClusterProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.pull_secret = pull_secret self.domain = domain self.version = version self.resource_group_id = resource_group_id -class ConsoleProfile(msrest.serialization.Model): +class ConsoleProfile(_serialization.Model): """ConsoleProfile represents a console profile. :ivar url: The URL to access the cluster console (immutable). @@ -160,24 +162,19 @@ class ConsoleProfile(msrest.serialization.Model): """ _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, } - def __init__( - self, - *, - url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, url: Optional[str] = None, **kwargs): """ :keyword url: The URL to access the cluster console (immutable). :paramtype url: str """ - super(ConsoleProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url -class Display(msrest.serialization.Model): +class Display(_serialization.Model): """Display represents the display details of an operation. :ivar provider: Friendly name of the resource provider. @@ -191,10 +188,10 @@ class Display(msrest.serialization.Model): """ _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__( @@ -216,88 +213,83 @@ def __init__( :keyword description: Friendly name of the operation. :paramtype description: str """ - super(Display, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class IngressProfile(msrest.serialization.Model): +class IngressProfile(_serialization.Model): """IngressProfile represents an ingress profile. :ivar name: The ingress profile name. Must be "default" (immutable). :vartype name: str - :ivar visibility: Ingress visibility (immutable). Possible values include: "Private", "Public". + :ivar visibility: Ingress visibility (immutable). Known values are: "Private" and "Public". :vartype visibility: str or ~azure.mgmt.redhatopenshift.v2020_04_30.models.Visibility :ivar ip: The IP of the ingress (immutable). :vartype ip: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'visibility': {'key': 'visibility', 'type': 'str'}, - 'ip': {'key': 'ip', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "visibility": {"key": "visibility", "type": "str"}, + "ip": {"key": "ip", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, - visibility: Optional[Union[str, "Visibility"]] = None, + visibility: Optional[Union[str, "_models.Visibility"]] = None, ip: Optional[str] = None, **kwargs ): """ :keyword name: The ingress profile name. Must be "default" (immutable). :paramtype name: str - :keyword visibility: Ingress visibility (immutable). Possible values include: "Private", - "Public". + :keyword visibility: Ingress visibility (immutable). Known values are: "Private" and "Public". :paramtype visibility: str or ~azure.mgmt.redhatopenshift.v2020_04_30.models.Visibility :keyword ip: The IP of the ingress (immutable). :paramtype ip: str """ - super(IngressProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.visibility = visibility self.ip = ip -class MasterProfile(msrest.serialization.Model): +class MasterProfile(_serialization.Model): """MasterProfile represents a master profile. - :ivar vm_size: The size of the master VMs (immutable). Possible values include: - "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3". + :ivar vm_size: The size of the master VMs (immutable). Known values are: "Standard_D2s_v3", + "Standard_D4s_v3", and "Standard_D8s_v3". :vartype vm_size: str or ~azure.mgmt.redhatopenshift.v2020_04_30.models.VMSize :ivar subnet_id: The Azure resource ID of the master subnet (immutable). :vartype subnet_id: str """ _attribute_map = { - 'vm_size': {'key': 'vmSize', 'type': 'str'}, - 'subnet_id': {'key': 'subnetId', 'type': 'str'}, + "vm_size": {"key": "vmSize", "type": "str"}, + "subnet_id": {"key": "subnetId", "type": "str"}, } def __init__( - self, - *, - vm_size: Optional[Union[str, "VMSize"]] = None, - subnet_id: Optional[str] = None, - **kwargs + self, *, vm_size: Optional[Union[str, "_models.VMSize"]] = None, subnet_id: Optional[str] = None, **kwargs ): """ - :keyword vm_size: The size of the master VMs (immutable). Possible values include: - "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3". + :keyword vm_size: The size of the master VMs (immutable). Known values are: "Standard_D2s_v3", + "Standard_D4s_v3", and "Standard_D8s_v3". :paramtype vm_size: str or ~azure.mgmt.redhatopenshift.v2020_04_30.models.VMSize :keyword subnet_id: The Azure resource ID of the master subnet (immutable). :paramtype subnet_id: str """ - super(MasterProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.vm_size = vm_size self.subnet_id = subnet_id -class NetworkProfile(msrest.serialization.Model): +class NetworkProfile(_serialization.Model): """NetworkProfile represents a network profile. :ivar pod_cidr: The CIDR used for OpenShift/Kubernetes Pods (immutable). @@ -307,29 +299,23 @@ class NetworkProfile(msrest.serialization.Model): """ _attribute_map = { - 'pod_cidr': {'key': 'podCidr', 'type': 'str'}, - 'service_cidr': {'key': 'serviceCidr', 'type': 'str'}, + "pod_cidr": {"key": "podCidr", "type": "str"}, + "service_cidr": {"key": "serviceCidr", "type": "str"}, } - def __init__( - self, - *, - pod_cidr: Optional[str] = None, - service_cidr: Optional[str] = None, - **kwargs - ): + def __init__(self, *, pod_cidr: Optional[str] = None, service_cidr: Optional[str] = None, **kwargs): """ :keyword pod_cidr: The CIDR used for OpenShift/Kubernetes Pods (immutable). :paramtype pod_cidr: str :keyword service_cidr: The CIDR used for OpenShift/Kubernetes Services (immutable). :paramtype service_cidr: str """ - super(NetworkProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.pod_cidr = pod_cidr self.service_cidr = service_cidr -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. @@ -345,24 +331,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - 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 @@ -383,46 +365,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :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}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - '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"}, + "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 OpenShiftCluster(TrackedResource): +class OpenShiftCluster(TrackedResource): # pylint: disable=too-many-instance-attributes """OpenShiftCluster represents an Azure Red Hat OpenShift cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -437,12 +413,12 @@ class OpenShiftCluster(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :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 provisioning_state: The cluster provisioning state (immutable). Possible values include: - "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: The cluster provisioning state (immutable). Known values are: + "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.redhatopenshift.v2020_04_30.models.ProvisioningState :ivar cluster_profile: The cluster profile. @@ -465,27 +441,27 @@ class OpenShiftCluster(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'cluster_profile': {'key': 'properties.clusterProfile', 'type': 'ClusterProfile'}, - 'console_profile': {'key': 'properties.consoleProfile', 'type': 'ConsoleProfile'}, - 'service_principal_profile': {'key': 'properties.servicePrincipalProfile', 'type': 'ServicePrincipalProfile'}, - 'network_profile': {'key': 'properties.networkProfile', 'type': 'NetworkProfile'}, - 'master_profile': {'key': 'properties.masterProfile', 'type': 'MasterProfile'}, - 'worker_profiles': {'key': 'properties.workerProfiles', 'type': '[WorkerProfile]'}, - 'apiserver_profile': {'key': 'properties.apiserverProfile', 'type': 'APIServerProfile'}, - 'ingress_profiles': {'key': 'properties.ingressProfiles', 'type': '[IngressProfile]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "cluster_profile": {"key": "properties.clusterProfile", "type": "ClusterProfile"}, + "console_profile": {"key": "properties.consoleProfile", "type": "ConsoleProfile"}, + "service_principal_profile": {"key": "properties.servicePrincipalProfile", "type": "ServicePrincipalProfile"}, + "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, + "master_profile": {"key": "properties.masterProfile", "type": "MasterProfile"}, + "worker_profiles": {"key": "properties.workerProfiles", "type": "[WorkerProfile]"}, + "apiserver_profile": {"key": "properties.apiserverProfile", "type": "APIServerProfile"}, + "ingress_profiles": {"key": "properties.ingressProfiles", "type": "[IngressProfile]"}, } def __init__( @@ -493,24 +469,24 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, - cluster_profile: Optional["ClusterProfile"] = None, - console_profile: Optional["ConsoleProfile"] = None, - service_principal_profile: Optional["ServicePrincipalProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - master_profile: Optional["MasterProfile"] = None, - worker_profiles: Optional[List["WorkerProfile"]] = None, - apiserver_profile: Optional["APIServerProfile"] = None, - ingress_profiles: Optional[List["IngressProfile"]] = None, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, + cluster_profile: Optional["_models.ClusterProfile"] = None, + console_profile: Optional["_models.ConsoleProfile"] = None, + service_principal_profile: Optional["_models.ServicePrincipalProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + master_profile: Optional["_models.MasterProfile"] = None, + worker_profiles: Optional[List["_models.WorkerProfile"]] = None, + apiserver_profile: Optional["_models.APIServerProfile"] = None, + ingress_profiles: Optional[List["_models.IngressProfile"]] = 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 provisioning_state: The cluster provisioning state (immutable). Possible values - include: "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", "Updating". + :keyword provisioning_state: The cluster provisioning state (immutable). Known values are: + "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", and "Updating". :paramtype provisioning_state: str or ~azure.mgmt.redhatopenshift.v2020_04_30.models.ProvisioningState :keyword cluster_profile: The cluster profile. @@ -532,7 +508,7 @@ def __init__( :paramtype ingress_profiles: list[~azure.mgmt.redhatopenshift.v2020_04_30.models.IngressProfile] """ - super(OpenShiftCluster, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.provisioning_state = provisioning_state self.cluster_profile = cluster_profile self.console_profile = console_profile @@ -544,7 +520,7 @@ def __init__( self.ingress_profiles = ingress_profiles -class OpenShiftClusterCredentials(msrest.serialization.Model): +class OpenShiftClusterCredentials(_serialization.Model): """OpenShiftClusterCredentials represents an OpenShift cluster's credentials. :ivar kubeadmin_username: The username for the kubeadmin user. @@ -554,29 +530,23 @@ class OpenShiftClusterCredentials(msrest.serialization.Model): """ _attribute_map = { - 'kubeadmin_username': {'key': 'kubeadminUsername', 'type': 'str'}, - 'kubeadmin_password': {'key': 'kubeadminPassword', 'type': 'str'}, + "kubeadmin_username": {"key": "kubeadminUsername", "type": "str"}, + "kubeadmin_password": {"key": "kubeadminPassword", "type": "str"}, } - def __init__( - self, - *, - kubeadmin_username: Optional[str] = None, - kubeadmin_password: Optional[str] = None, - **kwargs - ): + def __init__(self, *, kubeadmin_username: Optional[str] = None, kubeadmin_password: Optional[str] = None, **kwargs): """ :keyword kubeadmin_username: The username for the kubeadmin user. :paramtype kubeadmin_username: str :keyword kubeadmin_password: The password for the kubeadmin user. :paramtype kubeadmin_password: str """ - super(OpenShiftClusterCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.kubeadmin_username = kubeadmin_username self.kubeadmin_password = kubeadmin_password -class OpenShiftClusterList(msrest.serialization.Model): +class OpenShiftClusterList(_serialization.Model): """OpenShiftClusterList represents a list of OpenShift clusters. :ivar value: The list of OpenShift clusters. @@ -586,16 +556,12 @@ class OpenShiftClusterList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[OpenShiftCluster]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OpenShiftCluster]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["OpenShiftCluster"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.OpenShiftCluster"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of OpenShift clusters. @@ -603,18 +569,18 @@ def __init__( :keyword next_link: The link used to get the next page of operations. :paramtype next_link: str """ - super(OpenShiftClusterList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class OpenShiftClusterUpdate(msrest.serialization.Model): +class OpenShiftClusterUpdate(_serialization.Model): """OpenShiftCluster represents an Azure Red Hat OpenShift cluster. - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] - :ivar provisioning_state: The cluster provisioning state (immutable). Possible values include: - "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: The cluster provisioning state (immutable). Known values are: + "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.redhatopenshift.v2020_04_30.models.ProvisioningState :ivar cluster_profile: The cluster profile. @@ -637,38 +603,38 @@ class OpenShiftClusterUpdate(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'cluster_profile': {'key': 'properties.clusterProfile', 'type': 'ClusterProfile'}, - 'console_profile': {'key': 'properties.consoleProfile', 'type': 'ConsoleProfile'}, - 'service_principal_profile': {'key': 'properties.servicePrincipalProfile', 'type': 'ServicePrincipalProfile'}, - 'network_profile': {'key': 'properties.networkProfile', 'type': 'NetworkProfile'}, - 'master_profile': {'key': 'properties.masterProfile', 'type': 'MasterProfile'}, - 'worker_profiles': {'key': 'properties.workerProfiles', 'type': '[WorkerProfile]'}, - 'apiserver_profile': {'key': 'properties.apiserverProfile', 'type': 'APIServerProfile'}, - 'ingress_profiles': {'key': 'properties.ingressProfiles', 'type': '[IngressProfile]'}, + "tags": {"key": "tags", "type": "{str}"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "cluster_profile": {"key": "properties.clusterProfile", "type": "ClusterProfile"}, + "console_profile": {"key": "properties.consoleProfile", "type": "ConsoleProfile"}, + "service_principal_profile": {"key": "properties.servicePrincipalProfile", "type": "ServicePrincipalProfile"}, + "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, + "master_profile": {"key": "properties.masterProfile", "type": "MasterProfile"}, + "worker_profiles": {"key": "properties.workerProfiles", "type": "[WorkerProfile]"}, + "apiserver_profile": {"key": "properties.apiserverProfile", "type": "APIServerProfile"}, + "ingress_profiles": {"key": "properties.ingressProfiles", "type": "[IngressProfile]"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, - cluster_profile: Optional["ClusterProfile"] = None, - console_profile: Optional["ConsoleProfile"] = None, - service_principal_profile: Optional["ServicePrincipalProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - master_profile: Optional["MasterProfile"] = None, - worker_profiles: Optional[List["WorkerProfile"]] = None, - apiserver_profile: Optional["APIServerProfile"] = None, - ingress_profiles: Optional[List["IngressProfile"]] = None, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, + cluster_profile: Optional["_models.ClusterProfile"] = None, + console_profile: Optional["_models.ConsoleProfile"] = None, + service_principal_profile: Optional["_models.ServicePrincipalProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + master_profile: Optional["_models.MasterProfile"] = None, + worker_profiles: Optional[List["_models.WorkerProfile"]] = None, + apiserver_profile: Optional["_models.APIServerProfile"] = None, + ingress_profiles: Optional[List["_models.IngressProfile"]] = None, **kwargs ): """ - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] - :keyword provisioning_state: The cluster provisioning state (immutable). Possible values - include: "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", "Updating". + :keyword provisioning_state: The cluster provisioning state (immutable). Known values are: + "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", and "Updating". :paramtype provisioning_state: str or ~azure.mgmt.redhatopenshift.v2020_04_30.models.ProvisioningState :keyword cluster_profile: The cluster profile. @@ -690,7 +656,7 @@ def __init__( :paramtype ingress_profiles: list[~azure.mgmt.redhatopenshift.v2020_04_30.models.IngressProfile] """ - super(OpenShiftClusterUpdate, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.provisioning_state = provisioning_state self.cluster_profile = cluster_profile @@ -703,7 +669,7 @@ def __init__( self.ingress_profiles = ingress_profiles -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Operation represents an RP operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -716,16 +682,16 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'Display'}, - 'origin': {'key': 'origin', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "Display"}, + "origin": {"key": "origin", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["Display"] = None, + display: Optional["_models.Display"] = None, origin: Optional[str] = None, **kwargs ): @@ -738,13 +704,13 @@ def __init__( user or system, e.g. "user,system". :paramtype origin: str """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin -class OperationList(msrest.serialization.Model): +class OperationList(_serialization.Model): """OperationList represents an RP operation list. :ivar value: List of operations supported by the resource provider. @@ -754,29 +720,23 @@ class OperationList(msrest.serialization.Model): """ _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, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of operations supported by the resource provider. :paramtype value: list[~azure.mgmt.redhatopenshift.v2020_04_30.models.Operation] :keyword next_link: The link used to get the next page of operations. :paramtype next_link: str """ - super(OperationList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ServicePrincipalProfile(msrest.serialization.Model): +class ServicePrincipalProfile(_serialization.Model): """ServicePrincipalProfile represents a service principal profile. :ivar client_id: The client ID used for the cluster (immutable). @@ -786,35 +746,29 @@ class ServicePrincipalProfile(msrest.serialization.Model): """ _attribute_map = { - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + "client_id": {"key": "clientId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, } - def __init__( - self, - *, - client_id: Optional[str] = None, - client_secret: Optional[str] = None, - **kwargs - ): + def __init__(self, *, client_id: Optional[str] = None, client_secret: Optional[str] = None, **kwargs): """ :keyword client_id: The client ID used for the cluster (immutable). :paramtype client_id: str :keyword client_secret: The client secret used for the cluster (immutable). :paramtype client_secret: str """ - super(ServicePrincipalProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_id = client_id self.client_secret = client_secret -class WorkerProfile(msrest.serialization.Model): +class WorkerProfile(_serialization.Model): """WorkerProfile represents a worker profile. :ivar name: The worker profile name. Must be "worker" (immutable). :vartype name: str - :ivar vm_size: The size of the worker VMs (immutable). Possible values include: - "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3". + :ivar vm_size: The size of the worker VMs (immutable). Known values are: "Standard_D2s_v3", + "Standard_D4s_v3", and "Standard_D8s_v3". :vartype vm_size: str or ~azure.mgmt.redhatopenshift.v2020_04_30.models.VMSize :ivar disk_size_gb: The disk size of the worker VMs. Must be 128 or greater (immutable). :vartype disk_size_gb: int @@ -825,18 +779,18 @@ class WorkerProfile(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'vm_size': {'key': 'vmSize', 'type': 'str'}, - 'disk_size_gb': {'key': 'diskSizeGB', 'type': 'int'}, - 'subnet_id': {'key': 'subnetId', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "vm_size": {"key": "vmSize", "type": "str"}, + "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, + "subnet_id": {"key": "subnetId", "type": "str"}, + "count": {"key": "count", "type": "int"}, } def __init__( self, *, name: Optional[str] = None, - vm_size: Optional[Union[str, "VMSize"]] = None, + vm_size: Optional[Union[str, "_models.VMSize"]] = None, disk_size_gb: Optional[int] = None, subnet_id: Optional[str] = None, count: Optional[int] = None, @@ -845,8 +799,8 @@ def __init__( """ :keyword name: The worker profile name. Must be "worker" (immutable). :paramtype name: str - :keyword vm_size: The size of the worker VMs (immutable). Possible values include: - "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3". + :keyword vm_size: The size of the worker VMs (immutable). Known values are: "Standard_D2s_v3", + "Standard_D4s_v3", and "Standard_D8s_v3". :paramtype vm_size: str or ~azure.mgmt.redhatopenshift.v2020_04_30.models.VMSize :keyword disk_size_gb: The disk size of the worker VMs. Must be 128 or greater (immutable). :paramtype disk_size_gb: int @@ -855,7 +809,7 @@ def __init__( :keyword count: The number of worker VMs. Must be between 3 and 20 (immutable). :paramtype count: int """ - super(WorkerProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.vm_size = vm_size self.disk_size_gb = disk_size_gb diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/models/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/operations/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/operations/__init__.py index 7ffcf7895ee8..70ea64711791 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/operations/__init__.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import Operations from ._open_shift_clusters_operations import OpenShiftClustersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'OpenShiftClustersOperations', + "Operations", + "OpenShiftClustersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/operations/_open_shift_clusters_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/operations/_open_shift_clusters_operations.py index 2cbc68dd1caa..ac69317be703 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/operations/_open_shift_clusters_operations.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/operations/_open_shift_clusters_operations.py @@ -6,352 +6,338 @@ # 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 ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +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', "2020-04-30") # 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: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters" + ) # pylint: disable=line-too-long 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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', "2020-04-30") # 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: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters", + ) # 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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, - resource_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-04-30") # 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, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", + ) # 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), - "resourceName": _SERIALIZER.url("resource_name", resource_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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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, - resource_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, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-04-30") # 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: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", + ) # 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), - "resourceName": _SERIALIZER.url("resource_name", resource_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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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, - resource_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, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-04-30") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", + ) # 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), - "resourceName": _SERIALIZER.url("resource_name", resource_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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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 - ) - - -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-04-30") # 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: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", + ) # 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), - "resourceName": _SERIALIZER.url("resource_name", resource_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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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_list_credentials_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-04-30") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials", + ) # 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), - "resourceName": _SERIALIZER.url("resource_name", resource_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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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 - ) - -class OpenShiftClustersOperations(object): - """OpenShiftClustersOperations 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.redhatopenshift.v2020_04_30.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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class OpenShiftClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redhatopenshift.v2020_04_30.AzureRedHatOpenShift4Client`'s + :attr:`open_shift_clusters` 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.OpenShiftClusterList"]: + def list(self, **kwargs: Any) -> Iterable["_models.OpenShiftCluster"]: """Lists OpenShift clusters in the specified subscription. The operation returns properties of each OpenShift cluster. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OpenShiftClusterList or the result of - cls(response) + :return: An iterator like instance of either OpenShiftCluster or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftClusterList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-04-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + cls: ClsType[_models.OpenShiftClusterList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterList"] 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) 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) @@ -362,16 +348,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OpenShiftClusterList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -381,57 +365,65 @@ 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.RedHatOpenShift/openShiftClusters"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.OpenShiftClusterList"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.OpenShiftCluster"]: """Lists OpenShift clusters in the specified subscription and resource group. The operation returns properties of each OpenShift cluster. :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 OpenShiftClusterList or the result of - cls(response) + :return: An iterator like instance of either OpenShiftCluster or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftClusterList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-04-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + cls: ClsType[_models.OpenShiftClusterList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterList"] 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) 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) @@ -442,16 +434,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OpenShiftClusterList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -461,107 +451,124 @@ 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.RedHatOpenShift/openShiftClusters"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters" + } @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.OpenShiftCluster": + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.OpenShiftCluster: """Gets a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenShiftCluster, or the result of cls(response) + :return: OpenShiftCluster or the result of cls(response) :rtype: ~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftCluster"] 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', "2020-04-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftCluster", + parameters: Union[_models.OpenShiftCluster, IO], **kwargs: Any - ) -> "_models.OpenShiftCluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftCluster"] + ) -> _models.OpenShiftCluster: 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', "2020-04-30") # 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(parameters, 'OpenShiftCluster') + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OpenShiftCluster") + + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -569,38 +576,124 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.OpenShiftCluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + The operation returns properties of a OpenShift cluster. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster + :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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftCluster", + parameters: Union[_models.OpenShiftCluster, IO], **kwargs: Any - ) -> LROPoller["_models.OpenShiftCluster"]: + ) -> LROPoller[_models.OpenShiftCluster]: """Creates or updates a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str - :param parameters: The OpenShift cluster resource. - :type parameters: ~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster + :param parameters: The OpenShift cluster resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster 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 @@ -613,17 +706,17 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-04-30") # 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.OpenShiftCluster"] - 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: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, @@ -631,63 +724,71 @@ def begin_create_or_update( parameters=parameters, 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('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", 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: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any + self, resource_group_name: str, resource_name: str, **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', "2020-04-30") # 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: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -697,23 +798,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns nothing. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -725,80 +823,100 @@ 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', "2020-04-30") # 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: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_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): + 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, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } def _update_initial( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftClusterUpdate", + parameters: Union[_models.OpenShiftClusterUpdate, IO], **kwargs: Any - ) -> "_models.OpenShiftCluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftCluster"] + ) -> _models.OpenShiftCluster: 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', "2020-04-30") # 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(parameters, 'OpenShiftClusterUpdate') + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OpenShiftClusterUpdate") + + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -806,38 +924,124 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.OpenShiftClusterUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftClusterUpdate + :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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftClusterUpdate", + parameters: Union[_models.OpenShiftClusterUpdate, IO], **kwargs: Any - ) -> LROPoller["_models.OpenShiftCluster"]: + ) -> LROPoller[_models.OpenShiftCluster]: """Creates or updates a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str - :param parameters: The OpenShift cluster resource. - :type parameters: ~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftClusterUpdate + :param parameters: The OpenShift cluster resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftClusterUpdate 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 @@ -850,17 +1054,17 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftCluster] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-04-30") # 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.OpenShiftCluster"] - 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: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -868,90 +1072,100 @@ def begin_update( parameters=parameters, 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('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", 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: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } @distributed_trace def list_credentials( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.OpenShiftClusterCredentials": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.OpenShiftClusterCredentials: """Lists credentials of an OpenShift cluster with the specified subscription, resource group and resource name. The operation returns the credentials. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenShiftClusterCredentials, or the result of cls(response) + :return: OpenShiftClusterCredentials or the result of cls(response) :rtype: ~azure.mgmt.redhatopenshift.v2020_04_30.models.OpenShiftClusterCredentials - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterCredentials"] 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', "2020-04-30") # type: str + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + cls: ClsType[_models.OpenShiftClusterCredentials] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OpenShiftClusterCredentials', pipeline_response) + deserialized = self._deserialize("OpenShiftClusterCredentials", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials"} # type: ignore - + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials" + } diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/operations/_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/operations/_operations.py index ace078e37d1b..cd67143997af 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/operations/_operations.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/operations/_operations.py @@ -6,110 +6,128 @@ # 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 ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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', "2020-04-30") # 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: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.RedHatOpenShift/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.redhatopenshift.v2020_04_30.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.redhatopenshift.v2020_04_30.AzureRedHatOpenShift4Client`'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.OperationList"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available RP operations. The operation returns the RP operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationList or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2020_04_30.models.OperationList] - :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.redhatopenshift.v2020_04_30.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2020-04-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-04-30"] = kwargs.pop("api_version", _params.pop("api-version", "2020-04-30")) + cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] 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) 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) @@ -120,16 +138,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -139,8 +155,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.RedHatOpenShift/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.RedHatOpenShift/operations"} diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/operations/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2020_04_30/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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/__init__.py index a81e4a399ecf..c64163c98d3d 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/__init__.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AzureRedHatOpenShiftClient'] -# `._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 * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AzureRedHatOpenShiftClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_azure_red_hat_open_shift_client.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_azure_red_hat_open_shift_client.py index f1773f04fb8a..32280205eef8 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_azure_red_hat_open_shift_client.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_azure_red_hat_open_shift_client.py @@ -9,12 +9,11 @@ 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 . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import AzureRedHatOpenShiftClientConfiguration from .operations import OpenShiftClustersOperations, Operations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class AzureRedHatOpenShiftClient: + +class AzureRedHatOpenShiftClient: # pylint: disable=client-accepts-api-version-keyword """Rest API for Azure Red Hat OpenShift 4. :ivar operations: Operations operations @@ -30,9 +30,9 @@ class AzureRedHatOpenShiftClient: :ivar open_shift_clusters: OpenShiftClustersOperations operations :vartype open_shift_clusters: azure.mgmt.redhatopenshift.v2021_09_01_preview.operations.OpenShiftClustersOperations - :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 @@ -50,22 +50,21 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AzureRedHatOpenShiftClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AzureRedHatOpenShiftClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.open_shift_clusters = OpenShiftClustersOperations(self._client, self._config, self._serialize, self._deserialize) - + self.open_shift_clusters = OpenShiftClustersOperations( + 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 @@ -74,7 +73,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 @@ -87,15 +86,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> AzureRedHatOpenShiftClient + def __enter__(self) -> "AzureRedHatOpenShiftClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_configuration.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_configuration.py index 6f67bc712663..014529a1fc3f 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_configuration.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_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 AzureRedHatOpenShiftClientConfiguration(Configuration): # pylint: disable 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-09-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(AzureRedHatOpenShiftClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop("api_version", "2021-09-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +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-redhatopenshift/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-redhatopenshift/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs # type: Any - ): - # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_metadata.json b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_metadata.json index ecb242286926..b51acb84d1da 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_metadata.json +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureRedHatOpenShiftClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureRedHatOpenShiftClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureRedHatOpenShiftClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureRedHatOpenShiftClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -100,4 +100,4 @@ "operations": "Operations", "open_shift_clusters": "OpenShiftClustersOperations" } -} \ No newline at end of file +} diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_patch.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_vendor.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_vendor.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,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 +23,5 @@ 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) diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_version.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_version.py index 59deb8c7263b..e5754a47ce68 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_version.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/__init__.py index 6be616fa9ec0..b06f0016da77 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/__init__.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._azure_red_hat_open_shift_client import AzureRedHatOpenShiftClient -__all__ = ['AzureRedHatOpenShiftClient'] -# `._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 * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AzureRedHatOpenShiftClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/_azure_red_hat_open_shift_client.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/_azure_red_hat_open_shift_client.py index 9561a6edd8d2..e9f2b875259e 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/_azure_red_hat_open_shift_client.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/_azure_red_hat_open_shift_client.py @@ -9,12 +9,11 @@ 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 .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import AzureRedHatOpenShiftClientConfiguration from .operations import OpenShiftClustersOperations, Operations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class AzureRedHatOpenShiftClient: + +class AzureRedHatOpenShiftClient: # pylint: disable=client-accepts-api-version-keyword """Rest API for Azure Red Hat OpenShift 4. :ivar operations: Operations operations @@ -30,9 +30,9 @@ class AzureRedHatOpenShiftClient: :ivar open_shift_clusters: OpenShiftClustersOperations operations :vartype open_shift_clusters: azure.mgmt.redhatopenshift.v2021_09_01_preview.aio.operations.OpenShiftClustersOperations - :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 @@ -50,22 +50,21 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AzureRedHatOpenShiftClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AzureRedHatOpenShiftClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.open_shift_clusters = OpenShiftClustersOperations(self._client, self._config, self._serialize, self._deserialize) - + self.open_shift_clusters = OpenShiftClustersOperations( + 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 @@ -74,7 +73,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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/_configuration.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/_configuration.py index e1c023593a79..16e7e92e698d 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/_configuration.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/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 AzureRedHatOpenShiftClientConfiguration(Configuration): # pylint: disable 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-09-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(AzureRedHatOpenShiftClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop("api_version", "2021-09-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-redhatopenshift/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-redhatopenshift/{}".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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/_patch.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/operations/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/operations/__init__.py index 7ffcf7895ee8..70ea64711791 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/operations/__init__.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import Operations from ._open_shift_clusters_operations import OpenShiftClustersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'OpenShiftClustersOperations', + "Operations", + "OpenShiftClustersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/operations/_open_shift_clusters_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/operations/_open_shift_clusters_operations.py index 352e8b995039..5b31236288f6 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/operations/_open_shift_clusters_operations.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/operations/_open_shift_clusters_operations.py @@ -6,87 +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._open_shift_clusters_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_admin_credentials_request, build_list_by_resource_group_request, build_list_credentials_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._open_shift_clusters_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_admin_credentials_request, + build_list_by_resource_group_request, + build_list_credentials_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OpenShiftClustersOperations: - """OpenShiftClustersOperations 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 OpenShiftClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.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.redhatopenshift.v2021_09_01_preview.aio.AzureRedHatOpenShiftClient`'s + :attr:`open_shift_clusters` 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.OpenShiftClusterList"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.OpenShiftCluster"]: """Lists OpenShift clusters in the specified subscription. The operation returns properties of each OpenShift cluster. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OpenShiftClusterList or the result of - cls(response) + :return: An iterator like instance of either OpenShiftCluster or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftClusterList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.OpenShiftClusterList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterList"] 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) 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) @@ -97,16 +132,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OpenShiftClusterList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -116,57 +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.RedHatOpenShift/openShiftClusters"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters"} @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.OpenShiftClusterList"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.OpenShiftCluster"]: """Lists OpenShift clusters in the specified subscription and resource group. The operation returns properties of each OpenShift cluster. :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 OpenShiftClusterList or the result of - cls(response) + :return: An iterator like instance of either OpenShiftCluster or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftClusterList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.OpenShiftClusterList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterList"] 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) 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) @@ -177,16 +222,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OpenShiftClusterList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -196,107 +239,128 @@ 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.RedHatOpenShift/openShiftClusters"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.OpenShiftCluster": + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.OpenShiftCluster: """Gets a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenShiftCluster, or the result of cls(response) + :return: OpenShiftCluster or the result of cls(response) :rtype: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftCluster"] 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-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftCluster", + parameters: Union[_models.OpenShiftCluster, IO], **kwargs: Any - ) -> "_models.OpenShiftCluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftCluster"] + ) -> _models.OpenShiftCluster: 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-09-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(parameters, 'OpenShiftCluster') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OpenShiftCluster") + + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -304,38 +368,124 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.OpenShiftCluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster + :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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftCluster", + parameters: Union[_models.OpenShiftCluster, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.OpenShiftCluster"]: + ) -> AsyncLROPoller[_models.OpenShiftCluster]: """Creates or updates a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str - :param parameters: The OpenShift cluster resource. - :type parameters: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster + :param parameters: The OpenShift cluster resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster 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 @@ -348,17 +498,19 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-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.OpenShiftCluster"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, @@ -366,63 +518,73 @@ async def begin_create_or_update( parameters=parameters, 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('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", 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: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any + self, resource_group_name: str, resource_name: str, **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-09-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: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -432,23 +594,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns nothing. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -460,80 +619,104 @@ 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-09-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 + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_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): + 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, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } async def _update_initial( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftClusterUpdate", + parameters: Union[_models.OpenShiftClusterUpdate, IO], **kwargs: Any - ) -> "_models.OpenShiftCluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftCluster"] + ) -> _models.OpenShiftCluster: 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-09-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(parameters, 'OpenShiftClusterUpdate') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OpenShiftClusterUpdate") + + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -541,38 +724,125 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.OpenShiftClusterUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftClusterUpdate + :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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftClusterUpdate", + parameters: Union[_models.OpenShiftClusterUpdate, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.OpenShiftCluster"]: + ) -> AsyncLROPoller[_models.OpenShiftCluster]: """Creates or updates a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str - :param parameters: The OpenShift cluster resource. + :param parameters: The OpenShift cluster resource. Is either a model type or a IO type. + Required. :type parameters: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftClusterUpdate + 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 @@ -585,17 +855,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-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.OpenShiftCluster"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -603,151 +875,170 @@ async def begin_update( parameters=parameters, 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('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", 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: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } @distributed_trace_async async def list_admin_credentials( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.OpenShiftClusterAdminKubeconfig": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.OpenShiftClusterAdminKubeconfig: """Lists admin kubeconfig of an OpenShift cluster with the specified subscription, resource group and resource name. The operation returns the admin kubeconfig. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenShiftClusterAdminKubeconfig, or the result of cls(response) + :return: OpenShiftClusterAdminKubeconfig or the result of cls(response) :rtype: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftClusterAdminKubeconfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterAdminKubeconfig"] 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-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.OpenShiftClusterAdminKubeconfig] = kwargs.pop("cls", None) - request = build_list_admin_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_admin_credentials.metadata['url'], + template_url=self.list_admin_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OpenShiftClusterAdminKubeconfig', pipeline_response) + deserialized = self._deserialize("OpenShiftClusterAdminKubeconfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_admin_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listAdminCredentials"} # type: ignore - + list_admin_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listAdminCredentials" + } @distributed_trace_async async def list_credentials( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.OpenShiftClusterCredentials": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.OpenShiftClusterCredentials: """Lists credentials of an OpenShift cluster with the specified subscription, resource group and resource name. The operation returns the credentials. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenShiftClusterCredentials, or the result of cls(response) + :return: OpenShiftClusterCredentials or the result of cls(response) :rtype: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftClusterCredentials - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterCredentials"] 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-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.OpenShiftClusterCredentials] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OpenShiftClusterCredentials', pipeline_response) + deserialized = self._deserialize("OpenShiftClusterCredentials", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials"} # type: ignore - + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials" + } diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/operations/_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/operations/_operations.py index 9bc864770ab9..3404d8ea73ae 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/operations/_operations.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/operations/_operations.py @@ -6,81 +6,109 @@ # 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') + +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.redhatopenshift.v2021_09_01_preview.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.redhatopenshift.v2021_09_01_preview.aio.AzureRedHatOpenShiftClient`'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.OperationList"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available RP operations. The operation returns the RP operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationList or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] 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) 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) @@ -91,16 +119,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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': "/providers/Microsoft.RedHatOpenShift/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.RedHatOpenShift/operations"} diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/operations/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/models/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/models/__init__.py index 0b20a2573c35..cc65ebeef995 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/models/__init__.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/models/__init__.py @@ -27,41 +27,43 @@ from ._models_py3 import TrackedResource from ._models_py3 import WorkerProfile - -from ._azure_red_hat_open_shift_client_enums import ( - CreatedByType, - EncryptionAtHost, - ProvisioningState, - SoftwareDefinedNetwork, - VMSize, - Visibility, -) +from ._azure_red_hat_open_shift_client_enums import CreatedByType +from ._azure_red_hat_open_shift_client_enums import EncryptionAtHost +from ._azure_red_hat_open_shift_client_enums import ProvisioningState +from ._azure_red_hat_open_shift_client_enums import SoftwareDefinedNetwork +from ._azure_red_hat_open_shift_client_enums import VMSize +from ._azure_red_hat_open_shift_client_enums import Visibility +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'APIServerProfile', - 'CloudErrorBody', - 'ClusterProfile', - 'ConsoleProfile', - 'Display', - 'IngressProfile', - 'MasterProfile', - 'NetworkProfile', - 'OpenShiftCluster', - 'OpenShiftClusterAdminKubeconfig', - 'OpenShiftClusterCredentials', - 'OpenShiftClusterList', - 'OpenShiftClusterUpdate', - 'Operation', - 'OperationList', - 'Resource', - 'ServicePrincipalProfile', - 'SystemData', - 'TrackedResource', - 'WorkerProfile', - 'CreatedByType', - 'EncryptionAtHost', - 'ProvisioningState', - 'SoftwareDefinedNetwork', - 'VMSize', - 'Visibility', + "APIServerProfile", + "CloudErrorBody", + "ClusterProfile", + "ConsoleProfile", + "Display", + "IngressProfile", + "MasterProfile", + "NetworkProfile", + "OpenShiftCluster", + "OpenShiftClusterAdminKubeconfig", + "OpenShiftClusterCredentials", + "OpenShiftClusterList", + "OpenShiftClusterUpdate", + "Operation", + "OperationList", + "Resource", + "ServicePrincipalProfile", + "SystemData", + "TrackedResource", + "WorkerProfile", + "CreatedByType", + "EncryptionAtHost", + "ProvisioningState", + "SoftwareDefinedNetwork", + "VMSize", + "Visibility", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/models/_azure_red_hat_open_shift_client_enums.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/models/_azure_red_hat_open_shift_client_enums.py index 884fe7bbed1c..6e7d46b1c503 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/models/_azure_red_hat_open_shift_client_enums.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/models/_azure_red_hat_open_shift_client_enums.py @@ -7,29 +7,27 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -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 EncryptionAtHost(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """EncryptionAtHost represents encryption at host state - """ + +class EncryptionAtHost(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """EncryptionAtHost represents encryption at host state.""" DISABLED = "Disabled" ENABLED = "Enabled" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """ProvisioningState represents a provisioning state. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ProvisioningState represents a provisioning state.""" ADMIN_UPDATING = "AdminUpdating" CREATING = "Creating" @@ -38,23 +36,23 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -class SoftwareDefinedNetwork(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """SoftwareDefinedNetwork constants. - """ + +class SoftwareDefinedNetwork(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SoftwareDefinedNetwork constants.""" OVN_KUBERNETES = "OVNKubernetes" OPEN_SHIFT_SDN = "OpenShiftSDN" -class Visibility(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Visibility represents visibility. - """ + +class Visibility(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Visibility represents visibility.""" PRIVATE = "Private" PUBLIC = "Public" -class VMSize(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """VMSize represents a VM size. - """ + +class VMSize(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """VMSize represents a VM size.""" STANDARD_D16_AS_V4 = "Standard_D16as_v4" STANDARD_D16_S_V3 = "Standard_D16s_v3" diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/models/_models_py3.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/models/_models_py3.py index b483971cd4bd..74d21d348962 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/models/_models_py3.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/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,17 +8,19 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._azure_red_hat_open_shift_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class APIServerProfile(msrest.serialization.Model): +class APIServerProfile(_serialization.Model): """APIServerProfile represents an API server profile. - :ivar visibility: API server visibility. Possible values include: "Private", "Public". + :ivar visibility: API server visibility. Known values are: "Private" and "Public". :vartype visibility: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.Visibility :ivar url: The URL to access the cluster API server. :vartype url: str @@ -26,34 +29,34 @@ class APIServerProfile(msrest.serialization.Model): """ _attribute_map = { - 'visibility': {'key': 'visibility', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, - 'ip': {'key': 'ip', 'type': 'str'}, + "visibility": {"key": "visibility", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "ip": {"key": "ip", "type": "str"}, } def __init__( self, *, - visibility: Optional[Union[str, "Visibility"]] = None, + visibility: Optional[Union[str, "_models.Visibility"]] = None, url: Optional[str] = None, ip: Optional[str] = None, **kwargs ): """ - :keyword visibility: API server visibility. Possible values include: "Private", "Public". + :keyword visibility: API server visibility. Known values are: "Private" and "Public". :paramtype visibility: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.Visibility :keyword url: The URL to access the cluster API server. :paramtype url: str :keyword ip: The IP of the cluster API server. :paramtype ip: str """ - super(APIServerProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.visibility = visibility self.url = url self.ip = ip -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """CloudErrorBody represents the body of a cloud error. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -70,10 +73,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -82,7 +85,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -98,14 +101,14 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class ClusterProfile(msrest.serialization.Model): +class ClusterProfile(_serialization.Model): """ClusterProfile represents a cluster profile. :ivar pull_secret: The pull secret for the cluster. @@ -119,10 +122,10 @@ class ClusterProfile(msrest.serialization.Model): """ _attribute_map = { - 'pull_secret': {'key': 'pullSecret', 'type': 'str'}, - 'domain': {'key': 'domain', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'resource_group_id': {'key': 'resourceGroupId', 'type': 'str'}, + "pull_secret": {"key": "pullSecret", "type": "str"}, + "domain": {"key": "domain", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "resource_group_id": {"key": "resourceGroupId", "type": "str"}, } def __init__( @@ -144,14 +147,14 @@ def __init__( :keyword resource_group_id: The ID of the cluster resource group. :paramtype resource_group_id: str """ - super(ClusterProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.pull_secret = pull_secret self.domain = domain self.version = version self.resource_group_id = resource_group_id -class ConsoleProfile(msrest.serialization.Model): +class ConsoleProfile(_serialization.Model): """ConsoleProfile represents a console profile. :ivar url: The URL to access the cluster console. @@ -159,24 +162,19 @@ class ConsoleProfile(msrest.serialization.Model): """ _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, } - def __init__( - self, - *, - url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, url: Optional[str] = None, **kwargs): """ :keyword url: The URL to access the cluster console. :paramtype url: str """ - super(ConsoleProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url -class Display(msrest.serialization.Model): +class Display(_serialization.Model): """Display represents the display details of an operation. :ivar provider: Friendly name of the resource provider. @@ -190,10 +188,10 @@ class Display(msrest.serialization.Model): """ _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__( @@ -215,67 +213,67 @@ def __init__( :keyword description: Friendly name of the operation. :paramtype description: str """ - super(Display, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class IngressProfile(msrest.serialization.Model): +class IngressProfile(_serialization.Model): """IngressProfile represents an ingress profile. :ivar name: The ingress profile name. :vartype name: str - :ivar visibility: Ingress visibility. Possible values include: "Private", "Public". + :ivar visibility: Ingress visibility. Known values are: "Private" and "Public". :vartype visibility: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.Visibility :ivar ip: The IP of the ingress. :vartype ip: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'visibility': {'key': 'visibility', 'type': 'str'}, - 'ip': {'key': 'ip', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "visibility": {"key": "visibility", "type": "str"}, + "ip": {"key": "ip", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, - visibility: Optional[Union[str, "Visibility"]] = None, + visibility: Optional[Union[str, "_models.Visibility"]] = None, ip: Optional[str] = None, **kwargs ): """ :keyword name: The ingress profile name. :paramtype name: str - :keyword visibility: Ingress visibility. Possible values include: "Private", "Public". + :keyword visibility: Ingress visibility. Known values are: "Private" and "Public". :paramtype visibility: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.Visibility :keyword ip: The IP of the ingress. :paramtype ip: str """ - super(IngressProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.visibility = visibility self.ip = ip -class MasterProfile(msrest.serialization.Model): +class MasterProfile(_serialization.Model): """MasterProfile represents a master profile. - :ivar vm_size: The size of the master VMs. Possible values include: "Standard_D16as_v4", + :ivar vm_size: The size of the master VMs. Known values are: "Standard_D16as_v4", "Standard_D16s_v3", "Standard_D2s_v3", "Standard_D32as_v4", "Standard_D32s_v3", "Standard_D4as_v4", "Standard_D4s_v3", "Standard_D8as_v4", "Standard_D8s_v3", "Standard_E16s_v3", "Standard_E32s_v3", "Standard_E4s_v3", "Standard_E64i_v3", "Standard_E64is_v3", "Standard_E8s_v3", "Standard_F16s_v2", "Standard_F32s_v2", - "Standard_F4s_v2", "Standard_F72s_v2", "Standard_F8s_v2", "Standard_G5", "Standard_GS5", + "Standard_F4s_v2", "Standard_F72s_v2", "Standard_F8s_v2", "Standard_G5", "Standard_GS5", and "Standard_M128ms". :vartype vm_size: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.VMSize :ivar subnet_id: The Azure resource ID of the master subnet. :vartype subnet_id: str - :ivar encryption_at_host: Whether master virtual machines are encrypted at host. Possible - values include: "Disabled", "Enabled". + :ivar encryption_at_host: Whether master virtual machines are encrypted at host. Known values + are: "Disabled" and "Enabled". :vartype encryption_at_host: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.EncryptionAtHost :ivar disk_encryption_set_id: The resource ID of an associated DiskEncryptionSet, if @@ -284,52 +282,52 @@ class MasterProfile(msrest.serialization.Model): """ _attribute_map = { - 'vm_size': {'key': 'vmSize', 'type': 'str'}, - 'subnet_id': {'key': 'subnetId', 'type': 'str'}, - 'encryption_at_host': {'key': 'encryptionAtHost', 'type': 'str'}, - 'disk_encryption_set_id': {'key': 'diskEncryptionSetId', 'type': 'str'}, + "vm_size": {"key": "vmSize", "type": "str"}, + "subnet_id": {"key": "subnetId", "type": "str"}, + "encryption_at_host": {"key": "encryptionAtHost", "type": "str"}, + "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, } def __init__( self, *, - vm_size: Optional[Union[str, "VMSize"]] = None, + vm_size: Optional[Union[str, "_models.VMSize"]] = None, subnet_id: Optional[str] = None, - encryption_at_host: Optional[Union[str, "EncryptionAtHost"]] = None, + encryption_at_host: Optional[Union[str, "_models.EncryptionAtHost"]] = None, disk_encryption_set_id: Optional[str] = None, **kwargs ): """ - :keyword vm_size: The size of the master VMs. Possible values include: "Standard_D16as_v4", + :keyword vm_size: The size of the master VMs. Known values are: "Standard_D16as_v4", "Standard_D16s_v3", "Standard_D2s_v3", "Standard_D32as_v4", "Standard_D32s_v3", "Standard_D4as_v4", "Standard_D4s_v3", "Standard_D8as_v4", "Standard_D8s_v3", "Standard_E16s_v3", "Standard_E32s_v3", "Standard_E4s_v3", "Standard_E64i_v3", "Standard_E64is_v3", "Standard_E8s_v3", "Standard_F16s_v2", "Standard_F32s_v2", - "Standard_F4s_v2", "Standard_F72s_v2", "Standard_F8s_v2", "Standard_G5", "Standard_GS5", + "Standard_F4s_v2", "Standard_F72s_v2", "Standard_F8s_v2", "Standard_G5", "Standard_GS5", and "Standard_M128ms". :paramtype vm_size: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.VMSize :keyword subnet_id: The Azure resource ID of the master subnet. :paramtype subnet_id: str - :keyword encryption_at_host: Whether master virtual machines are encrypted at host. Possible - values include: "Disabled", "Enabled". + :keyword encryption_at_host: Whether master virtual machines are encrypted at host. Known + values are: "Disabled" and "Enabled". :paramtype encryption_at_host: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.EncryptionAtHost :keyword disk_encryption_set_id: The resource ID of an associated DiskEncryptionSet, if applicable. :paramtype disk_encryption_set_id: str """ - super(MasterProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.vm_size = vm_size self.subnet_id = subnet_id self.encryption_at_host = encryption_at_host self.disk_encryption_set_id = disk_encryption_set_id -class NetworkProfile(msrest.serialization.Model): +class NetworkProfile(_serialization.Model): """NetworkProfile represents a network profile. :ivar software_defined_network: The software defined network (SDN) to use when installing the - cluster. Possible values include: "OVNKubernetes", "OpenShiftSDN". + cluster. Known values are: "OVNKubernetes" and "OpenShiftSDN". :vartype software_defined_network: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.SoftwareDefinedNetwork :ivar pod_cidr: The CIDR used for OpenShift/Kubernetes Pods. @@ -339,22 +337,22 @@ class NetworkProfile(msrest.serialization.Model): """ _attribute_map = { - 'software_defined_network': {'key': 'softwareDefinedNetwork', 'type': 'str'}, - 'pod_cidr': {'key': 'podCidr', 'type': 'str'}, - 'service_cidr': {'key': 'serviceCidr', 'type': 'str'}, + "software_defined_network": {"key": "softwareDefinedNetwork", "type": "str"}, + "pod_cidr": {"key": "podCidr", "type": "str"}, + "service_cidr": {"key": "serviceCidr", "type": "str"}, } def __init__( self, *, - software_defined_network: Optional[Union[str, "SoftwareDefinedNetwork"]] = None, + software_defined_network: Optional[Union[str, "_models.SoftwareDefinedNetwork"]] = None, pod_cidr: Optional[str] = None, service_cidr: Optional[str] = None, **kwargs ): """ :keyword software_defined_network: The software defined network (SDN) to use when installing - the cluster. Possible values include: "OVNKubernetes", "OpenShiftSDN". + the cluster. Known values are: "OVNKubernetes" and "OpenShiftSDN". :paramtype software_defined_network: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.SoftwareDefinedNetwork :keyword pod_cidr: The CIDR used for OpenShift/Kubernetes Pods. @@ -362,13 +360,13 @@ def __init__( :keyword service_cidr: The CIDR used for OpenShift/Kubernetes Services. :paramtype service_cidr: str """ - super(NetworkProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.software_defined_network = software_defined_network self.pod_cidr = pod_cidr self.service_cidr = service_cidr -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. @@ -384,24 +382,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - 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 @@ -422,46 +416,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :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}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - '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"}, + "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 OpenShiftCluster(TrackedResource): +class OpenShiftCluster(TrackedResource): # pylint: disable=too-many-instance-attributes """OpenShiftCluster represents an Azure Red Hat OpenShift cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -476,14 +464,14 @@ class OpenShiftCluster(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :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 system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.SystemData - :ivar provisioning_state: The cluster provisioning state. Possible values include: - "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: The cluster provisioning state. Known values are: "AdminUpdating", + "Creating", "Deleting", "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ProvisioningState :ivar cluster_profile: The cluster profile. @@ -509,29 +497,29 @@ class OpenShiftCluster(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'cluster_profile': {'key': 'properties.clusterProfile', 'type': 'ClusterProfile'}, - 'console_profile': {'key': 'properties.consoleProfile', 'type': 'ConsoleProfile'}, - 'service_principal_profile': {'key': 'properties.servicePrincipalProfile', 'type': 'ServicePrincipalProfile'}, - 'network_profile': {'key': 'properties.networkProfile', 'type': 'NetworkProfile'}, - 'master_profile': {'key': 'properties.masterProfile', 'type': 'MasterProfile'}, - 'worker_profiles': {'key': 'properties.workerProfiles', 'type': '[WorkerProfile]'}, - 'apiserver_profile': {'key': 'properties.apiserverProfile', 'type': 'APIServerProfile'}, - 'ingress_profiles': {'key': 'properties.ingressProfiles', 'type': '[IngressProfile]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "cluster_profile": {"key": "properties.clusterProfile", "type": "ClusterProfile"}, + "console_profile": {"key": "properties.consoleProfile", "type": "ConsoleProfile"}, + "service_principal_profile": {"key": "properties.servicePrincipalProfile", "type": "ServicePrincipalProfile"}, + "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, + "master_profile": {"key": "properties.masterProfile", "type": "MasterProfile"}, + "worker_profiles": {"key": "properties.workerProfiles", "type": "[WorkerProfile]"}, + "apiserver_profile": {"key": "properties.apiserverProfile", "type": "APIServerProfile"}, + "ingress_profiles": {"key": "properties.ingressProfiles", "type": "[IngressProfile]"}, } def __init__( @@ -539,24 +527,24 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, - cluster_profile: Optional["ClusterProfile"] = None, - console_profile: Optional["ConsoleProfile"] = None, - service_principal_profile: Optional["ServicePrincipalProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - master_profile: Optional["MasterProfile"] = None, - worker_profiles: Optional[List["WorkerProfile"]] = None, - apiserver_profile: Optional["APIServerProfile"] = None, - ingress_profiles: Optional[List["IngressProfile"]] = None, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, + cluster_profile: Optional["_models.ClusterProfile"] = None, + console_profile: Optional["_models.ConsoleProfile"] = None, + service_principal_profile: Optional["_models.ServicePrincipalProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + master_profile: Optional["_models.MasterProfile"] = None, + worker_profiles: Optional[List["_models.WorkerProfile"]] = None, + apiserver_profile: Optional["_models.APIServerProfile"] = None, + ingress_profiles: Optional[List["_models.IngressProfile"]] = 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 provisioning_state: The cluster provisioning state. Possible values include: - "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", "Updating". + :keyword provisioning_state: The cluster provisioning state. Known values are: "AdminUpdating", + "Creating", "Deleting", "Failed", "Succeeded", and "Updating". :paramtype provisioning_state: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ProvisioningState :keyword cluster_profile: The cluster profile. @@ -583,7 +571,7 @@ def __init__( :paramtype ingress_profiles: list[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.IngressProfile] """ - super(OpenShiftCluster, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.system_data = None self.provisioning_state = provisioning_state self.cluster_profile = cluster_profile @@ -596,7 +584,7 @@ def __init__( self.ingress_profiles = ingress_profiles -class OpenShiftClusterAdminKubeconfig(msrest.serialization.Model): +class OpenShiftClusterAdminKubeconfig(_serialization.Model): """OpenShiftClusterAdminKubeconfig represents an OpenShift cluster's admin kubeconfig. :ivar kubeconfig: The base64-encoded kubeconfig file. @@ -604,24 +592,19 @@ class OpenShiftClusterAdminKubeconfig(msrest.serialization.Model): """ _attribute_map = { - 'kubeconfig': {'key': 'kubeconfig', 'type': 'str'}, + "kubeconfig": {"key": "kubeconfig", "type": "str"}, } - def __init__( - self, - *, - kubeconfig: Optional[str] = None, - **kwargs - ): + def __init__(self, *, kubeconfig: Optional[str] = None, **kwargs): """ :keyword kubeconfig: The base64-encoded kubeconfig file. :paramtype kubeconfig: str """ - super(OpenShiftClusterAdminKubeconfig, self).__init__(**kwargs) + super().__init__(**kwargs) self.kubeconfig = kubeconfig -class OpenShiftClusterCredentials(msrest.serialization.Model): +class OpenShiftClusterCredentials(_serialization.Model): """OpenShiftClusterCredentials represents an OpenShift cluster's credentials. :ivar kubeadmin_username: The username for the kubeadmin user. @@ -631,29 +614,23 @@ class OpenShiftClusterCredentials(msrest.serialization.Model): """ _attribute_map = { - 'kubeadmin_username': {'key': 'kubeadminUsername', 'type': 'str'}, - 'kubeadmin_password': {'key': 'kubeadminPassword', 'type': 'str'}, + "kubeadmin_username": {"key": "kubeadminUsername", "type": "str"}, + "kubeadmin_password": {"key": "kubeadminPassword", "type": "str"}, } - def __init__( - self, - *, - kubeadmin_username: Optional[str] = None, - kubeadmin_password: Optional[str] = None, - **kwargs - ): + def __init__(self, *, kubeadmin_username: Optional[str] = None, kubeadmin_password: Optional[str] = None, **kwargs): """ :keyword kubeadmin_username: The username for the kubeadmin user. :paramtype kubeadmin_username: str :keyword kubeadmin_password: The password for the kubeadmin user. :paramtype kubeadmin_password: str """ - super(OpenShiftClusterCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.kubeadmin_username = kubeadmin_username self.kubeadmin_password = kubeadmin_password -class OpenShiftClusterList(msrest.serialization.Model): +class OpenShiftClusterList(_serialization.Model): """OpenShiftClusterList represents a list of OpenShift clusters. :ivar value: The list of OpenShift clusters. @@ -663,16 +640,12 @@ class OpenShiftClusterList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[OpenShiftCluster]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OpenShiftCluster]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["OpenShiftCluster"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.OpenShiftCluster"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of OpenShift clusters. @@ -680,22 +653,22 @@ def __init__( :keyword next_link: The link used to get the next page of operations. :paramtype next_link: str """ - super(OpenShiftClusterList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class OpenShiftClusterUpdate(msrest.serialization.Model): +class OpenShiftClusterUpdate(_serialization.Model): # pylint: disable=too-many-instance-attributes """OpenShiftCluster represents an Azure Red Hat OpenShift cluster. Variables are only populated by the server, and will be ignored when sending a request. - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.SystemData - :ivar provisioning_state: The cluster provisioning state. Possible values include: - "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: The cluster provisioning state. Known values are: "AdminUpdating", + "Creating", "Deleting", "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ProvisioningState :ivar cluster_profile: The cluster profile. @@ -721,43 +694,43 @@ class OpenShiftClusterUpdate(msrest.serialization.Model): """ _validation = { - 'system_data': {'readonly': True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'cluster_profile': {'key': 'properties.clusterProfile', 'type': 'ClusterProfile'}, - 'console_profile': {'key': 'properties.consoleProfile', 'type': 'ConsoleProfile'}, - 'service_principal_profile': {'key': 'properties.servicePrincipalProfile', 'type': 'ServicePrincipalProfile'}, - 'network_profile': {'key': 'properties.networkProfile', 'type': 'NetworkProfile'}, - 'master_profile': {'key': 'properties.masterProfile', 'type': 'MasterProfile'}, - 'worker_profiles': {'key': 'properties.workerProfiles', 'type': '[WorkerProfile]'}, - 'apiserver_profile': {'key': 'properties.apiserverProfile', 'type': 'APIServerProfile'}, - 'ingress_profiles': {'key': 'properties.ingressProfiles', 'type': '[IngressProfile]'}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "cluster_profile": {"key": "properties.clusterProfile", "type": "ClusterProfile"}, + "console_profile": {"key": "properties.consoleProfile", "type": "ConsoleProfile"}, + "service_principal_profile": {"key": "properties.servicePrincipalProfile", "type": "ServicePrincipalProfile"}, + "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, + "master_profile": {"key": "properties.masterProfile", "type": "MasterProfile"}, + "worker_profiles": {"key": "properties.workerProfiles", "type": "[WorkerProfile]"}, + "apiserver_profile": {"key": "properties.apiserverProfile", "type": "APIServerProfile"}, + "ingress_profiles": {"key": "properties.ingressProfiles", "type": "[IngressProfile]"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, - cluster_profile: Optional["ClusterProfile"] = None, - console_profile: Optional["ConsoleProfile"] = None, - service_principal_profile: Optional["ServicePrincipalProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - master_profile: Optional["MasterProfile"] = None, - worker_profiles: Optional[List["WorkerProfile"]] = None, - apiserver_profile: Optional["APIServerProfile"] = None, - ingress_profiles: Optional[List["IngressProfile"]] = None, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, + cluster_profile: Optional["_models.ClusterProfile"] = None, + console_profile: Optional["_models.ConsoleProfile"] = None, + service_principal_profile: Optional["_models.ServicePrincipalProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + master_profile: Optional["_models.MasterProfile"] = None, + worker_profiles: Optional[List["_models.WorkerProfile"]] = None, + apiserver_profile: Optional["_models.APIServerProfile"] = None, + ingress_profiles: Optional[List["_models.IngressProfile"]] = None, **kwargs ): """ - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] - :keyword provisioning_state: The cluster provisioning state. Possible values include: - "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", "Updating". + :keyword provisioning_state: The cluster provisioning state. Known values are: "AdminUpdating", + "Creating", "Deleting", "Failed", "Succeeded", and "Updating". :paramtype provisioning_state: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.ProvisioningState :keyword cluster_profile: The cluster profile. @@ -784,7 +757,7 @@ def __init__( :paramtype ingress_profiles: list[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.IngressProfile] """ - super(OpenShiftClusterUpdate, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.system_data = None self.provisioning_state = provisioning_state @@ -798,7 +771,7 @@ def __init__( self.ingress_profiles = ingress_profiles -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Operation represents an RP operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -811,16 +784,16 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'Display'}, - 'origin': {'key': 'origin', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "Display"}, + "origin": {"key": "origin", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["Display"] = None, + display: Optional["_models.Display"] = None, origin: Optional[str] = None, **kwargs ): @@ -833,13 +806,13 @@ def __init__( user or system, e.g. "user,system". :paramtype origin: str """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin -class OperationList(msrest.serialization.Model): +class OperationList(_serialization.Model): """OperationList represents an RP operation list. :ivar value: List of operations supported by the resource provider. @@ -849,29 +822,23 @@ class OperationList(msrest.serialization.Model): """ _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, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of operations supported by the resource provider. :paramtype value: list[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.Operation] :keyword next_link: The link used to get the next page of operations. :paramtype next_link: str """ - super(OperationList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ServicePrincipalProfile(msrest.serialization.Model): +class ServicePrincipalProfile(_serialization.Model): """ServicePrincipalProfile represents a service principal profile. :ivar client_id: The client ID used for the cluster. @@ -881,43 +848,37 @@ class ServicePrincipalProfile(msrest.serialization.Model): """ _attribute_map = { - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + "client_id": {"key": "clientId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, } - def __init__( - self, - *, - client_id: Optional[str] = None, - client_secret: Optional[str] = None, - **kwargs - ): + def __init__(self, *, client_id: Optional[str] = None, client_secret: Optional[str] = None, **kwargs): """ :keyword client_id: The client ID used for the cluster. :paramtype client_id: str :keyword client_secret: The client secret used for the cluster. :paramtype client_secret: str """ - super(ServicePrincipalProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_id = client_id self.client_secret = client_secret -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.redhatopenshift.v2021_09_01_preview.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. 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.redhatopenshift.v2021_09_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -925,44 +886,44 @@ class SystemData(msrest.serialization.Model): """ _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.redhatopenshift.v2021_09_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. 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.redhatopenshift.v2021_09_01_preview.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 @@ -971,17 +932,17 @@ def __init__( self.last_modified_at = last_modified_at -class WorkerProfile(msrest.serialization.Model): +class WorkerProfile(_serialization.Model): """WorkerProfile represents a worker profile. :ivar name: The worker profile name. :vartype name: str - :ivar vm_size: The size of the worker VMs. Possible values include: "Standard_D16as_v4", + :ivar vm_size: The size of the worker VMs. Known values are: "Standard_D16as_v4", "Standard_D16s_v3", "Standard_D2s_v3", "Standard_D32as_v4", "Standard_D32s_v3", "Standard_D4as_v4", "Standard_D4s_v3", "Standard_D8as_v4", "Standard_D8s_v3", "Standard_E16s_v3", "Standard_E32s_v3", "Standard_E4s_v3", "Standard_E64i_v3", "Standard_E64is_v3", "Standard_E8s_v3", "Standard_F16s_v2", "Standard_F32s_v2", - "Standard_F4s_v2", "Standard_F72s_v2", "Standard_F8s_v2", "Standard_G5", "Standard_GS5", + "Standard_F4s_v2", "Standard_F72s_v2", "Standard_F8s_v2", "Standard_G5", "Standard_GS5", and "Standard_M128ms". :vartype vm_size: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.VMSize :ivar disk_size_gb: The disk size of the worker VMs. @@ -990,8 +951,8 @@ class WorkerProfile(msrest.serialization.Model): :vartype subnet_id: str :ivar count: The number of worker VMs. :vartype count: int - :ivar encryption_at_host: Whether master virtual machines are encrypted at host. Possible - values include: "Disabled", "Enabled". + :ivar encryption_at_host: Whether master virtual machines are encrypted at host. Known values + are: "Disabled" and "Enabled". :vartype encryption_at_host: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.EncryptionAtHost :ivar disk_encryption_set_id: The resource ID of an associated DiskEncryptionSet, if @@ -1000,36 +961,36 @@ class WorkerProfile(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'vm_size': {'key': 'vmSize', 'type': 'str'}, - 'disk_size_gb': {'key': 'diskSizeGB', 'type': 'int'}, - 'subnet_id': {'key': 'subnetId', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'int'}, - 'encryption_at_host': {'key': 'encryptionAtHost', 'type': 'str'}, - 'disk_encryption_set_id': {'key': 'diskEncryptionSetId', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "vm_size": {"key": "vmSize", "type": "str"}, + "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, + "subnet_id": {"key": "subnetId", "type": "str"}, + "count": {"key": "count", "type": "int"}, + "encryption_at_host": {"key": "encryptionAtHost", "type": "str"}, + "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, - vm_size: Optional[Union[str, "VMSize"]] = None, + vm_size: Optional[Union[str, "_models.VMSize"]] = None, disk_size_gb: Optional[int] = None, subnet_id: Optional[str] = None, count: Optional[int] = None, - encryption_at_host: Optional[Union[str, "EncryptionAtHost"]] = None, + encryption_at_host: Optional[Union[str, "_models.EncryptionAtHost"]] = None, disk_encryption_set_id: Optional[str] = None, **kwargs ): """ :keyword name: The worker profile name. :paramtype name: str - :keyword vm_size: The size of the worker VMs. Possible values include: "Standard_D16as_v4", + :keyword vm_size: The size of the worker VMs. Known values are: "Standard_D16as_v4", "Standard_D16s_v3", "Standard_D2s_v3", "Standard_D32as_v4", "Standard_D32s_v3", "Standard_D4as_v4", "Standard_D4s_v3", "Standard_D8as_v4", "Standard_D8s_v3", "Standard_E16s_v3", "Standard_E32s_v3", "Standard_E4s_v3", "Standard_E64i_v3", "Standard_E64is_v3", "Standard_E8s_v3", "Standard_F16s_v2", "Standard_F32s_v2", - "Standard_F4s_v2", "Standard_F72s_v2", "Standard_F8s_v2", "Standard_G5", "Standard_GS5", + "Standard_F4s_v2", "Standard_F72s_v2", "Standard_F8s_v2", "Standard_G5", "Standard_GS5", and "Standard_M128ms". :paramtype vm_size: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.VMSize :keyword disk_size_gb: The disk size of the worker VMs. @@ -1038,15 +999,15 @@ def __init__( :paramtype subnet_id: str :keyword count: The number of worker VMs. :paramtype count: int - :keyword encryption_at_host: Whether master virtual machines are encrypted at host. Possible - values include: "Disabled", "Enabled". + :keyword encryption_at_host: Whether master virtual machines are encrypted at host. Known + values are: "Disabled" and "Enabled". :paramtype encryption_at_host: str or ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.EncryptionAtHost :keyword disk_encryption_set_id: The resource ID of an associated DiskEncryptionSet, if applicable. :paramtype disk_encryption_set_id: str """ - super(WorkerProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.vm_size = vm_size self.disk_size_gb = disk_size_gb diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/models/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/operations/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/operations/__init__.py index 7ffcf7895ee8..70ea64711791 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/operations/__init__.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import Operations from ._open_shift_clusters_operations import OpenShiftClustersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'OpenShiftClustersOperations', + "Operations", + "OpenShiftClustersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/operations/_open_shift_clusters_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/operations/_open_shift_clusters_operations.py index 4b5885701094..441fe89f88ef 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/operations/_open_shift_clusters_operations.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/operations/_open_shift_clusters_operations.py @@ -6,388 +6,389 @@ # 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 ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +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-09-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: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters" + ) # pylint: disable=line-too-long 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-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: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters", + ) # 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", + ) # 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), - "resourceName": _SERIALIZER.url("resource_name", resource_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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-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: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", + ) # 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), - "resourceName": _SERIALIZER.url("resource_name", resource_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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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_delete_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", + ) # 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), - "resourceName": _SERIALIZER.url("resource_name", resource_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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-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: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", + ) # 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), - "resourceName": _SERIALIZER.url("resource_name", resource_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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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_list_admin_credentials_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listAdminCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listAdminCredentials", + ) # 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), - "resourceName": _SERIALIZER.url("resource_name", resource_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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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_list_credentials_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials", + ) # 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), - "resourceName": _SERIALIZER.url("resource_name", resource_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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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") -class OpenShiftClustersOperations(object): - """OpenShiftClustersOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - 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.redhatopenshift.v2021_09_01_preview.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. +class OpenShiftClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redhatopenshift.v2021_09_01_preview.AzureRedHatOpenShiftClient`'s + :attr:`open_shift_clusters` 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.OpenShiftClusterList"]: + def list(self, **kwargs: Any) -> Iterable["_models.OpenShiftCluster"]: """Lists OpenShift clusters in the specified subscription. The operation returns properties of each OpenShift cluster. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OpenShiftClusterList or the result of - cls(response) + :return: An iterator like instance of either OpenShiftCluster or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftClusterList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.OpenShiftClusterList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterList"] 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) 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) @@ -398,16 +399,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OpenShiftClusterList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -417,57 +416,67 @@ 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.RedHatOpenShift/openShiftClusters"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.OpenShiftClusterList"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.OpenShiftCluster"]: """Lists OpenShift clusters in the specified subscription and resource group. The operation returns properties of each OpenShift cluster. :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 OpenShiftClusterList or the result of - cls(response) + :return: An iterator like instance of either OpenShiftCluster or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftClusterList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.OpenShiftClusterList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterList"] 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) 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) @@ -478,16 +487,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OpenShiftClusterList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -497,107 +504,128 @@ 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.RedHatOpenShift/openShiftClusters"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters" + } @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.OpenShiftCluster": + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.OpenShiftCluster: """Gets a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenShiftCluster, or the result of cls(response) + :return: OpenShiftCluster or the result of cls(response) :rtype: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftCluster"] 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-09-01-preview") # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftCluster", + parameters: Union[_models.OpenShiftCluster, IO], **kwargs: Any - ) -> "_models.OpenShiftCluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftCluster"] + ) -> _models.OpenShiftCluster: 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-09-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(parameters, 'OpenShiftCluster') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OpenShiftCluster") + + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -605,38 +633,124 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.OpenShiftCluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster + :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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + The operation returns properties of a OpenShift cluster. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftCluster", + parameters: Union[_models.OpenShiftCluster, IO], **kwargs: Any - ) -> LROPoller["_models.OpenShiftCluster"]: + ) -> LROPoller[_models.OpenShiftCluster]: """Creates or updates a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str - :param parameters: The OpenShift cluster resource. - :type parameters: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster + :param parameters: The OpenShift cluster resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster 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 @@ -649,17 +763,19 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-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.OpenShiftCluster"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, @@ -667,63 +783,73 @@ def begin_create_or_update( parameters=parameters, 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('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", 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: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any + self, resource_group_name: str, resource_name: str, **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-09-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: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -733,23 +859,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns nothing. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -761,80 +884,104 @@ 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-09-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 + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_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): + 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, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } def _update_initial( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftClusterUpdate", + parameters: Union[_models.OpenShiftClusterUpdate, IO], **kwargs: Any - ) -> "_models.OpenShiftCluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftCluster"] + ) -> _models.OpenShiftCluster: 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-09-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(parameters, 'OpenShiftClusterUpdate') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OpenShiftClusterUpdate") + + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -842,38 +989,125 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.OpenShiftClusterUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftClusterUpdate + :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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + The operation returns properties of a OpenShift cluster. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftClusterUpdate", + parameters: Union[_models.OpenShiftClusterUpdate, IO], **kwargs: Any - ) -> LROPoller["_models.OpenShiftCluster"]: + ) -> LROPoller[_models.OpenShiftCluster]: """Creates or updates a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str - :param parameters: The OpenShift cluster resource. + :param parameters: The OpenShift cluster resource. Is either a model type or a IO type. + Required. :type parameters: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftClusterUpdate + 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 @@ -886,17 +1120,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftCluster] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-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.OpenShiftCluster"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -904,151 +1140,170 @@ def begin_update( parameters=parameters, 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('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", 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: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } @distributed_trace def list_admin_credentials( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.OpenShiftClusterAdminKubeconfig": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.OpenShiftClusterAdminKubeconfig: """Lists admin kubeconfig of an OpenShift cluster with the specified subscription, resource group and resource name. The operation returns the admin kubeconfig. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenShiftClusterAdminKubeconfig, or the result of cls(response) + :return: OpenShiftClusterAdminKubeconfig or the result of cls(response) :rtype: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftClusterAdminKubeconfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterAdminKubeconfig"] 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-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.OpenShiftClusterAdminKubeconfig] = kwargs.pop("cls", None) - request = build_list_admin_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_admin_credentials.metadata['url'], + template_url=self.list_admin_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OpenShiftClusterAdminKubeconfig', pipeline_response) + deserialized = self._deserialize("OpenShiftClusterAdminKubeconfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_admin_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listAdminCredentials"} # type: ignore - + list_admin_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listAdminCredentials" + } @distributed_trace def list_credentials( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.OpenShiftClusterCredentials": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.OpenShiftClusterCredentials: """Lists credentials of an OpenShift cluster with the specified subscription, resource group and resource name. The operation returns the credentials. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenShiftClusterCredentials, or the result of cls(response) + :return: OpenShiftClusterCredentials or the result of cls(response) :rtype: ~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OpenShiftClusterCredentials - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterCredentials"] 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-09-01-preview") # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.OpenShiftClusterCredentials] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OpenShiftClusterCredentials', pipeline_response) + deserialized = self._deserialize("OpenShiftClusterCredentials", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials"} # type: ignore - + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials" + } diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/operations/_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/operations/_operations.py index 1d40f0678698..2e19711442ae 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/operations/_operations.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/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 ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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-09-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: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.RedHatOpenShift/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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class Operations(object): - """Operations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - 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.redhatopenshift.v2021_09_01_preview.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. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redhatopenshift.v2021_09_01_preview.AzureRedHatOpenShiftClient`'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.OperationList"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available RP operations. The operation returns the RP operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationList or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.OperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2021_09_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] 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) 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) @@ -120,16 +143,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -139,8 +160,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.RedHatOpenShift/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.RedHatOpenShift/operations"} diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/operations/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2021_09_01_preview/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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/__init__.py index a81e4a399ecf..c64163c98d3d 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/__init__.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AzureRedHatOpenShiftClient'] -# `._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 * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AzureRedHatOpenShiftClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_azure_red_hat_open_shift_client.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_azure_red_hat_open_shift_client.py index 72e55920ca73..256ff2ea48b0 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_azure_red_hat_open_shift_client.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_azure_red_hat_open_shift_client.py @@ -9,12 +9,11 @@ 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 . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import AzureRedHatOpenShiftClientConfiguration from .operations import OpenShiftClustersOperations, Operations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class AzureRedHatOpenShiftClient: + +class AzureRedHatOpenShiftClient: # pylint: disable=client-accepts-api-version-keyword """Rest API for Azure Red Hat OpenShift 4. :ivar operations: Operations operations @@ -30,9 +30,9 @@ class AzureRedHatOpenShiftClient: :ivar open_shift_clusters: OpenShiftClustersOperations operations :vartype open_shift_clusters: azure.mgmt.redhatopenshift.v2022_04_01.operations.OpenShiftClustersOperations - :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 @@ -50,22 +50,21 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AzureRedHatOpenShiftClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AzureRedHatOpenShiftClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.open_shift_clusters = OpenShiftClustersOperations(self._client, self._config, self._serialize, self._deserialize) - + self.open_shift_clusters = OpenShiftClustersOperations( + 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 @@ -74,7 +73,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 @@ -87,15 +86,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> AzureRedHatOpenShiftClient + def __enter__(self) -> "AzureRedHatOpenShiftClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_configuration.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_configuration.py index cee01fb8b267..2eaf2b7f64f4 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_configuration.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_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 AzureRedHatOpenShiftClientConfiguration(Configuration): # pylint: disable 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 "2022-04-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AzureRedHatOpenShiftClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", "2022-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +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-redhatopenshift/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-redhatopenshift/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs # type: Any - ): - # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_metadata.json b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_metadata.json index a9507d3224c0..fe5b08d9dfa2 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_metadata.json +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureRedHatOpenShiftClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureRedHatOpenShiftClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureRedHatOpenShiftClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureRedHatOpenShiftClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -100,4 +100,4 @@ "operations": "Operations", "open_shift_clusters": "OpenShiftClustersOperations" } -} \ No newline at end of file +} diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_patch.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_vendor.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_vendor.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,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 +23,5 @@ 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) diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_version.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_version.py index 59deb8c7263b..e5754a47ce68 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_version.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/__init__.py index 6be616fa9ec0..b06f0016da77 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/__init__.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._azure_red_hat_open_shift_client import AzureRedHatOpenShiftClient -__all__ = ['AzureRedHatOpenShiftClient'] -# `._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 * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AzureRedHatOpenShiftClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/_azure_red_hat_open_shift_client.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/_azure_red_hat_open_shift_client.py index 20d25618b9aa..4eb2897f23e7 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/_azure_red_hat_open_shift_client.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/_azure_red_hat_open_shift_client.py @@ -9,12 +9,11 @@ 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 .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import AzureRedHatOpenShiftClientConfiguration from .operations import OpenShiftClustersOperations, Operations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class AzureRedHatOpenShiftClient: + +class AzureRedHatOpenShiftClient: # pylint: disable=client-accepts-api-version-keyword """Rest API for Azure Red Hat OpenShift 4. :ivar operations: Operations operations @@ -30,9 +30,9 @@ class AzureRedHatOpenShiftClient: :ivar open_shift_clusters: OpenShiftClustersOperations operations :vartype open_shift_clusters: azure.mgmt.redhatopenshift.v2022_04_01.aio.operations.OpenShiftClustersOperations - :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 @@ -50,22 +50,21 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = AzureRedHatOpenShiftClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = AzureRedHatOpenShiftClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.open_shift_clusters = OpenShiftClustersOperations(self._client, self._config, self._serialize, self._deserialize) - + self.open_shift_clusters = OpenShiftClustersOperations( + 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 @@ -74,7 +73,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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/_configuration.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/_configuration.py index 3fdb4fa67534..ef2705dad289 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/_configuration.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/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 AzureRedHatOpenShiftClientConfiguration(Configuration): # pylint: disable 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 "2022-04-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AzureRedHatOpenShiftClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", "2022-04-01") 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-redhatopenshift/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-redhatopenshift/{}".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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/_patch.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/operations/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/operations/__init__.py index 7ffcf7895ee8..70ea64711791 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/operations/__init__.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import Operations from ._open_shift_clusters_operations import OpenShiftClustersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'OpenShiftClustersOperations', + "Operations", + "OpenShiftClustersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/operations/_open_shift_clusters_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/operations/_open_shift_clusters_operations.py index 4a0f64e03a18..5ce8eea53035 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/operations/_open_shift_clusters_operations.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/operations/_open_shift_clusters_operations.py @@ -6,87 +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._open_shift_clusters_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_admin_credentials_request, build_list_by_resource_group_request, build_list_credentials_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._open_shift_clusters_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_admin_credentials_request, + build_list_by_resource_group_request, + build_list_credentials_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OpenShiftClustersOperations: - """OpenShiftClustersOperations 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 OpenShiftClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.redhatopenshift.v2022_04_01.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.redhatopenshift.v2022_04_01.aio.AzureRedHatOpenShiftClient`'s + :attr:`open_shift_clusters` 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.OpenShiftClusterList"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.OpenShiftCluster"]: """Lists OpenShift clusters in the specified subscription. The operation returns properties of each OpenShift cluster. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OpenShiftClusterList or the result of - cls(response) + :return: An iterator like instance of either OpenShiftCluster or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftClusterList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.OpenShiftClusterList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterList"] 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) 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) @@ -97,16 +130,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OpenShiftClusterList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -116,57 +147,67 @@ 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.RedHatOpenShift/openShiftClusters"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters"} @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.OpenShiftClusterList"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.OpenShiftCluster"]: """Lists OpenShift clusters in the specified subscription and resource group. The operation returns properties of each OpenShift cluster. :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 OpenShiftClusterList or the result of - cls(response) + :return: An iterator like instance of either OpenShiftCluster or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftClusterList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.OpenShiftClusterList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterList"] 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) 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) @@ -177,16 +218,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OpenShiftClusterList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -196,107 +235,124 @@ 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.RedHatOpenShift/openShiftClusters"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.OpenShiftCluster": + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.OpenShiftCluster: """Gets a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenShiftCluster, or the result of cls(response) + :return: OpenShiftCluster or the result of cls(response) :rtype: ~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftCluster"] 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', "2022-04-01") # type: str + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftCluster", + parameters: Union[_models.OpenShiftCluster, IO], **kwargs: Any - ) -> "_models.OpenShiftCluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftCluster"] + ) -> _models.OpenShiftCluster: 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', "2022-04-01") # 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(parameters, 'OpenShiftCluster') + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OpenShiftCluster") + + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -304,38 +360,124 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.OpenShiftCluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster + :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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftCluster", + parameters: Union[_models.OpenShiftCluster, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.OpenShiftCluster"]: + ) -> AsyncLROPoller[_models.OpenShiftCluster]: """Creates or updates a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str - :param parameters: The OpenShift cluster resource. - :type parameters: ~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster + :param parameters: The OpenShift cluster resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster 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 @@ -348,17 +490,17 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # 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.OpenShiftCluster"] - 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: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, @@ -366,63 +508,71 @@ async def begin_create_or_update( parameters=parameters, 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('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", 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: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any + self, resource_group_name: str, resource_name: str, **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', "2022-04-01") # 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: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -432,23 +582,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns nothing. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -460,80 +607,100 @@ 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', "2022-04-01") # 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: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_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): + 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, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } async def _update_initial( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftClusterUpdate", + parameters: Union[_models.OpenShiftClusterUpdate, IO], **kwargs: Any - ) -> "_models.OpenShiftCluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftCluster"] + ) -> _models.OpenShiftCluster: 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', "2022-04-01") # 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(parameters, 'OpenShiftClusterUpdate') + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OpenShiftClusterUpdate") + + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - 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) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -541,38 +708,124 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.OpenShiftClusterUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftClusterUpdate + :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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftClusterUpdate", + parameters: Union[_models.OpenShiftClusterUpdate, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.OpenShiftCluster"]: + ) -> AsyncLROPoller[_models.OpenShiftCluster]: """Creates or updates a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str - :param parameters: The OpenShift cluster resource. - :type parameters: ~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftClusterUpdate + :param parameters: The OpenShift cluster resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftClusterUpdate 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 @@ -585,17 +838,17 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # 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.OpenShiftCluster"] - 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: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_initial( resource_group_name=resource_group_name, @@ -603,151 +856,166 @@ async def begin_update( parameters=parameters, 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('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", 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: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } @distributed_trace_async async def list_admin_credentials( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.OpenShiftClusterAdminKubeconfig": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.OpenShiftClusterAdminKubeconfig: """Lists admin kubeconfig of an OpenShift cluster with the specified subscription, resource group and resource name. The operation returns the admin kubeconfig. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenShiftClusterAdminKubeconfig, or the result of cls(response) + :return: OpenShiftClusterAdminKubeconfig or the result of cls(response) :rtype: ~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftClusterAdminKubeconfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterAdminKubeconfig"] 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', "2022-04-01") # type: str + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.OpenShiftClusterAdminKubeconfig] = kwargs.pop("cls", None) - request = build_list_admin_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_admin_credentials.metadata['url'], + template_url=self.list_admin_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OpenShiftClusterAdminKubeconfig', pipeline_response) + deserialized = self._deserialize("OpenShiftClusterAdminKubeconfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_admin_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listAdminCredentials"} # type: ignore - + list_admin_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listAdminCredentials" + } @distributed_trace_async async def list_credentials( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.OpenShiftClusterCredentials": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.OpenShiftClusterCredentials: """Lists credentials of an OpenShift cluster with the specified subscription, resource group and resource name. The operation returns the credentials. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenShiftClusterCredentials, or the result of cls(response) + :return: OpenShiftClusterCredentials or the result of cls(response) :rtype: ~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftClusterCredentials - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterCredentials"] 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', "2022-04-01") # type: str + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.OpenShiftClusterCredentials] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OpenShiftClusterCredentials', pipeline_response) + deserialized = self._deserialize("OpenShiftClusterCredentials", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials"} # type: ignore - + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials" + } diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/operations/_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/operations/_operations.py index ceed1f41bf40..fdcb14324de6 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/operations/_operations.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/operations/_operations.py @@ -6,81 +6,107 @@ # 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') + +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.redhatopenshift.v2022_04_01.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.redhatopenshift.v2022_04_01.aio.AzureRedHatOpenShiftClient`'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.OperationList"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available RP operations. The operation returns the RP operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationList or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2022_04_01.models.OperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2022_04_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] 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) 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) @@ -91,16 +117,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -110,8 +134,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.RedHatOpenShift/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.RedHatOpenShift/operations"} diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/operations/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/models/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/models/__init__.py index e8fae19c6e76..64b94db9e1ff 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/models/__init__.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/models/__init__.py @@ -27,39 +27,41 @@ from ._models_py3 import TrackedResource from ._models_py3 import WorkerProfile - -from ._azure_red_hat_open_shift_client_enums import ( - CreatedByType, - EncryptionAtHost, - FipsValidatedModules, - ProvisioningState, - Visibility, -) +from ._azure_red_hat_open_shift_client_enums import CreatedByType +from ._azure_red_hat_open_shift_client_enums import EncryptionAtHost +from ._azure_red_hat_open_shift_client_enums import FipsValidatedModules +from ._azure_red_hat_open_shift_client_enums import ProvisioningState +from ._azure_red_hat_open_shift_client_enums import Visibility +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'APIServerProfile', - 'CloudErrorBody', - 'ClusterProfile', - 'ConsoleProfile', - 'Display', - 'IngressProfile', - 'MasterProfile', - 'NetworkProfile', - 'OpenShiftCluster', - 'OpenShiftClusterAdminKubeconfig', - 'OpenShiftClusterCredentials', - 'OpenShiftClusterList', - 'OpenShiftClusterUpdate', - 'Operation', - 'OperationList', - 'Resource', - 'ServicePrincipalProfile', - 'SystemData', - 'TrackedResource', - 'WorkerProfile', - 'CreatedByType', - 'EncryptionAtHost', - 'FipsValidatedModules', - 'ProvisioningState', - 'Visibility', + "APIServerProfile", + "CloudErrorBody", + "ClusterProfile", + "ConsoleProfile", + "Display", + "IngressProfile", + "MasterProfile", + "NetworkProfile", + "OpenShiftCluster", + "OpenShiftClusterAdminKubeconfig", + "OpenShiftClusterCredentials", + "OpenShiftClusterList", + "OpenShiftClusterUpdate", + "Operation", + "OperationList", + "Resource", + "ServicePrincipalProfile", + "SystemData", + "TrackedResource", + "WorkerProfile", + "CreatedByType", + "EncryptionAtHost", + "FipsValidatedModules", + "ProvisioningState", + "Visibility", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/models/_azure_red_hat_open_shift_client_enums.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/models/_azure_red_hat_open_shift_client_enums.py index aaffb9c2c7b5..7ca1dc70ec55 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/models/_azure_red_hat_open_shift_client_enums.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/models/_azure_red_hat_open_shift_client_enums.py @@ -7,36 +7,34 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -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 EncryptionAtHost(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """EncryptionAtHost represents encryption at host state - """ + +class EncryptionAtHost(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """EncryptionAtHost represents encryption at host state.""" DISABLED = "Disabled" ENABLED = "Enabled" -class FipsValidatedModules(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """FipsValidatedModules determines if FIPS is used. - """ + +class FipsValidatedModules(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """FipsValidatedModules determines if FIPS is used.""" DISABLED = "Disabled" ENABLED = "Enabled" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """ProvisioningState represents a provisioning state. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ProvisioningState represents a provisioning state.""" ADMIN_UPDATING = "AdminUpdating" CREATING = "Creating" @@ -45,9 +43,9 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -class Visibility(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Visibility represents visibility. - """ + +class Visibility(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Visibility represents visibility.""" PRIVATE = "Private" PUBLIC = "Public" diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/models/_models_py3.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/models/_models_py3.py index 321b7756128e..ce32314b4dd3 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/models/_models_py3.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/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,17 +8,19 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._azure_red_hat_open_shift_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class APIServerProfile(msrest.serialization.Model): +class APIServerProfile(_serialization.Model): """APIServerProfile represents an API server profile. - :ivar visibility: API server visibility. Possible values include: "Private", "Public". + :ivar visibility: API server visibility. Known values are: "Private" and "Public". :vartype visibility: str or ~azure.mgmt.redhatopenshift.v2022_04_01.models.Visibility :ivar url: The URL to access the cluster API server. :vartype url: str @@ -26,34 +29,34 @@ class APIServerProfile(msrest.serialization.Model): """ _attribute_map = { - 'visibility': {'key': 'visibility', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, - 'ip': {'key': 'ip', 'type': 'str'}, + "visibility": {"key": "visibility", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "ip": {"key": "ip", "type": "str"}, } def __init__( self, *, - visibility: Optional[Union[str, "Visibility"]] = None, + visibility: Optional[Union[str, "_models.Visibility"]] = None, url: Optional[str] = None, ip: Optional[str] = None, **kwargs ): """ - :keyword visibility: API server visibility. Possible values include: "Private", "Public". + :keyword visibility: API server visibility. Known values are: "Private" and "Public". :paramtype visibility: str or ~azure.mgmt.redhatopenshift.v2022_04_01.models.Visibility :keyword url: The URL to access the cluster API server. :paramtype url: str :keyword ip: The IP of the cluster API server. :paramtype ip: str """ - super(APIServerProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.visibility = visibility self.url = url self.ip = ip -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """CloudErrorBody represents the body of a cloud error. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -70,10 +73,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -82,7 +85,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -98,14 +101,14 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.redhatopenshift.v2022_04_01.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class ClusterProfile(msrest.serialization.Model): +class ClusterProfile(_serialization.Model): """ClusterProfile represents a cluster profile. :ivar pull_secret: The pull secret for the cluster. @@ -116,18 +119,18 @@ class ClusterProfile(msrest.serialization.Model): :vartype version: str :ivar resource_group_id: The ID of the cluster resource group. :vartype resource_group_id: str - :ivar fips_validated_modules: If FIPS validated crypto modules are used. Possible values - include: "Disabled", "Enabled". + :ivar fips_validated_modules: If FIPS validated crypto modules are used. Known values are: + "Disabled" and "Enabled". :vartype fips_validated_modules: str or ~azure.mgmt.redhatopenshift.v2022_04_01.models.FipsValidatedModules """ _attribute_map = { - 'pull_secret': {'key': 'pullSecret', 'type': 'str'}, - 'domain': {'key': 'domain', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'resource_group_id': {'key': 'resourceGroupId', 'type': 'str'}, - 'fips_validated_modules': {'key': 'fipsValidatedModules', 'type': 'str'}, + "pull_secret": {"key": "pullSecret", "type": "str"}, + "domain": {"key": "domain", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "resource_group_id": {"key": "resourceGroupId", "type": "str"}, + "fips_validated_modules": {"key": "fipsValidatedModules", "type": "str"}, } def __init__( @@ -137,7 +140,7 @@ def __init__( domain: Optional[str] = None, version: Optional[str] = None, resource_group_id: Optional[str] = None, - fips_validated_modules: Optional[Union[str, "FipsValidatedModules"]] = None, + fips_validated_modules: Optional[Union[str, "_models.FipsValidatedModules"]] = None, **kwargs ): """ @@ -149,12 +152,12 @@ def __init__( :paramtype version: str :keyword resource_group_id: The ID of the cluster resource group. :paramtype resource_group_id: str - :keyword fips_validated_modules: If FIPS validated crypto modules are used. Possible values - include: "Disabled", "Enabled". + :keyword fips_validated_modules: If FIPS validated crypto modules are used. Known values are: + "Disabled" and "Enabled". :paramtype fips_validated_modules: str or ~azure.mgmt.redhatopenshift.v2022_04_01.models.FipsValidatedModules """ - super(ClusterProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.pull_secret = pull_secret self.domain = domain self.version = version @@ -162,7 +165,7 @@ def __init__( self.fips_validated_modules = fips_validated_modules -class ConsoleProfile(msrest.serialization.Model): +class ConsoleProfile(_serialization.Model): """ConsoleProfile represents a console profile. :ivar url: The URL to access the cluster console. @@ -170,24 +173,19 @@ class ConsoleProfile(msrest.serialization.Model): """ _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, } - def __init__( - self, - *, - url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, url: Optional[str] = None, **kwargs): """ :keyword url: The URL to access the cluster console. :paramtype url: str """ - super(ConsoleProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url -class Display(msrest.serialization.Model): +class Display(_serialization.Model): """Display represents the display details of an operation. :ivar provider: Friendly name of the resource provider. @@ -201,10 +199,10 @@ class Display(msrest.serialization.Model): """ _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__( @@ -226,61 +224,61 @@ def __init__( :keyword description: Friendly name of the operation. :paramtype description: str """ - super(Display, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class IngressProfile(msrest.serialization.Model): +class IngressProfile(_serialization.Model): """IngressProfile represents an ingress profile. :ivar name: The ingress profile name. :vartype name: str - :ivar visibility: Ingress visibility. Possible values include: "Private", "Public". + :ivar visibility: Ingress visibility. Known values are: "Private" and "Public". :vartype visibility: str or ~azure.mgmt.redhatopenshift.v2022_04_01.models.Visibility :ivar ip: The IP of the ingress. :vartype ip: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'visibility': {'key': 'visibility', 'type': 'str'}, - 'ip': {'key': 'ip', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "visibility": {"key": "visibility", "type": "str"}, + "ip": {"key": "ip", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, - visibility: Optional[Union[str, "Visibility"]] = None, + visibility: Optional[Union[str, "_models.Visibility"]] = None, ip: Optional[str] = None, **kwargs ): """ :keyword name: The ingress profile name. :paramtype name: str - :keyword visibility: Ingress visibility. Possible values include: "Private", "Public". + :keyword visibility: Ingress visibility. Known values are: "Private" and "Public". :paramtype visibility: str or ~azure.mgmt.redhatopenshift.v2022_04_01.models.Visibility :keyword ip: The IP of the ingress. :paramtype ip: str """ - super(IngressProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.visibility = visibility self.ip = ip -class MasterProfile(msrest.serialization.Model): +class MasterProfile(_serialization.Model): """MasterProfile represents a master profile. :ivar vm_size: The size of the master VMs. :vartype vm_size: str :ivar subnet_id: The Azure resource ID of the master subnet. :vartype subnet_id: str - :ivar encryption_at_host: Whether master virtual machines are encrypted at host. Possible - values include: "Disabled", "Enabled". + :ivar encryption_at_host: Whether master virtual machines are encrypted at host. Known values + are: "Disabled" and "Enabled". :vartype encryption_at_host: str or ~azure.mgmt.redhatopenshift.v2022_04_01.models.EncryptionAtHost :ivar disk_encryption_set_id: The resource ID of an associated DiskEncryptionSet, if @@ -289,10 +287,10 @@ class MasterProfile(msrest.serialization.Model): """ _attribute_map = { - 'vm_size': {'key': 'vmSize', 'type': 'str'}, - 'subnet_id': {'key': 'subnetId', 'type': 'str'}, - 'encryption_at_host': {'key': 'encryptionAtHost', 'type': 'str'}, - 'disk_encryption_set_id': {'key': 'diskEncryptionSetId', 'type': 'str'}, + "vm_size": {"key": "vmSize", "type": "str"}, + "subnet_id": {"key": "subnetId", "type": "str"}, + "encryption_at_host": {"key": "encryptionAtHost", "type": "str"}, + "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, } def __init__( @@ -300,7 +298,7 @@ def __init__( *, vm_size: Optional[str] = None, subnet_id: Optional[str] = None, - encryption_at_host: Optional[Union[str, "EncryptionAtHost"]] = None, + encryption_at_host: Optional[Union[str, "_models.EncryptionAtHost"]] = None, disk_encryption_set_id: Optional[str] = None, **kwargs ): @@ -309,22 +307,22 @@ def __init__( :paramtype vm_size: str :keyword subnet_id: The Azure resource ID of the master subnet. :paramtype subnet_id: str - :keyword encryption_at_host: Whether master virtual machines are encrypted at host. Possible - values include: "Disabled", "Enabled". + :keyword encryption_at_host: Whether master virtual machines are encrypted at host. Known + values are: "Disabled" and "Enabled". :paramtype encryption_at_host: str or ~azure.mgmt.redhatopenshift.v2022_04_01.models.EncryptionAtHost :keyword disk_encryption_set_id: The resource ID of an associated DiskEncryptionSet, if applicable. :paramtype disk_encryption_set_id: str """ - super(MasterProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.vm_size = vm_size self.subnet_id = subnet_id self.encryption_at_host = encryption_at_host self.disk_encryption_set_id = disk_encryption_set_id -class NetworkProfile(msrest.serialization.Model): +class NetworkProfile(_serialization.Model): """NetworkProfile represents a network profile. :ivar pod_cidr: The CIDR used for OpenShift/Kubernetes Pods. @@ -334,29 +332,23 @@ class NetworkProfile(msrest.serialization.Model): """ _attribute_map = { - 'pod_cidr': {'key': 'podCidr', 'type': 'str'}, - 'service_cidr': {'key': 'serviceCidr', 'type': 'str'}, + "pod_cidr": {"key": "podCidr", "type": "str"}, + "service_cidr": {"key": "serviceCidr", "type": "str"}, } - def __init__( - self, - *, - pod_cidr: Optional[str] = None, - service_cidr: Optional[str] = None, - **kwargs - ): + def __init__(self, *, pod_cidr: Optional[str] = None, service_cidr: Optional[str] = None, **kwargs): """ :keyword pod_cidr: The CIDR used for OpenShift/Kubernetes Pods. :paramtype pod_cidr: str :keyword service_cidr: The CIDR used for OpenShift/Kubernetes Services. :paramtype service_cidr: str """ - super(NetworkProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.pod_cidr = pod_cidr self.service_cidr = service_cidr -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. @@ -372,24 +364,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - 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 @@ -410,46 +398,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :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}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - '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"}, + "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 OpenShiftCluster(TrackedResource): +class OpenShiftCluster(TrackedResource): # pylint: disable=too-many-instance-attributes """OpenShiftCluster represents an Azure Red Hat OpenShift cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -464,14 +446,14 @@ class OpenShiftCluster(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :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 system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.redhatopenshift.v2022_04_01.models.SystemData - :ivar provisioning_state: The cluster provisioning state. Possible values include: - "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: The cluster provisioning state. Known values are: "AdminUpdating", + "Creating", "Deleting", "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.redhatopenshift.v2022_04_01.models.ProvisioningState :ivar cluster_profile: The cluster profile. @@ -494,29 +476,29 @@ class OpenShiftCluster(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'cluster_profile': {'key': 'properties.clusterProfile', 'type': 'ClusterProfile'}, - 'console_profile': {'key': 'properties.consoleProfile', 'type': 'ConsoleProfile'}, - 'service_principal_profile': {'key': 'properties.servicePrincipalProfile', 'type': 'ServicePrincipalProfile'}, - 'network_profile': {'key': 'properties.networkProfile', 'type': 'NetworkProfile'}, - 'master_profile': {'key': 'properties.masterProfile', 'type': 'MasterProfile'}, - 'worker_profiles': {'key': 'properties.workerProfiles', 'type': '[WorkerProfile]'}, - 'apiserver_profile': {'key': 'properties.apiserverProfile', 'type': 'APIServerProfile'}, - 'ingress_profiles': {'key': 'properties.ingressProfiles', 'type': '[IngressProfile]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "cluster_profile": {"key": "properties.clusterProfile", "type": "ClusterProfile"}, + "console_profile": {"key": "properties.consoleProfile", "type": "ConsoleProfile"}, + "service_principal_profile": {"key": "properties.servicePrincipalProfile", "type": "ServicePrincipalProfile"}, + "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, + "master_profile": {"key": "properties.masterProfile", "type": "MasterProfile"}, + "worker_profiles": {"key": "properties.workerProfiles", "type": "[WorkerProfile]"}, + "apiserver_profile": {"key": "properties.apiserverProfile", "type": "APIServerProfile"}, + "ingress_profiles": {"key": "properties.ingressProfiles", "type": "[IngressProfile]"}, } def __init__( @@ -524,24 +506,24 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, - cluster_profile: Optional["ClusterProfile"] = None, - console_profile: Optional["ConsoleProfile"] = None, - service_principal_profile: Optional["ServicePrincipalProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - master_profile: Optional["MasterProfile"] = None, - worker_profiles: Optional[List["WorkerProfile"]] = None, - apiserver_profile: Optional["APIServerProfile"] = None, - ingress_profiles: Optional[List["IngressProfile"]] = None, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, + cluster_profile: Optional["_models.ClusterProfile"] = None, + console_profile: Optional["_models.ConsoleProfile"] = None, + service_principal_profile: Optional["_models.ServicePrincipalProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + master_profile: Optional["_models.MasterProfile"] = None, + worker_profiles: Optional[List["_models.WorkerProfile"]] = None, + apiserver_profile: Optional["_models.APIServerProfile"] = None, + ingress_profiles: Optional[List["_models.IngressProfile"]] = 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 provisioning_state: The cluster provisioning state. Possible values include: - "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", "Updating". + :keyword provisioning_state: The cluster provisioning state. Known values are: "AdminUpdating", + "Creating", "Deleting", "Failed", "Succeeded", and "Updating". :paramtype provisioning_state: str or ~azure.mgmt.redhatopenshift.v2022_04_01.models.ProvisioningState :keyword cluster_profile: The cluster profile. @@ -563,7 +545,7 @@ def __init__( :paramtype ingress_profiles: list[~azure.mgmt.redhatopenshift.v2022_04_01.models.IngressProfile] """ - super(OpenShiftCluster, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.system_data = None self.provisioning_state = provisioning_state self.cluster_profile = cluster_profile @@ -576,7 +558,7 @@ def __init__( self.ingress_profiles = ingress_profiles -class OpenShiftClusterAdminKubeconfig(msrest.serialization.Model): +class OpenShiftClusterAdminKubeconfig(_serialization.Model): """OpenShiftClusterAdminKubeconfig represents an OpenShift cluster's admin kubeconfig. :ivar kubeconfig: The base64-encoded kubeconfig file. @@ -584,24 +566,19 @@ class OpenShiftClusterAdminKubeconfig(msrest.serialization.Model): """ _attribute_map = { - 'kubeconfig': {'key': 'kubeconfig', 'type': 'str'}, + "kubeconfig": {"key": "kubeconfig", "type": "str"}, } - def __init__( - self, - *, - kubeconfig: Optional[str] = None, - **kwargs - ): + def __init__(self, *, kubeconfig: Optional[str] = None, **kwargs): """ :keyword kubeconfig: The base64-encoded kubeconfig file. :paramtype kubeconfig: str """ - super(OpenShiftClusterAdminKubeconfig, self).__init__(**kwargs) + super().__init__(**kwargs) self.kubeconfig = kubeconfig -class OpenShiftClusterCredentials(msrest.serialization.Model): +class OpenShiftClusterCredentials(_serialization.Model): """OpenShiftClusterCredentials represents an OpenShift cluster's credentials. :ivar kubeadmin_username: The username for the kubeadmin user. @@ -611,29 +588,23 @@ class OpenShiftClusterCredentials(msrest.serialization.Model): """ _attribute_map = { - 'kubeadmin_username': {'key': 'kubeadminUsername', 'type': 'str'}, - 'kubeadmin_password': {'key': 'kubeadminPassword', 'type': 'str'}, + "kubeadmin_username": {"key": "kubeadminUsername", "type": "str"}, + "kubeadmin_password": {"key": "kubeadminPassword", "type": "str"}, } - def __init__( - self, - *, - kubeadmin_username: Optional[str] = None, - kubeadmin_password: Optional[str] = None, - **kwargs - ): + def __init__(self, *, kubeadmin_username: Optional[str] = None, kubeadmin_password: Optional[str] = None, **kwargs): """ :keyword kubeadmin_username: The username for the kubeadmin user. :paramtype kubeadmin_username: str :keyword kubeadmin_password: The password for the kubeadmin user. :paramtype kubeadmin_password: str """ - super(OpenShiftClusterCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.kubeadmin_username = kubeadmin_username self.kubeadmin_password = kubeadmin_password -class OpenShiftClusterList(msrest.serialization.Model): +class OpenShiftClusterList(_serialization.Model): """OpenShiftClusterList represents a list of OpenShift clusters. :ivar value: The list of OpenShift clusters. @@ -643,16 +614,12 @@ class OpenShiftClusterList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[OpenShiftCluster]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OpenShiftCluster]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["OpenShiftCluster"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.OpenShiftCluster"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of OpenShift clusters. @@ -660,22 +627,22 @@ def __init__( :keyword next_link: The link used to get the next page of operations. :paramtype next_link: str """ - super(OpenShiftClusterList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class OpenShiftClusterUpdate(msrest.serialization.Model): +class OpenShiftClusterUpdate(_serialization.Model): # pylint: disable=too-many-instance-attributes """OpenShiftCluster represents an Azure Red Hat OpenShift cluster. Variables are only populated by the server, and will be ignored when sending a request. - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.redhatopenshift.v2022_04_01.models.SystemData - :ivar provisioning_state: The cluster provisioning state. Possible values include: - "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", "Updating". + :ivar provisioning_state: The cluster provisioning state. Known values are: "AdminUpdating", + "Creating", "Deleting", "Failed", "Succeeded", and "Updating". :vartype provisioning_state: str or ~azure.mgmt.redhatopenshift.v2022_04_01.models.ProvisioningState :ivar cluster_profile: The cluster profile. @@ -698,43 +665,43 @@ class OpenShiftClusterUpdate(msrest.serialization.Model): """ _validation = { - 'system_data': {'readonly': True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'cluster_profile': {'key': 'properties.clusterProfile', 'type': 'ClusterProfile'}, - 'console_profile': {'key': 'properties.consoleProfile', 'type': 'ConsoleProfile'}, - 'service_principal_profile': {'key': 'properties.servicePrincipalProfile', 'type': 'ServicePrincipalProfile'}, - 'network_profile': {'key': 'properties.networkProfile', 'type': 'NetworkProfile'}, - 'master_profile': {'key': 'properties.masterProfile', 'type': 'MasterProfile'}, - 'worker_profiles': {'key': 'properties.workerProfiles', 'type': '[WorkerProfile]'}, - 'apiserver_profile': {'key': 'properties.apiserverProfile', 'type': 'APIServerProfile'}, - 'ingress_profiles': {'key': 'properties.ingressProfiles', 'type': '[IngressProfile]'}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "cluster_profile": {"key": "properties.clusterProfile", "type": "ClusterProfile"}, + "console_profile": {"key": "properties.consoleProfile", "type": "ConsoleProfile"}, + "service_principal_profile": {"key": "properties.servicePrincipalProfile", "type": "ServicePrincipalProfile"}, + "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, + "master_profile": {"key": "properties.masterProfile", "type": "MasterProfile"}, + "worker_profiles": {"key": "properties.workerProfiles", "type": "[WorkerProfile]"}, + "apiserver_profile": {"key": "properties.apiserverProfile", "type": "APIServerProfile"}, + "ingress_profiles": {"key": "properties.ingressProfiles", "type": "[IngressProfile]"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, - cluster_profile: Optional["ClusterProfile"] = None, - console_profile: Optional["ConsoleProfile"] = None, - service_principal_profile: Optional["ServicePrincipalProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - master_profile: Optional["MasterProfile"] = None, - worker_profiles: Optional[List["WorkerProfile"]] = None, - apiserver_profile: Optional["APIServerProfile"] = None, - ingress_profiles: Optional[List["IngressProfile"]] = None, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, + cluster_profile: Optional["_models.ClusterProfile"] = None, + console_profile: Optional["_models.ConsoleProfile"] = None, + service_principal_profile: Optional["_models.ServicePrincipalProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + master_profile: Optional["_models.MasterProfile"] = None, + worker_profiles: Optional[List["_models.WorkerProfile"]] = None, + apiserver_profile: Optional["_models.APIServerProfile"] = None, + ingress_profiles: Optional[List["_models.IngressProfile"]] = None, **kwargs ): """ - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] - :keyword provisioning_state: The cluster provisioning state. Possible values include: - "AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", "Updating". + :keyword provisioning_state: The cluster provisioning state. Known values are: "AdminUpdating", + "Creating", "Deleting", "Failed", "Succeeded", and "Updating". :paramtype provisioning_state: str or ~azure.mgmt.redhatopenshift.v2022_04_01.models.ProvisioningState :keyword cluster_profile: The cluster profile. @@ -756,7 +723,7 @@ def __init__( :paramtype ingress_profiles: list[~azure.mgmt.redhatopenshift.v2022_04_01.models.IngressProfile] """ - super(OpenShiftClusterUpdate, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.system_data = None self.provisioning_state = provisioning_state @@ -770,7 +737,7 @@ def __init__( self.ingress_profiles = ingress_profiles -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Operation represents an RP operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -783,16 +750,16 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'Display'}, - 'origin': {'key': 'origin', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "Display"}, + "origin": {"key": "origin", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["Display"] = None, + display: Optional["_models.Display"] = None, origin: Optional[str] = None, **kwargs ): @@ -805,13 +772,13 @@ def __init__( user or system, e.g. "user,system". :paramtype origin: str """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin -class OperationList(msrest.serialization.Model): +class OperationList(_serialization.Model): """OperationList represents an RP operation list. :ivar value: List of operations supported by the resource provider. @@ -821,29 +788,23 @@ class OperationList(msrest.serialization.Model): """ _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, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of operations supported by the resource provider. :paramtype value: list[~azure.mgmt.redhatopenshift.v2022_04_01.models.Operation] :keyword next_link: The link used to get the next page of operations. :paramtype next_link: str """ - super(OperationList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ServicePrincipalProfile(msrest.serialization.Model): +class ServicePrincipalProfile(_serialization.Model): """ServicePrincipalProfile represents a service principal profile. :ivar client_id: The client ID used for the cluster. @@ -853,42 +814,36 @@ class ServicePrincipalProfile(msrest.serialization.Model): """ _attribute_map = { - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + "client_id": {"key": "clientId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, } - def __init__( - self, - *, - client_id: Optional[str] = None, - client_secret: Optional[str] = None, - **kwargs - ): + def __init__(self, *, client_id: Optional[str] = None, client_secret: Optional[str] = None, **kwargs): """ :keyword client_id: The client ID used for the cluster. :paramtype client_id: str :keyword client_secret: The client secret used for the cluster. :paramtype client_secret: str """ - super(ServicePrincipalProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_id = client_id self.client_secret = client_secret -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.redhatopenshift.v2022_04_01.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.redhatopenshift.v2022_04_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -896,43 +851,43 @@ class SystemData(msrest.serialization.Model): """ _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.redhatopenshift.v2022_04_01.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.redhatopenshift.v2022_04_01.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 @@ -941,7 +896,7 @@ def __init__( self.last_modified_at = last_modified_at -class WorkerProfile(msrest.serialization.Model): +class WorkerProfile(_serialization.Model): """WorkerProfile represents a worker profile. :ivar name: The worker profile name. @@ -954,8 +909,8 @@ class WorkerProfile(msrest.serialization.Model): :vartype subnet_id: str :ivar count: The number of worker VMs. :vartype count: int - :ivar encryption_at_host: Whether master virtual machines are encrypted at host. Possible - values include: "Disabled", "Enabled". + :ivar encryption_at_host: Whether master virtual machines are encrypted at host. Known values + are: "Disabled" and "Enabled". :vartype encryption_at_host: str or ~azure.mgmt.redhatopenshift.v2022_04_01.models.EncryptionAtHost :ivar disk_encryption_set_id: The resource ID of an associated DiskEncryptionSet, if @@ -964,13 +919,13 @@ class WorkerProfile(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'vm_size': {'key': 'vmSize', 'type': 'str'}, - 'disk_size_gb': {'key': 'diskSizeGB', 'type': 'int'}, - 'subnet_id': {'key': 'subnetId', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'int'}, - 'encryption_at_host': {'key': 'encryptionAtHost', 'type': 'str'}, - 'disk_encryption_set_id': {'key': 'diskEncryptionSetId', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "vm_size": {"key": "vmSize", "type": "str"}, + "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, + "subnet_id": {"key": "subnetId", "type": "str"}, + "count": {"key": "count", "type": "int"}, + "encryption_at_host": {"key": "encryptionAtHost", "type": "str"}, + "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, } def __init__( @@ -981,7 +936,7 @@ def __init__( disk_size_gb: Optional[int] = None, subnet_id: Optional[str] = None, count: Optional[int] = None, - encryption_at_host: Optional[Union[str, "EncryptionAtHost"]] = None, + encryption_at_host: Optional[Union[str, "_models.EncryptionAtHost"]] = None, disk_encryption_set_id: Optional[str] = None, **kwargs ): @@ -996,15 +951,15 @@ def __init__( :paramtype subnet_id: str :keyword count: The number of worker VMs. :paramtype count: int - :keyword encryption_at_host: Whether master virtual machines are encrypted at host. Possible - values include: "Disabled", "Enabled". + :keyword encryption_at_host: Whether master virtual machines are encrypted at host. Known + values are: "Disabled" and "Enabled". :paramtype encryption_at_host: str or ~azure.mgmt.redhatopenshift.v2022_04_01.models.EncryptionAtHost :keyword disk_encryption_set_id: The resource ID of an associated DiskEncryptionSet, if applicable. :paramtype disk_encryption_set_id: str """ - super(WorkerProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.vm_size = vm_size self.disk_size_gb = disk_size_gb diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/models/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/operations/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/operations/__init__.py index 7ffcf7895ee8..70ea64711791 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/operations/__init__.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/operations/__init__.py @@ -9,7 +9,13 @@ from ._operations import Operations from ._open_shift_clusters_operations import OpenShiftClustersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'OpenShiftClustersOperations', + "Operations", + "OpenShiftClustersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/operations/_open_shift_clusters_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/operations/_open_shift_clusters_operations.py index 21e084a8d424..dbaf7f51a867 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/operations/_open_shift_clusters_operations.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/operations/_open_shift_clusters_operations.py @@ -6,388 +6,371 @@ # 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 ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +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', "2022-04-01") # 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: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters" + ) # pylint: disable=line-too-long 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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', "2022-04-01") # 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: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters", + ) # 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) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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, - resource_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # 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, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", + ) # 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), - "resourceName": _SERIALIZER.url("resource_name", resource_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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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, - resource_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, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # 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: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", + ) # 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), - "resourceName": _SERIALIZER.url("resource_name", resource_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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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, - resource_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, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", + ) # 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), - "resourceName": _SERIALIZER.url("resource_name", resource_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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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 - ) - - -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # 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: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", + ) # 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), - "resourceName": _SERIALIZER.url("resource_name", resource_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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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_list_admin_credentials_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listAdminCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listAdminCredentials", + ) # 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), - "resourceName": _SERIALIZER.url("resource_name", resource_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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_credentials_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials", + ) # 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), - "resourceName": _SERIALIZER.url("resource_name", resource_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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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 - ) - -class OpenShiftClustersOperations(object): - """OpenShiftClustersOperations 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.redhatopenshift.v2022_04_01.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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class OpenShiftClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redhatopenshift.v2022_04_01.AzureRedHatOpenShiftClient`'s + :attr:`open_shift_clusters` 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.OpenShiftClusterList"]: + def list(self, **kwargs: Any) -> Iterable["_models.OpenShiftCluster"]: """Lists OpenShift clusters in the specified subscription. The operation returns properties of each OpenShift cluster. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OpenShiftClusterList or the result of - cls(response) + :return: An iterator like instance of either OpenShiftCluster or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftClusterList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.OpenShiftClusterList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterList"] 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) 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) @@ -398,16 +381,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OpenShiftClusterList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -417,57 +398,65 @@ 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.RedHatOpenShift/openShiftClusters"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.OpenShiftClusterList"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.OpenShiftCluster"]: """Lists OpenShift clusters in the specified subscription and resource group. The operation returns properties of each OpenShift cluster. :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 OpenShiftClusterList or the result of - cls(response) + :return: An iterator like instance of either OpenShiftCluster or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftClusterList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.OpenShiftClusterList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterList"] 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) 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) @@ -478,16 +467,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OpenShiftClusterList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -497,107 +484,124 @@ 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.RedHatOpenShift/openShiftClusters"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters" + } @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.OpenShiftCluster": + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.OpenShiftCluster: """Gets a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenShiftCluster, or the result of cls(response) + :return: OpenShiftCluster or the result of cls(response) :rtype: ~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftCluster"] 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', "2022-04-01") # type: str + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftCluster", + parameters: Union[_models.OpenShiftCluster, IO], **kwargs: Any - ) -> "_models.OpenShiftCluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftCluster"] + ) -> _models.OpenShiftCluster: 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', "2022-04-01") # 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(parameters, 'OpenShiftCluster') + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OpenShiftCluster") + + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -605,38 +609,124 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.OpenShiftCluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster + :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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftCluster", + parameters: Union[_models.OpenShiftCluster, IO], **kwargs: Any - ) -> LROPoller["_models.OpenShiftCluster"]: + ) -> LROPoller[_models.OpenShiftCluster]: """Creates or updates a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str - :param parameters: The OpenShift cluster resource. - :type parameters: ~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster + :param parameters: The OpenShift cluster resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster 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 @@ -649,17 +739,17 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # 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.OpenShiftCluster"] - 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: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, @@ -667,63 +757,71 @@ def begin_create_or_update( parameters=parameters, 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('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", 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: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any + self, resource_group_name: str, resource_name: str, **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', "2022-04-01") # 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: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -733,23 +831,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns nothing. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -761,80 +856,100 @@ 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', "2022-04-01") # 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: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_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): + 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, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } def _update_initial( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftClusterUpdate", + parameters: Union[_models.OpenShiftClusterUpdate, IO], **kwargs: Any - ) -> "_models.OpenShiftCluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftCluster"] + ) -> _models.OpenShiftCluster: 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', "2022-04-01") # 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(parameters, 'OpenShiftClusterUpdate') + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OpenShiftClusterUpdate") + + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - 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) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -842,38 +957,124 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.OpenShiftClusterUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftClusterUpdate + :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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.OpenShiftClusterUpdate", + parameters: Union[_models.OpenShiftClusterUpdate, IO], **kwargs: Any - ) -> LROPoller["_models.OpenShiftCluster"]: + ) -> LROPoller[_models.OpenShiftCluster]: """Creates or updates a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str - :param parameters: The OpenShift cluster resource. - :type parameters: ~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftClusterUpdate + :param parameters: The OpenShift cluster resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftClusterUpdate 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 @@ -886,17 +1087,17 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftCluster] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # 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.OpenShiftCluster"] - 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: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, @@ -904,151 +1105,166 @@ def begin_update( parameters=parameters, 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('OpenShiftCluster', pipeline_response) + deserialized = self._deserialize("OpenShiftCluster", 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: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}"} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } @distributed_trace def list_admin_credentials( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.OpenShiftClusterAdminKubeconfig": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.OpenShiftClusterAdminKubeconfig: """Lists admin kubeconfig of an OpenShift cluster with the specified subscription, resource group and resource name. The operation returns the admin kubeconfig. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenShiftClusterAdminKubeconfig, or the result of cls(response) + :return: OpenShiftClusterAdminKubeconfig or the result of cls(response) :rtype: ~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftClusterAdminKubeconfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterAdminKubeconfig"] 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', "2022-04-01") # type: str + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.OpenShiftClusterAdminKubeconfig] = kwargs.pop("cls", None) - request = build_list_admin_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_admin_credentials.metadata['url'], + template_url=self.list_admin_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OpenShiftClusterAdminKubeconfig', pipeline_response) + deserialized = self._deserialize("OpenShiftClusterAdminKubeconfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_admin_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listAdminCredentials"} # type: ignore - + list_admin_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listAdminCredentials" + } @distributed_trace def list_credentials( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.OpenShiftClusterCredentials": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.OpenShiftClusterCredentials: """Lists credentials of an OpenShift cluster with the specified subscription, resource group and resource name. The operation returns the credentials. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The name of the OpenShift cluster resource. + :param resource_name: The name of the OpenShift cluster resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OpenShiftClusterCredentials, or the result of cls(response) + :return: OpenShiftClusterCredentials or the result of cls(response) :rtype: ~azure.mgmt.redhatopenshift.v2022_04_01.models.OpenShiftClusterCredentials - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenShiftClusterCredentials"] 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', "2022-04-01") # type: str + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.OpenShiftClusterCredentials] = kwargs.pop("cls", None) - request = build_list_credentials_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_credentials.metadata['url'], + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OpenShiftClusterCredentials', pipeline_response) + deserialized = self._deserialize("OpenShiftClusterCredentials", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials"} # type: ignore - + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials" + } diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/operations/_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/operations/_operations.py index 1bb6e4bd3055..f7cf552dbbec 100644 --- a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/operations/_operations.py +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/operations/_operations.py @@ -6,110 +6,128 @@ # 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 ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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', "2022-04-01") # 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: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.RedHatOpenShift/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.redhatopenshift.v2022_04_01.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.redhatopenshift.v2022_04_01.AzureRedHatOpenShiftClient`'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.OperationList"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available RP operations. The operation returns the RP operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationList or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2022_04_01.models.OperationList] - :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.redhatopenshift.v2022_04_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] 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) 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) @@ -120,16 +138,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -139,8 +155,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.RedHatOpenShift/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.RedHatOpenShift/operations"} diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/operations/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_04_01/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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/__init__.py new file mode 100644 index 000000000000..c64163c98d3d --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/__init__.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._azure_red_hat_open_shift_client import AzureRedHatOpenShiftClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AzureRedHatOpenShiftClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/_azure_red_hat_open_shift_client.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/_azure_red_hat_open_shift_client.py new file mode 100644 index 000000000000..e6f07110b101 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/_azure_red_hat_open_shift_client.py @@ -0,0 +1,127 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import AzureRedHatOpenShiftClientConfiguration +from .operations import ( + MachinePoolsOperations, + OpenShiftClustersOperations, + OpenShiftVersionsOperations, + Operations, + SecretsOperations, + SyncIdentityProvidersOperations, + SyncSetsOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class AzureRedHatOpenShiftClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """Rest API for Azure Red Hat OpenShift 4. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.redhatopenshift.v2022_09_04.operations.Operations + :ivar open_shift_versions: OpenShiftVersionsOperations operations + :vartype open_shift_versions: + azure.mgmt.redhatopenshift.v2022_09_04.operations.OpenShiftVersionsOperations + :ivar open_shift_clusters: OpenShiftClustersOperations operations + :vartype open_shift_clusters: + azure.mgmt.redhatopenshift.v2022_09_04.operations.OpenShiftClustersOperations + :ivar machine_pools: MachinePoolsOperations operations + :vartype machine_pools: + azure.mgmt.redhatopenshift.v2022_09_04.operations.MachinePoolsOperations + :ivar secrets: SecretsOperations operations + :vartype secrets: azure.mgmt.redhatopenshift.v2022_09_04.operations.SecretsOperations + :ivar sync_identity_providers: SyncIdentityProvidersOperations operations + :vartype sync_identity_providers: + azure.mgmt.redhatopenshift.v2022_09_04.operations.SyncIdentityProvidersOperations + :ivar sync_sets: SyncSetsOperations operations + :vartype sync_sets: azure.mgmt.redhatopenshift.v2022_09_04.operations.SyncSetsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-09-04". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AzureRedHatOpenShiftClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.open_shift_versions = OpenShiftVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.open_shift_clusters = OpenShiftClustersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.machine_pools = MachinePoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.secrets = SecretsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sync_identity_providers = SyncIdentityProvidersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sync_sets = SyncSetsOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "AzureRedHatOpenShiftClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/_configuration.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/_configuration.py new file mode 100644 index 000000000000..478a189e2f1b --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/_configuration.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import sys +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class AzureRedHatOpenShiftClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for AzureRedHatOpenShiftClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-09-04". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(AzureRedHatOpenShiftClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", "2022-09-04") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-redhatopenshift/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/_metadata.json b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/_metadata.json new file mode 100644 index 000000000000..cd6626c22759 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/_metadata.json @@ -0,0 +1,108 @@ +{ + "chosen_version": "2022-09-04", + "total_api_version_list": ["2022-09-04"], + "client": { + "name": "AzureRedHatOpenShiftClient", + "filename": "_azure_red_hat_open_shift_client", + "description": "Rest API for Azure Red Hat OpenShift 4.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureRedHatOpenShiftClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AzureRedHatOpenShiftClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version: Optional[str]=None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "operations": "Operations", + "open_shift_versions": "OpenShiftVersionsOperations", + "open_shift_clusters": "OpenShiftClustersOperations", + "machine_pools": "MachinePoolsOperations", + "secrets": "SecretsOperations", + "sync_identity_providers": "SyncIdentityProvidersOperations", + "sync_sets": "SyncSetsOperations" + } +} diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/_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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/_vendor.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/_version.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/__init__.py new file mode 100644 index 000000000000..b06f0016da77 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._azure_red_hat_open_shift_client import AzureRedHatOpenShiftClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AzureRedHatOpenShiftClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/_azure_red_hat_open_shift_client.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/_azure_red_hat_open_shift_client.py new file mode 100644 index 000000000000..9fd2094b8037 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/_azure_red_hat_open_shift_client.py @@ -0,0 +1,127 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import AzureRedHatOpenShiftClientConfiguration +from .operations import ( + MachinePoolsOperations, + OpenShiftClustersOperations, + OpenShiftVersionsOperations, + Operations, + SecretsOperations, + SyncIdentityProvidersOperations, + SyncSetsOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AzureRedHatOpenShiftClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """Rest API for Azure Red Hat OpenShift 4. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.redhatopenshift.v2022_09_04.aio.operations.Operations + :ivar open_shift_versions: OpenShiftVersionsOperations operations + :vartype open_shift_versions: + azure.mgmt.redhatopenshift.v2022_09_04.aio.operations.OpenShiftVersionsOperations + :ivar open_shift_clusters: OpenShiftClustersOperations operations + :vartype open_shift_clusters: + azure.mgmt.redhatopenshift.v2022_09_04.aio.operations.OpenShiftClustersOperations + :ivar machine_pools: MachinePoolsOperations operations + :vartype machine_pools: + azure.mgmt.redhatopenshift.v2022_09_04.aio.operations.MachinePoolsOperations + :ivar secrets: SecretsOperations operations + :vartype secrets: azure.mgmt.redhatopenshift.v2022_09_04.aio.operations.SecretsOperations + :ivar sync_identity_providers: SyncIdentityProvidersOperations operations + :vartype sync_identity_providers: + azure.mgmt.redhatopenshift.v2022_09_04.aio.operations.SyncIdentityProvidersOperations + :ivar sync_sets: SyncSetsOperations operations + :vartype sync_sets: azure.mgmt.redhatopenshift.v2022_09_04.aio.operations.SyncSetsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-09-04". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AzureRedHatOpenShiftClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.open_shift_versions = OpenShiftVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.open_shift_clusters = OpenShiftClustersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.machine_pools = MachinePoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.secrets = SecretsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sync_identity_providers = SyncIdentityProvidersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sync_sets = SyncSetsOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AzureRedHatOpenShiftClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/_configuration.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/_configuration.py new file mode 100644 index 000000000000..8149513ffaa3 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/_configuration.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import sys +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AzureRedHatOpenShiftClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for AzureRedHatOpenShiftClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-09-04". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(AzureRedHatOpenShiftClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", "2022-09-04") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-redhatopenshift/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/__init__.py new file mode 100644 index 000000000000..f03257fe6903 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/__init__.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._open_shift_versions_operations import OpenShiftVersionsOperations +from ._open_shift_clusters_operations import OpenShiftClustersOperations +from ._machine_pools_operations import MachinePoolsOperations +from ._secrets_operations import SecretsOperations +from ._sync_identity_providers_operations import SyncIdentityProvidersOperations +from ._sync_sets_operations import SyncSetsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "Operations", + "OpenShiftVersionsOperations", + "OpenShiftClustersOperations", + "MachinePoolsOperations", + "SecretsOperations", + "SyncIdentityProvidersOperations", + "SyncSetsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_machine_pools_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_machine_pools_operations.py new file mode 100644 index 000000000000..ed59673c6198 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_machine_pools_operations.py @@ -0,0 +1,607 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.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 ... import models as _models +from ..._vendor import _convert_request +from ...operations._machine_pools_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class MachinePoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redhatopenshift.v2022_09_04.aio.AzureRedHatOpenShiftClient`'s + :attr:`machine_pools` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncIterable["_models.MachinePool"]: + """Lists MachinePools that belong to that Azure Red Hat OpenShift Cluster. + + The operation returns properties of each MachinePool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MachinePool or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.MachinePoolList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("MachinePoolList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftCluster/{resourceName}/machinePools" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any + ) -> _models.MachinePool: + """Gets a MachinePool with the specified subscription, resource group and resource name. + + The operation returns properties of a MachinePool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the MachinePool resource. Required. + :type child_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MachinePool or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.MachinePool] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MachinePool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/machinePool/{childResourceName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: _models.MachinePool, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MachinePool: + """Creates or updates a MachinePool with the specified subscription, resource group and resource + name. + + The operation returns properties of a MachinePool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the MachinePool resource. Required. + :type child_resource_name: str + :param parameters: The MachinePool resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool + :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: MachinePool or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MachinePool: + """Creates or updates a MachinePool with the specified subscription, resource group and resource + name. + + The operation returns properties of a MachinePool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the MachinePool resource. Required. + :type child_resource_name: str + :param parameters: The MachinePool resource. Required. + :type parameters: 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: MachinePool or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: Union[_models.MachinePool, IO], + **kwargs: Any + ) -> _models.MachinePool: + """Creates or updates a MachinePool with the specified subscription, resource group and resource + name. + + The operation returns properties of a MachinePool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the MachinePool resource. Required. + :type child_resource_name: str + :param parameters: The MachinePool resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool 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: MachinePool or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MachinePool] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MachinePool") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("MachinePool", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("MachinePool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/machinePool/{childResourceName}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any + ) -> None: + """Deletes a MachinePool with the specified subscription, resource group and resource name. + + The operation returns nothing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the MachinePool resource. Required. + :type child_resource_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) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/machinePool/{childResourceName}" + } + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: _models.MachinePoolUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MachinePool: + """Updates a MachinePool with the specified subscription, resource group and resource name. + + The operation returns properties of a MachinePool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the MachinePool resource. Required. + :type child_resource_name: str + :param parameters: The MachinePool resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePoolUpdate + :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: MachinePool or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MachinePool: + """Updates a MachinePool with the specified subscription, resource group and resource name. + + The operation returns properties of a MachinePool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the MachinePool resource. Required. + :type child_resource_name: str + :param parameters: The MachinePool resource. Required. + :type parameters: 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: MachinePool or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: Union[_models.MachinePoolUpdate, IO], + **kwargs: Any + ) -> _models.MachinePool: + """Updates a MachinePool with the specified subscription, resource group and resource name. + + The operation returns properties of a MachinePool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the MachinePool resource. Required. + :type child_resource_name: str + :param parameters: The MachinePool resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePoolUpdate 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: MachinePool or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MachinePool] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MachinePoolUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MachinePool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/machinePool/{childResourceName}" + } diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_open_shift_clusters_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_open_shift_clusters_operations.py new file mode 100644 index 000000000000..a57b0ce125b2 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_open_shift_clusters_operations.py @@ -0,0 +1,1021 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._open_shift_clusters_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_admin_credentials_request, + build_list_by_resource_group_request, + build_list_credentials_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class OpenShiftClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redhatopenshift.v2022_09_04.aio.AzureRedHatOpenShiftClient`'s + :attr:`open_shift_clusters` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.OpenShiftCluster"]: + """Lists OpenShift clusters in the specified subscription. + + The operation returns properties of each OpenShift cluster. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OpenShiftCluster or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.OpenShiftClusterList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OpenShiftClusterList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters"} + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.OpenShiftCluster"]: + """Lists OpenShift clusters in the specified subscription and resource group. + + The operation returns properties of each OpenShift cluster. + + :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 OpenShiftCluster or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.OpenShiftClusterList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OpenShiftClusterList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.OpenShiftCluster: + """Gets a OpenShift cluster with the specified subscription, resource group and resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OpenShiftCluster or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.OpenShiftCluster, IO], + **kwargs: Any + ) -> _models.OpenShiftCluster: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OpenShiftCluster") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.OpenShiftCluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster + :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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.OpenShiftCluster, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes a OpenShift cluster with the specified subscription, resource group and resource name. + + The operation returns nothing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + async def _update_initial( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.OpenShiftClusterUpdate, IO], + **kwargs: Any + ) -> _models.OpenShiftCluster: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OpenShiftClusterUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.OpenShiftClusterUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftClusterUpdate + :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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.OpenShiftClusterUpdate, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftClusterUpdate 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + @distributed_trace_async + async def list_admin_credentials( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.OpenShiftClusterAdminKubeconfig: + """Lists admin kubeconfig of an OpenShift cluster with the specified subscription, resource group + and resource name. + + The operation returns the admin kubeconfig. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OpenShiftClusterAdminKubeconfig or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftClusterAdminKubeconfig + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.OpenShiftClusterAdminKubeconfig] = kwargs.pop("cls", None) + + request = build_list_admin_credentials_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_admin_credentials.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OpenShiftClusterAdminKubeconfig", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_admin_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listAdminCredentials" + } + + @distributed_trace_async + async def list_credentials( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.OpenShiftClusterCredentials: + """Lists credentials of an OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns the credentials. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OpenShiftClusterCredentials or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftClusterCredentials + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.OpenShiftClusterCredentials] = kwargs.pop("cls", None) + + request = build_list_credentials_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OpenShiftClusterCredentials", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials" + } diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_open_shift_versions_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_open_shift_versions_operations.py new file mode 100644 index 000000000000..7287293ed5b3 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_open_shift_versions_operations.py @@ -0,0 +1,145 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._open_shift_versions_operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class OpenShiftVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redhatopenshift.v2022_09_04.aio.AzureRedHatOpenShiftClient`'s + :attr:`open_shift_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.OpenShiftVersion"]: + """Lists all OpenShift versions available to install in the specified location. + + The operation returns the installable OpenShift versions as strings. + + :param location: The name of Azure region. Required. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OpenShiftVersion or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.OpenShiftVersionList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OpenShiftVersionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/locations/{location}/openshiftversions" + } diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_operations.py new file mode 100644 index 000000000000..376611aecbc1 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_operations.py @@ -0,0 +1,139 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redhatopenshift.v2022_09_04.aio.AzureRedHatOpenShiftClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + """Lists all of the available RP operations. + + The operation returns the RP operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2022_09_04.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.RedHatOpenShift/operations"} diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_secrets_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_secrets_operations.py new file mode 100644 index 000000000000..af9e527f7af2 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_secrets_operations.py @@ -0,0 +1,604 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.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 ... import models as _models +from ..._vendor import _convert_request +from ...operations._secrets_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SecretsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redhatopenshift.v2022_09_04.aio.AzureRedHatOpenShiftClient`'s + :attr:`secrets` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncIterable["_models.Secret"]: + """Lists Secrets that belong to that Azure Red Hat OpenShift Cluster. + + The operation returns properties of each Secret. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Secret or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.SecretList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecretList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftCluster/{resourceName}/secrets" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any + ) -> _models.Secret: + """Gets a Secret with the specified subscription, resource group and resource name. + + The operation returns properties of a Secret. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the Secret resource. Required. + :type child_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Secret or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Secret", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/secret/{childResourceName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: _models.Secret, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Creates or updates a Secret with the specified subscription, resource group and resource name. + + The operation returns properties of a Secret. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the Secret resource. Required. + :type child_resource_name: str + :param parameters: The Secret resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret + :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: Secret or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Creates or updates a Secret with the specified subscription, resource group and resource name. + + The operation returns properties of a Secret. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the Secret resource. Required. + :type child_resource_name: str + :param parameters: The Secret resource. Required. + :type parameters: 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: Secret or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: Union[_models.Secret, IO], + **kwargs: Any + ) -> _models.Secret: + """Creates or updates a Secret with the specified subscription, resource group and resource name. + + The operation returns properties of a Secret. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the Secret resource. Required. + :type child_resource_name: str + :param parameters: The Secret resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret 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: Secret or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Secret") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Secret", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Secret", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/secret/{childResourceName}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any + ) -> None: + """Deletes a Secret with the specified subscription, resource group and resource name. + + The operation returns nothing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the Secret resource. Required. + :type child_resource_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) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/secret/{childResourceName}" + } + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: _models.SecretUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Updates a Secret with the specified subscription, resource group and resource name. + + The operation returns properties of a Secret. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the Secret resource. Required. + :type child_resource_name: str + :param parameters: The Secret resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SecretUpdate + :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: Secret or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Updates a Secret with the specified subscription, resource group and resource name. + + The operation returns properties of a Secret. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the Secret resource. Required. + :type child_resource_name: str + :param parameters: The Secret resource. Required. + :type parameters: 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: Secret or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: Union[_models.SecretUpdate, IO], + **kwargs: Any + ) -> _models.Secret: + """Updates a Secret with the specified subscription, resource group and resource name. + + The operation returns properties of a Secret. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the Secret resource. Required. + :type child_resource_name: str + :param parameters: The Secret resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SecretUpdate 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: Secret or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SecretUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Secret", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/secret/{childResourceName}" + } diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_sync_identity_providers_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_sync_identity_providers_operations.py new file mode 100644 index 000000000000..cc03a66a7d1e --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_sync_identity_providers_operations.py @@ -0,0 +1,617 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.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 ... import models as _models +from ..._vendor import _convert_request +from ...operations._sync_identity_providers_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SyncIdentityProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redhatopenshift.v2022_09_04.aio.AzureRedHatOpenShiftClient`'s + :attr:`sync_identity_providers` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SyncIdentityProvider"]: + """Lists SyncIdentityProviders that belong to that Azure Red Hat OpenShift Cluster. + + The operation returns properties of each SyncIdentityProvider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SyncIdentityProvider or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.SyncIdentityProviderList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SyncIdentityProviderList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftCluster/{resourceName}/syncIdentityProviders" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any + ) -> _models.SyncIdentityProvider: + """Gets a SyncIdentityProvider with the specified subscription, resource group and resource name. + + The operation returns properties of a SyncIdentityProvider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncIdentityProvider resource. Required. + :type child_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SyncIdentityProvider or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.SyncIdentityProvider] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SyncIdentityProvider", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncIdentityProvider/{childResourceName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: _models.SyncIdentityProvider, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SyncIdentityProvider: + """Creates or updates a SyncIdentityProvider with the specified subscription, resource group and + resource name. + + The operation returns properties of a SyncIdentityProvider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncIdentityProvider resource. Required. + :type child_resource_name: str + :param parameters: The SyncIdentityProvider resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider + :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: SyncIdentityProvider or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SyncIdentityProvider: + """Creates or updates a SyncIdentityProvider with the specified subscription, resource group and + resource name. + + The operation returns properties of a SyncIdentityProvider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncIdentityProvider resource. Required. + :type child_resource_name: str + :param parameters: The SyncIdentityProvider resource. Required. + :type parameters: 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: SyncIdentityProvider or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: Union[_models.SyncIdentityProvider, IO], + **kwargs: Any + ) -> _models.SyncIdentityProvider: + """Creates or updates a SyncIdentityProvider with the specified subscription, resource group and + resource name. + + The operation returns properties of a SyncIdentityProvider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncIdentityProvider resource. Required. + :type child_resource_name: str + :param parameters: The SyncIdentityProvider resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider 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: SyncIdentityProvider or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SyncIdentityProvider] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SyncIdentityProvider") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SyncIdentityProvider", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SyncIdentityProvider", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncIdentityProvider/{childResourceName}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any + ) -> None: + """Deletes a SyncIdentityProvider with the specified subscription, resource group and resource + name. + + The operation returns nothing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncIdentityProvider resource. Required. + :type child_resource_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) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncIdentityProvider/{childResourceName}" + } + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: _models.SyncIdentityProviderUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SyncIdentityProvider: + """Updates a SyncIdentityProvider with the specified subscription, resource group and resource + name. + + The operation returns properties of a SyncIdentityProvider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncIdentityProvider resource. Required. + :type child_resource_name: str + :param parameters: The SyncIdentityProvider resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProviderUpdate + :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: SyncIdentityProvider or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SyncIdentityProvider: + """Updates a SyncIdentityProvider with the specified subscription, resource group and resource + name. + + The operation returns properties of a SyncIdentityProvider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncIdentityProvider resource. Required. + :type child_resource_name: str + :param parameters: The SyncIdentityProvider resource. Required. + :type parameters: 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: SyncIdentityProvider or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: Union[_models.SyncIdentityProviderUpdate, IO], + **kwargs: Any + ) -> _models.SyncIdentityProvider: + """Updates a SyncIdentityProvider with the specified subscription, resource group and resource + name. + + The operation returns properties of a SyncIdentityProvider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncIdentityProvider resource. Required. + :type child_resource_name: str + :param parameters: The SyncIdentityProvider resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProviderUpdate 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: SyncIdentityProvider or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SyncIdentityProvider] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SyncIdentityProviderUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SyncIdentityProvider", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncIdentityProvider/{childResourceName}" + } diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_sync_sets_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_sync_sets_operations.py new file mode 100644 index 000000000000..ba86d9ddad78 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/aio/operations/_sync_sets_operations.py @@ -0,0 +1,604 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.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 ... import models as _models +from ..._vendor import _convert_request +from ...operations._sync_sets_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SyncSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redhatopenshift.v2022_09_04.aio.AzureRedHatOpenShiftClient`'s + :attr:`sync_sets` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncIterable["_models.SyncSet"]: + """Lists SyncSets that belong to that Azure Red Hat OpenShift Cluster. + + The operation returns properties of each SyncSet. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SyncSet or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.SyncSetList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SyncSetList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftCluster/{resourceName}/syncSets" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any + ) -> _models.SyncSet: + """Gets a SyncSet with the specified subscription, resource group and resource name. + + The operation returns properties of a SyncSet. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncSet resource. Required. + :type child_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SyncSet or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.SyncSet] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SyncSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncSet/{childResourceName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: _models.SyncSet, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SyncSet: + """Creates or updates a SyncSet with the specified subscription, resource group and resource name. + + The operation returns properties of a SyncSet. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncSet resource. Required. + :type child_resource_name: str + :param parameters: The SyncSet resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet + :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: SyncSet or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SyncSet: + """Creates or updates a SyncSet with the specified subscription, resource group and resource name. + + The operation returns properties of a SyncSet. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncSet resource. Required. + :type child_resource_name: str + :param parameters: The SyncSet resource. Required. + :type parameters: 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: SyncSet or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: Union[_models.SyncSet, IO], + **kwargs: Any + ) -> _models.SyncSet: + """Creates or updates a SyncSet with the specified subscription, resource group and resource name. + + The operation returns properties of a SyncSet. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncSet resource. Required. + :type child_resource_name: str + :param parameters: The SyncSet resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet 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: SyncSet or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SyncSet] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SyncSet") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SyncSet", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SyncSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncSet/{childResourceName}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any + ) -> None: + """Deletes a SyncSet with the specified subscription, resource group and resource name. + + The operation returns nothing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncSet resource. Required. + :type child_resource_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) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncSet/{childResourceName}" + } + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: _models.SyncSetUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SyncSet: + """Updates a SyncSet with the specified subscription, resource group and resource name. + + The operation returns properties of a SyncSet. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncSet resource. Required. + :type child_resource_name: str + :param parameters: The SyncSet resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSetUpdate + :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: SyncSet or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SyncSet: + """Updates a SyncSet with the specified subscription, resource group and resource name. + + The operation returns properties of a SyncSet. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncSet resource. Required. + :type child_resource_name: str + :param parameters: The SyncSet resource. Required. + :type parameters: 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: SyncSet or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: Union[_models.SyncSetUpdate, IO], + **kwargs: Any + ) -> _models.SyncSet: + """Updates a SyncSet with the specified subscription, resource group and resource name. + + The operation returns properties of a SyncSet. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncSet resource. Required. + :type child_resource_name: str + :param parameters: The SyncSet resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSetUpdate 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: SyncSet or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SyncSet] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SyncSetUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SyncSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncSet/{childResourceName}" + } diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/models/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/models/__init__.py new file mode 100644 index 000000000000..60aa421e93a2 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/models/__init__.py @@ -0,0 +1,97 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import APIServerProfile +from ._models_py3 import CloudErrorBody +from ._models_py3 import ClusterProfile +from ._models_py3 import ConsoleProfile +from ._models_py3 import Display +from ._models_py3 import IngressProfile +from ._models_py3 import MachinePool +from ._models_py3 import MachinePoolList +from ._models_py3 import MachinePoolUpdate +from ._models_py3 import MasterProfile +from ._models_py3 import NetworkProfile +from ._models_py3 import OpenShiftCluster +from ._models_py3 import OpenShiftClusterAdminKubeconfig +from ._models_py3 import OpenShiftClusterCredentials +from ._models_py3 import OpenShiftClusterList +from ._models_py3 import OpenShiftClusterUpdate +from ._models_py3 import OpenShiftVersion +from ._models_py3 import OpenShiftVersionList +from ._models_py3 import Operation +from ._models_py3 import OperationList +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import Secret +from ._models_py3 import SecretList +from ._models_py3 import SecretUpdate +from ._models_py3 import ServicePrincipalProfile +from ._models_py3 import SyncIdentityProvider +from ._models_py3 import SyncIdentityProviderList +from ._models_py3 import SyncIdentityProviderUpdate +from ._models_py3 import SyncSet +from ._models_py3 import SyncSetList +from ._models_py3 import SyncSetUpdate +from ._models_py3 import SystemData +from ._models_py3 import TrackedResource +from ._models_py3 import WorkerProfile + +from ._azure_red_hat_open_shift_client_enums import CreatedByType +from ._azure_red_hat_open_shift_client_enums import EncryptionAtHost +from ._azure_red_hat_open_shift_client_enums import FipsValidatedModules +from ._azure_red_hat_open_shift_client_enums import ProvisioningState +from ._azure_red_hat_open_shift_client_enums import Visibility +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "APIServerProfile", + "CloudErrorBody", + "ClusterProfile", + "ConsoleProfile", + "Display", + "IngressProfile", + "MachinePool", + "MachinePoolList", + "MachinePoolUpdate", + "MasterProfile", + "NetworkProfile", + "OpenShiftCluster", + "OpenShiftClusterAdminKubeconfig", + "OpenShiftClusterCredentials", + "OpenShiftClusterList", + "OpenShiftClusterUpdate", + "OpenShiftVersion", + "OpenShiftVersionList", + "Operation", + "OperationList", + "ProxyResource", + "Resource", + "Secret", + "SecretList", + "SecretUpdate", + "ServicePrincipalProfile", + "SyncIdentityProvider", + "SyncIdentityProviderList", + "SyncIdentityProviderUpdate", + "SyncSet", + "SyncSetList", + "SyncSetUpdate", + "SystemData", + "TrackedResource", + "WorkerProfile", + "CreatedByType", + "EncryptionAtHost", + "FipsValidatedModules", + "ProvisioningState", + "Visibility", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/models/_azure_red_hat_open_shift_client_enums.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/models/_azure_red_hat_open_shift_client_enums.py new file mode 100644 index 000000000000..7ca1dc70ec55 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/models/_azure_red_hat_open_shift_client_enums.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class EncryptionAtHost(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """EncryptionAtHost represents encryption at host state.""" + + DISABLED = "Disabled" + ENABLED = "Enabled" + + +class FipsValidatedModules(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """FipsValidatedModules determines if FIPS is used.""" + + DISABLED = "Disabled" + ENABLED = "Enabled" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ProvisioningState represents a provisioning state.""" + + ADMIN_UPDATING = "AdminUpdating" + CREATING = "Creating" + DELETING = "Deleting" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + UPDATING = "Updating" + + +class Visibility(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Visibility represents visibility.""" + + PRIVATE = "Private" + PUBLIC = "Public" diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/models/_models_py3.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/models/_models_py3.py new file mode 100644 index 000000000000..46ce95dc0e19 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/models/_models_py3.py @@ -0,0 +1,1493 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class APIServerProfile(_serialization.Model): + """APIServerProfile represents an API server profile. + + :ivar visibility: API server visibility. Known values are: "Private" and "Public". + :vartype visibility: str or ~azure.mgmt.redhatopenshift.v2022_09_04.models.Visibility + :ivar url: The URL to access the cluster API server. + :vartype url: str + :ivar ip: The IP of the cluster API server. + :vartype ip: str + """ + + _attribute_map = { + "visibility": {"key": "visibility", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "ip": {"key": "ip", "type": "str"}, + } + + def __init__( + self, + *, + visibility: Optional[Union[str, "_models.Visibility"]] = None, + url: Optional[str] = None, + ip: Optional[str] = None, + **kwargs + ): + """ + :keyword visibility: API server visibility. Known values are: "Private" and "Public". + :paramtype visibility: str or ~azure.mgmt.redhatopenshift.v2022_09_04.models.Visibility + :keyword url: The URL to access the cluster API server. + :paramtype url: str + :keyword ip: The IP of the cluster API server. + :paramtype ip: str + """ + super().__init__(**kwargs) + self.visibility = visibility + self.url = url + self.ip = ip + + +class CloudErrorBody(_serialization.Model): + """CloudErrorBody represents the body of a cloud error. + + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user + interface. + :vartype message: str + :ivar target: The target of the particular error. For example, the name of the property in + error. + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.CloudErrorBody] + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, + **kwargs + ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword target: The target of the particular error. For example, the name of the property in + error. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.CloudErrorBody] + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class ClusterProfile(_serialization.Model): + """ClusterProfile represents a cluster profile. + + :ivar pull_secret: The pull secret for the cluster. + :vartype pull_secret: str + :ivar domain: The domain for the cluster. + :vartype domain: str + :ivar version: The version of the cluster. + :vartype version: str + :ivar resource_group_id: The ID of the cluster resource group. + :vartype resource_group_id: str + :ivar fips_validated_modules: If FIPS validated crypto modules are used. Known values are: + "Disabled" and "Enabled". + :vartype fips_validated_modules: str or + ~azure.mgmt.redhatopenshift.v2022_09_04.models.FipsValidatedModules + """ + + _attribute_map = { + "pull_secret": {"key": "pullSecret", "type": "str"}, + "domain": {"key": "domain", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "resource_group_id": {"key": "resourceGroupId", "type": "str"}, + "fips_validated_modules": {"key": "fipsValidatedModules", "type": "str"}, + } + + def __init__( + self, + *, + pull_secret: Optional[str] = None, + domain: Optional[str] = None, + version: Optional[str] = None, + resource_group_id: Optional[str] = None, + fips_validated_modules: Optional[Union[str, "_models.FipsValidatedModules"]] = None, + **kwargs + ): + """ + :keyword pull_secret: The pull secret for the cluster. + :paramtype pull_secret: str + :keyword domain: The domain for the cluster. + :paramtype domain: str + :keyword version: The version of the cluster. + :paramtype version: str + :keyword resource_group_id: The ID of the cluster resource group. + :paramtype resource_group_id: str + :keyword fips_validated_modules: If FIPS validated crypto modules are used. Known values are: + "Disabled" and "Enabled". + :paramtype fips_validated_modules: str or + ~azure.mgmt.redhatopenshift.v2022_09_04.models.FipsValidatedModules + """ + super().__init__(**kwargs) + self.pull_secret = pull_secret + self.domain = domain + self.version = version + self.resource_group_id = resource_group_id + self.fips_validated_modules = fips_validated_modules + + +class ConsoleProfile(_serialization.Model): + """ConsoleProfile represents a console profile. + + :ivar url: The URL to access the cluster console. + :vartype url: str + """ + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + } + + def __init__(self, *, url: Optional[str] = None, **kwargs): + """ + :keyword url: The URL to access the cluster console. + :paramtype url: str + """ + super().__init__(**kwargs) + self.url = url + + +class Display(_serialization.Model): + """Display represents the display details of an operation. + + :ivar provider: Friendly name of the resource provider. + :vartype provider: str + :ivar resource: Resource type on which the operation is performed. + :vartype resource: str + :ivar operation: Operation type: read, write, delete, listKeys/action, etc. + :vartype operation: str + :ivar description: Friendly name of the operation. + :vartype description: str + """ + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Friendly name of the resource provider. + :paramtype provider: str + :keyword resource: Resource type on which the operation is performed. + :paramtype resource: str + :keyword operation: Operation type: read, write, delete, listKeys/action, etc. + :paramtype operation: str + :keyword description: Friendly name of the operation. + :paramtype description: str + """ + super().__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class IngressProfile(_serialization.Model): + """IngressProfile represents an ingress profile. + + :ivar name: The ingress profile name. + :vartype name: str + :ivar visibility: Ingress visibility. Known values are: "Private" and "Public". + :vartype visibility: str or ~azure.mgmt.redhatopenshift.v2022_09_04.models.Visibility + :ivar ip: The IP of the ingress. + :vartype ip: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "visibility": {"key": "visibility", "type": "str"}, + "ip": {"key": "ip", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + visibility: Optional[Union[str, "_models.Visibility"]] = None, + ip: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The ingress profile name. + :paramtype name: str + :keyword visibility: Ingress visibility. Known values are: "Private" and "Public". + :paramtype visibility: str or ~azure.mgmt.redhatopenshift.v2022_09_04.models.Visibility + :keyword ip: The IP of the ingress. + :paramtype ip: str + """ + super().__init__(**kwargs) + self.name = name + self.visibility = visibility + self.ip = ip + + +class Resource(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + + +class MachinePool(ProxyResource): + """MachinePool represents a MachinePool. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SystemData + :ivar resources: + :vartype resources: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "resources": {"key": "properties.resources", "type": "str"}, + } + + def __init__(self, *, resources: Optional[str] = None, **kwargs): + """ + :keyword resources: + :paramtype resources: str + """ + super().__init__(**kwargs) + self.resources = resources + + +class MachinePoolList(_serialization.Model): + """MachinePoolList represents a list of MachinePools. + + :ivar value: The list of Machine Pools. + :vartype value: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool] + :ivar next_link: The link used to get the next page of operations. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[MachinePool]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.MachinePool"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The list of Machine Pools. + :paramtype value: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool] + :keyword next_link: The link used to get the next page of operations. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class MachinePoolUpdate(_serialization.Model): + """MachinePool represents a MachinePool. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar system_data: The system meta data relating to this resource. + :vartype system_data: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SystemData + :ivar resources: + :vartype resources: str + """ + + _validation = { + "system_data": {"readonly": True}, + } + + _attribute_map = { + "system_data": {"key": "systemData", "type": "SystemData"}, + "resources": {"key": "properties.resources", "type": "str"}, + } + + def __init__(self, *, resources: Optional[str] = None, **kwargs): + """ + :keyword resources: + :paramtype resources: str + """ + super().__init__(**kwargs) + self.system_data = None + self.resources = resources + + +class MasterProfile(_serialization.Model): + """MasterProfile represents a master profile. + + :ivar vm_size: The size of the master VMs. + :vartype vm_size: str + :ivar subnet_id: The Azure resource ID of the master subnet. + :vartype subnet_id: str + :ivar encryption_at_host: Whether master virtual machines are encrypted at host. Known values + are: "Disabled" and "Enabled". + :vartype encryption_at_host: str or + ~azure.mgmt.redhatopenshift.v2022_09_04.models.EncryptionAtHost + :ivar disk_encryption_set_id: The resource ID of an associated DiskEncryptionSet, if + applicable. + :vartype disk_encryption_set_id: str + """ + + _attribute_map = { + "vm_size": {"key": "vmSize", "type": "str"}, + "subnet_id": {"key": "subnetId", "type": "str"}, + "encryption_at_host": {"key": "encryptionAtHost", "type": "str"}, + "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, + } + + def __init__( + self, + *, + vm_size: Optional[str] = None, + subnet_id: Optional[str] = None, + encryption_at_host: Optional[Union[str, "_models.EncryptionAtHost"]] = None, + disk_encryption_set_id: Optional[str] = None, + **kwargs + ): + """ + :keyword vm_size: The size of the master VMs. + :paramtype vm_size: str + :keyword subnet_id: The Azure resource ID of the master subnet. + :paramtype subnet_id: str + :keyword encryption_at_host: Whether master virtual machines are encrypted at host. Known + values are: "Disabled" and "Enabled". + :paramtype encryption_at_host: str or + ~azure.mgmt.redhatopenshift.v2022_09_04.models.EncryptionAtHost + :keyword disk_encryption_set_id: The resource ID of an associated DiskEncryptionSet, if + applicable. + :paramtype disk_encryption_set_id: str + """ + super().__init__(**kwargs) + self.vm_size = vm_size + self.subnet_id = subnet_id + self.encryption_at_host = encryption_at_host + self.disk_encryption_set_id = disk_encryption_set_id + + +class NetworkProfile(_serialization.Model): + """NetworkProfile represents a network profile. + + :ivar pod_cidr: The CIDR used for OpenShift/Kubernetes Pods. + :vartype pod_cidr: str + :ivar service_cidr: The CIDR used for OpenShift/Kubernetes Services. + :vartype service_cidr: str + """ + + _attribute_map = { + "pod_cidr": {"key": "podCidr", "type": "str"}, + "service_cidr": {"key": "serviceCidr", "type": "str"}, + } + + def __init__(self, *, pod_cidr: Optional[str] = None, service_cidr: Optional[str] = None, **kwargs): + """ + :keyword pod_cidr: The CIDR used for OpenShift/Kubernetes Pods. + :paramtype pod_cidr: str + :keyword service_cidr: The CIDR used for OpenShift/Kubernetes Services. + :paramtype service_cidr: str + """ + super().__init__(**kwargs) + self.pod_cidr = pod_cidr + self.service_cidr = service_cidr + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(**kwargs) + self.tags = tags + self.location = location + + +class OpenShiftCluster(TrackedResource): # pylint: disable=too-many-instance-attributes + """OpenShiftCluster represents an Azure Red Hat OpenShift cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar provisioning_state: The cluster provisioning state. Known values are: "AdminUpdating", + "Creating", "Deleting", "Failed", "Succeeded", and "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.redhatopenshift.v2022_09_04.models.ProvisioningState + :ivar cluster_profile: The cluster profile. + :vartype cluster_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.ClusterProfile + :ivar console_profile: The console profile. + :vartype console_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.ConsoleProfile + :ivar service_principal_profile: The cluster service principal profile. + :vartype service_principal_profile: + ~azure.mgmt.redhatopenshift.v2022_09_04.models.ServicePrincipalProfile + :ivar network_profile: The cluster network profile. + :vartype network_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.NetworkProfile + :ivar master_profile: The cluster master profile. + :vartype master_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MasterProfile + :ivar worker_profiles: The cluster worker profiles. + :vartype worker_profiles: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.WorkerProfile] + :ivar apiserver_profile: The cluster API server profile. + :vartype apiserver_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.APIServerProfile + :ivar ingress_profiles: The cluster ingress profiles. + :vartype ingress_profiles: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.IngressProfile] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "cluster_profile": {"key": "properties.clusterProfile", "type": "ClusterProfile"}, + "console_profile": {"key": "properties.consoleProfile", "type": "ConsoleProfile"}, + "service_principal_profile": {"key": "properties.servicePrincipalProfile", "type": "ServicePrincipalProfile"}, + "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, + "master_profile": {"key": "properties.masterProfile", "type": "MasterProfile"}, + "worker_profiles": {"key": "properties.workerProfiles", "type": "[WorkerProfile]"}, + "apiserver_profile": {"key": "properties.apiserverProfile", "type": "APIServerProfile"}, + "ingress_profiles": {"key": "properties.ingressProfiles", "type": "[IngressProfile]"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, + cluster_profile: Optional["_models.ClusterProfile"] = None, + console_profile: Optional["_models.ConsoleProfile"] = None, + service_principal_profile: Optional["_models.ServicePrincipalProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + master_profile: Optional["_models.MasterProfile"] = None, + worker_profiles: Optional[List["_models.WorkerProfile"]] = None, + apiserver_profile: Optional["_models.APIServerProfile"] = None, + ingress_profiles: Optional[List["_models.IngressProfile"]] = None, + **kwargs + ): + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword provisioning_state: The cluster provisioning state. Known values are: "AdminUpdating", + "Creating", "Deleting", "Failed", "Succeeded", and "Updating". + :paramtype provisioning_state: str or + ~azure.mgmt.redhatopenshift.v2022_09_04.models.ProvisioningState + :keyword cluster_profile: The cluster profile. + :paramtype cluster_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.ClusterProfile + :keyword console_profile: The console profile. + :paramtype console_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.ConsoleProfile + :keyword service_principal_profile: The cluster service principal profile. + :paramtype service_principal_profile: + ~azure.mgmt.redhatopenshift.v2022_09_04.models.ServicePrincipalProfile + :keyword network_profile: The cluster network profile. + :paramtype network_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.NetworkProfile + :keyword master_profile: The cluster master profile. + :paramtype master_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MasterProfile + :keyword worker_profiles: The cluster worker profiles. + :paramtype worker_profiles: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.WorkerProfile] + :keyword apiserver_profile: The cluster API server profile. + :paramtype apiserver_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.APIServerProfile + :keyword ingress_profiles: The cluster ingress profiles. + :paramtype ingress_profiles: + list[~azure.mgmt.redhatopenshift.v2022_09_04.models.IngressProfile] + """ + super().__init__(tags=tags, location=location, **kwargs) + self.provisioning_state = provisioning_state + self.cluster_profile = cluster_profile + self.console_profile = console_profile + self.service_principal_profile = service_principal_profile + self.network_profile = network_profile + self.master_profile = master_profile + self.worker_profiles = worker_profiles + self.apiserver_profile = apiserver_profile + self.ingress_profiles = ingress_profiles + + +class OpenShiftClusterAdminKubeconfig(_serialization.Model): + """OpenShiftClusterAdminKubeconfig represents an OpenShift cluster's admin kubeconfig. + + :ivar kubeconfig: The base64-encoded kubeconfig file. + :vartype kubeconfig: str + """ + + _attribute_map = { + "kubeconfig": {"key": "kubeconfig", "type": "str"}, + } + + def __init__(self, *, kubeconfig: Optional[str] = None, **kwargs): + """ + :keyword kubeconfig: The base64-encoded kubeconfig file. + :paramtype kubeconfig: str + """ + super().__init__(**kwargs) + self.kubeconfig = kubeconfig + + +class OpenShiftClusterCredentials(_serialization.Model): + """OpenShiftClusterCredentials represents an OpenShift cluster's credentials. + + :ivar kubeadmin_username: The username for the kubeadmin user. + :vartype kubeadmin_username: str + :ivar kubeadmin_password: The password for the kubeadmin user. + :vartype kubeadmin_password: str + """ + + _attribute_map = { + "kubeadmin_username": {"key": "kubeadminUsername", "type": "str"}, + "kubeadmin_password": {"key": "kubeadminPassword", "type": "str"}, + } + + def __init__(self, *, kubeadmin_username: Optional[str] = None, kubeadmin_password: Optional[str] = None, **kwargs): + """ + :keyword kubeadmin_username: The username for the kubeadmin user. + :paramtype kubeadmin_username: str + :keyword kubeadmin_password: The password for the kubeadmin user. + :paramtype kubeadmin_password: str + """ + super().__init__(**kwargs) + self.kubeadmin_username = kubeadmin_username + self.kubeadmin_password = kubeadmin_password + + +class OpenShiftClusterList(_serialization.Model): + """OpenShiftClusterList represents a list of OpenShift clusters. + + :ivar value: The list of OpenShift clusters. + :vartype value: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster] + :ivar next_link: The link used to get the next page of operations. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[OpenShiftCluster]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.OpenShiftCluster"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The list of OpenShift clusters. + :paramtype value: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster] + :keyword next_link: The link used to get the next page of operations. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OpenShiftClusterUpdate(_serialization.Model): # pylint: disable=too-many-instance-attributes + """OpenShiftCluster represents an Azure Red Hat OpenShift cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tags: The resource tags. + :vartype tags: dict[str, str] + :ivar system_data: The system meta data relating to this resource. + :vartype system_data: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SystemData + :ivar provisioning_state: The cluster provisioning state. Known values are: "AdminUpdating", + "Creating", "Deleting", "Failed", "Succeeded", and "Updating". + :vartype provisioning_state: str or + ~azure.mgmt.redhatopenshift.v2022_09_04.models.ProvisioningState + :ivar cluster_profile: The cluster profile. + :vartype cluster_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.ClusterProfile + :ivar console_profile: The console profile. + :vartype console_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.ConsoleProfile + :ivar service_principal_profile: The cluster service principal profile. + :vartype service_principal_profile: + ~azure.mgmt.redhatopenshift.v2022_09_04.models.ServicePrincipalProfile + :ivar network_profile: The cluster network profile. + :vartype network_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.NetworkProfile + :ivar master_profile: The cluster master profile. + :vartype master_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MasterProfile + :ivar worker_profiles: The cluster worker profiles. + :vartype worker_profiles: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.WorkerProfile] + :ivar apiserver_profile: The cluster API server profile. + :vartype apiserver_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.APIServerProfile + :ivar ingress_profiles: The cluster ingress profiles. + :vartype ingress_profiles: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.IngressProfile] + """ + + _validation = { + "system_data": {"readonly": True}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "cluster_profile": {"key": "properties.clusterProfile", "type": "ClusterProfile"}, + "console_profile": {"key": "properties.consoleProfile", "type": "ConsoleProfile"}, + "service_principal_profile": {"key": "properties.servicePrincipalProfile", "type": "ServicePrincipalProfile"}, + "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfile"}, + "master_profile": {"key": "properties.masterProfile", "type": "MasterProfile"}, + "worker_profiles": {"key": "properties.workerProfiles", "type": "[WorkerProfile]"}, + "apiserver_profile": {"key": "properties.apiserverProfile", "type": "APIServerProfile"}, + "ingress_profiles": {"key": "properties.ingressProfiles", "type": "[IngressProfile]"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, + cluster_profile: Optional["_models.ClusterProfile"] = None, + console_profile: Optional["_models.ConsoleProfile"] = None, + service_principal_profile: Optional["_models.ServicePrincipalProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + master_profile: Optional["_models.MasterProfile"] = None, + worker_profiles: Optional[List["_models.WorkerProfile"]] = None, + apiserver_profile: Optional["_models.APIServerProfile"] = None, + ingress_profiles: Optional[List["_models.IngressProfile"]] = None, + **kwargs + ): + """ + :keyword tags: The resource tags. + :paramtype tags: dict[str, str] + :keyword provisioning_state: The cluster provisioning state. Known values are: "AdminUpdating", + "Creating", "Deleting", "Failed", "Succeeded", and "Updating". + :paramtype provisioning_state: str or + ~azure.mgmt.redhatopenshift.v2022_09_04.models.ProvisioningState + :keyword cluster_profile: The cluster profile. + :paramtype cluster_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.ClusterProfile + :keyword console_profile: The console profile. + :paramtype console_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.ConsoleProfile + :keyword service_principal_profile: The cluster service principal profile. + :paramtype service_principal_profile: + ~azure.mgmt.redhatopenshift.v2022_09_04.models.ServicePrincipalProfile + :keyword network_profile: The cluster network profile. + :paramtype network_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.NetworkProfile + :keyword master_profile: The cluster master profile. + :paramtype master_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MasterProfile + :keyword worker_profiles: The cluster worker profiles. + :paramtype worker_profiles: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.WorkerProfile] + :keyword apiserver_profile: The cluster API server profile. + :paramtype apiserver_profile: ~azure.mgmt.redhatopenshift.v2022_09_04.models.APIServerProfile + :keyword ingress_profiles: The cluster ingress profiles. + :paramtype ingress_profiles: + list[~azure.mgmt.redhatopenshift.v2022_09_04.models.IngressProfile] + """ + super().__init__(**kwargs) + self.tags = tags + self.system_data = None + self.provisioning_state = provisioning_state + self.cluster_profile = cluster_profile + self.console_profile = console_profile + self.service_principal_profile = service_principal_profile + self.network_profile = network_profile + self.master_profile = master_profile + self.worker_profiles = worker_profiles + self.apiserver_profile = apiserver_profile + self.ingress_profiles = ingress_profiles + + +class OpenShiftVersion(ProxyResource): + """OpenShiftVersion represents an OpenShift version that can be installed. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SystemData + :ivar version: Version represents the version to create the cluster at. + :vartype version: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "version": {"key": "properties.version", "type": "str"}, + } + + def __init__(self, *, version: Optional[str] = None, **kwargs): + """ + :keyword version: Version represents the version to create the cluster at. + :paramtype version: str + """ + super().__init__(**kwargs) + self.version = version + + +class OpenShiftVersionList(_serialization.Model): + """OpenShiftVersionList represents a List of available versions. + + :ivar value: The List of available versions. + :vartype value: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftVersion] + :ivar next_link: Next Link to next operation. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[OpenShiftVersion]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.OpenShiftVersion"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The List of available versions. + :paramtype value: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftVersion] + :keyword next_link: Next Link to next operation. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Operation(_serialization.Model): + """Operation represents an RP operation. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that describes the operation. + :vartype display: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Display + :ivar origin: Sources of requests to this operation. Comma separated list with valid values + user or system, e.g. "user,system". + :vartype origin: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "Display"}, + "origin": {"key": "origin", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["_models.Display"] = None, + origin: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that describes the operation. + :paramtype display: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Display + :keyword origin: Sources of requests to this operation. Comma separated list with valid values + user or system, e.g. "user,system". + :paramtype origin: str + """ + super().__init__(**kwargs) + self.name = name + self.display = display + self.origin = origin + + +class OperationList(_serialization.Model): + """OperationList represents an RP operation list. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.Operation] + :ivar next_link: The link used to get the next page of operations. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): + """ + :keyword value: List of operations supported by the resource provider. + :paramtype value: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.Operation] + :keyword next_link: The link used to get the next page of operations. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Secret(ProxyResource): + """Secret represents a secret. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SystemData + :ivar secret_resources: The Secrets Resources. + :vartype secret_resources: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "secret_resources": {"key": "properties.secretResources", "type": "str"}, + } + + def __init__(self, *, secret_resources: Optional[str] = None, **kwargs): + """ + :keyword secret_resources: The Secrets Resources. + :paramtype secret_resources: str + """ + super().__init__(**kwargs) + self.secret_resources = secret_resources + + +class SecretList(_serialization.Model): + """SecretList represents a list of Secrets. + + :ivar value: The list of secrets. + :vartype value: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret] + :ivar next_link: The link used to get the next page of operations. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Secret]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Secret"]] = None, next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The list of secrets. + :paramtype value: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret] + :keyword next_link: The link used to get the next page of operations. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SecretUpdate(_serialization.Model): + """Secret represents a secret. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar system_data: The system meta data relating to this resource. + :vartype system_data: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SystemData + :ivar secret_resources: The Secrets Resources. + :vartype secret_resources: str + """ + + _validation = { + "system_data": {"readonly": True}, + } + + _attribute_map = { + "system_data": {"key": "systemData", "type": "SystemData"}, + "secret_resources": {"key": "properties.secretResources", "type": "str"}, + } + + def __init__(self, *, secret_resources: Optional[str] = None, **kwargs): + """ + :keyword secret_resources: The Secrets Resources. + :paramtype secret_resources: str + """ + super().__init__(**kwargs) + self.system_data = None + self.secret_resources = secret_resources + + +class ServicePrincipalProfile(_serialization.Model): + """ServicePrincipalProfile represents a service principal profile. + + :ivar client_id: The client ID used for the cluster. + :vartype client_id: str + :ivar client_secret: The client secret used for the cluster. + :vartype client_secret: str + """ + + _attribute_map = { + "client_id": {"key": "clientId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, + } + + def __init__(self, *, client_id: Optional[str] = None, client_secret: Optional[str] = None, **kwargs): + """ + :keyword client_id: The client ID used for the cluster. + :paramtype client_id: str + :keyword client_secret: The client secret used for the cluster. + :paramtype client_secret: str + """ + super().__init__(**kwargs) + self.client_id = client_id + self.client_secret = client_secret + + +class SyncIdentityProvider(ProxyResource): + """SyncIdentityProvider represents a SyncIdentityProvider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SystemData + :ivar resources: + :vartype resources: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "resources": {"key": "properties.resources", "type": "str"}, + } + + def __init__(self, *, resources: Optional[str] = None, **kwargs): + """ + :keyword resources: + :paramtype resources: str + """ + super().__init__(**kwargs) + self.resources = resources + + +class SyncIdentityProviderList(_serialization.Model): + """SyncSetList represents a list of SyncSets. + + :ivar value: The list of sync identity providers. + :vartype value: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider] + :ivar next_link: The link used to get the next page of operations. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[SyncIdentityProvider]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.SyncIdentityProvider"]] = None, next_link: Optional[str] = None, **kwargs + ): + """ + :keyword value: The list of sync identity providers. + :paramtype value: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider] + :keyword next_link: The link used to get the next page of operations. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SyncIdentityProviderUpdate(_serialization.Model): + """SyncIdentityProvider represents a SyncIdentityProvider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar system_data: The system meta data relating to this resource. + :vartype system_data: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SystemData + :ivar resources: + :vartype resources: str + """ + + _validation = { + "system_data": {"readonly": True}, + } + + _attribute_map = { + "system_data": {"key": "systemData", "type": "SystemData"}, + "resources": {"key": "properties.resources", "type": "str"}, + } + + def __init__(self, *, resources: Optional[str] = None, **kwargs): + """ + :keyword resources: + :paramtype resources: str + """ + super().__init__(**kwargs) + self.system_data = None + self.resources = resources + + +class SyncSet(ProxyResource): + """SyncSet represents a SyncSet for an Azure Red Hat OpenShift Cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SystemData + :ivar resources: Resources represents the SyncSets configuration. + :vartype resources: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "resources": {"key": "properties.resources", "type": "str"}, + } + + def __init__(self, *, resources: Optional[str] = None, **kwargs): + """ + :keyword resources: Resources represents the SyncSets configuration. + :paramtype resources: str + """ + super().__init__(**kwargs) + self.resources = resources + + +class SyncSetList(_serialization.Model): + """SyncSetList represents a list of SyncSets. + + :ivar value: The list of syncsets. + :vartype value: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet] + :ivar next_link: The link used to get the next page of operations. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[SyncSet]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.SyncSet"]] = None, next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The list of syncsets. + :paramtype value: list[~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet] + :keyword next_link: The link used to get the next page of operations. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SyncSetUpdate(_serialization.Model): + """SyncSet represents a SyncSet for an Azure Red Hat OpenShift Cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar system_data: The system meta data relating to this resource. + :vartype system_data: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SystemData + :ivar resources: Resources represents the SyncSets configuration. + :vartype resources: str + """ + + _validation = { + "system_data": {"readonly": True}, + } + + _attribute_map = { + "system_data": {"key": "systemData", "type": "SystemData"}, + "resources": {"key": "properties.resources", "type": "str"}, + } + + def __init__(self, *, resources: Optional[str] = None, **kwargs): + """ + :keyword resources: Resources represents the SyncSets configuration. + :paramtype resources: str + """ + super().__init__(**kwargs) + self.system_data = None + self.resources = resources + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.redhatopenshift.v2022_09_04.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.redhatopenshift.v2022_09_04.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.redhatopenshift.v2022_09_04.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.redhatopenshift.v2022_09_04.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class WorkerProfile(_serialization.Model): + """WorkerProfile represents a worker profile. + + :ivar name: The worker profile name. + :vartype name: str + :ivar vm_size: The size of the worker VMs. + :vartype vm_size: str + :ivar disk_size_gb: The disk size of the worker VMs. + :vartype disk_size_gb: int + :ivar subnet_id: The Azure resource ID of the worker subnet. + :vartype subnet_id: str + :ivar count: The number of worker VMs. + :vartype count: int + :ivar encryption_at_host: Whether master virtual machines are encrypted at host. Known values + are: "Disabled" and "Enabled". + :vartype encryption_at_host: str or + ~azure.mgmt.redhatopenshift.v2022_09_04.models.EncryptionAtHost + :ivar disk_encryption_set_id: The resource ID of an associated DiskEncryptionSet, if + applicable. + :vartype disk_encryption_set_id: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "vm_size": {"key": "vmSize", "type": "str"}, + "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, + "subnet_id": {"key": "subnetId", "type": "str"}, + "count": {"key": "count", "type": "int"}, + "encryption_at_host": {"key": "encryptionAtHost", "type": "str"}, + "disk_encryption_set_id": {"key": "diskEncryptionSetId", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + vm_size: Optional[str] = None, + disk_size_gb: Optional[int] = None, + subnet_id: Optional[str] = None, + count: Optional[int] = None, + encryption_at_host: Optional[Union[str, "_models.EncryptionAtHost"]] = None, + disk_encryption_set_id: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The worker profile name. + :paramtype name: str + :keyword vm_size: The size of the worker VMs. + :paramtype vm_size: str + :keyword disk_size_gb: The disk size of the worker VMs. + :paramtype disk_size_gb: int + :keyword subnet_id: The Azure resource ID of the worker subnet. + :paramtype subnet_id: str + :keyword count: The number of worker VMs. + :paramtype count: int + :keyword encryption_at_host: Whether master virtual machines are encrypted at host. Known + values are: "Disabled" and "Enabled". + :paramtype encryption_at_host: str or + ~azure.mgmt.redhatopenshift.v2022_09_04.models.EncryptionAtHost + :keyword disk_encryption_set_id: The resource ID of an associated DiskEncryptionSet, if + applicable. + :paramtype disk_encryption_set_id: str + """ + super().__init__(**kwargs) + self.name = name + self.vm_size = vm_size + self.disk_size_gb = disk_size_gb + self.subnet_id = subnet_id + self.count = count + self.encryption_at_host = encryption_at_host + self.disk_encryption_set_id = disk_encryption_set_id diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/models/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/__init__.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/__init__.py new file mode 100644 index 000000000000..f03257fe6903 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/__init__.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._open_shift_versions_operations import OpenShiftVersionsOperations +from ._open_shift_clusters_operations import OpenShiftClustersOperations +from ._machine_pools_operations import MachinePoolsOperations +from ._secrets_operations import SecretsOperations +from ._sync_identity_providers_operations import SyncIdentityProvidersOperations +from ._sync_sets_operations import SyncSetsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "Operations", + "OpenShiftVersionsOperations", + "OpenShiftClustersOperations", + "MachinePoolsOperations", + "SecretsOperations", + "SyncIdentityProvidersOperations", + "SyncSetsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_machine_pools_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_machine_pools_operations.py new file mode 100644 index 000000000000..79a3e89c7697 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_machine_pools_operations.py @@ -0,0 +1,841 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, 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.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftCluster/{resourceName}/machinePools", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/machinePool/{childResourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + "childResourceName": _SERIALIZER.url( + "child_resource_name", + child_resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/machinePool/{childResourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + "childResourceName": _SERIALIZER.url( + "child_resource_name", + child_resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/machinePool/{childResourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + "childResourceName": _SERIALIZER.url( + "child_resource_name", + child_resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/machinePool/{childResourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + "childResourceName": _SERIALIZER.url( + "child_resource_name", + child_resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class MachinePoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redhatopenshift.v2022_09_04.AzureRedHatOpenShiftClient`'s + :attr:`machine_pools` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.MachinePool"]: + """Lists MachinePools that belong to that Azure Red Hat OpenShift Cluster. + + The operation returns properties of each MachinePool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MachinePool or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.MachinePoolList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("MachinePoolList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftCluster/{resourceName}/machinePools" + } + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any + ) -> _models.MachinePool: + """Gets a MachinePool with the specified subscription, resource group and resource name. + + The operation returns properties of a MachinePool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the MachinePool resource. Required. + :type child_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MachinePool or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.MachinePool] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MachinePool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/machinePool/{childResourceName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: _models.MachinePool, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MachinePool: + """Creates or updates a MachinePool with the specified subscription, resource group and resource + name. + + The operation returns properties of a MachinePool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the MachinePool resource. Required. + :type child_resource_name: str + :param parameters: The MachinePool resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool + :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: MachinePool or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MachinePool: + """Creates or updates a MachinePool with the specified subscription, resource group and resource + name. + + The operation returns properties of a MachinePool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the MachinePool resource. Required. + :type child_resource_name: str + :param parameters: The MachinePool resource. Required. + :type parameters: 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: MachinePool or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: Union[_models.MachinePool, IO], + **kwargs: Any + ) -> _models.MachinePool: + """Creates or updates a MachinePool with the specified subscription, resource group and resource + name. + + The operation returns properties of a MachinePool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the MachinePool resource. Required. + :type child_resource_name: str + :param parameters: The MachinePool resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool 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: MachinePool or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MachinePool] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MachinePool") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("MachinePool", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("MachinePool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/machinePool/{childResourceName}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any + ) -> None: + """Deletes a MachinePool with the specified subscription, resource group and resource name. + + The operation returns nothing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the MachinePool resource. Required. + :type child_resource_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) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/machinePool/{childResourceName}" + } + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: _models.MachinePoolUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MachinePool: + """Updates a MachinePool with the specified subscription, resource group and resource name. + + The operation returns properties of a MachinePool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the MachinePool resource. Required. + :type child_resource_name: str + :param parameters: The MachinePool resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePoolUpdate + :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: MachinePool or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MachinePool: + """Updates a MachinePool with the specified subscription, resource group and resource name. + + The operation returns properties of a MachinePool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the MachinePool resource. Required. + :type child_resource_name: str + :param parameters: The MachinePool resource. Required. + :type parameters: 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: MachinePool or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: Union[_models.MachinePoolUpdate, IO], + **kwargs: Any + ) -> _models.MachinePool: + """Updates a MachinePool with the specified subscription, resource group and resource name. + + The operation returns properties of a MachinePool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the MachinePool resource. Required. + :type child_resource_name: str + :param parameters: The MachinePool resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePoolUpdate 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: MachinePool or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.MachinePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MachinePool] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MachinePoolUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MachinePool", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/machinePool/{childResourceName}" + } diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_open_shift_clusters_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_open_shift_clusters_operations.py new file mode 100644 index 000000000000..0404aec7b180 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_open_shift_clusters_operations.py @@ -0,0 +1,1270 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_admin_credentials_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listAdminCredentials", + ) # 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_credentials_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials", + ) # 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class OpenShiftClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redhatopenshift.v2022_09_04.AzureRedHatOpenShiftClient`'s + :attr:`open_shift_clusters` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.OpenShiftCluster"]: + """Lists OpenShift clusters in the specified subscription. + + The operation returns properties of each OpenShift cluster. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OpenShiftCluster or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.OpenShiftClusterList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OpenShiftClusterList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters"} + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.OpenShiftCluster"]: + """Lists OpenShift clusters in the specified subscription and resource group. + + The operation returns properties of each OpenShift cluster. + + :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 OpenShiftCluster or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.OpenShiftClusterList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OpenShiftClusterList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters" + } + + @distributed_trace + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.OpenShiftCluster: + """Gets a OpenShift cluster with the specified subscription, resource group and resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OpenShiftCluster or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.OpenShiftCluster, IO], + **kwargs: Any + ) -> _models.OpenShiftCluster: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OpenShiftCluster") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.OpenShiftCluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster + :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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.OpenShiftCluster, IO], + **kwargs: Any + ) -> LROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + @distributed_trace + def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a OpenShift cluster with the specified subscription, resource group and resource name. + + The operation returns nothing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + def _update_initial( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.OpenShiftClusterUpdate, IO], + **kwargs: Any + ) -> _models.OpenShiftCluster: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OpenShiftClusterUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.OpenShiftClusterUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftClusterUpdate + :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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Required. + :type parameters: 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: Union[_models.OpenShiftClusterUpdate, IO], + **kwargs: Any + ) -> LROPoller[_models.OpenShiftCluster]: + """Creates or updates a OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns properties of a OpenShift cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param parameters: The OpenShift cluster resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftClusterUpdate 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 OpenShiftCluster or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenShiftCluster] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OpenShiftCluster", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}" + } + + @distributed_trace + def list_admin_credentials( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.OpenShiftClusterAdminKubeconfig: + """Lists admin kubeconfig of an OpenShift cluster with the specified subscription, resource group + and resource name. + + The operation returns the admin kubeconfig. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OpenShiftClusterAdminKubeconfig or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftClusterAdminKubeconfig + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.OpenShiftClusterAdminKubeconfig] = kwargs.pop("cls", None) + + request = build_list_admin_credentials_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_admin_credentials.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OpenShiftClusterAdminKubeconfig", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_admin_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listAdminCredentials" + } + + @distributed_trace + def list_credentials( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.OpenShiftClusterCredentials: + """Lists credentials of an OpenShift cluster with the specified subscription, resource group and + resource name. + + The operation returns the credentials. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OpenShiftClusterCredentials or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftClusterCredentials + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.OpenShiftClusterCredentials] = kwargs.pop("cls", None) + + request = build_list_credentials_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_credentials.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OpenShiftClusterCredentials", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials" + } diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_open_shift_versions_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_open_shift_versions_operations.py new file mode 100644 index 000000000000..322f059b079f --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_open_shift_versions_operations.py @@ -0,0 +1,176 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _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(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/locations/{location}/openshiftversions", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class OpenShiftVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redhatopenshift.v2022_09_04.AzureRedHatOpenShiftClient`'s + :attr:`open_shift_versions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, location: str, **kwargs: Any) -> Iterable["_models.OpenShiftVersion"]: + """Lists all OpenShift versions available to install in the specified location. + + The operation returns the installable OpenShift versions as strings. + + :param location: The name of Azure region. Required. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OpenShiftVersion or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2022_09_04.models.OpenShiftVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.OpenShiftVersionList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OpenShiftVersionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/locations/{location}/openshiftversions" + } diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_operations.py new file mode 100644 index 000000000000..cb6d4ee1ad62 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_operations.py @@ -0,0 +1,160 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.RedHatOpenShift/operations") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redhatopenshift.v2022_09_04.AzureRedHatOpenShiftClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + """Lists all of the available RP operations. + + The operation returns the RP operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2022_09_04.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.RedHatOpenShift/operations"} diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_patch.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/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/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_secrets_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_secrets_operations.py new file mode 100644 index 000000000000..1c94c58d08d4 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_secrets_operations.py @@ -0,0 +1,837 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, 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.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftCluster/{resourceName}/secrets", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/secret/{childResourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + "childResourceName": _SERIALIZER.url( + "child_resource_name", + child_resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/secret/{childResourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + "childResourceName": _SERIALIZER.url( + "child_resource_name", + child_resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/secret/{childResourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + "childResourceName": _SERIALIZER.url( + "child_resource_name", + child_resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/secret/{childResourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + "childResourceName": _SERIALIZER.url( + "child_resource_name", + child_resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class SecretsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redhatopenshift.v2022_09_04.AzureRedHatOpenShiftClient`'s + :attr:`secrets` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.Secret"]: + """Lists Secrets that belong to that Azure Red Hat OpenShift Cluster. + + The operation returns properties of each Secret. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Secret or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.SecretList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecretList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftCluster/{resourceName}/secrets" + } + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any + ) -> _models.Secret: + """Gets a Secret with the specified subscription, resource group and resource name. + + The operation returns properties of a Secret. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the Secret resource. Required. + :type child_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Secret or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Secret", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/secret/{childResourceName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: _models.Secret, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Creates or updates a Secret with the specified subscription, resource group and resource name. + + The operation returns properties of a Secret. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the Secret resource. Required. + :type child_resource_name: str + :param parameters: The Secret resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret + :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: Secret or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Creates or updates a Secret with the specified subscription, resource group and resource name. + + The operation returns properties of a Secret. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the Secret resource. Required. + :type child_resource_name: str + :param parameters: The Secret resource. Required. + :type parameters: 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: Secret or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: Union[_models.Secret, IO], + **kwargs: Any + ) -> _models.Secret: + """Creates or updates a Secret with the specified subscription, resource group and resource name. + + The operation returns properties of a Secret. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the Secret resource. Required. + :type child_resource_name: str + :param parameters: The Secret resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret 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: Secret or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Secret") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Secret", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Secret", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/secret/{childResourceName}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any + ) -> None: + """Deletes a Secret with the specified subscription, resource group and resource name. + + The operation returns nothing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the Secret resource. Required. + :type child_resource_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) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/secret/{childResourceName}" + } + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: _models.SecretUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Updates a Secret with the specified subscription, resource group and resource name. + + The operation returns properties of a Secret. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the Secret resource. Required. + :type child_resource_name: str + :param parameters: The Secret resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SecretUpdate + :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: Secret or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Secret: + """Updates a Secret with the specified subscription, resource group and resource name. + + The operation returns properties of a Secret. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the Secret resource. Required. + :type child_resource_name: str + :param parameters: The Secret resource. Required. + :type parameters: 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: Secret or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: Union[_models.SecretUpdate, IO], + **kwargs: Any + ) -> _models.Secret: + """Updates a Secret with the specified subscription, resource group and resource name. + + The operation returns properties of a Secret. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the Secret resource. Required. + :type child_resource_name: str + :param parameters: The Secret resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SecretUpdate 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: Secret or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SecretUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Secret", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/secret/{childResourceName}" + } diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_sync_identity_providers_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_sync_identity_providers_operations.py new file mode 100644 index 000000000000..329e234af7ba --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_sync_identity_providers_operations.py @@ -0,0 +1,851 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, 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.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftCluster/{resourceName}/syncIdentityProviders", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncIdentityProvider/{childResourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + "childResourceName": _SERIALIZER.url( + "child_resource_name", + child_resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncIdentityProvider/{childResourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + "childResourceName": _SERIALIZER.url( + "child_resource_name", + child_resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncIdentityProvider/{childResourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + "childResourceName": _SERIALIZER.url( + "child_resource_name", + child_resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncIdentityProvider/{childResourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + "childResourceName": _SERIALIZER.url( + "child_resource_name", + child_resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class SyncIdentityProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redhatopenshift.v2022_09_04.AzureRedHatOpenShiftClient`'s + :attr:`sync_identity_providers` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.SyncIdentityProvider"]: + """Lists SyncIdentityProviders that belong to that Azure Red Hat OpenShift Cluster. + + The operation returns properties of each SyncIdentityProvider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SyncIdentityProvider or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.SyncIdentityProviderList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SyncIdentityProviderList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftCluster/{resourceName}/syncIdentityProviders" + } + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any + ) -> _models.SyncIdentityProvider: + """Gets a SyncIdentityProvider with the specified subscription, resource group and resource name. + + The operation returns properties of a SyncIdentityProvider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncIdentityProvider resource. Required. + :type child_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SyncIdentityProvider or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.SyncIdentityProvider] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SyncIdentityProvider", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncIdentityProvider/{childResourceName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: _models.SyncIdentityProvider, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SyncIdentityProvider: + """Creates or updates a SyncIdentityProvider with the specified subscription, resource group and + resource name. + + The operation returns properties of a SyncIdentityProvider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncIdentityProvider resource. Required. + :type child_resource_name: str + :param parameters: The SyncIdentityProvider resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider + :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: SyncIdentityProvider or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SyncIdentityProvider: + """Creates or updates a SyncIdentityProvider with the specified subscription, resource group and + resource name. + + The operation returns properties of a SyncIdentityProvider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncIdentityProvider resource. Required. + :type child_resource_name: str + :param parameters: The SyncIdentityProvider resource. Required. + :type parameters: 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: SyncIdentityProvider or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: Union[_models.SyncIdentityProvider, IO], + **kwargs: Any + ) -> _models.SyncIdentityProvider: + """Creates or updates a SyncIdentityProvider with the specified subscription, resource group and + resource name. + + The operation returns properties of a SyncIdentityProvider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncIdentityProvider resource. Required. + :type child_resource_name: str + :param parameters: The SyncIdentityProvider resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider 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: SyncIdentityProvider or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SyncIdentityProvider] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SyncIdentityProvider") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SyncIdentityProvider", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SyncIdentityProvider", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncIdentityProvider/{childResourceName}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any + ) -> None: + """Deletes a SyncIdentityProvider with the specified subscription, resource group and resource + name. + + The operation returns nothing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncIdentityProvider resource. Required. + :type child_resource_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) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncIdentityProvider/{childResourceName}" + } + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: _models.SyncIdentityProviderUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SyncIdentityProvider: + """Updates a SyncIdentityProvider with the specified subscription, resource group and resource + name. + + The operation returns properties of a SyncIdentityProvider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncIdentityProvider resource. Required. + :type child_resource_name: str + :param parameters: The SyncIdentityProvider resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProviderUpdate + :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: SyncIdentityProvider or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SyncIdentityProvider: + """Updates a SyncIdentityProvider with the specified subscription, resource group and resource + name. + + The operation returns properties of a SyncIdentityProvider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncIdentityProvider resource. Required. + :type child_resource_name: str + :param parameters: The SyncIdentityProvider resource. Required. + :type parameters: 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: SyncIdentityProvider or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: Union[_models.SyncIdentityProviderUpdate, IO], + **kwargs: Any + ) -> _models.SyncIdentityProvider: + """Updates a SyncIdentityProvider with the specified subscription, resource group and resource + name. + + The operation returns properties of a SyncIdentityProvider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncIdentityProvider resource. Required. + :type child_resource_name: str + :param parameters: The SyncIdentityProvider resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProviderUpdate 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: SyncIdentityProvider or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncIdentityProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SyncIdentityProvider] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SyncIdentityProviderUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SyncIdentityProvider", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncIdentityProvider/{childResourceName}" + } diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_sync_sets_operations.py b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_sync_sets_operations.py new file mode 100644 index 000000000000..3aa40fcee155 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/operations/_sync_sets_operations.py @@ -0,0 +1,837 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, 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.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftCluster/{resourceName}/syncSets", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncSet/{childResourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + "childResourceName": _SERIALIZER.url( + "child_resource_name", + child_resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncSet/{childResourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + "childResourceName": _SERIALIZER.url( + "child_resource_name", + child_resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncSet/{childResourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + "childResourceName": _SERIALIZER.url( + "child_resource_name", + child_resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, resource_name: str, child_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncSet/{childResourceName}", + ) # 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 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + "childResourceName": _SERIALIZER.url( + "child_resource_name", + child_resource_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]*[a-zA-Z0-9]$", + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class SyncSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.redhatopenshift.v2022_09_04.AzureRedHatOpenShiftClient`'s + :attr:`sync_sets` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.SyncSet"]: + """Lists SyncSets that belong to that Azure Red Hat OpenShift Cluster. + + The operation returns properties of each SyncSet. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SyncSet or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.SyncSetList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SyncSetList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftCluster/{resourceName}/syncSets" + } + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any + ) -> _models.SyncSet: + """Gets a SyncSet with the specified subscription, resource group and resource name. + + The operation returns properties of a SyncSet. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncSet resource. Required. + :type child_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SyncSet or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[_models.SyncSet] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SyncSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncSet/{childResourceName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: _models.SyncSet, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SyncSet: + """Creates or updates a SyncSet with the specified subscription, resource group and resource name. + + The operation returns properties of a SyncSet. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncSet resource. Required. + :type child_resource_name: str + :param parameters: The SyncSet resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet + :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: SyncSet or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SyncSet: + """Creates or updates a SyncSet with the specified subscription, resource group and resource name. + + The operation returns properties of a SyncSet. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncSet resource. Required. + :type child_resource_name: str + :param parameters: The SyncSet resource. Required. + :type parameters: 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: SyncSet or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: Union[_models.SyncSet, IO], + **kwargs: Any + ) -> _models.SyncSet: + """Creates or updates a SyncSet with the specified subscription, resource group and resource name. + + The operation returns properties of a SyncSet. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncSet resource. Required. + :type child_resource_name: str + :param parameters: The SyncSet resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet 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: SyncSet or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SyncSet] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SyncSet") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SyncSet", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SyncSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncSet/{childResourceName}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, child_resource_name: str, **kwargs: Any + ) -> None: + """Deletes a SyncSet with the specified subscription, resource group and resource name. + + The operation returns nothing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncSet resource. Required. + :type child_resource_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) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncSet/{childResourceName}" + } + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: _models.SyncSetUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SyncSet: + """Updates a SyncSet with the specified subscription, resource group and resource name. + + The operation returns properties of a SyncSet. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncSet resource. Required. + :type child_resource_name: str + :param parameters: The SyncSet resource. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSetUpdate + :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: SyncSet or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SyncSet: + """Updates a SyncSet with the specified subscription, resource group and resource name. + + The operation returns properties of a SyncSet. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncSet resource. Required. + :type child_resource_name: str + :param parameters: The SyncSet resource. Required. + :type parameters: 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: SyncSet or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + resource_name: str, + child_resource_name: str, + parameters: Union[_models.SyncSetUpdate, IO], + **kwargs: Any + ) -> _models.SyncSet: + """Updates a SyncSet with the specified subscription, resource group and resource name. + + The operation returns properties of a SyncSet. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the OpenShift cluster resource. Required. + :type resource_name: str + :param child_resource_name: The name of the SyncSet resource. Required. + :type child_resource_name: str + :param parameters: The SyncSet resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSetUpdate 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: SyncSet or the result of cls(response) + :rtype: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SyncSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-09-04"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-04")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SyncSet] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SyncSetUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + child_resource_name=child_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SyncSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openshiftclusters/{resourceName}/syncSet/{childResourceName}" + } diff --git a/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/py.typed b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/redhatopenshift/azure-mgmt-redhatopenshift/azure/mgmt/redhatopenshift/v2022_09_04/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file