diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/_meta.json b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/_meta.json index 9b34d242565a..31f0da9cd867 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/_meta.json +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "commit": "108c6127f039dd68d7dce99ca4152a21a5138007", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.9.2", "use": [ - "@autorest/python@5.12.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.4.0", + "@autorest/modelerfour@4.24.3" ], - "commit": "8b95273ab48c9cce6f1497674ed5f878bdede04e", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/kubernetesconfiguration/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/kubernetesconfiguration/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.4.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/kubernetesconfiguration/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/__init__.py index b0a136e072d9..05bac22d8ecf 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/__init__.py @@ -14,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/_configuration.py index 6cd5f3b0fb03..ece4e8f4f3ec 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/_configuration.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/_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 SourceControlConfigurationClientConfiguration(Configuration): @@ -28,19 +26,18 @@ class SourceControlConfigurationClientConfiguration(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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/_serialization.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/_serialization.py new file mode 100644 index 000000000000..25467dfc00bb --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/_serialization.py @@ -0,0 +1,1998 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + TypeVar, + MutableMapping, + Type, + List, + Mapping, +) + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback +from azure.core.serialization import NULL as AzureCoreNull + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +ModelType = TypeVar("ModelType", bound="Model") +JSON = MutableMapping[str, Any] + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # 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"(? None: + self.additional_properties: Dict[str, Any] = {} + for k in kwargs: + if k not in self._attribute_map: + _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) + elif k in self._validation and self._validation[k].get("readonly", False): + _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) + else: + setattr(self, k, kwargs[k]) + + def __eq__(self, other: Any) -> bool: + """Compare objects by comparing all attributes.""" + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + return False + + def __ne__(self, other: Any) -> bool: + """Compare objects by comparing all attributes.""" + return not self.__eq__(other) + + def __str__(self) -> str: + return str(self.__dict__) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} + + @classmethod + def is_xml_model(cls) -> bool: + try: + cls._xml_map # type: ignore + except AttributeError: + return False + return True + + @classmethod + def _create_xml_node(cls): + """Create XML node.""" + try: + xml_map = cls._xml_map # type: ignore + except AttributeError: + xml_map = {} + + return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) + + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to azure from this model. + + This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[ + [str, Dict[str, Any], Any], Any + ] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. + + Advanced usage might optionally use a callback as parameter: + + .. code::python + + def my_key_transformer(key, attr_desc, value): + return key + + Key is the attribute name used in Python. Attr_desc + is a dict of metadata. Currently contains 'type' with the + msrest type and 'key' with the RestAPI encoded key. + Value is the current value in this object. + + The string returned will be used to serialize the key. + If the return type is a list, this is considered hierarchical + result dict. + + See the three examples in this file: + + - attribute_transformer + - full_restapi_key_transformer + - last_restapi_key_transformer + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param function key_transformer: A key transformer function. + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + + @classmethod + def _infer_class_models(cls): + try: + str_models = cls.__module__.rsplit(".", 1)[0] + models = sys.modules[str_models] + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + if cls.__name__ not in client_models: + raise ValueError("Not Autorest generated code") + except Exception: + # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. + client_models = {cls.__name__: cls} + return client_models + + @classmethod + def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: + """Parse a str using the RestAPI syntax and return a model. + + :param str data: A str using RestAPI structure. JSON by default. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + """ + deserializer = Deserializer(cls._infer_class_models()) + return deserializer(cls.__name__, data, content_type=content_type) + + @classmethod + def from_dict( + cls: Type[ModelType], + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> ModelType: + """Parse a dict using given key extractor return a model. + + By default consider key + extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor + and last_rest_key_case_insensitive_extractor) + + :param dict data: A dict using RestAPI structure + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + """ + deserializer = Deserializer(cls._infer_class_models()) + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) + return deserializer(cls.__name__, data, content_type=content_type) + + @classmethod + def _flatten_subtype(cls, key, objects): + if "_subtype_map" not in cls.__dict__: + return {} + result = dict(cls._subtype_map[key]) + for valuetype in cls._subtype_map[key].values(): + result.update(objects[valuetype]._flatten_subtype(key, objects)) + return result + + @classmethod + def _classify(cls, response, objects): + """Check the class _subtype_map for any child classes. + We want to ignore any inherited _subtype_maps. + Remove the polymorphic key from the initial data. + """ + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): + subtype_value = None + + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + else: + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) + if subtype_value: + # Try to match base class. Can be class name only + # (bug to fix in Autorest to support x-ms-discriminator-name) + if cls.__name__ == subtype_value: + return cls + flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) + try: + return objects[flatten_mapping_type[subtype_value]] # type: ignore + except KeyError: + _LOGGER.warning( + "Subtype value %s has no mapping, use base class %s.", + subtype_value, + cls.__name__, + ) + break + else: + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) + break + return cls + + @classmethod + def _get_rest_key_parts(cls, attr_key): + """Get the RestAPI key of this attr, split it and decode part + :param str attr_key: Attribute key must be in attribute_map. + :returns: A list of RestAPI part + :rtype: list + """ + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) + return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] + + +def _decode_attribute_map_key(key): + """This decode a key in an _attribute_map to the actual key we want to look at + inside the received data. + + :param str key: A key string from the generated code + """ + return key.replace("\\.", ".") + + +class Serializer(object): + """Request object model serializer.""" + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } + validation = { + "min_length": lambda x, y: len(x) < y, + "max_length": lambda x, y: len(x) > y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies: Dict[str, Type[ModelType]] = 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 + new_attr = {k: new_attr} + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError: + 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_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_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 is AzureCoreNull: + return None + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_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: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # 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: Optional[Mapping[str, Type[ModelType]]]=None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies: Dict[str, Type[ModelType]] = 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 deserialize. + """ + 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__ # type: ignore + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/_source_control_configuration_client.py index a75870fe68b8..0f2c3ea5fe53 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/_source_control_configuration_client.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/_source_control_configuration_client.py @@ -9,19 +9,17 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 msrest import Deserializer, Serializer from ._configuration import SourceControlConfigurationClientConfiguration +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): @@ -42,9 +40,9 @@ class SourceControlConfigurationClient(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 @@ -55,27 +53,30 @@ class SourceControlConfigurationClient(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-03-01' + DEFAULT_API_VERSION = '2022-11-01' _PROFILE_TAG = "azure.mgmt.kubernetesconfiguration.SourceControlConfigurationClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { None: DEFAULT_API_VERSION, - 'cluster_extension_type': '2022-01-01-preview', - 'cluster_extension_types': '2022-01-01-preview', - 'extension_type_versions': '2022-01-01-preview', - 'location_extension_types': '2022-01-01-preview', + 'cluster_extension_type': '2022-01-15-preview', + 'cluster_extension_types': '2022-01-15-preview', + 'extension_type_versions': '2022-01-15-preview', + 'location_extension_types': '2022-01-15-preview', + 'private_endpoint_connections': '2022-04-02-preview', + 'private_link_resources': '2022-04-02-preview', + 'private_link_scopes': '2022-04-02-preview', }}, _PROFILE_TAG + " latest" ) 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 = SourceControlConfigurationClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -99,7 +100,11 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-09-01: :mod:`v2021_09_01.models` * 2021-11-01-preview: :mod:`v2021_11_01_preview.models` * 2022-01-01-preview: :mod:`v2022_01_01_preview.models` + * 2022-01-15-preview: :mod:`v2022_01_15_preview.models` * 2022-03-01: :mod:`v2022_03_01.models` + * 2022-04-02-preview: :mod:`v2022_04_02_preview.models` + * 2022-07-01: :mod:`v2022_07_01.models` + * 2022-11-01: :mod:`v2022_11_01.models` """ if api_version == '2020-07-01-preview': from .v2020_07_01_preview import models @@ -122,9 +127,21 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-01-01-preview': from .v2022_01_01_preview import models return models + elif api_version == '2022-01-15-preview': + from .v2022_01_15_preview import models + return models elif api_version == '2022-03-01': from .v2022_03_01 import models return models + elif api_version == '2022-04-02-preview': + from .v2022_04_02_preview import models + return models + elif api_version == '2022-07-01': + from .v2022_07_01 import models + return models + elif api_version == '2022-11-01': + from .v2022_11_01 import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -134,6 +151,7 @@ def cluster_extension_type(self): * 2021-05-01-preview: :class:`ClusterExtensionTypeOperations` * 2021-11-01-preview: :class:`ClusterExtensionTypeOperations` * 2022-01-01-preview: :class:`ClusterExtensionTypeOperations` + * 2022-01-15-preview: :class:`ClusterExtensionTypeOperations` """ api_version = self._get_api_version('cluster_extension_type') if api_version == '2021-05-01-preview': @@ -142,8 +160,11 @@ def cluster_extension_type(self): from .v2021_11_01_preview.operations import ClusterExtensionTypeOperations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import ClusterExtensionTypeOperations as OperationClass + elif api_version == '2022-01-15-preview': + from .v2022_01_15_preview.operations import ClusterExtensionTypeOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'cluster_extension_type'".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 @@ -153,6 +174,7 @@ def cluster_extension_types(self): * 2021-05-01-preview: :class:`ClusterExtensionTypesOperations` * 2021-11-01-preview: :class:`ClusterExtensionTypesOperations` * 2022-01-01-preview: :class:`ClusterExtensionTypesOperations` + * 2022-01-15-preview: :class:`ClusterExtensionTypesOperations` """ api_version = self._get_api_version('cluster_extension_types') if api_version == '2021-05-01-preview': @@ -161,8 +183,11 @@ def cluster_extension_types(self): from .v2021_11_01_preview.operations import ClusterExtensionTypesOperations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import ClusterExtensionTypesOperations as OperationClass + elif api_version == '2022-01-15-preview': + from .v2022_01_15_preview.operations import ClusterExtensionTypesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'cluster_extension_types'".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 @@ -172,6 +197,7 @@ def extension_type_versions(self): * 2021-05-01-preview: :class:`ExtensionTypeVersionsOperations` * 2021-11-01-preview: :class:`ExtensionTypeVersionsOperations` * 2022-01-01-preview: :class:`ExtensionTypeVersionsOperations` + * 2022-01-15-preview: :class:`ExtensionTypeVersionsOperations` """ api_version = self._get_api_version('extension_type_versions') if api_version == '2021-05-01-preview': @@ -180,8 +206,11 @@ def extension_type_versions(self): from .v2021_11_01_preview.operations import ExtensionTypeVersionsOperations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import ExtensionTypeVersionsOperations as OperationClass + elif api_version == '2022-01-15-preview': + from .v2022_01_15_preview.operations import ExtensionTypeVersionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'extension_type_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 @@ -193,7 +222,11 @@ def extensions(self): * 2021-09-01: :class:`ExtensionsOperations` * 2021-11-01-preview: :class:`ExtensionsOperations` * 2022-01-01-preview: :class:`ExtensionsOperations` + * 2022-01-15-preview: :class:`ExtensionsOperations` * 2022-03-01: :class:`ExtensionsOperations` + * 2022-04-02-preview: :class:`ExtensionsOperations` + * 2022-07-01: :class:`ExtensionsOperations` + * 2022-11-01: :class:`ExtensionsOperations` """ api_version = self._get_api_version('extensions') if api_version == '2020-07-01-preview': @@ -206,10 +239,19 @@ def extensions(self): from .v2021_11_01_preview.operations import ExtensionsOperations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import ExtensionsOperations as OperationClass + elif api_version == '2022-01-15-preview': + from .v2022_01_15_preview.operations import ExtensionsOperations as OperationClass elif api_version == '2022-03-01': from .v2022_03_01.operations import ExtensionsOperations as OperationClass + elif api_version == '2022-04-02-preview': + from .v2022_04_02_preview.operations import ExtensionsOperations as OperationClass + elif api_version == '2022-07-01': + from .v2022_07_01.operations import ExtensionsOperations as OperationClass + elif api_version == '2022-11-01': + from .v2022_11_01.operations import ExtensionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'extensions'".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 @@ -218,17 +260,27 @@ def flux_config_operation_status(self): * 2021-11-01-preview: :class:`FluxConfigOperationStatusOperations` * 2022-01-01-preview: :class:`FluxConfigOperationStatusOperations` + * 2022-01-15-preview: :class:`FluxConfigOperationStatusOperations` * 2022-03-01: :class:`FluxConfigOperationStatusOperations` + * 2022-07-01: :class:`FluxConfigOperationStatusOperations` + * 2022-11-01: :class:`FluxConfigOperationStatusOperations` """ api_version = self._get_api_version('flux_config_operation_status') if api_version == '2021-11-01-preview': from .v2021_11_01_preview.operations import FluxConfigOperationStatusOperations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import FluxConfigOperationStatusOperations as OperationClass + elif api_version == '2022-01-15-preview': + from .v2022_01_15_preview.operations import FluxConfigOperationStatusOperations as OperationClass elif api_version == '2022-03-01': from .v2022_03_01.operations import FluxConfigOperationStatusOperations as OperationClass + elif api_version == '2022-07-01': + from .v2022_07_01.operations import FluxConfigOperationStatusOperations as OperationClass + elif api_version == '2022-11-01': + from .v2022_11_01.operations import FluxConfigOperationStatusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'flux_config_operation_status'".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 @@ -237,17 +289,27 @@ def flux_configurations(self): * 2021-11-01-preview: :class:`FluxConfigurationsOperations` * 2022-01-01-preview: :class:`FluxConfigurationsOperations` + * 2022-01-15-preview: :class:`FluxConfigurationsOperations` * 2022-03-01: :class:`FluxConfigurationsOperations` + * 2022-07-01: :class:`FluxConfigurationsOperations` + * 2022-11-01: :class:`FluxConfigurationsOperations` """ api_version = self._get_api_version('flux_configurations') if api_version == '2021-11-01-preview': from .v2021_11_01_preview.operations import FluxConfigurationsOperations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import FluxConfigurationsOperations as OperationClass + elif api_version == '2022-01-15-preview': + from .v2022_01_15_preview.operations import FluxConfigurationsOperations as OperationClass elif api_version == '2022-03-01': from .v2022_03_01.operations import FluxConfigurationsOperations as OperationClass + elif api_version == '2022-07-01': + from .v2022_07_01.operations import FluxConfigurationsOperations as OperationClass + elif api_version == '2022-11-01': + from .v2022_11_01.operations import FluxConfigurationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'flux_configurations'".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 @@ -257,6 +319,7 @@ def location_extension_types(self): * 2021-05-01-preview: :class:`LocationExtensionTypesOperations` * 2021-11-01-preview: :class:`LocationExtensionTypesOperations` * 2022-01-01-preview: :class:`LocationExtensionTypesOperations` + * 2022-01-15-preview: :class:`LocationExtensionTypesOperations` """ api_version = self._get_api_version('location_extension_types') if api_version == '2021-05-01-preview': @@ -265,8 +328,11 @@ def location_extension_types(self): from .v2021_11_01_preview.operations import LocationExtensionTypesOperations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import LocationExtensionTypesOperations as OperationClass + elif api_version == '2022-01-15-preview': + from .v2022_01_15_preview.operations import LocationExtensionTypesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'location_extension_types'".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 @@ -277,7 +343,11 @@ def operation_status(self): * 2021-09-01: :class:`OperationStatusOperations` * 2021-11-01-preview: :class:`OperationStatusOperations` * 2022-01-01-preview: :class:`OperationStatusOperations` + * 2022-01-15-preview: :class:`OperationStatusOperations` * 2022-03-01: :class:`OperationStatusOperations` + * 2022-04-02-preview: :class:`OperationStatusOperations` + * 2022-07-01: :class:`OperationStatusOperations` + * 2022-11-01: :class:`OperationStatusOperations` """ api_version = self._get_api_version('operation_status') if api_version == '2021-05-01-preview': @@ -288,10 +358,19 @@ def operation_status(self): from .v2021_11_01_preview.operations import OperationStatusOperations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import OperationStatusOperations as OperationClass + elif api_version == '2022-01-15-preview': + from .v2022_01_15_preview.operations import OperationStatusOperations as OperationClass elif api_version == '2022-03-01': from .v2022_03_01.operations import OperationStatusOperations as OperationClass + elif api_version == '2022-04-02-preview': + from .v2022_04_02_preview.operations import OperationStatusOperations as OperationClass + elif api_version == '2022-07-01': + from .v2022_07_01.operations import OperationStatusOperations as OperationClass + elif api_version == '2022-11-01': + from .v2022_11_01.operations import OperationStatusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'operation_status'".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 @@ -305,7 +384,10 @@ def operations(self): * 2021-09-01: :class:`Operations` * 2021-11-01-preview: :class:`Operations` * 2022-01-01-preview: :class:`Operations` + * 2022-01-15-preview: :class:`Operations` * 2022-03-01: :class:`Operations` + * 2022-07-01: :class:`Operations` + * 2022-11-01: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2020-07-01-preview': @@ -322,10 +404,59 @@ def operations(self): from .v2021_11_01_preview.operations import Operations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import Operations as OperationClass + elif api_version == '2022-01-15-preview': + from .v2022_01_15_preview.operations import Operations as OperationClass elif api_version == '2022-03-01': from .v2022_03_01.operations import Operations as OperationClass + elif api_version == '2022-07-01': + from .v2022_07_01.operations import Operations as OperationClass + elif api_version == '2022-11-01': + from .v2022_11_01.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 private_endpoint_connections(self): + """Instance depends on the API version: + + * 2022-04-02-preview: :class:`PrivateEndpointConnectionsOperations` + """ + api_version = self._get_api_version('private_endpoint_connections') + if api_version == '2022-04-02-preview': + from .v2022_04_02_preview.operations import PrivateEndpointConnectionsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".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 private_link_resources(self): + """Instance depends on the API version: + + * 2022-04-02-preview: :class:`PrivateLinkResourcesOperations` + """ + api_version = self._get_api_version('private_link_resources') + if api_version == '2022-04-02-preview': + from .v2022_04_02_preview.operations import PrivateLinkResourcesOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'private_link_resources'".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 private_link_scopes(self): + """Instance depends on the API version: + + * 2022-04-02-preview: :class:`PrivateLinkScopesOperations` + """ + api_version = self._get_api_version('private_link_scopes') + if api_version == '2022-04-02-preview': + from .v2022_04_02_preview.operations import PrivateLinkScopesOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'private_link_scopes'".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 @@ -338,7 +469,10 @@ def source_control_configurations(self): * 2021-05-01-preview: :class:`SourceControlConfigurationsOperations` * 2021-11-01-preview: :class:`SourceControlConfigurationsOperations` * 2022-01-01-preview: :class:`SourceControlConfigurationsOperations` + * 2022-01-15-preview: :class:`SourceControlConfigurationsOperations` * 2022-03-01: :class:`SourceControlConfigurationsOperations` + * 2022-07-01: :class:`SourceControlConfigurationsOperations` + * 2022-11-01: :class:`SourceControlConfigurationsOperations` """ api_version = self._get_api_version('source_control_configurations') if api_version == '2020-07-01-preview': @@ -353,10 +487,17 @@ def source_control_configurations(self): from .v2021_11_01_preview.operations import SourceControlConfigurationsOperations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import SourceControlConfigurationsOperations as OperationClass + elif api_version == '2022-01-15-preview': + from .v2022_01_15_preview.operations import SourceControlConfigurationsOperations as OperationClass elif api_version == '2022-03-01': from .v2022_03_01.operations import SourceControlConfigurationsOperations as OperationClass + elif api_version == '2022-07-01': + from .v2022_07_01.operations import SourceControlConfigurationsOperations as OperationClass + elif api_version == '2022-11-01': + from .v2022_11_01.operations import SourceControlConfigurationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'source_control_configurations'".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/aio/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/aio/_configuration.py index dfeb48eb057d..f1676e683a70 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/aio/_configuration.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/aio/_configuration.py @@ -26,9 +26,9 @@ class SourceControlConfigurationClientConfiguration(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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/aio/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/aio/_source_control_configuration_client.py index ed320e3b24c6..12f811cf1858 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/aio/_source_control_configuration_client.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/aio/_source_control_configuration_client.py @@ -14,13 +14,12 @@ from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin -from msrest import Deserializer, Serializer +from .._serialization import Deserializer, Serializer from ._configuration import SourceControlConfigurationClientConfiguration 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): @@ -41,9 +40,9 @@ class SourceControlConfigurationClient(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 @@ -54,15 +53,18 @@ class SourceControlConfigurationClient(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-03-01' + DEFAULT_API_VERSION = '2022-11-01' _PROFILE_TAG = "azure.mgmt.kubernetesconfiguration.SourceControlConfigurationClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { None: DEFAULT_API_VERSION, - 'cluster_extension_type': '2022-01-01-preview', - 'cluster_extension_types': '2022-01-01-preview', - 'extension_type_versions': '2022-01-01-preview', - 'location_extension_types': '2022-01-01-preview', + 'cluster_extension_type': '2022-01-15-preview', + 'cluster_extension_types': '2022-01-15-preview', + 'extension_type_versions': '2022-01-15-preview', + 'location_extension_types': '2022-01-15-preview', + 'private_endpoint_connections': '2022-04-02-preview', + 'private_link_resources': '2022-04-02-preview', + 'private_link_scopes': '2022-04-02-preview', }}, _PROFILE_TAG + " latest" ) @@ -74,7 +76,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 = SourceControlConfigurationClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -98,7 +100,11 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-09-01: :mod:`v2021_09_01.models` * 2021-11-01-preview: :mod:`v2021_11_01_preview.models` * 2022-01-01-preview: :mod:`v2022_01_01_preview.models` + * 2022-01-15-preview: :mod:`v2022_01_15_preview.models` * 2022-03-01: :mod:`v2022_03_01.models` + * 2022-04-02-preview: :mod:`v2022_04_02_preview.models` + * 2022-07-01: :mod:`v2022_07_01.models` + * 2022-11-01: :mod:`v2022_11_01.models` """ if api_version == '2020-07-01-preview': from ..v2020_07_01_preview import models @@ -121,9 +127,21 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview import models return models + elif api_version == '2022-01-15-preview': + from ..v2022_01_15_preview import models + return models elif api_version == '2022-03-01': from ..v2022_03_01 import models return models + elif api_version == '2022-04-02-preview': + from ..v2022_04_02_preview import models + return models + elif api_version == '2022-07-01': + from ..v2022_07_01 import models + return models + elif api_version == '2022-11-01': + from ..v2022_11_01 import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -133,6 +151,7 @@ def cluster_extension_type(self): * 2021-05-01-preview: :class:`ClusterExtensionTypeOperations` * 2021-11-01-preview: :class:`ClusterExtensionTypeOperations` * 2022-01-01-preview: :class:`ClusterExtensionTypeOperations` + * 2022-01-15-preview: :class:`ClusterExtensionTypeOperations` """ api_version = self._get_api_version('cluster_extension_type') if api_version == '2021-05-01-preview': @@ -141,8 +160,11 @@ def cluster_extension_type(self): from ..v2021_11_01_preview.aio.operations import ClusterExtensionTypeOperations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import ClusterExtensionTypeOperations as OperationClass + elif api_version == '2022-01-15-preview': + from ..v2022_01_15_preview.aio.operations import ClusterExtensionTypeOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'cluster_extension_type'".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 @@ -152,6 +174,7 @@ def cluster_extension_types(self): * 2021-05-01-preview: :class:`ClusterExtensionTypesOperations` * 2021-11-01-preview: :class:`ClusterExtensionTypesOperations` * 2022-01-01-preview: :class:`ClusterExtensionTypesOperations` + * 2022-01-15-preview: :class:`ClusterExtensionTypesOperations` """ api_version = self._get_api_version('cluster_extension_types') if api_version == '2021-05-01-preview': @@ -160,8 +183,11 @@ def cluster_extension_types(self): from ..v2021_11_01_preview.aio.operations import ClusterExtensionTypesOperations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import ClusterExtensionTypesOperations as OperationClass + elif api_version == '2022-01-15-preview': + from ..v2022_01_15_preview.aio.operations import ClusterExtensionTypesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'cluster_extension_types'".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 @@ -171,6 +197,7 @@ def extension_type_versions(self): * 2021-05-01-preview: :class:`ExtensionTypeVersionsOperations` * 2021-11-01-preview: :class:`ExtensionTypeVersionsOperations` * 2022-01-01-preview: :class:`ExtensionTypeVersionsOperations` + * 2022-01-15-preview: :class:`ExtensionTypeVersionsOperations` """ api_version = self._get_api_version('extension_type_versions') if api_version == '2021-05-01-preview': @@ -179,8 +206,11 @@ def extension_type_versions(self): from ..v2021_11_01_preview.aio.operations import ExtensionTypeVersionsOperations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import ExtensionTypeVersionsOperations as OperationClass + elif api_version == '2022-01-15-preview': + from ..v2022_01_15_preview.aio.operations import ExtensionTypeVersionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'extension_type_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 @@ -192,7 +222,11 @@ def extensions(self): * 2021-09-01: :class:`ExtensionsOperations` * 2021-11-01-preview: :class:`ExtensionsOperations` * 2022-01-01-preview: :class:`ExtensionsOperations` + * 2022-01-15-preview: :class:`ExtensionsOperations` * 2022-03-01: :class:`ExtensionsOperations` + * 2022-04-02-preview: :class:`ExtensionsOperations` + * 2022-07-01: :class:`ExtensionsOperations` + * 2022-11-01: :class:`ExtensionsOperations` """ api_version = self._get_api_version('extensions') if api_version == '2020-07-01-preview': @@ -205,10 +239,19 @@ def extensions(self): from ..v2021_11_01_preview.aio.operations import ExtensionsOperations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import ExtensionsOperations as OperationClass + elif api_version == '2022-01-15-preview': + from ..v2022_01_15_preview.aio.operations import ExtensionsOperations as OperationClass elif api_version == '2022-03-01': from ..v2022_03_01.aio.operations import ExtensionsOperations as OperationClass + elif api_version == '2022-04-02-preview': + from ..v2022_04_02_preview.aio.operations import ExtensionsOperations as OperationClass + elif api_version == '2022-07-01': + from ..v2022_07_01.aio.operations import ExtensionsOperations as OperationClass + elif api_version == '2022-11-01': + from ..v2022_11_01.aio.operations import ExtensionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'extensions'".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 @@ -217,17 +260,27 @@ def flux_config_operation_status(self): * 2021-11-01-preview: :class:`FluxConfigOperationStatusOperations` * 2022-01-01-preview: :class:`FluxConfigOperationStatusOperations` + * 2022-01-15-preview: :class:`FluxConfigOperationStatusOperations` * 2022-03-01: :class:`FluxConfigOperationStatusOperations` + * 2022-07-01: :class:`FluxConfigOperationStatusOperations` + * 2022-11-01: :class:`FluxConfigOperationStatusOperations` """ api_version = self._get_api_version('flux_config_operation_status') if api_version == '2021-11-01-preview': from ..v2021_11_01_preview.aio.operations import FluxConfigOperationStatusOperations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import FluxConfigOperationStatusOperations as OperationClass + elif api_version == '2022-01-15-preview': + from ..v2022_01_15_preview.aio.operations import FluxConfigOperationStatusOperations as OperationClass elif api_version == '2022-03-01': from ..v2022_03_01.aio.operations import FluxConfigOperationStatusOperations as OperationClass + elif api_version == '2022-07-01': + from ..v2022_07_01.aio.operations import FluxConfigOperationStatusOperations as OperationClass + elif api_version == '2022-11-01': + from ..v2022_11_01.aio.operations import FluxConfigOperationStatusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'flux_config_operation_status'".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 @@ -236,17 +289,27 @@ def flux_configurations(self): * 2021-11-01-preview: :class:`FluxConfigurationsOperations` * 2022-01-01-preview: :class:`FluxConfigurationsOperations` + * 2022-01-15-preview: :class:`FluxConfigurationsOperations` * 2022-03-01: :class:`FluxConfigurationsOperations` + * 2022-07-01: :class:`FluxConfigurationsOperations` + * 2022-11-01: :class:`FluxConfigurationsOperations` """ api_version = self._get_api_version('flux_configurations') if api_version == '2021-11-01-preview': from ..v2021_11_01_preview.aio.operations import FluxConfigurationsOperations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import FluxConfigurationsOperations as OperationClass + elif api_version == '2022-01-15-preview': + from ..v2022_01_15_preview.aio.operations import FluxConfigurationsOperations as OperationClass elif api_version == '2022-03-01': from ..v2022_03_01.aio.operations import FluxConfigurationsOperations as OperationClass + elif api_version == '2022-07-01': + from ..v2022_07_01.aio.operations import FluxConfigurationsOperations as OperationClass + elif api_version == '2022-11-01': + from ..v2022_11_01.aio.operations import FluxConfigurationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'flux_configurations'".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 @@ -256,6 +319,7 @@ def location_extension_types(self): * 2021-05-01-preview: :class:`LocationExtensionTypesOperations` * 2021-11-01-preview: :class:`LocationExtensionTypesOperations` * 2022-01-01-preview: :class:`LocationExtensionTypesOperations` + * 2022-01-15-preview: :class:`LocationExtensionTypesOperations` """ api_version = self._get_api_version('location_extension_types') if api_version == '2021-05-01-preview': @@ -264,8 +328,11 @@ def location_extension_types(self): from ..v2021_11_01_preview.aio.operations import LocationExtensionTypesOperations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import LocationExtensionTypesOperations as OperationClass + elif api_version == '2022-01-15-preview': + from ..v2022_01_15_preview.aio.operations import LocationExtensionTypesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'location_extension_types'".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 @@ -276,7 +343,11 @@ def operation_status(self): * 2021-09-01: :class:`OperationStatusOperations` * 2021-11-01-preview: :class:`OperationStatusOperations` * 2022-01-01-preview: :class:`OperationStatusOperations` + * 2022-01-15-preview: :class:`OperationStatusOperations` * 2022-03-01: :class:`OperationStatusOperations` + * 2022-04-02-preview: :class:`OperationStatusOperations` + * 2022-07-01: :class:`OperationStatusOperations` + * 2022-11-01: :class:`OperationStatusOperations` """ api_version = self._get_api_version('operation_status') if api_version == '2021-05-01-preview': @@ -287,10 +358,19 @@ def operation_status(self): from ..v2021_11_01_preview.aio.operations import OperationStatusOperations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import OperationStatusOperations as OperationClass + elif api_version == '2022-01-15-preview': + from ..v2022_01_15_preview.aio.operations import OperationStatusOperations as OperationClass elif api_version == '2022-03-01': from ..v2022_03_01.aio.operations import OperationStatusOperations as OperationClass + elif api_version == '2022-04-02-preview': + from ..v2022_04_02_preview.aio.operations import OperationStatusOperations as OperationClass + elif api_version == '2022-07-01': + from ..v2022_07_01.aio.operations import OperationStatusOperations as OperationClass + elif api_version == '2022-11-01': + from ..v2022_11_01.aio.operations import OperationStatusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'operation_status'".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 @@ -304,7 +384,10 @@ def operations(self): * 2021-09-01: :class:`Operations` * 2021-11-01-preview: :class:`Operations` * 2022-01-01-preview: :class:`Operations` + * 2022-01-15-preview: :class:`Operations` * 2022-03-01: :class:`Operations` + * 2022-07-01: :class:`Operations` + * 2022-11-01: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2020-07-01-preview': @@ -321,10 +404,59 @@ def operations(self): from ..v2021_11_01_preview.aio.operations import Operations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import Operations as OperationClass + elif api_version == '2022-01-15-preview': + from ..v2022_01_15_preview.aio.operations import Operations as OperationClass elif api_version == '2022-03-01': from ..v2022_03_01.aio.operations import Operations as OperationClass + elif api_version == '2022-07-01': + from ..v2022_07_01.aio.operations import Operations as OperationClass + elif api_version == '2022-11-01': + from ..v2022_11_01.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 private_endpoint_connections(self): + """Instance depends on the API version: + + * 2022-04-02-preview: :class:`PrivateEndpointConnectionsOperations` + """ + api_version = self._get_api_version('private_endpoint_connections') + if api_version == '2022-04-02-preview': + from ..v2022_04_02_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".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 private_link_resources(self): + """Instance depends on the API version: + + * 2022-04-02-preview: :class:`PrivateLinkResourcesOperations` + """ + api_version = self._get_api_version('private_link_resources') + if api_version == '2022-04-02-preview': + from ..v2022_04_02_preview.aio.operations import PrivateLinkResourcesOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'private_link_resources'".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 private_link_scopes(self): + """Instance depends on the API version: + + * 2022-04-02-preview: :class:`PrivateLinkScopesOperations` + """ + api_version = self._get_api_version('private_link_scopes') + if api_version == '2022-04-02-preview': + from ..v2022_04_02_preview.aio.operations import PrivateLinkScopesOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'private_link_scopes'".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 @@ -337,7 +469,10 @@ def source_control_configurations(self): * 2021-05-01-preview: :class:`SourceControlConfigurationsOperations` * 2021-11-01-preview: :class:`SourceControlConfigurationsOperations` * 2022-01-01-preview: :class:`SourceControlConfigurationsOperations` + * 2022-01-15-preview: :class:`SourceControlConfigurationsOperations` * 2022-03-01: :class:`SourceControlConfigurationsOperations` + * 2022-07-01: :class:`SourceControlConfigurationsOperations` + * 2022-11-01: :class:`SourceControlConfigurationsOperations` """ api_version = self._get_api_version('source_control_configurations') if api_version == '2020-07-01-preview': @@ -352,10 +487,17 @@ def source_control_configurations(self): from ..v2021_11_01_preview.aio.operations import SourceControlConfigurationsOperations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import SourceControlConfigurationsOperations as OperationClass + elif api_version == '2022-01-15-preview': + from ..v2022_01_15_preview.aio.operations import SourceControlConfigurationsOperations as OperationClass elif api_version == '2022-03-01': from ..v2022_03_01.aio.operations import SourceControlConfigurationsOperations as OperationClass + elif api_version == '2022-07-01': + from ..v2022_07_01.aio.operations import SourceControlConfigurationsOperations as OperationClass + elif api_version == '2022-11-01': + from ..v2022_11_01.aio.operations import SourceControlConfigurationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'source_control_configurations'".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/models.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/models.py index c9c8d2ae1602..c172941ccce2 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/models.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/models.py @@ -4,5 +4,6 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from .v2022_01_01_preview.models import * -from .v2022_03_01.models import * +from .v2022_01_15_preview.models import * +from .v2022_04_02_preview.models import * +from .v2022_11_01.models import * diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/__init__.py index e90963036337..3ad4bd8b604e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['SourceControlConfigurationClient'] -# `._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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_configuration.py index a175e772c245..b17bd4560e1e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_configuration.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_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,30 +15,36 @@ 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 SourceControlConfigurationClientConfiguration(Configuration): +class SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SourceControlConfigurationClient. 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 Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. + 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-07-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(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2020-07-01-preview"] = kwargs.pop("api_version", "2020-07-01-preview") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +52,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-07-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_metadata.json b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_metadata.json index b34a4cb64d8e..f75b4c9e2413 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_metadata.json +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_metadata.json @@ -10,34 +10,36 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SourceControlConfigurationClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SourceControlConfigurationClientConfiguration\"]}}, \"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\": [\"SourceControlConfigurationClientConfiguration\"], \".._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\": [\"SourceControlConfigurationClientConfiguration\"], \"..._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 + "required": true, + "method_location": "positional" }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).", + "signature": "subscription_id: str,", + "description": "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "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 Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).", + "description": "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). Required.", "docstring_type": "str", "required": true } @@ -48,22 +50,25 @@ "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 + "required": false, + "method_location": "positional" }, "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 + "required": false, + "method_location": "positional" }, "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 + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "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 + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -101,4 +109,4 @@ "operations": "Operations", "extensions": "ExtensionsOperations" } -} \ No newline at end of file +} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_patch.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_source_control_configuration_client.py index 4a2066e60af2..47f0882f8229 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_source_control_configuration_client.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_source_control_configuration_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer -from . import models +from . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import SourceControlConfigurationClientConfiguration from .operations import ExtensionsOperations, Operations, SourceControlConfigurationsOperations @@ -21,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SourceControlConfigurationClient: + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword """KubernetesConfiguration Client. :ivar source_control_configurations: SourceControlConfigurationsOperations operations @@ -33,13 +34,16 @@ class SourceControlConfigurationClient: :ivar extensions: ExtensionsOperations operations :vartype extensions: azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.operations.ExtensionsOperations - :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 Azure subscription ID. This is a GUID-formatted string (e.g. - 00000000-0000-0000-0000-000000000000). + 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -51,23 +55,22 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SourceControlConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SourceControlConfigurationClientConfiguration( + 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.source_control_configurations = SourceControlConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request, # type: 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 @@ -76,7 +79,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 @@ -89,15 +92,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: () -> SourceControlConfigurationClient + def __enter__(self) -> "SourceControlConfigurationClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_vendor.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_vendor.py index 138f663c53a4..bd0df84f5319 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_vendor.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_vendor.py @@ -5,8 +5,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + 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,14 +17,14 @@ def _convert_request(request, files=None): 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 - ] + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_version.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_version.py index 48944bf3938a..59deb8c7263b 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_version.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.1.0" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/__init__.py index 5f583276b4ed..b95230ae03c5 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._source_control_configuration_client import SourceControlConfigurationClient -__all__ = ['SourceControlConfigurationClient'] -# `._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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/_configuration.py index 5d42c644d800..4684b8487515 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/_configuration.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_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,30 +15,36 @@ 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 SourceControlConfigurationClientConfiguration(Configuration): +class SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SourceControlConfigurationClient. 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 Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. + 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-07-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(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2020-07-01-preview"] = kwargs.pop("api_version", "2020-07-01-preview") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +52,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-07-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/_patch.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/_source_control_configuration_client.py index 786354552c09..63a8ba854a3e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/_source_control_configuration_client.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/_source_control_configuration_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer -from .. import models +from .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import SourceControlConfigurationClientConfiguration from .operations import ExtensionsOperations, Operations, SourceControlConfigurationsOperations @@ -21,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SourceControlConfigurationClient: + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword """KubernetesConfiguration Client. :ivar source_control_configurations: SourceControlConfigurationsOperations operations @@ -33,13 +34,16 @@ class SourceControlConfigurationClient: :ivar extensions: ExtensionsOperations operations :vartype extensions: azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.aio.operations.ExtensionsOperations - :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 Azure subscription ID. This is a GUID-formatted string (e.g. - 00000000-0000-0000-0000-000000000000). + 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2020-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -51,23 +55,22 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SourceControlConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SourceControlConfigurationClientConfiguration( + 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.source_control_configurations = SourceControlConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.extensions = ExtensionsOperations(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 @@ -76,7 +79,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 @@ -96,5 +99,5 @@ async def __aenter__(self) -> "SourceControlConfigurationClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/operations/__init__.py index 2e68d5ecb0c7..4a64188d9a66 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/operations/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import Operations from ._extensions_operations import ExtensionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'SourceControlConfigurationsOperations', - 'Operations', - 'ExtensionsOperations', + "SourceControlConfigurationsOperations", + "Operations", + "ExtensionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/operations/_extensions_operations.py index 2cb12620a0e1..553c1e09970d 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/operations/_extensions_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/operations/_extensions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,234 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +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, 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.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._extensions_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._extensions_operations import ( + build_create_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 ExtensionsOperations: - """ExtensionsOperations 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 ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2020_07_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.kubernetesconfiguration.v2020_07_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_instance_name: str, - extension_instance: "_models.ExtensionInstance", + extension_instance: _models.ExtensionInstance, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ExtensionInstance": + ) -> _models.ExtensionInstance: """Create a new Kubernetes Cluster Extension Instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_instance_name: Name of an instance of the Extension. + :param extension_instance_name: Name of an instance of the Extension. Required. :type extension_instance_name: str - :param extension_instance: Properties necessary to Create an Extension Instance. + :param extension_instance: Properties necessary to Create an Extension Instance. Required. :type extension_instance: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance + :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: ExtensionInstance or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_instance_name: str, + extension_instance: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ExtensionInstance: + """Create a new Kubernetes Cluster Extension Instance. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_instance_name: Name of an instance of the Extension. Required. + :type extension_instance_name: str + :param extension_instance: Properties necessary to Create an Extension Instance. Required. + :type extension_instance: 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: ExtensionInstance or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_instance_name: str, + extension_instance: Union[_models.ExtensionInstance, IO], + **kwargs: Any + ) -> _models.ExtensionInstance: + """Create a new Kubernetes Cluster Extension Instance. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_instance_name: Name of an instance of the Extension. Required. + :type extension_instance_name: str + :param extension_instance: Properties necessary to Create an Extension Instance. Is either a + ExtensionInstance type or a IO type. Required. + :type extension_instance: + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance 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: ExtensionInstance, or the result of cls(response) + :return: ExtensionInstance or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionInstance"] 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 {}) - 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(extension_instance, 'ExtensionInstance') + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExtensionInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_instance, (IO, bytes)): + _content = extension_instance + else: + _json = self._serialize.body(extension_instance, "ExtensionInstance") request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_instance_name=extension_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.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(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]: @@ -112,66 +241,84 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExtensionInstance', pipeline_response) + deserialized = self._deserialize("ExtensionInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}'} # type: ignore - + create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}" + } @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_instance_name: str, **kwargs: Any - ) -> "_models.ExtensionInstance": + ) -> _models.ExtensionInstance: """Gets details of the Kubernetes Cluster Extension Instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_instance_name: Name of an instance of the Extension. + :param extension_instance_name: Name of an instance of the Extension. Required. :type extension_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExtensionInstance, or the result of cls(response) + :return: ExtensionInstance or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionInstance"] 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: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + cls: ClsType[_models.ExtensionInstance] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_instance_name=extension_instance_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -179,75 +326,187 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExtensionInstance', pipeline_response) + deserialized = self._deserialize("ExtensionInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}'} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}" + } + + @overload + async def update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_instance_name: str, + extension_instance: _models.ExtensionInstanceUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ExtensionInstance: + """Update an existing Kubernetes Cluster Extension Instance. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_instance_name: Name of an instance of the Extension. Required. + :type extension_instance_name: str + :param extension_instance: Properties to Update in the Extension Instance. Required. + :type extension_instance: + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstanceUpdate + :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: ExtensionInstance or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_instance_name: str, + extension_instance: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ExtensionInstance: + """Update an existing Kubernetes Cluster Extension Instance. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_instance_name: Name of an instance of the Extension. Required. + :type extension_instance_name: str + :param extension_instance: Properties to Update in the Extension Instance. Required. + :type extension_instance: 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: ExtensionInstance or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_instance_name: str, - extension_instance: "_models.ExtensionInstanceUpdate", + extension_instance: Union[_models.ExtensionInstanceUpdate, IO], **kwargs: Any - ) -> "_models.ExtensionInstance": + ) -> _models.ExtensionInstance: """Update an existing Kubernetes Cluster Extension Instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_instance_name: Name of an instance of the Extension. + :param extension_instance_name: Name of an instance of the Extension. Required. :type extension_instance_name: str - :param extension_instance: Properties to Update in the Extension Instance. + :param extension_instance: Properties to Update in the Extension Instance. Is either a + ExtensionInstanceUpdate type or a IO type. Required. :type extension_instance: - ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstanceUpdate + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstanceUpdate 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: ExtensionInstance, or the result of cls(response) + :return: ExtensionInstance or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionInstance"] 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 {}) - 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 {}) + + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExtensionInstance] = kwargs.pop("cls", None) - _json = self._serialize.body(extension_instance, 'ExtensionInstanceUpdate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_instance, (IO, bytes)): + _content = extension_instance + else: + _json = self._serialize.body(extension_instance, "ExtensionInstanceUpdate") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_instance_name=extension_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(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]: @@ -255,22 +514,23 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExtensionInstance', pipeline_response) + deserialized = self._deserialize("ExtensionInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}'} # type: ignore - + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}" + } @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_instance_name: str, **kwargs: Any @@ -278,44 +538,61 @@ async def delete( """Delete a Kubernetes Cluster Extension Instance. This will cause the Agent to Uninstall the extension instance from the cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_instance_name: Name of an instance of the Extension. + :param extension_instance_name: Name of an instance of the Extension. Required. :type extension_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_instance_name=extension_instance_name, - template_url=self.delete.metadata['url'], + 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 = await self._client._pipeline.run(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, 204]: @@ -326,66 +603,85 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}'} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ExtensionInstancesList"]: + ) -> AsyncIterable["_models.ExtensionInstance"]: """List all Source Control Configurations. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionInstancesList or the result of - cls(response) + :return: An iterator like instance of either ExtensionInstance or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstancesList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionInstancesList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + cls: ClsType[_models.ExtensionInstancesList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -396,13 +692,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionInstancesList", 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(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]: @@ -412,8 +710,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/operations/_operations.py index 15d34648a9cd..a411be5ca75c 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/operations/_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,79 +6,108 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.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._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.kubernetesconfiguration.v2020_07_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.kubernetesconfiguration.v2020_07_01_preview.aio.SourceControlConfigurationClient`'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.ResourceProviderOperationList"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceProviderOperation"]: """List all the available operations the KubernetesConfiguration resource provider supports. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of + :return: An iterator like instance of either ResourceProviderOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ResourceProviderOperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + cls: ClsType[_models.ResourceProviderOperationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - 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) @@ -88,13 +118,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ResourceProviderOperationList", 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(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]: @@ -104,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.KubernetesConfiguration/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/operations/_source_control_configurations_operations.py index 540d16d33ae4..cac27ff850c9 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/operations/_source_control_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/aio/operations/_source_control_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,100 +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 functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +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._source_control_configurations_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._source_control_configurations_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + 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 SourceControlConfigurationsOperations: - """SourceControlConfigurationsOperations 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 SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2020_07_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.kubernetesconfiguration.v2020_07_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Gets details of the Source Control Configuration. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -106,76 +140,192 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, - source_control_configuration: "_models.SourceControlConfiguration", + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Create a new Kubernetes Source Control Configuration. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. :type source_control_configuration: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.SourceControlConfiguration + :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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.SourceControlConfiguration 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: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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 {}) - 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(source_control_configuration, 'SourceControlConfiguration') + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -184,66 +334,84 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_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 {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self._delete_initial.metadata['url'], + 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 = await self._client._pipeline.run(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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace_async async def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any @@ -251,18 +419,20 @@ async def begin_delete( """This will delete the YAML file used to set up the Source control configuration, thus stopping future sync from the source repo. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_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. @@ -274,104 +444,132 @@ async def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - cls=lambda x,y,z: x, + api_version=api_version, + 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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SourceControlConfigurationList"]: + ) -> AsyncIterable["_models.SourceControlConfiguration"]: """List all Source Control Configurations. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlConfigurationList or the result of + :return: An iterator like instance of either SourceControlConfiguration or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.SourceControlConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + cls: ClsType[_models.SourceControlConfigurationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -382,13 +580,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlConfigurationList", 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(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]: @@ -398,8 +598,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/models/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/models/__init__.py index 70c78dcb2d46..be8eb15cab78 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/models/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/models/__init__.py @@ -28,50 +28,52 @@ from ._models_py3 import SourceControlConfigurationList from ._models_py3 import SystemData - -from ._source_control_configuration_client_enums import ( - ComplianceStateType, - Enum0, - Enum1, - InstallStateType, - LevelType, - MessageLevelType, - OperatorScopeType, - OperatorType, - ProvisioningStateType, - ResourceIdentityType, -) +from ._source_control_configuration_client_enums import ComplianceStateType +from ._source_control_configuration_client_enums import Enum0 +from ._source_control_configuration_client_enums import Enum1 +from ._source_control_configuration_client_enums import InstallStateType +from ._source_control_configuration_client_enums import LevelType +from ._source_control_configuration_client_enums import MessageLevelType +from ._source_control_configuration_client_enums import OperatorScopeType +from ._source_control_configuration_client_enums import OperatorType +from ._source_control_configuration_client_enums import ProvisioningStateType +from ._source_control_configuration_client_enums import ResourceIdentityType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ComplianceStatus', - 'ConfigurationIdentity', - 'ErrorDefinition', - 'ErrorResponse', - 'ExtensionInstance', - 'ExtensionInstanceUpdate', - 'ExtensionInstancesList', - 'ExtensionStatus', - 'HelmOperatorProperties', - 'ProxyResource', - 'Resource', - 'ResourceProviderOperation', - 'ResourceProviderOperationDisplay', - 'ResourceProviderOperationList', - 'Result', - 'Scope', - 'ScopeCluster', - 'ScopeNamespace', - 'SourceControlConfiguration', - 'SourceControlConfigurationList', - 'SystemData', - 'ComplianceStateType', - 'Enum0', - 'Enum1', - 'InstallStateType', - 'LevelType', - 'MessageLevelType', - 'OperatorScopeType', - 'OperatorType', - 'ProvisioningStateType', - 'ResourceIdentityType', + "ComplianceStatus", + "ConfigurationIdentity", + "ErrorDefinition", + "ErrorResponse", + "ExtensionInstance", + "ExtensionInstanceUpdate", + "ExtensionInstancesList", + "ExtensionStatus", + "HelmOperatorProperties", + "ProxyResource", + "Resource", + "ResourceProviderOperation", + "ResourceProviderOperationDisplay", + "ResourceProviderOperationList", + "Result", + "Scope", + "ScopeCluster", + "ScopeNamespace", + "SourceControlConfiguration", + "SourceControlConfigurationList", + "SystemData", + "ComplianceStateType", + "Enum0", + "Enum1", + "InstallStateType", + "LevelType", + "MessageLevelType", + "OperatorScopeType", + "OperatorType", + "ProvisioningStateType", + "ResourceIdentityType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/models/_models_py3.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/models/_models_py3.py index d28c93715ed6..4434fb0db6e5 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/models/_models_py3.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_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,42 +8,43 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._source_control_configuration_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class ComplianceStatus(msrest.serialization.Model): +class ComplianceStatus(_serialization.Model): """Compliance Status details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar compliance_state: The compliance state of the configuration. Possible values include: - "Pending", "Compliant", "Noncompliant", "Installed", "Failed". + :ivar compliance_state: The compliance state of the configuration. Known values are: "Pending", + "Compliant", "Noncompliant", "Installed", and "Failed". :vartype compliance_state: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ComplianceStateType :ivar last_config_applied: Datetime the configuration was last applied. :vartype last_config_applied: ~datetime.datetime :ivar message: Message from when the configuration was applied. :vartype message: str - :ivar message_level: Level of the message. Possible values include: "Error", "Warning", + :ivar message_level: Level of the message. Known values are: "Error", "Warning", and "Information". :vartype message_level: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.MessageLevelType """ _validation = { - 'compliance_state': {'readonly': True}, + "compliance_state": {"readonly": True}, } _attribute_map = { - 'compliance_state': {'key': 'complianceState', 'type': 'str'}, - 'last_config_applied': {'key': 'lastConfigApplied', 'type': 'iso-8601'}, - 'message': {'key': 'message', 'type': 'str'}, - 'message_level': {'key': 'messageLevel', 'type': 'str'}, + "compliance_state": {"key": "complianceState", "type": "str"}, + "last_config_applied": {"key": "lastConfigApplied", "type": "iso-8601"}, + "message": {"key": "message", "type": "str"}, + "message_level": {"key": "messageLevel", "type": "str"}, } def __init__( @@ -50,27 +52,27 @@ def __init__( *, last_config_applied: Optional[datetime.datetime] = None, message: Optional[str] = None, - message_level: Optional[Union[str, "MessageLevelType"]] = None, - **kwargs - ): + message_level: Optional[Union[str, "_models.MessageLevelType"]] = None, + **kwargs: Any + ) -> None: """ :keyword last_config_applied: Datetime the configuration was last applied. :paramtype last_config_applied: ~datetime.datetime :keyword message: Message from when the configuration was applied. :paramtype message: str - :keyword message_level: Level of the message. Possible values include: "Error", "Warning", + :keyword message_level: Level of the message. Known values are: "Error", "Warning", and "Information". :paramtype message_level: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.MessageLevelType """ - super(ComplianceStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.compliance_state = None self.last_config_applied = last_config_applied self.message = message self.message_level = message_level -class ConfigurationIdentity(msrest.serialization.Model): +class ConfigurationIdentity(_serialization.Model): """Identity for the managed cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -83,83 +85,72 @@ class ConfigurationIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the configuration. Type 'SystemAssigned' will use an implicitly created identity. Type 'None' will not use Managed Identity for the configuration. - Possible values include: "SystemAssigned", "None". + Known values are: "SystemAssigned" and "None". :vartype type: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ResourceIdentityType """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - **kwargs - ): + def __init__(self, *, type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, **kwargs: Any) -> None: """ :keyword type: The type of identity used for the configuration. Type 'SystemAssigned' will use an implicitly created identity. Type 'None' will not use Managed Identity for the - configuration. Possible values include: "SystemAssigned", "None". + configuration. Known values are: "SystemAssigned" and "None". :paramtype type: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ResourceIdentityType """ - super(ConfigurationIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class ErrorDefinition(msrest.serialization.Model): +class ErrorDefinition(_serialization.Model): """Error definition. All required parameters must be populated in order to send to Azure. - :ivar code: Required. Service specific error code which serves as the substatus for the HTTP - error code. + :ivar code: Service specific error code which serves as the substatus for the HTTP error code. + Required. :vartype code: str - :ivar message: Required. Description of the error. + :ivar message: Description of the error. Required. :vartype message: str """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "code": {"required": True}, + "message": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: str, - message: str, - **kwargs - ): + def __init__(self, *, code: str, message: str, **kwargs: Any) -> None: """ - :keyword code: Required. Service specific error code which serves as the substatus for the HTTP - error code. + :keyword code: Service specific error code which serves as the substatus for the HTTP error + code. Required. :paramtype code: str - :keyword message: Required. Description of the error. + :keyword message: Description of the error. Required. :paramtype message: str """ - super(ErrorDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Error response. Variables are only populated by the server, and will be ignored when sending a request. @@ -169,24 +160,20 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'error': {'readonly': True}, + "error": {"readonly": True}, } _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + "error": {"key": "error", "type": "ErrorDefinition"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.error = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The Resource model definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -203,31 +190,26 @@ 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'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - *, - system_data: Optional["SystemData"] = None, - **kwargs - ): + def __init__(self, *, system_data: Optional["_models.SystemData"] = None, **kwargs: Any) -> None: """ :keyword system_data: Top level metadata https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. :paramtype system_data: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.SystemData """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -251,34 +233,29 @@ class ProxyResource(Resource): """ _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'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - *, - system_data: Optional["SystemData"] = None, - **kwargs - ): + def __init__(self, *, system_data: Optional["_models.SystemData"] = None, **kwargs: Any) -> None: """ :keyword system_data: Top level metadata https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. :paramtype system_data: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.SystemData """ - super(ProxyResource, self).__init__(system_data=system_data, **kwargs) + super().__init__(system_data=system_data, **kwargs) -class ExtensionInstance(ProxyResource): +class ExtensionInstance(ProxyResource): # pylint: disable=too-many-instance-attributes """The Extension Instance object. Variables are only populated by the server, and will be ignored when sending a request. @@ -313,8 +290,8 @@ class ExtensionInstance(ProxyResource): :ivar configuration_protected_settings: Configuration settings that are sensitive, as name-value pairs for configuring this instance of the extension. :vartype configuration_protected_settings: dict[str, str] - :ivar install_state: Status of installation of this instance of the extension. Possible values - include: "Pending", "Installed", "Failed". + :ivar install_state: Status of installation of this instance of the extension. Known values + are: "Pending", "Installed", and "Failed". :vartype install_state: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.InstallStateType :ivar statuses: Status from this instance of the extension. @@ -338,52 +315,52 @@ class ExtensionInstance(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'install_state': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'last_status_time': {'readonly': True}, - 'error_info': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "install_state": {"readonly": True}, + "creation_time": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "last_status_time": {"readonly": True}, + "error_info": {"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'}, - 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, - 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, - 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'Scope'}, - 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, - 'install_state': {'key': 'properties.installState', 'type': 'str'}, - 'statuses': {'key': 'properties.statuses', 'type': '[ExtensionStatus]'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'str'}, - 'last_status_time': {'key': 'properties.lastStatusTime', 'type': 'str'}, - 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDefinition'}, - 'identity': {'key': 'properties.identity', 'type': 'ConfigurationIdentity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "extension_type": {"key": "properties.extensionType", "type": "str"}, + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "scope": {"key": "properties.scope", "type": "Scope"}, + "configuration_settings": {"key": "properties.configurationSettings", "type": "{str}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "install_state": {"key": "properties.installState", "type": "str"}, + "statuses": {"key": "properties.statuses", "type": "[ExtensionStatus]"}, + "creation_time": {"key": "properties.creationTime", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "str"}, + "last_status_time": {"key": "properties.lastStatusTime", "type": "str"}, + "error_info": {"key": "properties.errorInfo", "type": "ErrorDefinition"}, + "identity": {"key": "properties.identity", "type": "ConfigurationIdentity"}, } def __init__( self, *, - system_data: Optional["SystemData"] = None, + system_data: Optional["_models.SystemData"] = None, extension_type: Optional[str] = None, auto_upgrade_minor_version: Optional[bool] = None, - release_train: Optional[str] = "Stable", + release_train: str = "Stable", version: Optional[str] = None, - scope: Optional["Scope"] = None, + scope: Optional["_models.Scope"] = None, configuration_settings: Optional[Dict[str, str]] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - statuses: Optional[List["ExtensionStatus"]] = None, - identity: Optional["ConfigurationIdentity"] = None, - **kwargs - ): + statuses: Optional[List["_models.ExtensionStatus"]] = None, + identity: Optional["_models.ConfigurationIdentity"] = None, + **kwargs: Any + ) -> None: """ :keyword system_data: Top level metadata https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. @@ -417,7 +394,7 @@ def __init__( :paramtype identity: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ConfigurationIdentity """ - super(ExtensionInstance, self).__init__(system_data=system_data, **kwargs) + super().__init__(system_data=system_data, **kwargs) self.extension_type = extension_type self.auto_upgrade_minor_version = auto_upgrade_minor_version self.release_train = release_train @@ -434,8 +411,9 @@ def __init__( self.identity = identity -class ExtensionInstancesList(msrest.serialization.Model): - """Result of the request to list Extension Instances. It contains a list of ExtensionInstance objects and a URL link to get the next set of results. +class ExtensionInstancesList(_serialization.Model): + """Result of the request to list Extension Instances. It contains a list of ExtensionInstance + objects and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -447,27 +425,23 @@ class ExtensionInstancesList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ExtensionInstance]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ExtensionInstance]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ExtensionInstancesList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ExtensionInstanceUpdate(msrest.serialization.Model): +class ExtensionInstanceUpdate(_serialization.Model): """Update Extension Instance request object. :ivar auto_upgrade_minor_version: Flag to note if this instance participates in Extension @@ -482,19 +456,19 @@ class ExtensionInstanceUpdate(msrest.serialization.Model): """ _attribute_map = { - 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, - 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, } def __init__( self, *, auto_upgrade_minor_version: Optional[bool] = None, - release_train: Optional[str] = "Stable", + release_train: str = "Stable", version: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword auto_upgrade_minor_version: Flag to note if this instance participates in Extension Lifecycle Management or not. @@ -506,21 +480,20 @@ def __init__( autoUpgradeMinorVersion must be 'false'. :paramtype version: str """ - super(ExtensionInstanceUpdate, self).__init__(**kwargs) + super().__init__(**kwargs) self.auto_upgrade_minor_version = auto_upgrade_minor_version self.release_train = release_train self.version = version -class ExtensionStatus(msrest.serialization.Model): +class ExtensionStatus(_serialization.Model): """Status from this instance of the extension. :ivar code: Status code provided by the Extension. :vartype code: str :ivar display_status: Short description of status of this instance of the extension. :vartype display_status: str - :ivar level: Level of the status. Possible values include: "Error", "Warning", "Information". - Default value: "Information". + :ivar level: Level of the status. Known values are: "Error", "Warning", and "Information". :vartype level: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.LevelType :ivar message: Detailed message of the status from the Extension instance. :vartype message: str @@ -529,11 +502,11 @@ class ExtensionStatus(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'level': {'key': 'level', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'time': {'key': 'time', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "display_status": {"key": "displayStatus", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "time": {"key": "time", "type": "str"}, } def __init__( @@ -541,18 +514,17 @@ def __init__( *, code: Optional[str] = None, display_status: Optional[str] = None, - level: Optional[Union[str, "LevelType"]] = "Information", + level: Union[str, "_models.LevelType"] = "Information", message: Optional[str] = None, time: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword code: Status code provided by the Extension. :paramtype code: str :keyword display_status: Short description of status of this instance of the extension. :paramtype display_status: str - :keyword level: Level of the status. Possible values include: "Error", "Warning", - "Information". Default value: "Information". + :keyword level: Level of the status. Known values are: "Error", "Warning", and "Information". :paramtype level: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.LevelType :keyword message: Detailed message of the status from the Extension instance. @@ -560,7 +532,7 @@ def __init__( :keyword time: DateLiteral (per ISO8601) noting the time of installation status. :paramtype time: str """ - super(ExtensionStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.display_status = display_status self.level = level @@ -568,7 +540,7 @@ def __init__( self.time = time -class HelmOperatorProperties(msrest.serialization.Model): +class HelmOperatorProperties(_serialization.Model): """Properties for Helm operator. :ivar chart_version: Version of the operator Helm chart. @@ -578,29 +550,25 @@ class HelmOperatorProperties(msrest.serialization.Model): """ _attribute_map = { - 'chart_version': {'key': 'chartVersion', 'type': 'str'}, - 'chart_values': {'key': 'chartValues', 'type': 'str'}, + "chart_version": {"key": "chartVersion", "type": "str"}, + "chart_values": {"key": "chartValues", "type": "str"}, } def __init__( - self, - *, - chart_version: Optional[str] = None, - chart_values: Optional[str] = None, - **kwargs - ): + self, *, chart_version: Optional[str] = None, chart_values: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword chart_version: Version of the operator Helm chart. :paramtype chart_version: str :keyword chart_values: Values override for the operator Helm chart. :paramtype chart_values: str """ - super(HelmOperatorProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.chart_version = chart_version self.chart_values = chart_values -class ResourceProviderOperation(msrest.serialization.Model): +class ResourceProviderOperation(_serialization.Model): """Supported operation of this resource provider. Variables are only populated by the server, and will be ignored when sending a request. @@ -615,22 +583,22 @@ class ResourceProviderOperation(msrest.serialization.Model): """ _validation = { - 'is_data_action': {'readonly': True}, + "is_data_action": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "ResourceProviderOperationDisplay"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["ResourceProviderOperationDisplay"] = None, - **kwargs - ): + display: Optional["_models.ResourceProviderOperationDisplay"] = None, + **kwargs: Any + ) -> None: """ :keyword name: Operation name, in format of {provider}/{resource}/{operation}. :paramtype name: str @@ -638,13 +606,13 @@ def __init__( :paramtype display: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ResourceProviderOperationDisplay """ - super(ResourceProviderOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.is_data_action = None -class ResourceProviderOperationDisplay(msrest.serialization.Model): +class ResourceProviderOperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Resource provider: Microsoft KubernetesConfiguration. @@ -658,10 +626,10 @@ class ResourceProviderOperationDisplay(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__( @@ -671,8 +639,8 @@ def __init__( resource: Optional[str] = None, operation: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword provider: Resource provider: Microsoft KubernetesConfiguration. :paramtype provider: str @@ -683,14 +651,14 @@ def __init__( :keyword description: Description of this operation. :paramtype description: str """ - super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class ResourceProviderOperationList(msrest.serialization.Model): +class ResourceProviderOperationList(_serialization.Model): """Result of the request to list operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -703,31 +671,26 @@ class ResourceProviderOperationList(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceProviderOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceProviderOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceProviderOperation"]] = None, **kwargs: Any) -> None: """ :keyword value: List of operations supported by this resource provider. :paramtype value: list[~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ResourceProviderOperation] """ - super(ResourceProviderOperationList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class Result(msrest.serialization.Model): +class Result(_serialization.Model): """Sample result definition. :ivar sample_property: Sample property of type string. @@ -735,24 +698,19 @@ class Result(msrest.serialization.Model): """ _attribute_map = { - 'sample_property': {'key': 'sampleProperty', 'type': 'str'}, + "sample_property": {"key": "sampleProperty", "type": "str"}, } - def __init__( - self, - *, - sample_property: Optional[str] = None, - **kwargs - ): + def __init__(self, *, sample_property: Optional[str] = None, **kwargs: Any) -> None: """ :keyword sample_property: Sample property of type string. :paramtype sample_property: str """ - super(Result, self).__init__(**kwargs) + super().__init__(**kwargs) self.sample_property = sample_property -class Scope(msrest.serialization.Model): +class Scope(_serialization.Model): """Scope of the extensionInstance. It can be either Cluster or Namespace; but not both. :ivar cluster: Specifies that the scope of the extensionInstance is Cluster. @@ -763,17 +721,17 @@ class Scope(msrest.serialization.Model): """ _attribute_map = { - 'cluster': {'key': 'cluster', 'type': 'ScopeCluster'}, - 'namespace': {'key': 'namespace', 'type': 'ScopeNamespace'}, + "cluster": {"key": "cluster", "type": "ScopeCluster"}, + "namespace": {"key": "namespace", "type": "ScopeNamespace"}, } def __init__( self, *, - cluster: Optional["ScopeCluster"] = None, - namespace: Optional["ScopeNamespace"] = None, - **kwargs - ): + cluster: Optional["_models.ScopeCluster"] = None, + namespace: Optional["_models.ScopeNamespace"] = None, + **kwargs: Any + ) -> None: """ :keyword cluster: Specifies that the scope of the extensionInstance is Cluster. :paramtype cluster: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ScopeCluster @@ -781,12 +739,12 @@ def __init__( :paramtype namespace: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ScopeNamespace """ - super(Scope, self).__init__(**kwargs) + super().__init__(**kwargs) self.cluster = cluster self.namespace = namespace -class ScopeCluster(msrest.serialization.Model): +class ScopeCluster(_serialization.Model): """Specifies that the scope of the extensionInstance is Cluster. :ivar release_namespace: Namespace where the extension Release must be placed, for a Cluster @@ -795,25 +753,20 @@ class ScopeCluster(msrest.serialization.Model): """ _attribute_map = { - 'release_namespace': {'key': 'releaseNamespace', 'type': 'str'}, + "release_namespace": {"key": "releaseNamespace", "type": "str"}, } - def __init__( - self, - *, - release_namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, release_namespace: Optional[str] = None, **kwargs: Any) -> None: """ :keyword release_namespace: Namespace where the extension Release must be placed, for a Cluster scoped extensionInstance. If this namespace does not exist, it will be created. :paramtype release_namespace: str """ - super(ScopeCluster, self).__init__(**kwargs) + super().__init__(**kwargs) self.release_namespace = release_namespace -class ScopeNamespace(msrest.serialization.Model): +class ScopeNamespace(_serialization.Model): """Specifies that the scope of the extensionInstance is Namespace. :ivar target_namespace: Namespace where the extensionInstance will be created for an Namespace @@ -822,25 +775,20 @@ class ScopeNamespace(msrest.serialization.Model): """ _attribute_map = { - 'target_namespace': {'key': 'targetNamespace', 'type': 'str'}, + "target_namespace": {"key": "targetNamespace", "type": "str"}, } - def __init__( - self, - *, - target_namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_namespace: Optional[str] = None, **kwargs: Any) -> None: """ :keyword target_namespace: Namespace where the extensionInstance will be created for an Namespace scoped extensionInstance. If this namespace does not exist, it will be created. :paramtype target_namespace: str """ - super(ScopeNamespace, self).__init__(**kwargs) + super().__init__(**kwargs) self.target_namespace = target_namespace -class SourceControlConfiguration(ProxyResource): +class SourceControlConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes """The SourceControl Configuration object returned in Get & Put response. Variables are only populated by the server, and will be ignored when sending a request. @@ -862,7 +810,7 @@ class SourceControlConfiguration(ProxyResource): :ivar operator_instance_name: Instance name of the operator - identifying the specific configuration. :vartype operator_instance_name: str - :ivar operator_type: Type of the operator. Possible values include: "Flux". + :ivar operator_type: Type of the operator. "Flux" :vartype operator_type: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.OperatorType :ivar operator_params: Any Parameters for the Operator instance in string format. @@ -870,8 +818,8 @@ class SourceControlConfiguration(ProxyResource): :ivar configuration_protected_settings: Name-value pairs of protected configuration settings for the configuration. :vartype configuration_protected_settings: dict[str, str] - :ivar operator_scope: Scope at which the operator will be installed. Possible values include: - "cluster", "namespace". Default value: "cluster". + :ivar operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". :vartype operator_scope: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.OperatorScopeType :ivar repository_public_key: Public Key associated with this SourceControl configuration @@ -885,8 +833,8 @@ class SourceControlConfiguration(ProxyResource): :ivar helm_operator_properties: Properties for Helm operator. :vartype helm_operator_properties: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.HelmOperatorProperties - :ivar provisioning_state: The provisioning state of the resource provider. Possible values - include: "Accepted", "Deleting", "Running", "Succeeded", "Failed". + :ivar provisioning_state: The provisioning state of the resource provider. Known values are: + "Accepted", "Deleting", "Running", "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ProvisioningStateType :ivar compliance_status: Compliance Status of the Configuration. @@ -895,50 +843,50 @@ class SourceControlConfiguration(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'repository_public_key': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'compliance_status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "repository_public_key": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "compliance_status": {"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'}, - 'repository_url': {'key': 'properties.repositoryUrl', 'type': 'str'}, - 'operator_namespace': {'key': 'properties.operatorNamespace', 'type': 'str'}, - 'operator_instance_name': {'key': 'properties.operatorInstanceName', 'type': 'str'}, - 'operator_type': {'key': 'properties.operatorType', 'type': 'str'}, - 'operator_params': {'key': 'properties.operatorParams', 'type': 'str'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, - 'operator_scope': {'key': 'properties.operatorScope', 'type': 'str'}, - 'repository_public_key': {'key': 'properties.repositoryPublicKey', 'type': 'str'}, - 'ssh_known_hosts_contents': {'key': 'properties.sshKnownHostsContents', 'type': 'str'}, - 'enable_helm_operator': {'key': 'properties.enableHelmOperator', 'type': 'bool'}, - 'helm_operator_properties': {'key': 'properties.helmOperatorProperties', 'type': 'HelmOperatorProperties'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'compliance_status': {'key': 'properties.complianceStatus', 'type': 'ComplianceStatus'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "repository_url": {"key": "properties.repositoryUrl", "type": "str"}, + "operator_namespace": {"key": "properties.operatorNamespace", "type": "str"}, + "operator_instance_name": {"key": "properties.operatorInstanceName", "type": "str"}, + "operator_type": {"key": "properties.operatorType", "type": "str"}, + "operator_params": {"key": "properties.operatorParams", "type": "str"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "operator_scope": {"key": "properties.operatorScope", "type": "str"}, + "repository_public_key": {"key": "properties.repositoryPublicKey", "type": "str"}, + "ssh_known_hosts_contents": {"key": "properties.sshKnownHostsContents", "type": "str"}, + "enable_helm_operator": {"key": "properties.enableHelmOperator", "type": "bool"}, + "helm_operator_properties": {"key": "properties.helmOperatorProperties", "type": "HelmOperatorProperties"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "compliance_status": {"key": "properties.complianceStatus", "type": "ComplianceStatus"}, } def __init__( self, *, - system_data: Optional["SystemData"] = None, + system_data: Optional["_models.SystemData"] = None, repository_url: Optional[str] = None, - operator_namespace: Optional[str] = "default", + operator_namespace: str = "default", operator_instance_name: Optional[str] = None, - operator_type: Optional[Union[str, "OperatorType"]] = None, + operator_type: Optional[Union[str, "_models.OperatorType"]] = None, operator_params: Optional[str] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - operator_scope: Optional[Union[str, "OperatorScopeType"]] = "cluster", + operator_scope: Union[str, "_models.OperatorScopeType"] = "cluster", ssh_known_hosts_contents: Optional[str] = None, enable_helm_operator: Optional[bool] = None, - helm_operator_properties: Optional["HelmOperatorProperties"] = None, - **kwargs - ): + helm_operator_properties: Optional["_models.HelmOperatorProperties"] = None, + **kwargs: Any + ) -> None: """ :keyword system_data: Top level metadata https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. @@ -952,7 +900,7 @@ def __init__( :keyword operator_instance_name: Instance name of the operator - identifying the specific configuration. :paramtype operator_instance_name: str - :keyword operator_type: Type of the operator. Possible values include: "Flux". + :keyword operator_type: Type of the operator. "Flux" :paramtype operator_type: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.OperatorType :keyword operator_params: Any Parameters for the Operator instance in string format. @@ -960,8 +908,8 @@ def __init__( :keyword configuration_protected_settings: Name-value pairs of protected configuration settings for the configuration. :paramtype configuration_protected_settings: dict[str, str] - :keyword operator_scope: Scope at which the operator will be installed. Possible values - include: "cluster", "namespace". Default value: "cluster". + :keyword operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". :paramtype operator_scope: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.OperatorScopeType :keyword ssh_known_hosts_contents: Base64-encoded known_hosts contents containing public SSH @@ -973,7 +921,7 @@ def __init__( :paramtype helm_operator_properties: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.HelmOperatorProperties """ - super(SourceControlConfiguration, self).__init__(system_data=system_data, **kwargs) + super().__init__(system_data=system_data, **kwargs) self.repository_url = repository_url self.operator_namespace = operator_namespace self.operator_instance_name = operator_instance_name @@ -989,8 +937,9 @@ def __init__( self.compliance_status = None -class SourceControlConfigurationList(msrest.serialization.Model): - """Result of the request to list Source Control Configurations. It contains a list of SourceControlConfiguration objects and a URL link to get the next set of results. +class SourceControlConfigurationList(_serialization.Model): + """Result of the request to list Source Control Configurations. It contains a list of + SourceControlConfiguration objects and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -1002,28 +951,25 @@ class SourceControlConfigurationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SourceControlConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SourceControlConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SourceControlConfigurationList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SystemData(msrest.serialization.Model): - """Top level metadata https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. +class SystemData(_serialization.Model): + """Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -1044,30 +990,26 @@ class SystemData(msrest.serialization.Model): """ _validation = { - 'created_by': {'readonly': True}, - 'created_by_type': {'readonly': True}, - 'created_at': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - 'last_modified_by_type': {'readonly': True}, - 'last_modified_at': {'readonly': True}, + "created_by": {"readonly": True}, + "created_by_type": {"readonly": True}, + "created_at": {"readonly": True}, + "last_modified_by": {"readonly": True}, + "last_modified_by_type": {"readonly": True}, + "last_modified_at": {"readonly": True}, } _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, - **kwargs - ): - """ - """ - super(SystemData, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.created_by = None self.created_by_type = None self.created_at = None diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/models/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/models/_source_control_configuration_client_enums.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/models/_source_control_configuration_client_enums.py index bae6382fbce5..0e70d056c1c9 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/models/_source_control_configuration_client_enums.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/models/_source_control_configuration_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ComplianceStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The compliance state of the configuration. - """ +class ComplianceStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The compliance state of the configuration.""" PENDING = "Pending" COMPLIANT = "Compliant" @@ -21,56 +19,60 @@ class ComplianceStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INSTALLED = "Installed" FAILED = "Failed" -class Enum0(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class Enum0(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum0.""" MICROSOFT_CONTAINER_SERVICE = "Microsoft.ContainerService" MICROSOFT_KUBERNETES = "Microsoft.Kubernetes" -class Enum1(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class Enum1(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum1.""" MANAGED_CLUSTERS = "managedClusters" CONNECTED_CLUSTERS = "connectedClusters" -class InstallStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Status of installation of this instance of the extension. - """ + +class InstallStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of installation of this instance of the extension.""" PENDING = "Pending" INSTALLED = "Installed" FAILED = "Failed" -class LevelType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Level of the status. - """ + +class LevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the status.""" ERROR = "Error" WARNING = "Warning" INFORMATION = "Information" -class MessageLevelType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Level of the message. - """ + +class MessageLevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the message.""" ERROR = "Error" WARNING = "Warning" INFORMATION = "Information" -class OperatorScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Scope at which the operator will be installed. - """ + +class OperatorScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scope at which the operator will be installed.""" CLUSTER = "cluster" NAMESPACE = "namespace" -class OperatorType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the operator - """ + +class OperatorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the operator.""" FLUX = "Flux" -class ProvisioningStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of the resource provider. - """ + +class ProvisioningStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource provider.""" ACCEPTED = "Accepted" DELETING = "Deleting" @@ -78,7 +80,8 @@ class ProvisioningStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" FAILED = "Failed" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the configuration. Type 'SystemAssigned' will use an implicitly created identity. Type 'None' will not use Managed Identity for the configuration. """ diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/operations/__init__.py index 2e68d5ecb0c7..4a64188d9a66 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/operations/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/operations/__init__.py @@ -10,8 +10,14 @@ from ._operations import Operations from ._extensions_operations import ExtensionsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'SourceControlConfigurationsOperations', - 'Operations', - 'ExtensionsOperations', + "SourceControlConfigurationsOperations", + "Operations", + "ExtensionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/operations/_extensions_operations.py index f0a15e102ca4..b18e2fd6f8df 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/operations/_extensions_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/operations/_extensions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,329 +6,444 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 msrest import Serializer 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_create_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_instance_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2020-07-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionInstanceName": _SERIALIZER.url("extension_instance_name", extension_instance_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionInstanceName": _SERIALIZER.url("extension_instance_name", extension_instance_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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_instance_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionInstanceName": _SERIALIZER.url("extension_instance_name", extension_instance_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionInstanceName": _SERIALIZER.url("extension_instance_name", extension_instance_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_update_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_instance_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2020-07-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionInstanceName": _SERIALIZER.url("extension_instance_name", extension_instance_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionInstanceName": _SERIALIZER.url("extension_instance_name", extension_instance_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_delete_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_instance_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionInstanceName": _SERIALIZER.url("extension_instance_name", extension_instance_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionInstanceName": _SERIALIZER.url("extension_instance_name", extension_instance_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_list_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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") -class ExtensionsOperations(object): - """ExtensionsOperations 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.kubernetesconfiguration.v2020_07_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 ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.SourceControlConfigurationClient`'s + :attr:`extensions` 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 + @overload def create( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_instance_name: str, - extension_instance: "_models.ExtensionInstance", + extension_instance: _models.ExtensionInstance, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ExtensionInstance": + ) -> _models.ExtensionInstance: """Create a new Kubernetes Cluster Extension Instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_instance_name: Name of an instance of the Extension. + :param extension_instance_name: Name of an instance of the Extension. Required. :type extension_instance_name: str - :param extension_instance: Properties necessary to Create an Extension Instance. + :param extension_instance: Properties necessary to Create an Extension Instance. Required. :type extension_instance: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance + :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: ExtensionInstance or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_instance_name: str, + extension_instance: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ExtensionInstance: + """Create a new Kubernetes Cluster Extension Instance. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_instance_name: Name of an instance of the Extension. Required. + :type extension_instance_name: str + :param extension_instance: Properties necessary to Create an Extension Instance. Required. + :type extension_instance: 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: ExtensionInstance, or the result of cls(response) + :return: ExtensionInstance or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_instance_name: str, + extension_instance: Union[_models.ExtensionInstance, IO], + **kwargs: Any + ) -> _models.ExtensionInstance: + """Create a new Kubernetes Cluster Extension Instance. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_instance_name: Name of an instance of the Extension. Required. + :type extension_instance_name: str + :param extension_instance: Properties necessary to Create an Extension Instance. Is either a + ExtensionInstance type or a IO type. Required. + :type extension_instance: + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance 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: ExtensionInstance or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionInstance"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExtensionInstance] = kwargs.pop("cls", None) - _json = self._serialize.body(extension_instance, 'ExtensionInstance') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_instance, (IO, bytes)): + _content = extension_instance + else: + _json = self._serialize.body(extension_instance, "ExtensionInstance") request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_instance_name=extension_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(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]: @@ -335,66 +451,84 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExtensionInstance', pipeline_response) + deserialized = self._deserialize("ExtensionInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}'} # type: ignore - + create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}" + } @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_instance_name: str, **kwargs: Any - ) -> "_models.ExtensionInstance": + ) -> _models.ExtensionInstance: """Gets details of the Kubernetes Cluster Extension Instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_instance_name: Name of an instance of the Extension. + :param extension_instance_name: Name of an instance of the Extension. Required. :type extension_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExtensionInstance, or the result of cls(response) + :return: ExtensionInstance or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionInstance"] 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: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + cls: ClsType[_models.ExtensionInstance] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_instance_name=extension_instance_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -402,75 +536,187 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExtensionInstance', pipeline_response) + deserialized = self._deserialize("ExtensionInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}'} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}" + } + @overload + def update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_instance_name: str, + extension_instance: _models.ExtensionInstanceUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ExtensionInstance: + """Update an existing Kubernetes Cluster Extension Instance. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_instance_name: Name of an instance of the Extension. Required. + :type extension_instance_name: str + :param extension_instance: Properties to Update in the Extension Instance. Required. + :type extension_instance: + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstanceUpdate + :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: ExtensionInstance or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_instance_name: str, + extension_instance: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ExtensionInstance: + """Update an existing Kubernetes Cluster Extension Instance. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_instance_name: Name of an instance of the Extension. Required. + :type extension_instance_name: str + :param extension_instance: Properties to Update in the Extension Instance. Required. + :type extension_instance: 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: ExtensionInstance or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_instance_name: str, - extension_instance: "_models.ExtensionInstanceUpdate", + extension_instance: Union[_models.ExtensionInstanceUpdate, IO], **kwargs: Any - ) -> "_models.ExtensionInstance": + ) -> _models.ExtensionInstance: """Update an existing Kubernetes Cluster Extension Instance. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_instance_name: Name of an instance of the Extension. + :param extension_instance_name: Name of an instance of the Extension. Required. :type extension_instance_name: str - :param extension_instance: Properties to Update in the Extension Instance. + :param extension_instance: Properties to Update in the Extension Instance. Is either a + ExtensionInstanceUpdate type or a IO type. Required. :type extension_instance: - ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstanceUpdate + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstanceUpdate 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: ExtensionInstance, or the result of cls(response) + :return: ExtensionInstance or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionInstance"] 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 {}) - 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 {}) + + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ExtensionInstance] = kwargs.pop("cls", None) - _json = self._serialize.body(extension_instance, 'ExtensionInstanceUpdate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_instance, (IO, bytes)): + _content = extension_instance + else: + _json = self._serialize.body(extension_instance, "ExtensionInstanceUpdate") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_instance_name=extension_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(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]: @@ -478,22 +724,23 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExtensionInstance', pipeline_response) + deserialized = self._deserialize("ExtensionInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}'} # type: ignore - + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}" + } @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_instance_name: str, **kwargs: Any @@ -501,44 +748,61 @@ def delete( """Delete a Kubernetes Cluster Extension Instance. This will cause the Agent to Uninstall the extension instance from the cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_instance_name: Name of an instance of the Extension. + :param extension_instance_name: Name of an instance of the Extension. Required. :type extension_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_instance_name=extension_instance_name, - template_url=self.delete.metadata['url'], + 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 = self._client._pipeline.run(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, 204]: @@ -549,66 +813,85 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}'} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.ExtensionInstancesList"]: + ) -> Iterable["_models.ExtensionInstance"]: """List all Source Control Configurations. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionInstancesList or the result of - cls(response) + :return: An iterator like instance of either ExtensionInstance or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstancesList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ExtensionInstance] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionInstancesList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + cls: ClsType[_models.ExtensionInstancesList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -619,13 +902,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionInstancesList", 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(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]: @@ -635,8 +920,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/operations/_operations.py index 3e405e2ae48f..d4485741cbef 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/operations/_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,132 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 msrest import Serializer 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 = "2020-07-01-preview" - 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-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.KubernetesConfiguration/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.KubernetesConfiguration/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.kubernetesconfiguration.v2020_07_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.kubernetesconfiguration.v2020_07_01_preview.SourceControlConfigurationClient`'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.ResourceProviderOperationList"]: + def list(self, **kwargs: Any) -> Iterable["_models.ResourceProviderOperation"]: """List all the available operations the KubernetesConfiguration resource provider supports. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of + :return: An iterator like instance of either ResourceProviderOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ResourceProviderOperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + cls: ClsType[_models.ResourceProviderOperationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - 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) @@ -114,13 +142,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ResourceProviderOperationList", 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(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]: @@ -130,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.KubernetesConfiguration/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/operations/_source_control_configurations_operations.py index 3a8636804488..abdcf93cd380 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/operations/_source_control_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_07_01_preview/operations/_source_control_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,273 +6,305 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -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 msrest import Serializer 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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2020-07-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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, + +def build_delete_request( resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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_list_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-07-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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") -class SourceControlConfigurationsOperations(object): - """SourceControlConfigurationsOperations 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.kubernetesconfiguration.v2020_07_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 SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Gets details of the Source Control Configuration. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -279,76 +312,192 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, - source_control_configuration: "_models.SourceControlConfiguration", + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Create a new Kubernetes Source Control Configuration. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. :type source_control_configuration: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.SourceControlConfiguration + :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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.SourceControlConfiguration 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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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 {}) - 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(source_control_configuration, 'SourceControlConfiguration') + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -357,66 +506,84 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_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 {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self._delete_initial.metadata['url'], + 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 = self._client._pipeline.run(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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any @@ -424,18 +591,20 @@ def begin_delete( """This will delete the YAML file used to set up the Source control configuration, thus stopping future sync from the source repo. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_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. @@ -447,104 +616,132 @@ def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - cls=lambda x,y,z: x, + api_version=api_version, + 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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.SourceControlConfigurationList"]: + ) -> Iterable["_models.SourceControlConfiguration"]: """List all Source Control Configurations. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlConfigurationList or the result of + :return: An iterator like instance of either SourceControlConfiguration or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.SourceControlConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_07_01_preview.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-07-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) + cls: ClsType[_models.SourceControlConfigurationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -555,13 +752,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlConfigurationList", 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(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]: @@ -571,8 +770,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/__init__.py index e90963036337..3ad4bd8b604e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['SourceControlConfigurationClient'] -# `._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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_configuration.py index 7167f9bec314..c11c2e8813e6 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_configuration.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_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,30 +15,36 @@ 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 SourceControlConfigurationClientConfiguration(Configuration): +class SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SourceControlConfigurationClient. 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 Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. + 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-10-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2020-10-01-preview"] = kwargs.pop("api_version", "2020-10-01-preview") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +52,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-10-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_metadata.json b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_metadata.json index 3ad8203a6e50..beacd0ece51e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_metadata.json +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_metadata.json @@ -10,34 +10,36 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SourceControlConfigurationClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SourceControlConfigurationClientConfiguration\"]}}, \"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\": [\"SourceControlConfigurationClientConfiguration\"], \".._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\": [\"SourceControlConfigurationClientConfiguration\"], \"..._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 + "required": true, + "method_location": "positional" }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).", + "signature": "subscription_id: str,", + "description": "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "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 Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).", + "description": "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). Required.", "docstring_type": "str", "required": true } @@ -48,22 +50,25 @@ "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 + "required": false, + "method_location": "positional" }, "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 + "required": false, + "method_location": "positional" }, "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 + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "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 + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -100,4 +108,4 @@ "source_control_configurations": "SourceControlConfigurationsOperations", "operations": "Operations" } -} \ No newline at end of file +} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_patch.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_source_control_configuration_client.py index 435ce16a3a2f..313c0c694ab1 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_source_control_configuration_client.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_source_control_configuration_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer -from . import models +from . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import SourceControlConfigurationClientConfiguration from .operations import Operations, SourceControlConfigurationsOperations @@ -21,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SourceControlConfigurationClient: + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword """KubernetesConfiguration Client. :ivar source_control_configurations: SourceControlConfigurationsOperations operations @@ -30,13 +31,16 @@ class SourceControlConfigurationClient: :ivar operations: Operations operations :vartype operations: azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.operations.Operations - :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 Azure subscription ID. This is a GUID-formatted string (e.g. - 00000000-0000-0000-0000-000000000000). + 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2020-10-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -48,22 +52,21 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SourceControlConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SourceControlConfigurationClientConfiguration( + 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.source_control_configurations = SourceControlConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request, # type: 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 @@ -72,7 +75,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 @@ -85,15 +88,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: () -> SourceControlConfigurationClient + def __enter__(self) -> "SourceControlConfigurationClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_vendor.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_vendor.py index 138f663c53a4..bd0df84f5319 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_vendor.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_vendor.py @@ -5,8 +5,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + 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,14 +17,14 @@ def _convert_request(request, files=None): 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 - ] + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_version.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_version.py index 48944bf3938a..59deb8c7263b 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_version.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.1.0" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/__init__.py index 5f583276b4ed..b95230ae03c5 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._source_control_configuration_client import SourceControlConfigurationClient -__all__ = ['SourceControlConfigurationClient'] -# `._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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/_configuration.py index 2ea6b77035b0..16a3fbb1fb9c 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/_configuration.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_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,30 +15,36 @@ 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 SourceControlConfigurationClientConfiguration(Configuration): +class SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SourceControlConfigurationClient. 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 Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. + 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-10-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2020-10-01-preview"] = kwargs.pop("api_version", "2020-10-01-preview") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +52,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-10-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/_patch.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/_source_control_configuration_client.py index 24c6800aa80f..acbb8060d93e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/_source_control_configuration_client.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/_source_control_configuration_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer -from .. import models +from .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import SourceControlConfigurationClientConfiguration from .operations import Operations, SourceControlConfigurationsOperations @@ -21,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SourceControlConfigurationClient: + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword """KubernetesConfiguration Client. :ivar source_control_configurations: SourceControlConfigurationsOperations operations @@ -30,13 +31,16 @@ class SourceControlConfigurationClient: :ivar operations: Operations operations :vartype operations: azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.aio.operations.Operations - :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 Azure subscription ID. This is a GUID-formatted string (e.g. - 00000000-0000-0000-0000-000000000000). + 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2020-10-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -48,22 +52,21 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SourceControlConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SourceControlConfigurationClientConfiguration( + 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.source_control_configurations = SourceControlConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **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 @@ -72,7 +75,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 @@ -92,5 +95,5 @@ async def __aenter__(self) -> "SourceControlConfigurationClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/operations/__init__.py index 07db19b318c0..7a7def29a23a 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/operations/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/operations/__init__.py @@ -9,7 +9,13 @@ from ._source_control_configurations_operations import SourceControlConfigurationsOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'SourceControlConfigurationsOperations', - 'Operations', + "SourceControlConfigurationsOperations", + "Operations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/operations/_operations.py index d10b2c945f21..a71399933043 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/operations/_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,79 +6,108 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.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._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.kubernetesconfiguration.v2020_10_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.kubernetesconfiguration.v2020_10_01_preview.aio.SourceControlConfigurationClient`'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.ResourceProviderOperationList"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceProviderOperation"]: """List all the available operations the KubernetesConfiguration resource provider supports. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of + :return: An iterator like instance of either ResourceProviderOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.ResourceProviderOperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-10-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-10-01-preview") + ) + cls: ClsType[_models.ResourceProviderOperationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - 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) @@ -88,13 +118,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ResourceProviderOperationList", 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(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]: @@ -104,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.KubernetesConfiguration/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/operations/_source_control_configurations_operations.py index 1ff137c7cc06..f2f9dee6c18e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/operations/_source_control_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/aio/operations/_source_control_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,100 +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 functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +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._source_control_configurations_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._source_control_configurations_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + 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 SourceControlConfigurationsOperations: - """SourceControlConfigurationsOperations 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 SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2020_10_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.kubernetesconfiguration.v2020_10_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Gets details of the Source Control Configuration. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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: Literal["2020-10-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-10-01-preview") + ) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -106,76 +140,192 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, - source_control_configuration: "_models.SourceControlConfiguration", + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Create a new Kubernetes Source Control Configuration. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. :type source_control_configuration: ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.SourceControlConfiguration + :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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.SourceControlConfiguration 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: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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 {}) - 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(source_control_configuration, 'SourceControlConfiguration') + api_version: Literal["2020-10-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-10-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -184,66 +334,84 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_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 {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-10-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-10-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self._delete_initial.metadata['url'], + 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 = await self._client._pipeline.run(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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace_async async def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any @@ -251,18 +419,20 @@ async def begin_delete( """This will delete the YAML file used to set up the Source control configuration, thus stopping future sync from the source repo. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_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. @@ -274,104 +444,132 @@ async def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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["2020-10-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-10-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - cls=lambda x,y,z: x, + api_version=api_version, + 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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SourceControlConfigurationList"]: + ) -> AsyncIterable["_models.SourceControlConfiguration"]: """List all Source Control Configurations. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlConfigurationList or the result of + :return: An iterator like instance of either SourceControlConfiguration or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.SourceControlConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-10-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-10-01-preview") + ) + cls: ClsType[_models.SourceControlConfigurationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -382,13 +580,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlConfigurationList", 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(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]: @@ -398,8 +598,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/models/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/models/__init__.py index f851a5fd8064..5091422d70d9 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/models/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/models/__init__.py @@ -20,36 +20,38 @@ from ._models_py3 import SourceControlConfigurationList from ._models_py3 import SystemData - -from ._source_control_configuration_client_enums import ( - ComplianceStateType, - Enum0, - Enum1, - MessageLevelType, - OperatorScopeType, - OperatorType, - ProvisioningStateType, -) +from ._source_control_configuration_client_enums import ComplianceStateType +from ._source_control_configuration_client_enums import Enum0 +from ._source_control_configuration_client_enums import Enum1 +from ._source_control_configuration_client_enums import MessageLevelType +from ._source_control_configuration_client_enums import OperatorScopeType +from ._source_control_configuration_client_enums import OperatorType +from ._source_control_configuration_client_enums import ProvisioningStateType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ComplianceStatus', - 'ErrorDefinition', - 'ErrorResponse', - 'HelmOperatorProperties', - 'ProxyResource', - 'Resource', - 'ResourceProviderOperation', - 'ResourceProviderOperationDisplay', - 'ResourceProviderOperationList', - 'Result', - 'SourceControlConfiguration', - 'SourceControlConfigurationList', - 'SystemData', - 'ComplianceStateType', - 'Enum0', - 'Enum1', - 'MessageLevelType', - 'OperatorScopeType', - 'OperatorType', - 'ProvisioningStateType', + "ComplianceStatus", + "ErrorDefinition", + "ErrorResponse", + "HelmOperatorProperties", + "ProxyResource", + "Resource", + "ResourceProviderOperation", + "ResourceProviderOperationDisplay", + "ResourceProviderOperationList", + "Result", + "SourceControlConfiguration", + "SourceControlConfigurationList", + "SystemData", + "ComplianceStateType", + "Enum0", + "Enum1", + "MessageLevelType", + "OperatorScopeType", + "OperatorType", + "ProvisioningStateType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/models/_models_py3.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/models/_models_py3.py index b3ea2a3dcc46..b2b0383ac6e5 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/models/_models_py3.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_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,42 +8,43 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._source_control_configuration_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class ComplianceStatus(msrest.serialization.Model): +class ComplianceStatus(_serialization.Model): """Compliance Status details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar compliance_state: The compliance state of the configuration. Possible values include: - "Pending", "Compliant", "Noncompliant", "Installed", "Failed". + :ivar compliance_state: The compliance state of the configuration. Known values are: "Pending", + "Compliant", "Noncompliant", "Installed", and "Failed". :vartype compliance_state: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.ComplianceStateType :ivar last_config_applied: Datetime the configuration was last applied. :vartype last_config_applied: ~datetime.datetime :ivar message: Message from when the configuration was applied. :vartype message: str - :ivar message_level: Level of the message. Possible values include: "Error", "Warning", + :ivar message_level: Level of the message. Known values are: "Error", "Warning", and "Information". :vartype message_level: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.MessageLevelType """ _validation = { - 'compliance_state': {'readonly': True}, + "compliance_state": {"readonly": True}, } _attribute_map = { - 'compliance_state': {'key': 'complianceState', 'type': 'str'}, - 'last_config_applied': {'key': 'lastConfigApplied', 'type': 'iso-8601'}, - 'message': {'key': 'message', 'type': 'str'}, - 'message_level': {'key': 'messageLevel', 'type': 'str'}, + "compliance_state": {"key": "complianceState", "type": "str"}, + "last_config_applied": {"key": "lastConfigApplied", "type": "iso-8601"}, + "message": {"key": "message", "type": "str"}, + "message_level": {"key": "messageLevel", "type": "str"}, } def __init__( @@ -50,68 +52,62 @@ def __init__( *, last_config_applied: Optional[datetime.datetime] = None, message: Optional[str] = None, - message_level: Optional[Union[str, "MessageLevelType"]] = None, - **kwargs - ): + message_level: Optional[Union[str, "_models.MessageLevelType"]] = None, + **kwargs: Any + ) -> None: """ :keyword last_config_applied: Datetime the configuration was last applied. :paramtype last_config_applied: ~datetime.datetime :keyword message: Message from when the configuration was applied. :paramtype message: str - :keyword message_level: Level of the message. Possible values include: "Error", "Warning", + :keyword message_level: Level of the message. Known values are: "Error", "Warning", and "Information". :paramtype message_level: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.MessageLevelType """ - super(ComplianceStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.compliance_state = None self.last_config_applied = last_config_applied self.message = message self.message_level = message_level -class ErrorDefinition(msrest.serialization.Model): +class ErrorDefinition(_serialization.Model): """Error definition. All required parameters must be populated in order to send to Azure. - :ivar code: Required. Service specific error code which serves as the substatus for the HTTP - error code. + :ivar code: Service specific error code which serves as the substatus for the HTTP error code. + Required. :vartype code: str - :ivar message: Required. Description of the error. + :ivar message: Description of the error. Required. :vartype message: str """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "code": {"required": True}, + "message": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: str, - message: str, - **kwargs - ): + def __init__(self, *, code: str, message: str, **kwargs: Any) -> None: """ - :keyword code: Required. Service specific error code which serves as the substatus for the HTTP - error code. + :keyword code: Service specific error code which serves as the substatus for the HTTP error + code. Required. :paramtype code: str - :keyword message: Required. Description of the error. + :keyword message: Description of the error. Required. :paramtype message: str """ - super(ErrorDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Error response. Variables are only populated by the server, and will be ignored when sending a request. @@ -121,24 +117,20 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'error': {'readonly': True}, + "error": {"readonly": True}, } _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + "error": {"key": "error", "type": "ErrorDefinition"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.error = None -class HelmOperatorProperties(msrest.serialization.Model): +class HelmOperatorProperties(_serialization.Model): """Properties for Helm operator. :ivar chart_version: Version of the operator Helm chart. @@ -148,29 +140,25 @@ class HelmOperatorProperties(msrest.serialization.Model): """ _attribute_map = { - 'chart_version': {'key': 'chartVersion', 'type': 'str'}, - 'chart_values': {'key': 'chartValues', 'type': 'str'}, + "chart_version": {"key": "chartVersion", "type": "str"}, + "chart_values": {"key": "chartValues", "type": "str"}, } def __init__( - self, - *, - chart_version: Optional[str] = None, - chart_values: Optional[str] = None, - **kwargs - ): + self, *, chart_version: Optional[str] = None, chart_values: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword chart_version: Version of the operator Helm chart. :paramtype chart_version: str :keyword chart_values: Values override for the operator Helm chart. :paramtype chart_values: str """ - super(HelmOperatorProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.chart_version = chart_version self.chart_values = chart_values -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The Resource model definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -187,31 +175,26 @@ 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'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - *, - system_data: Optional["SystemData"] = None, - **kwargs - ): + def __init__(self, *, system_data: Optional["_models.SystemData"] = None, **kwargs: Any) -> None: """ :keyword system_data: Top level metadata https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. :paramtype system_data: ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.SystemData """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -235,34 +218,29 @@ class ProxyResource(Resource): """ _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'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - *, - system_data: Optional["SystemData"] = None, - **kwargs - ): + def __init__(self, *, system_data: Optional["_models.SystemData"] = None, **kwargs: Any) -> None: """ :keyword system_data: Top level metadata https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. :paramtype system_data: ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.SystemData """ - super(ProxyResource, self).__init__(system_data=system_data, **kwargs) + super().__init__(system_data=system_data, **kwargs) -class ResourceProviderOperation(msrest.serialization.Model): +class ResourceProviderOperation(_serialization.Model): """Supported operation of this resource provider. Variables are only populated by the server, and will be ignored when sending a request. @@ -277,22 +255,22 @@ class ResourceProviderOperation(msrest.serialization.Model): """ _validation = { - 'is_data_action': {'readonly': True}, + "is_data_action": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "ResourceProviderOperationDisplay"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["ResourceProviderOperationDisplay"] = None, - **kwargs - ): + display: Optional["_models.ResourceProviderOperationDisplay"] = None, + **kwargs: Any + ) -> None: """ :keyword name: Operation name, in format of {provider}/{resource}/{operation}. :paramtype name: str @@ -300,13 +278,13 @@ def __init__( :paramtype display: ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.ResourceProviderOperationDisplay """ - super(ResourceProviderOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.is_data_action = None -class ResourceProviderOperationDisplay(msrest.serialization.Model): +class ResourceProviderOperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Resource provider: Microsoft KubernetesConfiguration. @@ -320,10 +298,10 @@ class ResourceProviderOperationDisplay(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__( @@ -333,8 +311,8 @@ def __init__( resource: Optional[str] = None, operation: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword provider: Resource provider: Microsoft KubernetesConfiguration. :paramtype provider: str @@ -345,14 +323,14 @@ def __init__( :keyword description: Description of this operation. :paramtype description: str """ - super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class ResourceProviderOperationList(msrest.serialization.Model): +class ResourceProviderOperationList(_serialization.Model): """Result of the request to list operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -365,31 +343,26 @@ class ResourceProviderOperationList(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceProviderOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceProviderOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceProviderOperation"]] = None, **kwargs: Any) -> None: """ :keyword value: List of operations supported by this resource provider. :paramtype value: list[~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.ResourceProviderOperation] """ - super(ResourceProviderOperationList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class Result(msrest.serialization.Model): +class Result(_serialization.Model): """Sample result definition. :ivar sample_property: Sample property of type string. @@ -397,24 +370,19 @@ class Result(msrest.serialization.Model): """ _attribute_map = { - 'sample_property': {'key': 'sampleProperty', 'type': 'str'}, + "sample_property": {"key": "sampleProperty", "type": "str"}, } - def __init__( - self, - *, - sample_property: Optional[str] = None, - **kwargs - ): + def __init__(self, *, sample_property: Optional[str] = None, **kwargs: Any) -> None: """ :keyword sample_property: Sample property of type string. :paramtype sample_property: str """ - super(Result, self).__init__(**kwargs) + super().__init__(**kwargs) self.sample_property = sample_property -class SourceControlConfiguration(ProxyResource): +class SourceControlConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes """The SourceControl Configuration object returned in Get & Put response. Variables are only populated by the server, and will be ignored when sending a request. @@ -436,7 +404,7 @@ class SourceControlConfiguration(ProxyResource): :ivar operator_instance_name: Instance name of the operator - identifying the specific configuration. :vartype operator_instance_name: str - :ivar operator_type: Type of the operator. Possible values include: "Flux". + :ivar operator_type: Type of the operator. "Flux" :vartype operator_type: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.OperatorType :ivar operator_params: Any Parameters for the Operator instance in string format. @@ -444,8 +412,8 @@ class SourceControlConfiguration(ProxyResource): :ivar configuration_protected_settings: Name-value pairs of protected configuration settings for the configuration. :vartype configuration_protected_settings: dict[str, str] - :ivar operator_scope: Scope at which the operator will be installed. Possible values include: - "cluster", "namespace". Default value: "cluster". + :ivar operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". :vartype operator_scope: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.OperatorScopeType :ivar repository_public_key: Public Key associated with this SourceControl configuration @@ -459,8 +427,8 @@ class SourceControlConfiguration(ProxyResource): :ivar helm_operator_properties: Properties for Helm operator. :vartype helm_operator_properties: ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.HelmOperatorProperties - :ivar provisioning_state: The provisioning state of the resource provider. Possible values - include: "Accepted", "Deleting", "Running", "Succeeded", "Failed". + :ivar provisioning_state: The provisioning state of the resource provider. Known values are: + "Accepted", "Deleting", "Running", "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.ProvisioningStateType :ivar compliance_status: Compliance Status of the Configuration. @@ -469,50 +437,50 @@ class SourceControlConfiguration(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'repository_public_key': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'compliance_status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "repository_public_key": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "compliance_status": {"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'}, - 'repository_url': {'key': 'properties.repositoryUrl', 'type': 'str'}, - 'operator_namespace': {'key': 'properties.operatorNamespace', 'type': 'str'}, - 'operator_instance_name': {'key': 'properties.operatorInstanceName', 'type': 'str'}, - 'operator_type': {'key': 'properties.operatorType', 'type': 'str'}, - 'operator_params': {'key': 'properties.operatorParams', 'type': 'str'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, - 'operator_scope': {'key': 'properties.operatorScope', 'type': 'str'}, - 'repository_public_key': {'key': 'properties.repositoryPublicKey', 'type': 'str'}, - 'ssh_known_hosts_contents': {'key': 'properties.sshKnownHostsContents', 'type': 'str'}, - 'enable_helm_operator': {'key': 'properties.enableHelmOperator', 'type': 'bool'}, - 'helm_operator_properties': {'key': 'properties.helmOperatorProperties', 'type': 'HelmOperatorProperties'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'compliance_status': {'key': 'properties.complianceStatus', 'type': 'ComplianceStatus'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "repository_url": {"key": "properties.repositoryUrl", "type": "str"}, + "operator_namespace": {"key": "properties.operatorNamespace", "type": "str"}, + "operator_instance_name": {"key": "properties.operatorInstanceName", "type": "str"}, + "operator_type": {"key": "properties.operatorType", "type": "str"}, + "operator_params": {"key": "properties.operatorParams", "type": "str"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "operator_scope": {"key": "properties.operatorScope", "type": "str"}, + "repository_public_key": {"key": "properties.repositoryPublicKey", "type": "str"}, + "ssh_known_hosts_contents": {"key": "properties.sshKnownHostsContents", "type": "str"}, + "enable_helm_operator": {"key": "properties.enableHelmOperator", "type": "bool"}, + "helm_operator_properties": {"key": "properties.helmOperatorProperties", "type": "HelmOperatorProperties"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "compliance_status": {"key": "properties.complianceStatus", "type": "ComplianceStatus"}, } def __init__( self, *, - system_data: Optional["SystemData"] = None, + system_data: Optional["_models.SystemData"] = None, repository_url: Optional[str] = None, - operator_namespace: Optional[str] = "default", + operator_namespace: str = "default", operator_instance_name: Optional[str] = None, - operator_type: Optional[Union[str, "OperatorType"]] = None, + operator_type: Optional[Union[str, "_models.OperatorType"]] = None, operator_params: Optional[str] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - operator_scope: Optional[Union[str, "OperatorScopeType"]] = "cluster", + operator_scope: Union[str, "_models.OperatorScopeType"] = "cluster", ssh_known_hosts_contents: Optional[str] = None, enable_helm_operator: Optional[bool] = None, - helm_operator_properties: Optional["HelmOperatorProperties"] = None, - **kwargs - ): + helm_operator_properties: Optional["_models.HelmOperatorProperties"] = None, + **kwargs: Any + ) -> None: """ :keyword system_data: Top level metadata https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. @@ -526,7 +494,7 @@ def __init__( :keyword operator_instance_name: Instance name of the operator - identifying the specific configuration. :paramtype operator_instance_name: str - :keyword operator_type: Type of the operator. Possible values include: "Flux". + :keyword operator_type: Type of the operator. "Flux" :paramtype operator_type: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.OperatorType :keyword operator_params: Any Parameters for the Operator instance in string format. @@ -534,8 +502,8 @@ def __init__( :keyword configuration_protected_settings: Name-value pairs of protected configuration settings for the configuration. :paramtype configuration_protected_settings: dict[str, str] - :keyword operator_scope: Scope at which the operator will be installed. Possible values - include: "cluster", "namespace". Default value: "cluster". + :keyword operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". :paramtype operator_scope: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.OperatorScopeType :keyword ssh_known_hosts_contents: Base64-encoded known_hosts contents containing public SSH @@ -547,7 +515,7 @@ def __init__( :paramtype helm_operator_properties: ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.HelmOperatorProperties """ - super(SourceControlConfiguration, self).__init__(system_data=system_data, **kwargs) + super().__init__(system_data=system_data, **kwargs) self.repository_url = repository_url self.operator_namespace = operator_namespace self.operator_instance_name = operator_instance_name @@ -563,8 +531,9 @@ def __init__( self.compliance_status = None -class SourceControlConfigurationList(msrest.serialization.Model): - """Result of the request to list Source Control Configurations. It contains a list of SourceControlConfiguration objects and a URL link to get the next set of results. +class SourceControlConfigurationList(_serialization.Model): + """Result of the request to list Source Control Configurations. It contains a list of + SourceControlConfiguration objects and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -576,28 +545,25 @@ class SourceControlConfigurationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SourceControlConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SourceControlConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SourceControlConfigurationList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SystemData(msrest.serialization.Model): - """Top level metadata https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. +class SystemData(_serialization.Model): + """Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -618,30 +584,26 @@ class SystemData(msrest.serialization.Model): """ _validation = { - 'created_by': {'readonly': True}, - 'created_by_type': {'readonly': True}, - 'created_at': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - 'last_modified_by_type': {'readonly': True}, - 'last_modified_at': {'readonly': True}, + "created_by": {"readonly": True}, + "created_by_type": {"readonly": True}, + "created_at": {"readonly": True}, + "last_modified_by": {"readonly": True}, + "last_modified_by_type": {"readonly": True}, + "last_modified_at": {"readonly": True}, } _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, - **kwargs - ): - """ - """ - super(SystemData, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.created_by = None self.created_by_type = None self.created_at = None diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/models/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/models/_source_control_configuration_client_enums.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/models/_source_control_configuration_client_enums.py index f15af9df3a01..c3679c17da02 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/models/_source_control_configuration_client_enums.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/models/_source_control_configuration_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ComplianceStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The compliance state of the configuration. - """ +class ComplianceStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The compliance state of the configuration.""" PENDING = "Pending" COMPLIANT = "Compliant" @@ -21,40 +19,44 @@ class ComplianceStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INSTALLED = "Installed" FAILED = "Failed" -class Enum0(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class Enum0(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum0.""" MICROSOFT_CONTAINER_SERVICE = "Microsoft.ContainerService" MICROSOFT_KUBERNETES = "Microsoft.Kubernetes" -class Enum1(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class Enum1(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum1.""" MANAGED_CLUSTERS = "managedClusters" CONNECTED_CLUSTERS = "connectedClusters" -class MessageLevelType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Level of the message. - """ + +class MessageLevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the message.""" ERROR = "Error" WARNING = "Warning" INFORMATION = "Information" -class OperatorScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Scope at which the operator will be installed. - """ + +class OperatorScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scope at which the operator will be installed.""" CLUSTER = "cluster" NAMESPACE = "namespace" -class OperatorType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the operator - """ + +class OperatorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the operator.""" FLUX = "Flux" -class ProvisioningStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of the resource provider. - """ + +class ProvisioningStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource provider.""" ACCEPTED = "Accepted" DELETING = "Deleting" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/operations/__init__.py index 07db19b318c0..7a7def29a23a 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/operations/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/operations/__init__.py @@ -9,7 +9,13 @@ from ._source_control_configurations_operations import SourceControlConfigurationsOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'SourceControlConfigurationsOperations', - 'Operations', + "SourceControlConfigurationsOperations", + "Operations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/operations/_operations.py index 04f675b2f5e4..9c7f2be4fc0f 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/operations/_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,132 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 msrest import Serializer 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 = "2020-10-01-preview" - 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-10-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-10-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.KubernetesConfiguration/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.KubernetesConfiguration/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.kubernetesconfiguration.v2020_10_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.kubernetesconfiguration.v2020_10_01_preview.SourceControlConfigurationClient`'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.ResourceProviderOperationList"]: + def list(self, **kwargs: Any) -> Iterable["_models.ResourceProviderOperation"]: """List all the available operations the KubernetesConfiguration resource provider supports. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of + :return: An iterator like instance of either ResourceProviderOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.ResourceProviderOperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-10-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-10-01-preview") + ) + cls: ClsType[_models.ResourceProviderOperationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - 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) @@ -114,13 +142,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ResourceProviderOperationList", 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(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]: @@ -130,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.KubernetesConfiguration/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/operations/_source_control_configurations_operations.py index 8eebc4837900..8e51d1249c58 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/operations/_source_control_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2020_10_01_preview/operations/_source_control_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,273 +6,305 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -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 msrest import Serializer 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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-10-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-10-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-10-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-10-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2020-10-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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, + +def build_delete_request( resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-10-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-10-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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_list_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-10-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-10-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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") -class SourceControlConfigurationsOperations(object): - """SourceControlConfigurationsOperations 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.kubernetesconfiguration.v2020_10_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 SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Gets details of the Source Control Configuration. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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: Literal["2020-10-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-10-01-preview") + ) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -279,76 +312,192 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, - source_control_configuration: "_models.SourceControlConfiguration", + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Create a new Kubernetes Source Control Configuration. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. :type source_control_configuration: ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.SourceControlConfiguration + :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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.SourceControlConfiguration 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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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 {}) - 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(source_control_configuration, 'SourceControlConfiguration') + api_version: Literal["2020-10-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-10-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -357,66 +506,84 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_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 {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-10-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-10-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self._delete_initial.metadata['url'], + 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 = self._client._pipeline.run(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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any @@ -424,18 +591,20 @@ def begin_delete( """This will delete the YAML file used to set up the Source control configuration, thus stopping future sync from the source repo. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_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. @@ -447,104 +616,132 @@ def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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["2020-10-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-10-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - cls=lambda x,y,z: x, + api_version=api_version, + 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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.SourceControlConfigurationList"]: + ) -> Iterable["_models.SourceControlConfiguration"]: """List all Source Control Configurations. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlConfigurationList or the result of + :return: An iterator like instance of either SourceControlConfiguration or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.SourceControlConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2020_10_01_preview.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-10-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-10-01-preview") + ) + cls: ClsType[_models.SourceControlConfigurationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -555,13 +752,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlConfigurationList", 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(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]: @@ -571,8 +770,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/__init__.py index e90963036337..3ad4bd8b604e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['SourceControlConfigurationClient'] -# `._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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_configuration.py index d1e0dc4fffe1..ef54d36a0d9e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_configuration.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_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,30 +15,36 @@ 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 SourceControlConfigurationClientConfiguration(Configuration): +class SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SourceControlConfigurationClient. 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 Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. + 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-03-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(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2021-03-01"] = kwargs.pop("api_version", "2021-03-01") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +52,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-03-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_metadata.json b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_metadata.json index 324f873c032c..b872e0f0c088 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_metadata.json +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_metadata.json @@ -10,34 +10,36 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SourceControlConfigurationClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SourceControlConfigurationClientConfiguration\"]}}, \"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\": [\"SourceControlConfigurationClientConfiguration\"], \".._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\": [\"SourceControlConfigurationClientConfiguration\"], \"..._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 + "required": true, + "method_location": "positional" }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).", + "signature": "subscription_id: str,", + "description": "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "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 Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).", + "description": "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). Required.", "docstring_type": "str", "required": true } @@ -48,22 +50,25 @@ "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 + "required": false, + "method_location": "positional" }, "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 + "required": false, + "method_location": "positional" }, "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 + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "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 + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -100,4 +108,4 @@ "source_control_configurations": "SourceControlConfigurationsOperations", "operations": "Operations" } -} \ No newline at end of file +} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_patch.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_source_control_configuration_client.py index d88edd7b180c..f2f19032b89e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_source_control_configuration_client.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_source_control_configuration_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer -from . import models +from . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import SourceControlConfigurationClientConfiguration from .operations import Operations, SourceControlConfigurationsOperations @@ -21,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SourceControlConfigurationClient: + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword """KubernetesConfiguration Client. :ivar source_control_configurations: SourceControlConfigurationsOperations operations @@ -29,13 +30,16 @@ class SourceControlConfigurationClient: azure.mgmt.kubernetesconfiguration.v2021_03_01.operations.SourceControlConfigurationsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.kubernetesconfiguration.v2021_03_01.operations.Operations - :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 Azure subscription ID. This is a GUID-formatted string (e.g. - 00000000-0000-0000-0000-000000000000). + 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-03-01". 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. """ @@ -47,22 +51,21 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SourceControlConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SourceControlConfigurationClientConfiguration( + 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.source_control_configurations = SourceControlConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request, # type: 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 @@ -71,7 +74,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 @@ -84,15 +87,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: () -> SourceControlConfigurationClient + def __enter__(self) -> "SourceControlConfigurationClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_vendor.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_vendor.py index 138f663c53a4..bd0df84f5319 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_vendor.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_vendor.py @@ -5,8 +5,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + 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,14 +17,14 @@ def _convert_request(request, files=None): 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 - ] + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_version.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_version.py index 48944bf3938a..59deb8c7263b 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_version.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.1.0" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/__init__.py index 5f583276b4ed..b95230ae03c5 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._source_control_configuration_client import SourceControlConfigurationClient -__all__ = ['SourceControlConfigurationClient'] -# `._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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/_configuration.py index 6e8d28ce1acc..4b34622e6271 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/_configuration.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_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,30 +15,36 @@ 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 SourceControlConfigurationClientConfiguration(Configuration): +class SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SourceControlConfigurationClient. 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 Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. + 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-03-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(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2021-03-01"] = kwargs.pop("api_version", "2021-03-01") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +52,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-03-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/_patch.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/_source_control_configuration_client.py index ebbe4381c953..3660c52b5e6d 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/_source_control_configuration_client.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/_source_control_configuration_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer -from .. import models +from .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import SourceControlConfigurationClientConfiguration from .operations import Operations, SourceControlConfigurationsOperations @@ -21,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SourceControlConfigurationClient: + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword """KubernetesConfiguration Client. :ivar source_control_configurations: SourceControlConfigurationsOperations operations @@ -29,13 +30,16 @@ class SourceControlConfigurationClient: azure.mgmt.kubernetesconfiguration.v2021_03_01.aio.operations.SourceControlConfigurationsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.kubernetesconfiguration.v2021_03_01.aio.operations.Operations - :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 Azure subscription ID. This is a GUID-formatted string (e.g. - 00000000-0000-0000-0000-000000000000). + 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-03-01". 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. """ @@ -47,22 +51,21 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SourceControlConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SourceControlConfigurationClientConfiguration( + 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.source_control_configurations = SourceControlConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **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 @@ -71,7 +74,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 @@ -91,5 +94,5 @@ async def __aenter__(self) -> "SourceControlConfigurationClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/operations/__init__.py index 07db19b318c0..7a7def29a23a 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/operations/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/operations/__init__.py @@ -9,7 +9,13 @@ from ._source_control_configurations_operations import SourceControlConfigurationsOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'SourceControlConfigurationsOperations', - 'Operations', + "SourceControlConfigurationsOperations", + "Operations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/operations/_operations.py index ced61c241997..cf0968d9520e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/operations/_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,79 +6,106 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.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._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.kubernetesconfiguration.v2021_03_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.kubernetesconfiguration.v2021_03_01.aio.SourceControlConfigurationClient`'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.ResourceProviderOperationList"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceProviderOperation"]: """List all the available operations the KubernetesConfiguration resource provider supports. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of + :return: An iterator like instance of either ResourceProviderOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.ResourceProviderOperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01")) + cls: ClsType[_models.ResourceProviderOperationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - 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) @@ -88,13 +116,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ResourceProviderOperationList", 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(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]: @@ -104,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.KubernetesConfiguration/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/operations/_source_control_configurations_operations.py index 8ca4a2f361a8..364ada392196 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/operations/_source_control_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/aio/operations/_source_control_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,99 +6,130 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +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._source_control_configurations_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._source_control_configurations_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + 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 SourceControlConfigurationsOperations: - """SourceControlConfigurationsOperations 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 SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_03_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.kubernetesconfiguration.v2021_03_01.aio.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Gets details of the Source Control Configuration. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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: Literal["2021-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01")) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -105,75 +137,187 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, - source_control_configuration: "_models.SourceControlConfiguration", + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Create a new Kubernetes Source Control Configuration. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. :type source_control_configuration: ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.SourceControlConfiguration + :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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.SourceControlConfiguration 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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version: Literal["2021-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) - _json = self._serialize.body(source_control_configuration, 'SourceControlConfiguration') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -182,66 +326,82 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_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 {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self._delete_initial.metadata['url'], + 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 = await self._client._pipeline.run(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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace_async async def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any @@ -249,18 +409,20 @@ async def begin_delete( """This will delete the YAML file used to set up the Source control configuration, thus stopping future sync from the source repo. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_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. @@ -272,104 +434,128 @@ async def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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["2021-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - cls=lambda x,y,z: x, + api_version=api_version, + 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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SourceControlConfigurationList"]: + ) -> AsyncIterable["_models.SourceControlConfiguration"]: """List all Source Control Configurations. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlConfigurationList or the result of + :return: An iterator like instance of either SourceControlConfiguration or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.SourceControlConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01")) + cls: ClsType[_models.SourceControlConfigurationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -380,13 +566,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlConfigurationList", 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(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]: @@ -396,8 +584,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/models/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/models/__init__.py index ec901c15835a..2deeb4209fbe 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/models/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/models/__init__.py @@ -20,38 +20,40 @@ from ._models_py3 import SourceControlConfigurationList from ._models_py3 import SystemData - -from ._source_control_configuration_client_enums import ( - ComplianceStateType, - CreatedByType, - Enum0, - Enum1, - MessageLevelType, - OperatorScopeType, - OperatorType, - ProvisioningStateType, -) +from ._source_control_configuration_client_enums import ComplianceStateType +from ._source_control_configuration_client_enums import CreatedByType +from ._source_control_configuration_client_enums import Enum0 +from ._source_control_configuration_client_enums import Enum1 +from ._source_control_configuration_client_enums import MessageLevelType +from ._source_control_configuration_client_enums import OperatorScopeType +from ._source_control_configuration_client_enums import OperatorType +from ._source_control_configuration_client_enums import ProvisioningStateType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ComplianceStatus', - 'ErrorDefinition', - 'ErrorResponse', - 'HelmOperatorProperties', - 'ProxyResource', - 'Resource', - 'ResourceProviderOperation', - 'ResourceProviderOperationDisplay', - 'ResourceProviderOperationList', - 'Result', - 'SourceControlConfiguration', - 'SourceControlConfigurationList', - 'SystemData', - 'ComplianceStateType', - 'CreatedByType', - 'Enum0', - 'Enum1', - 'MessageLevelType', - 'OperatorScopeType', - 'OperatorType', - 'ProvisioningStateType', + "ComplianceStatus", + "ErrorDefinition", + "ErrorResponse", + "HelmOperatorProperties", + "ProxyResource", + "Resource", + "ResourceProviderOperation", + "ResourceProviderOperationDisplay", + "ResourceProviderOperationList", + "Result", + "SourceControlConfiguration", + "SourceControlConfigurationList", + "SystemData", + "ComplianceStateType", + "CreatedByType", + "Enum0", + "Enum1", + "MessageLevelType", + "OperatorScopeType", + "OperatorType", + "ProvisioningStateType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/models/_models_py3.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/models/_models_py3.py index fb21995b82b7..bf368286b011 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/models/_models_py3.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_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,42 +8,43 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._source_control_configuration_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class ComplianceStatus(msrest.serialization.Model): +class ComplianceStatus(_serialization.Model): """Compliance Status details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar compliance_state: The compliance state of the configuration. Possible values include: - "Pending", "Compliant", "Noncompliant", "Installed", "Failed". + :ivar compliance_state: The compliance state of the configuration. Known values are: "Pending", + "Compliant", "Noncompliant", "Installed", and "Failed". :vartype compliance_state: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.ComplianceStateType :ivar last_config_applied: Datetime the configuration was last applied. :vartype last_config_applied: ~datetime.datetime :ivar message: Message from when the configuration was applied. :vartype message: str - :ivar message_level: Level of the message. Possible values include: "Error", "Warning", + :ivar message_level: Level of the message. Known values are: "Error", "Warning", and "Information". :vartype message_level: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.MessageLevelType """ _validation = { - 'compliance_state': {'readonly': True}, + "compliance_state": {"readonly": True}, } _attribute_map = { - 'compliance_state': {'key': 'complianceState', 'type': 'str'}, - 'last_config_applied': {'key': 'lastConfigApplied', 'type': 'iso-8601'}, - 'message': {'key': 'message', 'type': 'str'}, - 'message_level': {'key': 'messageLevel', 'type': 'str'}, + "compliance_state": {"key": "complianceState", "type": "str"}, + "last_config_applied": {"key": "lastConfigApplied", "type": "iso-8601"}, + "message": {"key": "message", "type": "str"}, + "message_level": {"key": "messageLevel", "type": "str"}, } def __init__( @@ -50,68 +52,62 @@ def __init__( *, last_config_applied: Optional[datetime.datetime] = None, message: Optional[str] = None, - message_level: Optional[Union[str, "MessageLevelType"]] = None, - **kwargs - ): + message_level: Optional[Union[str, "_models.MessageLevelType"]] = None, + **kwargs: Any + ) -> None: """ :keyword last_config_applied: Datetime the configuration was last applied. :paramtype last_config_applied: ~datetime.datetime :keyword message: Message from when the configuration was applied. :paramtype message: str - :keyword message_level: Level of the message. Possible values include: "Error", "Warning", + :keyword message_level: Level of the message. Known values are: "Error", "Warning", and "Information". :paramtype message_level: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.MessageLevelType """ - super(ComplianceStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.compliance_state = None self.last_config_applied = last_config_applied self.message = message self.message_level = message_level -class ErrorDefinition(msrest.serialization.Model): +class ErrorDefinition(_serialization.Model): """Error definition. All required parameters must be populated in order to send to Azure. - :ivar code: Required. Service specific error code which serves as the substatus for the HTTP - error code. + :ivar code: Service specific error code which serves as the substatus for the HTTP error code. + Required. :vartype code: str - :ivar message: Required. Description of the error. + :ivar message: Description of the error. Required. :vartype message: str """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "code": {"required": True}, + "message": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: str, - message: str, - **kwargs - ): + def __init__(self, *, code: str, message: str, **kwargs: Any) -> None: """ - :keyword code: Required. Service specific error code which serves as the substatus for the HTTP - error code. + :keyword code: Service specific error code which serves as the substatus for the HTTP error + code. Required. :paramtype code: str - :keyword message: Required. Description of the error. + :keyword message: Description of the error. Required. :paramtype message: str """ - super(ErrorDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Error response. Variables are only populated by the server, and will be ignored when sending a request. @@ -121,24 +117,20 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'error': {'readonly': True}, + "error": {"readonly": True}, } _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + "error": {"key": "error", "type": "ErrorDefinition"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.error = None -class HelmOperatorProperties(msrest.serialization.Model): +class HelmOperatorProperties(_serialization.Model): """Properties for Helm operator. :ivar chart_version: Version of the operator Helm chart. @@ -148,29 +140,25 @@ class HelmOperatorProperties(msrest.serialization.Model): """ _attribute_map = { - 'chart_version': {'key': 'chartVersion', 'type': 'str'}, - 'chart_values': {'key': 'chartValues', 'type': 'str'}, + "chart_version": {"key": "chartVersion", "type": "str"}, + "chart_values": {"key": "chartValues", "type": "str"}, } def __init__( - self, - *, - chart_version: Optional[str] = None, - chart_values: Optional[str] = None, - **kwargs - ): + self, *, chart_version: Optional[str] = None, chart_values: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword chart_version: Version of the operator Helm chart. :paramtype chart_version: str :keyword chart_values: Values override for the operator Helm chart. :paramtype chart_values: str """ - super(HelmOperatorProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.chart_version = chart_version self.chart_values = chart_values -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. @@ -186,31 +174,28 @@ 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: Any) -> None: + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + """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. @@ -225,27 +210,23 @@ class ProxyResource(Resource): """ _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(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) -class ResourceProviderOperation(msrest.serialization.Model): +class ResourceProviderOperation(_serialization.Model): """Supported operation of this resource provider. Variables are only populated by the server, and will be ignored when sending a request. @@ -260,22 +241,22 @@ class ResourceProviderOperation(msrest.serialization.Model): """ _validation = { - 'is_data_action': {'readonly': True}, + "is_data_action": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "ResourceProviderOperationDisplay"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["ResourceProviderOperationDisplay"] = None, - **kwargs - ): + display: Optional["_models.ResourceProviderOperationDisplay"] = None, + **kwargs: Any + ) -> None: """ :keyword name: Operation name, in format of {provider}/{resource}/{operation}. :paramtype name: str @@ -283,13 +264,13 @@ def __init__( :paramtype display: ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.ResourceProviderOperationDisplay """ - super(ResourceProviderOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.is_data_action = None -class ResourceProviderOperationDisplay(msrest.serialization.Model): +class ResourceProviderOperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Resource provider: Microsoft KubernetesConfiguration. @@ -303,10 +284,10 @@ class ResourceProviderOperationDisplay(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__( @@ -316,8 +297,8 @@ def __init__( resource: Optional[str] = None, operation: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword provider: Resource provider: Microsoft KubernetesConfiguration. :paramtype provider: str @@ -328,14 +309,14 @@ def __init__( :keyword description: Description of this operation. :paramtype description: str """ - super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class ResourceProviderOperationList(msrest.serialization.Model): +class ResourceProviderOperationList(_serialization.Model): """Result of the request to list operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -348,31 +329,26 @@ class ResourceProviderOperationList(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceProviderOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceProviderOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceProviderOperation"]] = None, **kwargs: Any) -> None: """ :keyword value: List of operations supported by this resource provider. :paramtype value: list[~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.ResourceProviderOperation] """ - super(ResourceProviderOperationList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class Result(msrest.serialization.Model): +class Result(_serialization.Model): """Sample result definition. :ivar sample_property: Sample property of type string. @@ -380,24 +356,19 @@ class Result(msrest.serialization.Model): """ _attribute_map = { - 'sample_property': {'key': 'sampleProperty', 'type': 'str'}, + "sample_property": {"key": "sampleProperty", "type": "str"}, } - def __init__( - self, - *, - sample_property: Optional[str] = None, - **kwargs - ): + def __init__(self, *, sample_property: Optional[str] = None, **kwargs: Any) -> None: """ :keyword sample_property: Sample property of type string. :paramtype sample_property: str """ - super(Result, self).__init__(**kwargs) + super().__init__(**kwargs) self.sample_property = sample_property -class SourceControlConfiguration(ProxyResource): +class SourceControlConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes """The SourceControl Configuration object returned in Get & Put response. Variables are only populated by the server, and will be ignored when sending a request. @@ -421,7 +392,7 @@ class SourceControlConfiguration(ProxyResource): :ivar operator_instance_name: Instance name of the operator - identifying the specific configuration. :vartype operator_instance_name: str - :ivar operator_type: Type of the operator. Possible values include: "Flux". + :ivar operator_type: Type of the operator. "Flux" :vartype operator_type: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.OperatorType :ivar operator_params: Any Parameters for the Operator instance in string format. @@ -429,8 +400,8 @@ class SourceControlConfiguration(ProxyResource): :ivar configuration_protected_settings: Name-value pairs of protected configuration settings for the configuration. :vartype configuration_protected_settings: dict[str, str] - :ivar operator_scope: Scope at which the operator will be installed. Possible values include: - "cluster", "namespace". Default value: "cluster". + :ivar operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". :vartype operator_scope: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.OperatorScopeType :ivar repository_public_key: Public Key associated with this SourceControl configuration @@ -444,8 +415,8 @@ class SourceControlConfiguration(ProxyResource): :ivar helm_operator_properties: Properties for Helm operator. :vartype helm_operator_properties: ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.HelmOperatorProperties - :ivar provisioning_state: The provisioning state of the resource provider. Possible values - include: "Accepted", "Deleting", "Running", "Succeeded", "Failed". + :ivar provisioning_state: The provisioning state of the resource provider. Known values are: + "Accepted", "Deleting", "Running", "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.ProvisioningStateType :ivar compliance_status: Compliance Status of the Configuration. @@ -454,50 +425,50 @@ class SourceControlConfiguration(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'repository_public_key': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'compliance_status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "repository_public_key": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "compliance_status": {"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'}, - 'repository_url': {'key': 'properties.repositoryUrl', 'type': 'str'}, - 'operator_namespace': {'key': 'properties.operatorNamespace', 'type': 'str'}, - 'operator_instance_name': {'key': 'properties.operatorInstanceName', 'type': 'str'}, - 'operator_type': {'key': 'properties.operatorType', 'type': 'str'}, - 'operator_params': {'key': 'properties.operatorParams', 'type': 'str'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, - 'operator_scope': {'key': 'properties.operatorScope', 'type': 'str'}, - 'repository_public_key': {'key': 'properties.repositoryPublicKey', 'type': 'str'}, - 'ssh_known_hosts_contents': {'key': 'properties.sshKnownHostsContents', 'type': 'str'}, - 'enable_helm_operator': {'key': 'properties.enableHelmOperator', 'type': 'bool'}, - 'helm_operator_properties': {'key': 'properties.helmOperatorProperties', 'type': 'HelmOperatorProperties'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'compliance_status': {'key': 'properties.complianceStatus', 'type': 'ComplianceStatus'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "repository_url": {"key": "properties.repositoryUrl", "type": "str"}, + "operator_namespace": {"key": "properties.operatorNamespace", "type": "str"}, + "operator_instance_name": {"key": "properties.operatorInstanceName", "type": "str"}, + "operator_type": {"key": "properties.operatorType", "type": "str"}, + "operator_params": {"key": "properties.operatorParams", "type": "str"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "operator_scope": {"key": "properties.operatorScope", "type": "str"}, + "repository_public_key": {"key": "properties.repositoryPublicKey", "type": "str"}, + "ssh_known_hosts_contents": {"key": "properties.sshKnownHostsContents", "type": "str"}, + "enable_helm_operator": {"key": "properties.enableHelmOperator", "type": "bool"}, + "helm_operator_properties": {"key": "properties.helmOperatorProperties", "type": "HelmOperatorProperties"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "compliance_status": {"key": "properties.complianceStatus", "type": "ComplianceStatus"}, } def __init__( self, *, repository_url: Optional[str] = None, - operator_namespace: Optional[str] = "default", + operator_namespace: str = "default", operator_instance_name: Optional[str] = None, - operator_type: Optional[Union[str, "OperatorType"]] = None, + operator_type: Optional[Union[str, "_models.OperatorType"]] = None, operator_params: Optional[str] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - operator_scope: Optional[Union[str, "OperatorScopeType"]] = "cluster", + operator_scope: Union[str, "_models.OperatorScopeType"] = "cluster", ssh_known_hosts_contents: Optional[str] = None, enable_helm_operator: Optional[bool] = None, - helm_operator_properties: Optional["HelmOperatorProperties"] = None, - **kwargs - ): + helm_operator_properties: Optional["_models.HelmOperatorProperties"] = None, + **kwargs: Any + ) -> None: """ :keyword repository_url: Url of the SourceControl Repository. :paramtype repository_url: str @@ -507,7 +478,7 @@ def __init__( :keyword operator_instance_name: Instance name of the operator - identifying the specific configuration. :paramtype operator_instance_name: str - :keyword operator_type: Type of the operator. Possible values include: "Flux". + :keyword operator_type: Type of the operator. "Flux" :paramtype operator_type: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.OperatorType :keyword operator_params: Any Parameters for the Operator instance in string format. @@ -515,8 +486,8 @@ def __init__( :keyword configuration_protected_settings: Name-value pairs of protected configuration settings for the configuration. :paramtype configuration_protected_settings: dict[str, str] - :keyword operator_scope: Scope at which the operator will be installed. Possible values - include: "cluster", "namespace". Default value: "cluster". + :keyword operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". :paramtype operator_scope: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.OperatorScopeType :keyword ssh_known_hosts_contents: Base64-encoded known_hosts contents containing public SSH @@ -528,7 +499,7 @@ def __init__( :paramtype helm_operator_properties: ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.HelmOperatorProperties """ - super(SourceControlConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.repository_url = repository_url self.operator_namespace = operator_namespace @@ -545,8 +516,9 @@ def __init__( self.compliance_status = None -class SourceControlConfigurationList(msrest.serialization.Model): - """Result of the request to list Source Control Configurations. It contains a list of SourceControlConfiguration objects and a URL link to get the next set of results. +class SourceControlConfigurationList(_serialization.Model): + """Result of the request to list Source Control Configurations. It contains a list of + SourceControlConfiguration objects and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -558,41 +530,37 @@ class SourceControlConfigurationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SourceControlConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SourceControlConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SourceControlConfigurationList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -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.kubernetesconfiguration.v2021_03_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.kubernetesconfiguration.v2021_03_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -600,44 +568,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 - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. 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.kubernetesconfiguration.v2021_03_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.kubernetesconfiguration.v2021_03_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 diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/models/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/models/_source_control_configuration_client_enums.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/models/_source_control_configuration_client_enums.py index 68b551afcbe1..1b6b4e41970b 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/models/_source_control_configuration_client_enums.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/models/_source_control_configuration_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ComplianceStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The compliance state of the configuration. - """ +class ComplianceStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The compliance state of the configuration.""" PENDING = "Pending" COMPLIANT = "Compliant" @@ -21,49 +19,53 @@ class ComplianceStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INSTALLED = "Installed" FAILED = "Failed" -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 Enum0(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class Enum0(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum0.""" MICROSOFT_CONTAINER_SERVICE = "Microsoft.ContainerService" MICROSOFT_KUBERNETES = "Microsoft.Kubernetes" -class Enum1(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class Enum1(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum1.""" MANAGED_CLUSTERS = "managedClusters" CONNECTED_CLUSTERS = "connectedClusters" -class MessageLevelType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Level of the message. - """ + +class MessageLevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the message.""" ERROR = "Error" WARNING = "Warning" INFORMATION = "Information" -class OperatorScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Scope at which the operator will be installed. - """ + +class OperatorScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scope at which the operator will be installed.""" CLUSTER = "cluster" NAMESPACE = "namespace" -class OperatorType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the operator - """ + +class OperatorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the operator.""" FLUX = "Flux" -class ProvisioningStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of the resource provider. - """ + +class ProvisioningStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource provider.""" ACCEPTED = "Accepted" DELETING = "Deleting" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/operations/__init__.py index 07db19b318c0..7a7def29a23a 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/operations/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/operations/__init__.py @@ -9,7 +9,13 @@ from ._source_control_configurations_operations import SourceControlConfigurationsOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'SourceControlConfigurationsOperations', - 'Operations', + "SourceControlConfigurationsOperations", + "Operations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/operations/_operations.py index 284e6510ab74..74c75a571fcf 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/operations/_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +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 functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 msrest import Serializer 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 = "2021-03-01" - 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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.KubernetesConfiguration/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.KubernetesConfiguration/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.kubernetesconfiguration.v2021_03_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.kubernetesconfiguration.v2021_03_01.SourceControlConfigurationClient`'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.ResourceProviderOperationList"]: + def list(self, **kwargs: Any) -> Iterable["_models.ResourceProviderOperation"]: """List all the available operations the KubernetesConfiguration resource provider supports. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of + :return: An iterator like instance of either ResourceProviderOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.ResourceProviderOperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01")) + cls: ClsType[_models.ResourceProviderOperationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - 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) @@ -114,13 +138,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ResourceProviderOperationList", 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(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]: @@ -130,8 +156,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.KubernetesConfiguration/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/operations/_source_control_configurations_operations.py index a36d0e745c0f..f9f418ec43ec 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/operations/_source_control_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_03_01/operations/_source_control_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,272 +6,294 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -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 msrest import Serializer 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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2021-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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 - ) - -class SourceControlConfigurationsOperations(object): - """SourceControlConfigurationsOperations 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.kubernetesconfiguration.v2021_03_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 SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2021_03_01.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Gets details of the Source Control Configuration. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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: Literal["2021-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01")) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -278,75 +301,187 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, - source_control_configuration: "_models.SourceControlConfiguration", + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Create a new Kubernetes Source Control Configuration. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. :type source_control_configuration: ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.SourceControlConfiguration + :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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.SourceControlConfiguration 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: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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 {}) - 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(source_control_configuration, 'SourceControlConfiguration') + api_version: Literal["2021-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -355,66 +490,82 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_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 {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self._delete_initial.metadata['url'], + 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 = self._client._pipeline.run(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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any @@ -422,18 +573,20 @@ def begin_delete( """This will delete the YAML file used to set up the Source control configuration, thus stopping future sync from the source repo. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_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. @@ -445,104 +598,128 @@ def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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["2021-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - cls=lambda x,y,z: x, + api_version=api_version, + 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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.SourceControlConfigurationList"]: + ) -> Iterable["_models.SourceControlConfiguration"]: """List all Source Control Configurations. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlConfigurationList or the result of + :return: An iterator like instance of either SourceControlConfiguration or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.SourceControlConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_03_01.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01")) + cls: ClsType[_models.SourceControlConfigurationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -553,13 +730,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlConfigurationList", 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(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]: @@ -569,8 +748,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/__init__.py index e90963036337..3ad4bd8b604e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['SourceControlConfigurationClient'] -# `._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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_configuration.py index e0d799c13103..041ec5821fa0 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_configuration.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_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,30 +15,35 @@ 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 SourceControlConfigurationClientConfiguration(Configuration): +class SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SourceControlConfigurationClient. 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-05-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(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2021-05-01-preview"] = kwargs.pop("api_version", "2021-05-01-preview") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +51,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-05-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_metadata.json b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_metadata.json index 49325700ea44..ac1bce9b6982 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_metadata.json +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_metadata.json @@ -10,34 +10,36 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SourceControlConfigurationClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SourceControlConfigurationClientConfiguration\"]}}, \"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\": [\"SourceControlConfigurationClientConfiguration\"], \".._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\": [\"SourceControlConfigurationClientConfiguration\"], \"..._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 + "required": true, + "method_location": "positional" }, "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 + "required": true, + "method_location": "positional" } }, "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,22 +50,25 @@ "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 + "required": false, + "method_location": "positional" }, "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 + "required": false, + "method_location": "positional" }, "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 + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "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 + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -106,4 +114,4 @@ "source_control_configurations": "SourceControlConfigurationsOperations", "operations": "Operations" } -} \ No newline at end of file +} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_patch.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_source_control_configuration_client.py index caa563f1320a..c24cbe1419a9 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_source_control_configuration_client.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_source_control_configuration_client.py @@ -7,21 +7,31 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer -from . import models +from . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import SourceControlConfigurationClientConfiguration -from .operations import ClusterExtensionTypeOperations, ClusterExtensionTypesOperations, ExtensionTypeVersionsOperations, ExtensionsOperations, LocationExtensionTypesOperations, OperationStatusOperations, Operations, SourceControlConfigurationsOperations +from .operations import ( + ClusterExtensionTypeOperations, + ClusterExtensionTypesOperations, + ExtensionTypeVersionsOperations, + ExtensionsOperations, + LocationExtensionTypesOperations, + OperationStatusOperations, + Operations, + SourceControlConfigurationsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SourceControlConfigurationClient: + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """KubernetesConfiguration Client. :ivar extensions: ExtensionsOperations operations @@ -48,12 +58,15 @@ class SourceControlConfigurationClient: :ivar operations: Operations operations :vartype operations: azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.operations.Operations - :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'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -65,28 +78,37 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SourceControlConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SourceControlConfigurationClientConfiguration( + 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.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_status = OperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.cluster_extension_type = ClusterExtensionTypeOperations(self._client, self._config, self._serialize, self._deserialize) - self.cluster_extension_types = ClusterExtensionTypesOperations(self._client, self._config, self._serialize, self._deserialize) - self.extension_type_versions = ExtensionTypeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.location_extension_types = LocationExtensionTypesOperations(self._client, self._config, self._serialize, self._deserialize) - self.source_control_configurations = SourceControlConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cluster_extension_type = ClusterExtensionTypeOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cluster_extension_types = ClusterExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.extension_type_versions = ExtensionTypeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.location_extension_types = LocationExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request, # type: 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 @@ -95,7 +117,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 @@ -108,15 +130,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: () -> SourceControlConfigurationClient + def __enter__(self) -> "SourceControlConfigurationClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_vendor.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_vendor.py index 138f663c53a4..bd0df84f5319 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_vendor.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_vendor.py @@ -5,8 +5,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + 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,14 +17,14 @@ def _convert_request(request, files=None): 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 - ] + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_version.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_version.py index 48944bf3938a..59deb8c7263b 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_version.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.1.0" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/__init__.py index 5f583276b4ed..b95230ae03c5 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._source_control_configuration_client import SourceControlConfigurationClient -__all__ = ['SourceControlConfigurationClient'] -# `._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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/_configuration.py index d457ecaa9748..7d85fdf92898 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/_configuration.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_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,30 +15,35 @@ 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 SourceControlConfigurationClientConfiguration(Configuration): +class SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SourceControlConfigurationClient. 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-05-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(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2021-05-01-preview"] = kwargs.pop("api_version", "2021-05-01-preview") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +51,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-05-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/_patch.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/_source_control_configuration_client.py index a2fbc1fdda50..eb75a70c49e3 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/_source_control_configuration_client.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/_source_control_configuration_client.py @@ -7,21 +7,31 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer -from .. import models +from .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import SourceControlConfigurationClientConfiguration -from .operations import ClusterExtensionTypeOperations, ClusterExtensionTypesOperations, ExtensionTypeVersionsOperations, ExtensionsOperations, LocationExtensionTypesOperations, OperationStatusOperations, Operations, SourceControlConfigurationsOperations +from .operations import ( + ClusterExtensionTypeOperations, + ClusterExtensionTypesOperations, + ExtensionTypeVersionsOperations, + ExtensionsOperations, + LocationExtensionTypesOperations, + OperationStatusOperations, + Operations, + SourceControlConfigurationsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SourceControlConfigurationClient: + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """KubernetesConfiguration Client. :ivar extensions: ExtensionsOperations operations @@ -48,12 +58,15 @@ class SourceControlConfigurationClient: :ivar operations: Operations operations :vartype operations: azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.aio.operations.Operations - :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'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -65,28 +78,37 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SourceControlConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SourceControlConfigurationClientConfiguration( + 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.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_status = OperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.cluster_extension_type = ClusterExtensionTypeOperations(self._client, self._config, self._serialize, self._deserialize) - self.cluster_extension_types = ClusterExtensionTypesOperations(self._client, self._config, self._serialize, self._deserialize) - self.extension_type_versions = ExtensionTypeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.location_extension_types = LocationExtensionTypesOperations(self._client, self._config, self._serialize, self._deserialize) - self.source_control_configurations = SourceControlConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cluster_extension_type = ClusterExtensionTypeOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cluster_extension_types = ClusterExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.extension_type_versions = ExtensionTypeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.location_extension_types = LocationExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **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 @@ -95,7 +117,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 @@ -115,5 +137,5 @@ async def __aenter__(self) -> "SourceControlConfigurationClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/__init__.py index 5f4504b206d8..dd2b466df343 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/__init__.py @@ -15,13 +15,19 @@ from ._source_control_configurations_operations import SourceControlConfigurationsOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ExtensionsOperations', - 'OperationStatusOperations', - 'ClusterExtensionTypeOperations', - 'ClusterExtensionTypesOperations', - 'ExtensionTypeVersionsOperations', - 'LocationExtensionTypesOperations', - 'SourceControlConfigurationsOperations', - 'Operations', + "ExtensionsOperations", + "OperationStatusOperations", + "ClusterExtensionTypeOperations", + "ClusterExtensionTypesOperations", + "ExtensionTypeVersionsOperations", + "LocationExtensionTypesOperations", + "SourceControlConfigurationsOperations", + "Operations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_cluster_extension_type_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_cluster_extension_type_operations.py index c77d6b319975..fb8e4e6a0c8e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_cluster_extension_type_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_cluster_extension_type_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,94 +6,122 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._cluster_extension_type_operations import build_get_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 ClusterExtensionTypeOperations: - """ClusterExtensionTypeOperations 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 ClusterExtensionTypeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_05_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.kubernetesconfiguration.v2021_05_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`cluster_extension_type` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_type: Union[str, "_models.Enum5"], + cluster_rp: Union[str, _models.Enum0], + cluster_type: Union[str, _models.Enum5], cluster_name: str, extension_type_name: str, **kwargs: Any - ) -> "_models.ExtensionType": + ) -> _models.ExtensionType: """Get Extension Type details. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_type: The Kubernetes cluster resource name - either managedClusters (for AKS - clusters) or connectedClusters (for OnPrem K8S clusters). + clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: "managedClusters" + and "connectedClusters". Required. :type cluster_type: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum5 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_type_name: Extension type name. + :param extension_type_name: Extension type name. Required. :type extension_type_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExtensionType, or the result of cls(response) + :return: ExtensionType or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ExtensionType - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionType"] 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: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.ExtensionType] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_type=cluster_type, cluster_name=cluster_name, extension_type_name=extension_type_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -100,12 +129,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExtensionType', pipeline_response) + deserialized = self._deserialize("ExtensionType", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterType}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterType}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_cluster_extension_types_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_cluster_extension_types_operations.py index b99f307b6adb..cb7253dbd15e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_cluster_extension_types_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_cluster_extension_types_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,96 +6,122 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +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.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._cluster_extension_types_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 ClusterExtensionTypesOperations: - """ClusterExtensionTypesOperations 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 ClusterExtensionTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_05_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.kubernetesconfiguration.v2021_05_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`cluster_extension_types` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ExtensionTypeList"]: + self, resource_group_name: str, cluster_rp: Union[str, _models.Enum0], cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ExtensionType"]: """Get Extension Types. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionTypeList or the result of cls(response) + :return: An iterator like instance of either ExtensionType or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ExtensionTypeList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ExtensionType] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionTypeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.ExtensionTypeList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_name=cluster_name, - 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) @@ -105,13 +132,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionTypeList", 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(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]: @@ -121,8 +150,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/connectedClusters/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/connectedClusters/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_extension_type_versions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_extension_type_versions_operations.py index 0fd76dd062aa..e57a99fb4ec9 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_extension_type_versions_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_extension_type_versions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,91 +6,117 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.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._extension_type_versions_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 ExtensionTypeVersionsOperations: - """ExtensionTypeVersionsOperations 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 ExtensionTypeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_05_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.kubernetesconfiguration.v2021_05_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`extension_type_versions` 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, - location: str, - extension_type_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ExtensionVersionList"]: + self, location: str, extension_type_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ExtensionVersionListVersionsItem"]: """List available versions for an Extension Type. - :param location: extension location. + :param location: extension location. Required. :type location: str - :param extension_type_name: Extension type name. + :param extension_type_name: Extension type name. Required. :type extension_type_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionVersionList or the result of + :return: An iterator like instance of either ExtensionVersionListVersionsItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ExtensionVersionList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ExtensionVersionListVersionsItem] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionVersionList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.ExtensionVersionList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, extension_type_name=extension_type_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - extension_type_name=extension_type_name, - 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) @@ -100,13 +127,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionVersionList", pipeline_response) list_of_elem = deserialized.versions 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(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]: @@ -116,8 +145,8 @@ 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.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_extensions_operations.py index 65591042bb26..404a5a77b91f 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_extensions_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_extensions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,132 +6,281 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +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._extensions_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._extensions_operations import ( + build_create_request, + build_delete_request, + build_get_request, + 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 ExtensionsOperations: - """ExtensionsOperations 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 ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_05_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.kubernetesconfiguration.v2021_05_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> "_models.Extension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + ) -> _models.Extension: 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 {}) - 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(extension, 'Extension') + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IO, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Extension + :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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Extension"]: + ) -> AsyncLROPoller[_models.Extension]: """Create a new Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param extension: Properties necessary to Create an Extension. - :type extension: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Extension + :param extension: Properties necessary to Create an Extension. Is either a Extension type or a + IO type. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Extension 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 @@ -143,16 +293,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Extension] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] - 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-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-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.Extension] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -161,85 +314,111 @@ async def begin_create( cluster_name=cluster_name, extension_name=extension_name, extension=extension, + 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('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, **kwargs: Any - ) -> "_models.Extension": + ) -> _models.Extension: """Gets Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Extension, or the result of cls(response) + :return: Extension or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Extension - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] 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: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -247,65 +426,83 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } - - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, force_delete: Optional[bool] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, force_delete=force_delete, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(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, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace_async async def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, force_delete: Optional[bool] = None, @@ -315,20 +512,23 @@ async def begin_delete( from the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :param force_delete: Delete the extension resource in Azure - not the normal asynchronous - delete. + delete. Default value is None. :type force_delete: bool :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. @@ -340,104 +540,136 @@ async def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, force_delete=force_delete, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ExtensionsList"]: + ) -> AsyncIterable["_models.Extension"]: """List all Extensions in the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionsList or the result of cls(response) + :return: An iterator like instance of either Extension or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ExtensionsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.ExtensionsList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -448,13 +680,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionsList", 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(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]: @@ -464,8 +698,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_location_extension_types_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_location_extension_types_operations.py index 024729f2f0f8..f7f6f5c611ee 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_location_extension_types_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_location_extension_types_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,85 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.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._location_extension_types_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 LocationExtensionTypesOperations: - """LocationExtensionTypesOperations 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 LocationExtensionTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_05_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.kubernetesconfiguration.v2021_05_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`location_extension_types` 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, - location: str, - **kwargs: Any - ) -> AsyncIterable["_models.ExtensionTypeList"]: + def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.ExtensionType"]: """List all Extension Types. - :param location: extension location. + :param location: extension location. 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 ExtensionTypeList or the result of cls(response) + :return: An iterator like instance of either ExtensionType or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ExtensionTypeList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ExtensionType] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionTypeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.ExtensionTypeList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - 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) @@ -94,13 +121,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionTypeList", 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(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]: @@ -110,8 +139,8 @@ 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.KubernetesConfiguration/locations/{location}/extensionTypes'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_operation_status_operations.py index 2d99d5e6b2f3..d263a1e0b7c2 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_operation_status_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_operation_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,135 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +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.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._operation_status_operations import build_get_request, 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 OperationStatusOperations: - """OperationStatusOperations 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 OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_05_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.kubernetesconfiguration.v2021_05_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.OperationStatusList"]: + ) -> AsyncIterable["_models.OperationStatusResult"]: """List Async Operations, currently in progress, in a cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationStatusList or the result of cls(response) + :return: An iterator like instance of either OperationStatusResult or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.OperationStatusList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.OperationStatusList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -112,13 +145,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationStatusList", 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(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]: @@ -128,66 +163,84 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations" + } @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationStatusResult": + ) -> _models.OperationStatusResult: """Get Async Operation status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param operation_id: operation Id. + :param operation_id: operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatusResult, or the result of cls(response) + :return: OperationStatusResult or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.OperationStatusResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -195,12 +248,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_operations.py index d62dc62020b1..7c7f614e6813 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,79 +6,108 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.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._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.kubernetesconfiguration.v2021_05_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.kubernetesconfiguration.v2021_05_01_preview.aio.SourceControlConfigurationClient`'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.ResourceProviderOperationList"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceProviderOperation"]: """List all the available operations the KubernetesConfiguration resource provider supports. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of + :return: An iterator like instance of either ResourceProviderOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ResourceProviderOperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.ResourceProviderOperationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - 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) @@ -88,13 +118,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ResourceProviderOperationList", 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(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]: @@ -104,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.KubernetesConfiguration/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_source_control_configurations_operations.py index d63c27542d25..f08c753bbdce 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_source_control_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/aio/operations/_source_control_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,100 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +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._source_control_configurations_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._source_control_configurations_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + 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 SourceControlConfigurationsOperations: - """SourceControlConfigurationsOperations 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 SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_05_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.kubernetesconfiguration.v2021_05_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Gets details of the Source Control Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -106,76 +141,195 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, - source_control_configuration: "_models.SourceControlConfiguration", + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Create a new Kubernetes Source Control Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. :type source_control_configuration: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.SourceControlConfiguration + :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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.SourceControlConfiguration 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: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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 {}) - 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(source_control_configuration, 'SourceControlConfiguration') + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -184,66 +338,84 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_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 {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self._delete_initial.metadata['url'], + 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 = await self._client._pipeline.run(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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace_async async def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any @@ -252,17 +424,20 @@ async def begin_delete( future sync from the source repo. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_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. @@ -274,104 +449,133 @@ async def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - cls=lambda x,y,z: x, + api_version=api_version, + 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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SourceControlConfigurationList"]: + ) -> AsyncIterable["_models.SourceControlConfiguration"]: """List all Source Control Configurations. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlConfigurationList or the result of + :return: An iterator like instance of either SourceControlConfiguration or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.SourceControlConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.SourceControlConfigurationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -382,13 +586,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlConfigurationList", 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(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]: @@ -398,8 +604,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/models/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/models/__init__.py index 2b481eea8c90..e01298b5ecbd 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/models/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/models/__init__.py @@ -35,61 +35,63 @@ from ._models_py3 import SupportedScopes from ._models_py3 import SystemData - -from ._source_control_configuration_client_enums import ( - ClusterTypes, - ComplianceStateType, - CreatedByType, - Enum0, - Enum1, - Enum5, - LevelType, - MessageLevelType, - OperatorScopeType, - OperatorType, - ProvisioningState, - ProvisioningStateType, -) +from ._source_control_configuration_client_enums import ClusterTypes +from ._source_control_configuration_client_enums import ComplianceStateType +from ._source_control_configuration_client_enums import CreatedByType +from ._source_control_configuration_client_enums import Enum0 +from ._source_control_configuration_client_enums import Enum1 +from ._source_control_configuration_client_enums import Enum5 +from ._source_control_configuration_client_enums import LevelType +from ._source_control_configuration_client_enums import MessageLevelType +from ._source_control_configuration_client_enums import OperatorScopeType +from ._source_control_configuration_client_enums import OperatorType +from ._source_control_configuration_client_enums import ProvisioningState +from ._source_control_configuration_client_enums import ProvisioningStateType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ClusterScopeSettings', - 'ComplianceStatus', - 'ErrorAdditionalInfo', - 'ErrorDetail', - 'ErrorResponse', - 'Extension', - 'ExtensionStatus', - 'ExtensionType', - 'ExtensionTypeList', - 'ExtensionVersionList', - 'ExtensionVersionListVersionsItem', - 'ExtensionsList', - 'HelmOperatorProperties', - 'Identity', - 'OperationStatusList', - 'OperationStatusResult', - 'ProxyResource', - 'Resource', - 'ResourceProviderOperation', - 'ResourceProviderOperationDisplay', - 'ResourceProviderOperationList', - 'Scope', - 'ScopeCluster', - 'ScopeNamespace', - 'SourceControlConfiguration', - 'SourceControlConfigurationList', - 'SupportedScopes', - 'SystemData', - 'ClusterTypes', - 'ComplianceStateType', - 'CreatedByType', - 'Enum0', - 'Enum1', - 'Enum5', - 'LevelType', - 'MessageLevelType', - 'OperatorScopeType', - 'OperatorType', - 'ProvisioningState', - 'ProvisioningStateType', + "ClusterScopeSettings", + "ComplianceStatus", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "Extension", + "ExtensionStatus", + "ExtensionType", + "ExtensionTypeList", + "ExtensionVersionList", + "ExtensionVersionListVersionsItem", + "ExtensionsList", + "HelmOperatorProperties", + "Identity", + "OperationStatusList", + "OperationStatusResult", + "ProxyResource", + "Resource", + "ResourceProviderOperation", + "ResourceProviderOperationDisplay", + "ResourceProviderOperationList", + "Scope", + "ScopeCluster", + "ScopeNamespace", + "SourceControlConfiguration", + "SourceControlConfigurationList", + "SupportedScopes", + "SystemData", + "ClusterTypes", + "ComplianceStateType", + "CreatedByType", + "Enum0", + "Enum1", + "Enum5", + "LevelType", + "MessageLevelType", + "OperatorScopeType", + "OperatorType", + "ProvisioningState", + "ProvisioningStateType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/models/_models_py3.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/models/_models_py3.py index 975976069789..c3862d1116b0 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/models/_models_py3.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_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,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._source_control_configuration_client_enums import * +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 .. import models as _models -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. @@ -31,31 +39,28 @@ 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: Any) -> None: + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + """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. @@ -70,24 +75,20 @@ class ProxyResource(Resource): """ _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(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) class ClusterScopeSettings(ProxyResource): @@ -110,17 +111,17 @@ class ClusterScopeSettings(ProxyResource): """ _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'}, - 'allow_multiple_instances': {'key': 'properties.allowMultipleInstances', 'type': 'bool'}, - 'default_release_namespace': {'key': 'properties.defaultReleaseNamespace', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "allow_multiple_instances": {"key": "properties.allowMultipleInstances", "type": "bool"}, + "default_release_namespace": {"key": "properties.defaultReleaseNamespace", "type": "str"}, } def __init__( @@ -128,8 +129,8 @@ def __init__( *, allow_multiple_instances: Optional[bool] = None, default_release_namespace: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword allow_multiple_instances: Describes if multiple instances of the extension are allowed. @@ -137,39 +138,39 @@ def __init__( :keyword default_release_namespace: Default extension release namespace. :paramtype default_release_namespace: str """ - super(ClusterScopeSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.allow_multiple_instances = allow_multiple_instances self.default_release_namespace = default_release_namespace -class ComplianceStatus(msrest.serialization.Model): +class ComplianceStatus(_serialization.Model): """Compliance Status details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar compliance_state: The compliance state of the configuration. Possible values include: - "Pending", "Compliant", "Noncompliant", "Installed", "Failed". + :ivar compliance_state: The compliance state of the configuration. Known values are: "Pending", + "Compliant", "Noncompliant", "Installed", and "Failed". :vartype compliance_state: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ComplianceStateType :ivar last_config_applied: Datetime the configuration was last applied. :vartype last_config_applied: ~datetime.datetime :ivar message: Message from when the configuration was applied. :vartype message: str - :ivar message_level: Level of the message. Possible values include: "Error", "Warning", + :ivar message_level: Level of the message. Known values are: "Error", "Warning", and "Information". :vartype message_level: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.MessageLevelType """ _validation = { - 'compliance_state': {'readonly': True}, + "compliance_state": {"readonly": True}, } _attribute_map = { - 'compliance_state': {'key': 'complianceState', 'type': 'str'}, - 'last_config_applied': {'key': 'lastConfigApplied', 'type': 'iso-8601'}, - 'message': {'key': 'message', 'type': 'str'}, - 'message_level': {'key': 'messageLevel', 'type': 'str'}, + "compliance_state": {"key": "complianceState", "type": "str"}, + "last_config_applied": {"key": "lastConfigApplied", "type": "iso-8601"}, + "message": {"key": "message", "type": "str"}, + "message_level": {"key": "messageLevel", "type": "str"}, } def __init__( @@ -177,27 +178,27 @@ def __init__( *, last_config_applied: Optional[datetime.datetime] = None, message: Optional[str] = None, - message_level: Optional[Union[str, "MessageLevelType"]] = None, - **kwargs - ): + message_level: Optional[Union[str, "_models.MessageLevelType"]] = None, + **kwargs: Any + ) -> None: """ :keyword last_config_applied: Datetime the configuration was last applied. :paramtype last_config_applied: ~datetime.datetime :keyword message: Message from when the configuration was applied. :paramtype message: str - :keyword message_level: Level of the message. Possible values include: "Error", "Warning", + :keyword message_level: Level of the message. Known values are: "Error", "Warning", and "Information". :paramtype message_level: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.MessageLevelType """ - super(ComplianceStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.compliance_state = None self.last_config_applied = last_config_applied self.message = message self.message_level = message_level -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -205,31 +206,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -249,28 +246,24 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -278,32 +271,28 @@ def __init__( self.additional_info = None -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ErrorDetail """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ErrorDetail """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class Extension(ProxyResource): +class Extension(ProxyResource): # pylint: disable=too-many-instance-attributes """The Extension object. Variables are only populated by the server, and will be ignored when sending a request. @@ -342,8 +331,8 @@ class Extension(ProxyResource): :ivar configuration_protected_settings: Configuration settings that are sensitive, as name-value pairs for configuring this extension. :vartype configuration_protected_settings: dict[str, str] - :ivar provisioning_state: Status of installation of this extension. Possible values include: - "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting". + :ivar provisioning_state: Status of installation of this extension. Known values are: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ProvisioningState :ivar statuses: Status from this extension. @@ -358,50 +347,50 @@ class Extension(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'error_info': {'readonly': True}, - 'custom_location_settings': {'readonly': True}, - 'package_uri': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "error_info": {"readonly": True}, + "custom_location_settings": {"readonly": True}, + "package_uri": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, - 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, - 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'Scope'}, - 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'statuses': {'key': 'properties.statuses', 'type': '[ExtensionStatus]'}, - 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDetail'}, - 'custom_location_settings': {'key': 'properties.customLocationSettings', 'type': '{str}'}, - 'package_uri': {'key': 'properties.packageUri', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "extension_type": {"key": "properties.extensionType", "type": "str"}, + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "scope": {"key": "properties.scope", "type": "Scope"}, + "configuration_settings": {"key": "properties.configurationSettings", "type": "{str}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "statuses": {"key": "properties.statuses", "type": "[ExtensionStatus]"}, + "error_info": {"key": "properties.errorInfo", "type": "ErrorDetail"}, + "custom_location_settings": {"key": "properties.customLocationSettings", "type": "{str}"}, + "package_uri": {"key": "properties.packageUri", "type": "str"}, } def __init__( self, *, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, extension_type: Optional[str] = None, - auto_upgrade_minor_version: Optional[bool] = True, - release_train: Optional[str] = "Stable", + auto_upgrade_minor_version: bool = True, + release_train: str = "Stable", version: Optional[str] = None, - scope: Optional["Scope"] = None, + scope: Optional["_models.Scope"] = None, configuration_settings: Optional[Dict[str, str]] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - statuses: Optional[List["ExtensionStatus"]] = None, - **kwargs - ): + statuses: Optional[List["_models.ExtensionStatus"]] = None, + **kwargs: Any + ) -> None: """ :keyword identity: Identity of the Extension resource. :paramtype identity: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Identity @@ -430,7 +419,7 @@ def __init__( :paramtype statuses: list[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ExtensionStatus] """ - super(Extension, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.system_data = None self.extension_type = extension_type @@ -447,8 +436,9 @@ def __init__( self.package_uri = None -class ExtensionsList(msrest.serialization.Model): - """Result of the request to list Extensions. It contains a list of Extension objects and a URL link to get the next set of results. +class ExtensionsList(_serialization.Model): + """Result of the request to list Extensions. It contains a list of Extension objects and a URL + link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -459,35 +449,30 @@ class ExtensionsList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Extension]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Extension]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ExtensionsList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ExtensionStatus(msrest.serialization.Model): +class ExtensionStatus(_serialization.Model): """Status from the extension. :ivar code: Status code provided by the Extension. :vartype code: str :ivar display_status: Short description of status of the extension. :vartype display_status: str - :ivar level: Level of the status. Possible values include: "Error", "Warning", "Information". - Default value: "Information". + :ivar level: Level of the status. Known values are: "Error", "Warning", and "Information". :vartype level: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.LevelType :ivar message: Detailed message of the status from the Extension. :vartype message: str @@ -496,11 +481,11 @@ class ExtensionStatus(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'level': {'key': 'level', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'time': {'key': 'time', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "display_status": {"key": "displayStatus", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "time": {"key": "time", "type": "str"}, } def __init__( @@ -508,18 +493,17 @@ def __init__( *, code: Optional[str] = None, display_status: Optional[str] = None, - level: Optional[Union[str, "LevelType"]] = "Information", + level: Union[str, "_models.LevelType"] = "Information", message: Optional[str] = None, time: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword code: Status code provided by the Extension. :paramtype code: str :keyword display_status: Short description of status of the extension. :paramtype display_status: str - :keyword level: Level of the status. Possible values include: "Error", "Warning", - "Information". Default value: "Information". + :keyword level: Level of the status. Known values are: "Error", "Warning", and "Information". :paramtype level: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.LevelType :keyword message: Detailed message of the status from the Extension. @@ -527,7 +511,7 @@ def __init__( :keyword time: DateLiteral (per ISO8601) noting the time of installation status. :paramtype time: str """ - super(ExtensionStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.display_status = display_status self.level = level @@ -535,7 +519,7 @@ def __init__( self.time = time -class ExtensionType(msrest.serialization.Model): +class ExtensionType(_serialization.Model): """Represents an Extension Type. Variables are only populated by the server, and will be ignored when sending a request. @@ -544,7 +528,7 @@ class ExtensionType(msrest.serialization.Model): :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.SystemData :ivar release_trains: Extension release train: preview or stable. :vartype release_trains: list[str] - :ivar cluster_types: Cluster types. Possible values include: "connectedClusters", + :ivar cluster_types: Cluster types. Known values are: "connectedClusters" and "managedClusters". :vartype cluster_types: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ClusterTypes @@ -554,33 +538,29 @@ class ExtensionType(msrest.serialization.Model): """ _validation = { - 'system_data': {'readonly': True}, - 'release_trains': {'readonly': True}, - 'cluster_types': {'readonly': True}, - 'supported_scopes': {'readonly': True}, + "system_data": {"readonly": True}, + "release_trains": {"readonly": True}, + "cluster_types": {"readonly": True}, + "supported_scopes": {"readonly": True}, } _attribute_map = { - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'release_trains': {'key': 'properties.releaseTrains', 'type': '[str]'}, - 'cluster_types': {'key': 'properties.clusterTypes', 'type': 'str'}, - 'supported_scopes': {'key': 'properties.supportedScopes', 'type': 'SupportedScopes'}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "release_trains": {"key": "properties.releaseTrains", "type": "[str]"}, + "cluster_types": {"key": "properties.clusterTypes", "type": "str"}, + "supported_scopes": {"key": "properties.supportedScopes", "type": "SupportedScopes"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ExtensionType, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.system_data = None self.release_trains = None self.cluster_types = None self.supported_scopes = None -class ExtensionTypeList(msrest.serialization.Model): +class ExtensionTypeList(_serialization.Model): """List Extension Types. :ivar value: The list of Extension Types. @@ -591,17 +571,13 @@ class ExtensionTypeList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ExtensionType]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ExtensionType]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ExtensionType"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + self, *, value: Optional[List["_models.ExtensionType"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: The list of Extension Types. :paramtype value: @@ -609,12 +585,12 @@ def __init__( :keyword next_link: The link to fetch the next page of Extension Types. :paramtype next_link: str """ - super(ExtensionTypeList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ExtensionVersionList(msrest.serialization.Model): +class ExtensionVersionList(_serialization.Model): """List versions for an Extension. Variables are only populated by the server, and will be ignored when sending a request. @@ -629,22 +605,22 @@ class ExtensionVersionList(msrest.serialization.Model): """ _validation = { - 'system_data': {'readonly': True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'versions': {'key': 'versions', 'type': '[ExtensionVersionListVersionsItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "versions": {"key": "versions", "type": "[ExtensionVersionListVersionsItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } def __init__( self, *, - versions: Optional[List["ExtensionVersionListVersionsItem"]] = None, + versions: Optional[List["_models.ExtensionVersionListVersionsItem"]] = None, next_link: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword versions: Versions available for this Extension Type. :paramtype versions: @@ -652,13 +628,13 @@ def __init__( :keyword next_link: The link to fetch the next page of Extension Types. :paramtype next_link: str """ - super(ExtensionVersionList, self).__init__(**kwargs) + super().__init__(**kwargs) self.versions = versions self.next_link = next_link self.system_data = None -class ExtensionVersionListVersionsItem(msrest.serialization.Model): +class ExtensionVersionListVersionsItem(_serialization.Model): """ExtensionVersionListVersionsItem. :ivar release_train: The release train for this Extension Type. @@ -668,29 +644,25 @@ class ExtensionVersionListVersionsItem(msrest.serialization.Model): """ _attribute_map = { - 'release_train': {'key': 'releaseTrain', 'type': 'str'}, - 'versions': {'key': 'versions', 'type': '[str]'}, + "release_train": {"key": "releaseTrain", "type": "str"}, + "versions": {"key": "versions", "type": "[str]"}, } def __init__( - self, - *, - release_train: Optional[str] = None, - versions: Optional[List[str]] = None, - **kwargs - ): + self, *, release_train: Optional[str] = None, versions: Optional[List[str]] = None, **kwargs: Any + ) -> None: """ :keyword release_train: The release train for this Extension Type. :paramtype release_train: str :keyword versions: Versions available for this Extension Type and release train. :paramtype versions: list[str] """ - super(ExtensionVersionListVersionsItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.release_train = release_train self.versions = versions -class HelmOperatorProperties(msrest.serialization.Model): +class HelmOperatorProperties(_serialization.Model): """Properties for Helm operator. :ivar chart_version: Version of the operator Helm chart. @@ -700,29 +672,25 @@ class HelmOperatorProperties(msrest.serialization.Model): """ _attribute_map = { - 'chart_version': {'key': 'chartVersion', 'type': 'str'}, - 'chart_values': {'key': 'chartValues', 'type': 'str'}, + "chart_version": {"key": "chartVersion", "type": "str"}, + "chart_values": {"key": "chartValues", "type": "str"}, } def __init__( - self, - *, - chart_version: Optional[str] = None, - chart_values: Optional[str] = None, - **kwargs - ): + self, *, chart_version: Optional[str] = None, chart_values: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword chart_version: Version of the operator Helm chart. :paramtype chart_version: str :keyword chart_values: Values override for the operator Helm chart. :paramtype chart_values: str """ - super(HelmOperatorProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.chart_version = chart_version self.chart_values = chart_values -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -731,40 +699,33 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :ivar type: The identity type. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: """ - :keyword type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :keyword type: The identity type. Default value is "SystemAssigned". :paramtype type: str """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class OperationStatusList(msrest.serialization.Model): +class OperationStatusList(_serialization.Model): """The async operations in progress, in the cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -777,27 +738,23 @@ class OperationStatusList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationStatusResult]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OperationStatusResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationStatusList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class OperationStatusResult(msrest.serialization.Model): +class OperationStatusResult(_serialization.Model): """The current status of an async operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -808,7 +765,7 @@ class OperationStatusResult(msrest.serialization.Model): :vartype id: str :ivar name: Name of the async operation. :vartype name: str - :ivar status: Required. Operation status. + :ivar status: Operation status. Required. :vartype status: str :ivar properties: Additional information, if available. :vartype properties: dict[str, str] @@ -817,38 +774,38 @@ class OperationStatusResult(msrest.serialization.Model): """ _validation = { - 'status': {'required': True}, - 'error': {'readonly': True}, + "status": {"required": True}, + "error": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, + "error": {"key": "error", "type": "ErrorDetail"}, } def __init__( self, *, status: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, properties: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: Fully qualified ID for the async operation. :paramtype id: str :keyword name: Name of the async operation. :paramtype name: str - :keyword status: Required. Operation status. + :keyword status: Operation status. Required. :paramtype status: str :keyword properties: Additional information, if available. :paramtype properties: dict[str, str] """ - super(OperationStatusResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.status = status @@ -856,7 +813,7 @@ def __init__( self.error = None -class ResourceProviderOperation(msrest.serialization.Model): +class ResourceProviderOperation(_serialization.Model): """Supported operation of this resource provider. Variables are only populated by the server, and will be ignored when sending a request. @@ -874,24 +831,24 @@ class ResourceProviderOperation(msrest.serialization.Model): """ _validation = { - 'is_data_action': {'readonly': True}, + "is_data_action": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "ResourceProviderOperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["ResourceProviderOperationDisplay"] = None, + display: Optional["_models.ResourceProviderOperationDisplay"] = None, origin: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Operation name, in format of {provider}/{resource}/{operation}. :paramtype name: str @@ -902,14 +859,14 @@ def __init__( the RBAC UX and the audit logs UX. :paramtype origin: str """ - super(ResourceProviderOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.is_data_action = None -class ResourceProviderOperationDisplay(msrest.serialization.Model): +class ResourceProviderOperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Resource provider: Microsoft KubernetesConfiguration. @@ -923,10 +880,10 @@ class ResourceProviderOperationDisplay(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__( @@ -936,8 +893,8 @@ def __init__( resource: Optional[str] = None, operation: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword provider: Resource provider: Microsoft KubernetesConfiguration. :paramtype provider: str @@ -948,14 +905,14 @@ def __init__( :keyword description: Description of this operation. :paramtype description: str """ - super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class ResourceProviderOperationList(msrest.serialization.Model): +class ResourceProviderOperationList(_serialization.Model): """Result of the request to list operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -968,31 +925,26 @@ class ResourceProviderOperationList(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceProviderOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceProviderOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceProviderOperation"]] = None, **kwargs: Any) -> None: """ :keyword value: List of operations supported by this resource provider. :paramtype value: list[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ResourceProviderOperation] """ - super(ResourceProviderOperationList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class Scope(msrest.serialization.Model): +class Scope(_serialization.Model): """Scope of the extension. It can be either Cluster or Namespace; but not both. :ivar cluster: Specifies that the scope of the extension is Cluster. @@ -1003,17 +955,17 @@ class Scope(msrest.serialization.Model): """ _attribute_map = { - 'cluster': {'key': 'cluster', 'type': 'ScopeCluster'}, - 'namespace': {'key': 'namespace', 'type': 'ScopeNamespace'}, + "cluster": {"key": "cluster", "type": "ScopeCluster"}, + "namespace": {"key": "namespace", "type": "ScopeNamespace"}, } def __init__( self, *, - cluster: Optional["ScopeCluster"] = None, - namespace: Optional["ScopeNamespace"] = None, - **kwargs - ): + cluster: Optional["_models.ScopeCluster"] = None, + namespace: Optional["_models.ScopeNamespace"] = None, + **kwargs: Any + ) -> None: """ :keyword cluster: Specifies that the scope of the extension is Cluster. :paramtype cluster: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ScopeCluster @@ -1021,12 +973,12 @@ def __init__( :paramtype namespace: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ScopeNamespace """ - super(Scope, self).__init__(**kwargs) + super().__init__(**kwargs) self.cluster = cluster self.namespace = namespace -class ScopeCluster(msrest.serialization.Model): +class ScopeCluster(_serialization.Model): """Specifies that the scope of the extension is Cluster. :ivar release_namespace: Namespace where the extension Release must be placed, for a Cluster @@ -1035,25 +987,20 @@ class ScopeCluster(msrest.serialization.Model): """ _attribute_map = { - 'release_namespace': {'key': 'releaseNamespace', 'type': 'str'}, + "release_namespace": {"key": "releaseNamespace", "type": "str"}, } - def __init__( - self, - *, - release_namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, release_namespace: Optional[str] = None, **kwargs: Any) -> None: """ :keyword release_namespace: Namespace where the extension Release must be placed, for a Cluster scoped extension. If this namespace does not exist, it will be created. :paramtype release_namespace: str """ - super(ScopeCluster, self).__init__(**kwargs) + super().__init__(**kwargs) self.release_namespace = release_namespace -class ScopeNamespace(msrest.serialization.Model): +class ScopeNamespace(_serialization.Model): """Specifies that the scope of the extension is Namespace. :ivar target_namespace: Namespace where the extension will be created for an Namespace scoped @@ -1062,25 +1009,20 @@ class ScopeNamespace(msrest.serialization.Model): """ _attribute_map = { - 'target_namespace': {'key': 'targetNamespace', 'type': 'str'}, + "target_namespace": {"key": "targetNamespace", "type": "str"}, } - def __init__( - self, - *, - target_namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_namespace: Optional[str] = None, **kwargs: Any) -> None: """ :keyword target_namespace: Namespace where the extension will be created for an Namespace scoped extension. If this namespace does not exist, it will be created. :paramtype target_namespace: str """ - super(ScopeNamespace, self).__init__(**kwargs) + super().__init__(**kwargs) self.target_namespace = target_namespace -class SourceControlConfiguration(ProxyResource): +class SourceControlConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes """The SourceControl Configuration object returned in Get & Put response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1104,7 +1046,7 @@ class SourceControlConfiguration(ProxyResource): :ivar operator_instance_name: Instance name of the operator - identifying the specific configuration. :vartype operator_instance_name: str - :ivar operator_type: Type of the operator. Possible values include: "Flux". + :ivar operator_type: Type of the operator. "Flux" :vartype operator_type: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.OperatorType :ivar operator_params: Any Parameters for the Operator instance in string format. @@ -1112,8 +1054,8 @@ class SourceControlConfiguration(ProxyResource): :ivar configuration_protected_settings: Name-value pairs of protected configuration settings for the configuration. :vartype configuration_protected_settings: dict[str, str] - :ivar operator_scope: Scope at which the operator will be installed. Possible values include: - "cluster", "namespace". Default value: "cluster". + :ivar operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". :vartype operator_scope: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.OperatorScopeType :ivar repository_public_key: Public Key associated with this SourceControl configuration @@ -1127,8 +1069,8 @@ class SourceControlConfiguration(ProxyResource): :ivar helm_operator_properties: Properties for Helm operator. :vartype helm_operator_properties: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.HelmOperatorProperties - :ivar provisioning_state: The provisioning state of the resource provider. Possible values - include: "Accepted", "Deleting", "Running", "Succeeded", "Failed". + :ivar provisioning_state: The provisioning state of the resource provider. Known values are: + "Accepted", "Deleting", "Running", "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ProvisioningStateType :ivar compliance_status: Compliance Status of the Configuration. @@ -1137,50 +1079,50 @@ class SourceControlConfiguration(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'repository_public_key': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'compliance_status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "repository_public_key": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "compliance_status": {"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'}, - 'repository_url': {'key': 'properties.repositoryUrl', 'type': 'str'}, - 'operator_namespace': {'key': 'properties.operatorNamespace', 'type': 'str'}, - 'operator_instance_name': {'key': 'properties.operatorInstanceName', 'type': 'str'}, - 'operator_type': {'key': 'properties.operatorType', 'type': 'str'}, - 'operator_params': {'key': 'properties.operatorParams', 'type': 'str'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, - 'operator_scope': {'key': 'properties.operatorScope', 'type': 'str'}, - 'repository_public_key': {'key': 'properties.repositoryPublicKey', 'type': 'str'}, - 'ssh_known_hosts_contents': {'key': 'properties.sshKnownHostsContents', 'type': 'str'}, - 'enable_helm_operator': {'key': 'properties.enableHelmOperator', 'type': 'bool'}, - 'helm_operator_properties': {'key': 'properties.helmOperatorProperties', 'type': 'HelmOperatorProperties'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'compliance_status': {'key': 'properties.complianceStatus', 'type': 'ComplianceStatus'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "repository_url": {"key": "properties.repositoryUrl", "type": "str"}, + "operator_namespace": {"key": "properties.operatorNamespace", "type": "str"}, + "operator_instance_name": {"key": "properties.operatorInstanceName", "type": "str"}, + "operator_type": {"key": "properties.operatorType", "type": "str"}, + "operator_params": {"key": "properties.operatorParams", "type": "str"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "operator_scope": {"key": "properties.operatorScope", "type": "str"}, + "repository_public_key": {"key": "properties.repositoryPublicKey", "type": "str"}, + "ssh_known_hosts_contents": {"key": "properties.sshKnownHostsContents", "type": "str"}, + "enable_helm_operator": {"key": "properties.enableHelmOperator", "type": "bool"}, + "helm_operator_properties": {"key": "properties.helmOperatorProperties", "type": "HelmOperatorProperties"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "compliance_status": {"key": "properties.complianceStatus", "type": "ComplianceStatus"}, } def __init__( self, *, repository_url: Optional[str] = None, - operator_namespace: Optional[str] = "default", + operator_namespace: str = "default", operator_instance_name: Optional[str] = None, - operator_type: Optional[Union[str, "OperatorType"]] = None, + operator_type: Optional[Union[str, "_models.OperatorType"]] = None, operator_params: Optional[str] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - operator_scope: Optional[Union[str, "OperatorScopeType"]] = "cluster", + operator_scope: Union[str, "_models.OperatorScopeType"] = "cluster", ssh_known_hosts_contents: Optional[str] = None, enable_helm_operator: Optional[bool] = None, - helm_operator_properties: Optional["HelmOperatorProperties"] = None, - **kwargs - ): + helm_operator_properties: Optional["_models.HelmOperatorProperties"] = None, + **kwargs: Any + ) -> None: """ :keyword repository_url: Url of the SourceControl Repository. :paramtype repository_url: str @@ -1190,7 +1132,7 @@ def __init__( :keyword operator_instance_name: Instance name of the operator - identifying the specific configuration. :paramtype operator_instance_name: str - :keyword operator_type: Type of the operator. Possible values include: "Flux". + :keyword operator_type: Type of the operator. "Flux" :paramtype operator_type: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.OperatorType :keyword operator_params: Any Parameters for the Operator instance in string format. @@ -1198,8 +1140,8 @@ def __init__( :keyword configuration_protected_settings: Name-value pairs of protected configuration settings for the configuration. :paramtype configuration_protected_settings: dict[str, str] - :keyword operator_scope: Scope at which the operator will be installed. Possible values - include: "cluster", "namespace". Default value: "cluster". + :keyword operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". :paramtype operator_scope: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.OperatorScopeType :keyword ssh_known_hosts_contents: Base64-encoded known_hosts contents containing public SSH @@ -1211,7 +1153,7 @@ def __init__( :paramtype helm_operator_properties: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.HelmOperatorProperties """ - super(SourceControlConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.repository_url = repository_url self.operator_namespace = operator_namespace @@ -1228,8 +1170,9 @@ def __init__( self.compliance_status = None -class SourceControlConfigurationList(msrest.serialization.Model): - """Result of the request to list Source Control Configurations. It contains a list of SourceControlConfiguration objects and a URL link to get the next set of results. +class SourceControlConfigurationList(_serialization.Model): + """Result of the request to list Source Control Configurations. It contains a list of + SourceControlConfiguration objects and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -1241,27 +1184,23 @@ class SourceControlConfigurationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SourceControlConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SourceControlConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SourceControlConfigurationList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SupportedScopes(msrest.serialization.Model): +class SupportedScopes(_serialization.Model): """Extension scopes. :ivar default_scope: Default extension scopes: cluster or namespace. @@ -1272,17 +1211,17 @@ class SupportedScopes(msrest.serialization.Model): """ _attribute_map = { - 'default_scope': {'key': 'defaultScope', 'type': 'str'}, - 'cluster_scope_settings': {'key': 'clusterScopeSettings', 'type': 'ClusterScopeSettings'}, + "default_scope": {"key": "defaultScope", "type": "str"}, + "cluster_scope_settings": {"key": "clusterScopeSettings", "type": "ClusterScopeSettings"}, } def __init__( self, *, default_scope: Optional[str] = None, - cluster_scope_settings: Optional["ClusterScopeSettings"] = None, - **kwargs - ): + cluster_scope_settings: Optional["_models.ClusterScopeSettings"] = None, + **kwargs: Any + ) -> None: """ :keyword default_scope: Default extension scopes: cluster or namespace. :paramtype default_scope: str @@ -1290,26 +1229,26 @@ def __init__( :paramtype cluster_scope_settings: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ClusterScopeSettings """ - super(SupportedScopes, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_scope = default_scope self.cluster_scope_settings = cluster_scope_settings -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.kubernetesconfiguration.v2021_05_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.kubernetesconfiguration.v2021_05_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -1317,44 +1256,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 - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. 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.kubernetesconfiguration.v2021_05_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.kubernetesconfiguration.v2021_05_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 diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/models/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/models/_source_control_configuration_client_enums.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/models/_source_control_configuration_client_enums.py index bd58c28c2790..43459c30c52c 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/models/_source_control_configuration_client_enums.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/models/_source_control_configuration_client_enums.py @@ -7,20 +7,18 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ClusterTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Cluster types - """ +class ClusterTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Cluster types.""" CONNECTED_CLUSTERS = "connectedClusters" MANAGED_CLUSTERS = "managedClusters" -class ComplianceStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The compliance state of the configuration. - """ + +class ComplianceStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The compliance state of the configuration.""" PENDING = "Pending" COMPLIANT = "Compliant" @@ -28,62 +26,68 @@ class ComplianceStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INSTALLED = "Installed" FAILED = "Failed" -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 Enum0(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class Enum0(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum0.""" MICROSOFT_CONTAINER_SERVICE = "Microsoft.ContainerService" MICROSOFT_KUBERNETES = "Microsoft.Kubernetes" -class Enum1(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class Enum1(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum1.""" MANAGED_CLUSTERS = "managedClusters" CONNECTED_CLUSTERS = "connectedClusters" -class Enum5(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class Enum5(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum5.""" MANAGED_CLUSTERS = "managedClusters" CONNECTED_CLUSTERS = "connectedClusters" -class LevelType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Level of the status. - """ + +class LevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the status.""" ERROR = "Error" WARNING = "Warning" INFORMATION = "Information" -class MessageLevelType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Level of the message. - """ + +class MessageLevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the message.""" ERROR = "Error" WARNING = "Warning" INFORMATION = "Information" -class OperatorScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Scope at which the operator will be installed. - """ + +class OperatorScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scope at which the operator will be installed.""" CLUSTER = "cluster" NAMESPACE = "namespace" -class OperatorType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the operator - """ + +class OperatorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the operator.""" FLUX = "Flux" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of the extension resource. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the extension resource.""" SUCCEEDED = "Succeeded" FAILED = "Failed" @@ -92,9 +96,9 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" DELETING = "Deleting" -class ProvisioningStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of the resource provider. - """ + +class ProvisioningStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource provider.""" ACCEPTED = "Accepted" DELETING = "Deleting" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/__init__.py index 5f4504b206d8..dd2b466df343 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/__init__.py @@ -15,13 +15,19 @@ from ._source_control_configurations_operations import SourceControlConfigurationsOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ExtensionsOperations', - 'OperationStatusOperations', - 'ClusterExtensionTypeOperations', - 'ClusterExtensionTypesOperations', - 'ExtensionTypeVersionsOperations', - 'LocationExtensionTypesOperations', - 'SourceControlConfigurationsOperations', - 'Operations', + "ExtensionsOperations", + "OperationStatusOperations", + "ClusterExtensionTypeOperations", + "ClusterExtensionTypesOperations", + "ExtensionTypeVersionsOperations", + "LocationExtensionTypesOperations", + "SourceControlConfigurationsOperations", + "Operations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_cluster_extension_type_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_cluster_extension_type_operations.py index a9e523f7ed1e..e6ada0e1047b 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_cluster_extension_type_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_cluster_extension_type_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,137 +6,169 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_type: Union[str, "_models.Enum5"], + cluster_rp: Union[str, _models.Enum0], + cluster_type: Union[str, _models.Enum5], cluster_name: str, extension_type_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterType}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterType}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterType": _SERIALIZER.url("cluster_type", cluster_type, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionTypeName": _SERIALIZER.url("extension_type_name", extension_type_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterType": _SERIALIZER.url("cluster_type", cluster_type, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionTypeName": _SERIALIZER.url("extension_type_name", extension_type_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) -class ClusterExtensionTypeOperations(object): - """ClusterExtensionTypeOperations 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 ClusterExtensionTypeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_05_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.kubernetesconfiguration.v2021_05_01_preview.SourceControlConfigurationClient`'s + :attr:`cluster_extension_type` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_type: Union[str, "_models.Enum5"], + cluster_rp: Union[str, _models.Enum0], + cluster_type: Union[str, _models.Enum5], cluster_name: str, extension_type_name: str, **kwargs: Any - ) -> "_models.ExtensionType": + ) -> _models.ExtensionType: """Get Extension Type details. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_type: The Kubernetes cluster resource name - either managedClusters (for AKS - clusters) or connectedClusters (for OnPrem K8S clusters). + clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: "managedClusters" + and "connectedClusters". Required. :type cluster_type: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum5 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_type_name: Extension type name. + :param extension_type_name: Extension type name. Required. :type extension_type_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExtensionType, or the result of cls(response) + :return: ExtensionType or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ExtensionType - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionType"] 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: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.ExtensionType] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_type=cluster_type, cluster_name=cluster_name, extension_type_name=extension_type_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -143,12 +176,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExtensionType', pipeline_response) + deserialized = self._deserialize("ExtensionType", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterType}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterType}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_cluster_extension_types_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_cluster_extension_types_operations.py index 210d4945423c..f25c47c40f61 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_cluster_extension_types_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_cluster_extension_types_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,134 +6,165 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +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 msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], + cluster_rp: Union[str, _models.Enum0], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/connectedClusters/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/connectedClusters/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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) -class ClusterExtensionTypesOperations(object): - """ClusterExtensionTypesOperations 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 ClusterExtensionTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_05_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.kubernetesconfiguration.v2021_05_01_preview.SourceControlConfigurationClient`'s + :attr:`cluster_extension_types` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_name: str, - **kwargs: Any - ) -> Iterable["_models.ExtensionTypeList"]: + self, resource_group_name: str, cluster_rp: Union[str, _models.Enum0], cluster_name: str, **kwargs: Any + ) -> Iterable["_models.ExtensionType"]: """Get Extension Types. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionTypeList or the result of cls(response) + :return: An iterator like instance of either ExtensionType or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ExtensionTypeList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ExtensionType] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionTypeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.ExtensionTypeList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_name=cluster_name, - 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) @@ -143,13 +175,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionTypeList", 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(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]: @@ -159,8 +193,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/connectedClusters/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/connectedClusters/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_extension_type_versions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_extension_type_versions_operations.py index c978497cf589..21c12c3eabfd 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_extension_type_versions_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_extension_type_versions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,127 +6,151 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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( - subscription_id: str, - location: str, - extension_type_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + +def build_list_request(location: str, extension_type_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-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions", + ) # 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'), - "extensionTypeName": _SERIALIZER.url("extension_type_name", extension_type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), + "extensionTypeName": _SERIALIZER.url("extension_type_name", extension_type_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) -class ExtensionTypeVersionsOperations(object): - """ExtensionTypeVersionsOperations 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 ExtensionTypeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_05_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.kubernetesconfiguration.v2021_05_01_preview.SourceControlConfigurationClient`'s + :attr:`extension_type_versions` 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, - location: str, - extension_type_name: str, - **kwargs: Any - ) -> Iterable["_models.ExtensionVersionList"]: + self, location: str, extension_type_name: str, **kwargs: Any + ) -> Iterable["_models.ExtensionVersionListVersionsItem"]: """List available versions for an Extension Type. - :param location: extension location. + :param location: extension location. Required. :type location: str - :param extension_type_name: Extension type name. + :param extension_type_name: Extension type name. Required. :type extension_type_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionVersionList or the result of + :return: An iterator like instance of either ExtensionVersionListVersionsItem or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ExtensionVersionList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ExtensionVersionListVersionsItem] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionVersionList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.ExtensionVersionList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, extension_type_name=extension_type_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - extension_type_name=extension_type_name, - 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) @@ -136,13 +161,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionVersionList", pipeline_response) list_of_elem = deserialized.versions 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(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]: @@ -152,8 +179,8 @@ 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.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_extensions_operations.py index 36fca482e884..9e3e7cf279fa 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_extensions_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_extensions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,309 +6,457 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -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 msrest import Serializer 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_create_request_initial( - subscription_id: str, + +def build_create_request( resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2021-05-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_delete_request_initial( - subscription_id: str, + +def build_delete_request( resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, + subscription_id: str, *, force_delete: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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") if force_delete is not None: - query_parameters['forceDelete'] = _SERIALIZER.query("force_delete", force_delete, 'bool') + _params["forceDelete"] = _SERIALIZER.query("force_delete", force_delete, "bool") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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") -class ExtensionsOperations(object): - """ExtensionsOperations 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.kubernetesconfiguration.v2021_05_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 ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _create_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> "_models.Extension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + ) -> _models.Extension: 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 {}) - 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(extension, 'Extension') + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IO, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Extension + :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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> LROPoller["_models.Extension"]: + ) -> LROPoller[_models.Extension]: """Create a new Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param extension: Properties necessary to Create an Extension. - :type extension: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Extension + :param extension: Properties necessary to Create an Extension. Is either a Extension type or a + IO type. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Extension 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 @@ -319,16 +468,19 @@ def begin_create( :return: An instance of LROPoller that returns either Extension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Extension] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] - 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-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-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.Extension] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -337,85 +489,110 @@ def begin_create( cluster_name=cluster_name, extension_name=extension_name, extension=extension, + 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('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, **kwargs: Any - ) -> "_models.Extension": + ) -> _models.Extension: """Gets Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Extension, or the result of cls(response) + :return: Extension or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Extension - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] 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: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -423,65 +600,83 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, force_delete: Optional[bool] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, force_delete=force_delete, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(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, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, force_delete: Optional[bool] = None, @@ -491,20 +686,23 @@ def begin_delete( from the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :param force_delete: Delete the extension resource in Azure - not the normal asynchronous - delete. + delete. Default value is None. :type force_delete: bool :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. @@ -516,104 +714,135 @@ def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, force_delete=force_delete, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.ExtensionsList"]: + ) -> Iterable["_models.Extension"]: """List all Extensions in the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionsList or the result of cls(response) + :return: An iterator like instance of either Extension or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ExtensionsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.ExtensionsList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -624,13 +853,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionsList", 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(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]: @@ -640,8 +871,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_location_extension_types_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_location_extension_types_operations.py index 5a8c204da5e8..f967d893a296 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_location_extension_types_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_location_extension_types_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,119 +6,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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( - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + +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["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes", + ) # 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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "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) -class LocationExtensionTypesOperations(object): - """LocationExtensionTypesOperations 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 LocationExtensionTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_05_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.kubernetesconfiguration.v2021_05_01_preview.SourceControlConfigurationClient`'s + :attr:`location_extension_types` 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, - location: str, - **kwargs: Any - ) -> Iterable["_models.ExtensionTypeList"]: + def list(self, location: str, **kwargs: Any) -> Iterable["_models.ExtensionType"]: """List all Extension Types. - :param location: extension location. + :param location: extension location. 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 ExtensionTypeList or the result of cls(response) + :return: An iterator like instance of either ExtensionType or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ExtensionTypeList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ExtensionType] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionTypeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.ExtensionTypeList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - 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) @@ -128,13 +154,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionTypeList", 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(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]: @@ -144,8 +172,8 @@ 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.KubernetesConfiguration/locations/{location}/extensionTypes'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_operation_status_operations.py index c1cdf65ac6d7..8a3e20cc45ae 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_operation_status_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_operation_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,186 +6,225 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +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 msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, operation_id: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_name, 'str'), - "operationId": _SERIALIZER.url("operation_id", operation_id, '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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "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") -class OperationStatusOperations(object): - """OperationStatusOperations 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.kubernetesconfiguration.v2021_05_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 OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.SourceControlConfigurationClient`'s + :attr:`operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.OperationStatusList"]: + ) -> Iterable["_models.OperationStatusResult"]: """List Async Operations, currently in progress, in a cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationStatusList or the result of cls(response) + :return: An iterator like instance of either OperationStatusResult or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.OperationStatusList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.OperationStatusList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -195,13 +235,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationStatusList", 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(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]: @@ -211,66 +253,84 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations" + } @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationStatusResult": + ) -> _models.OperationStatusResult: """Get Async Operation status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param operation_id: operation Id. + :param operation_id: operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatusResult, or the result of cls(response) + :return: OperationStatusResult or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.OperationStatusResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -278,12 +338,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_operations.py index 6fd3ea82cea0..1b694075fdb2 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,132 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 msrest import Serializer 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 = "2021-05-01-preview" - 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-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.KubernetesConfiguration/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.KubernetesConfiguration/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.kubernetesconfiguration.v2021_05_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.kubernetesconfiguration.v2021_05_01_preview.SourceControlConfigurationClient`'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.ResourceProviderOperationList"]: + def list(self, **kwargs: Any) -> Iterable["_models.ResourceProviderOperation"]: """List all the available operations the KubernetesConfiguration resource provider supports. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of + :return: An iterator like instance of either ResourceProviderOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ResourceProviderOperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.ResourceProviderOperationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - 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) @@ -114,13 +142,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ResourceProviderOperationList", 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(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]: @@ -130,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.KubernetesConfiguration/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_source_control_configurations_operations.py index f79edc229968..fdf6c8e2b623 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_source_control_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_05_01_preview/operations/_source_control_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,273 +6,314 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -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 msrest import Serializer 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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2021-05-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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, + +def build_delete_request( resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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_list_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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") -class SourceControlConfigurationsOperations(object): - """SourceControlConfigurationsOperations 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.kubernetesconfiguration.v2021_05_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 SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Gets details of the Source Control Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -279,76 +321,195 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, - source_control_configuration: "_models.SourceControlConfiguration", + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Create a new Kubernetes Source Control Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. :type source_control_configuration: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.SourceControlConfiguration + :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: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.SourceControlConfiguration 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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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 {}) - 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(source_control_configuration, 'SourceControlConfiguration') + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -357,66 +518,84 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_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 {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self._delete_initial.metadata['url'], + 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 = self._client._pipeline.run(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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any @@ -425,17 +604,20 @@ def begin_delete( future sync from the source repo. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_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. @@ -447,104 +629,133 @@ def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - cls=lambda x,y,z: x, + api_version=api_version, + 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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.SourceControlConfigurationList"]: + ) -> Iterable["_models.SourceControlConfiguration"]: """List all Source Control Configurations. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlConfigurationList or the result of + :return: An iterator like instance of either SourceControlConfiguration or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.SourceControlConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_05_01_preview.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.SourceControlConfigurationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -555,13 +766,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlConfigurationList", 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(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]: @@ -571,8 +784,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/__init__.py index e90963036337..3ad4bd8b604e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['SourceControlConfigurationClient'] -# `._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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_configuration.py index b83d2cdd71b5..d75800b9114f 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_configuration.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_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,30 +15,35 @@ 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 SourceControlConfigurationClientConfiguration(Configuration): +class SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SourceControlConfigurationClient. 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". 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(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", "2021-09-01") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +51,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-09-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_metadata.json b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_metadata.json index 54bcbac73239..663ebfb0f1ba 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_metadata.json +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_metadata.json @@ -10,34 +10,36 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SourceControlConfigurationClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SourceControlConfigurationClientConfiguration\"]}}, \"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\": [\"SourceControlConfigurationClientConfiguration\"], \".._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\": [\"SourceControlConfigurationClientConfiguration\"], \"..._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 + "required": true, + "method_location": "positional" }, "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 + "required": true, + "method_location": "positional" } }, "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,22 +50,25 @@ "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 + "required": false, + "method_location": "positional" }, "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 + "required": false, + "method_location": "positional" }, "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 + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "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 + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -101,4 +109,4 @@ "operation_status": "OperationStatusOperations", "operations": "Operations" } -} \ No newline at end of file +} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_patch.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_source_control_configuration_client.py index 537f5bba3259..e33142db1297 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_source_control_configuration_client.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_source_control_configuration_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer -from . import models +from . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import SourceControlConfigurationClientConfiguration from .operations import ExtensionsOperations, OperationStatusOperations, Operations @@ -21,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SourceControlConfigurationClient: + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword """KubernetesConfiguration Client. :ivar extensions: ExtensionsOperations operations @@ -32,12 +33,15 @@ class SourceControlConfigurationClient: azure.mgmt.kubernetesconfiguration.v2021_09_01.operations.OperationStatusOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.kubernetesconfiguration.v2021_09_01.operations.Operations - :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'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-09-01". 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. """ @@ -49,23 +53,22 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SourceControlConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SourceControlConfigurationClientConfiguration( + 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.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_status = OperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request, # type: 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 +77,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 +90,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: () -> SourceControlConfigurationClient + def __enter__(self) -> "SourceControlConfigurationClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_vendor.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_vendor.py index 138f663c53a4..bd0df84f5319 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_vendor.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_vendor.py @@ -5,8 +5,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + 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,14 +17,14 @@ def _convert_request(request, files=None): 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 - ] + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_version.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_version.py index 48944bf3938a..59deb8c7263b 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_version.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.1.0" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/__init__.py index 5f583276b4ed..b95230ae03c5 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._source_control_configuration_client import SourceControlConfigurationClient -__all__ = ['SourceControlConfigurationClient'] -# `._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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/_configuration.py index 710846e073d3..91e73d50318c 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/_configuration.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_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,30 +15,35 @@ 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 SourceControlConfigurationClientConfiguration(Configuration): +class SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SourceControlConfigurationClient. 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". 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(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", "2021-09-01") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +51,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-09-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/_patch.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/_source_control_configuration_client.py index 96bdeb10bc78..debdc1b29b65 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/_source_control_configuration_client.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/_source_control_configuration_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer -from .. import models +from .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import SourceControlConfigurationClientConfiguration from .operations import ExtensionsOperations, OperationStatusOperations, Operations @@ -21,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SourceControlConfigurationClient: + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword """KubernetesConfiguration Client. :ivar extensions: ExtensionsOperations operations @@ -32,12 +33,15 @@ class SourceControlConfigurationClient: azure.mgmt.kubernetesconfiguration.v2021_09_01.aio.operations.OperationStatusOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.kubernetesconfiguration.v2021_09_01.aio.operations.Operations - :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'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-09-01". 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. """ @@ -49,23 +53,22 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SourceControlConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SourceControlConfigurationClientConfiguration( + 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.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_status = OperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **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 +77,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 @@ -94,5 +97,5 @@ async def __aenter__(self) -> "SourceControlConfigurationClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/operations/__init__.py index 632ac4c1eeb9..bd1d079823a2 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/operations/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/operations/__init__.py @@ -10,8 +10,14 @@ from ._operation_status_operations import OperationStatusOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ExtensionsOperations', - 'OperationStatusOperations', - 'Operations', + "ExtensionsOperations", + "OperationStatusOperations", + "Operations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/operations/_extensions_operations.py index 46475d98ddf9..35fb7da71b59 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/operations/_extensions_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/operations/_extensions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,132 +6,280 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +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._extensions_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._extensions_operations import ( + build_create_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 ExtensionsOperations: - """ExtensionsOperations 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 ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_09_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.kubernetesconfiguration.v2021_09_01.aio.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> "_models.Extension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + ) -> _models.Extension: 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 {}) - 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(extension, 'Extension') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IO, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") + + request = build_create_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension + :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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Extension"]: + ) -> AsyncLROPoller[_models.Extension]: """Create a new Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param extension: Properties necessary to Create an Extension. - :type extension: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension + :param extension: Properties necessary to Create an Extension. Is either a Extension type or a + IO type. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension 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 @@ -143,16 +292,17 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] - 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["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -161,85 +311,109 @@ async def begin_create( cluster_name=cluster_name, extension_name=extension_name, extension=extension, + 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('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, **kwargs: Any - ) -> "_models.Extension": + ) -> _models.Extension: """Gets Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Extension, or the result of cls(response) + :return: Extension or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] 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: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -247,65 +421,81 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, force_delete: Optional[bool] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, force_delete=force_delete, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(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, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace_async async def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, force_delete: Optional[bool] = None, @@ -315,20 +505,23 @@ async def begin_delete( from the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :param force_delete: Delete the extension resource in Azure - not the normal asynchronous - delete. + delete. Default value is None. :type force_delete: bool :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. @@ -340,127 +533,271 @@ async def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, force_delete=force_delete, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } async def _update_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - patch_extension: "_models.PatchExtension", + patch_extension: Union[_models.PatchExtension, IO], **kwargs: Any - ) -> "_models.Extension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + ) -> _models.Extension: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 304: ResourceNotModifiedError, + 409: lambda response: ResourceExistsError( + response=response, model=self._deserialize(_models.ErrorResponse, response), error_format=ARMErrorFormat + ), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - 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(patch_extension, 'PatchExtension') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = 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(patch_extension, (IO, bytes)): + _content = patch_extension + else: + _json = self._serialize.body(patch_extension, "PatchExtension") + + request = build_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_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(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + patch_extension: _models.PatchExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.PatchExtension + :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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + patch_extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - patch_extension: "_models.PatchExtension", + patch_extension: Union[_models.PatchExtension, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Extension"]: + ) -> AsyncLROPoller[_models.Extension]: """Patch an existing Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param patch_extension: Properties to Patch in an existing Extension. - :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.PatchExtension + :param patch_extension: Properties to Patch in an existing Extension. Is either a + PatchExtension type or a IO type. Required. + :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.PatchExtension 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 @@ -473,16 +810,17 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] - 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["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = 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, @@ -491,91 +829,117 @@ async def begin_update( cluster_name=cluster_name, extension_name=extension_name, patch_extension=patch_extension, + 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('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ExtensionsList"]: + ) -> AsyncIterable["_models.Extension"]: """List all Extensions in the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionsList or the result of cls(response) + :return: An iterator like instance of either Extension or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.ExtensionsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.ExtensionsList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -586,13 +950,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionsList", 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(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]: @@ -602,8 +968,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/operations/_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/operations/_operation_status_operations.py index 0d2cb035b00d..b76c781c2b5a 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/operations/_operation_status_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/operations/_operation_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +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 functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +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.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._operation_status_operations import build_get_request, 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 OperationStatusOperations: - """OperationStatusOperations 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 OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_09_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.kubernetesconfiguration.v2021_09_01.aio.SourceControlConfigurationClient`'s + :attr:`operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.OperationStatusList"]: + ) -> AsyncIterable["_models.OperationStatusResult"]: """List Async Operations, currently in progress, in a cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationStatusList or the result of cls(response) + :return: An iterator like instance of either OperationStatusResult or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.OperationStatusList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.OperationStatusList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -112,13 +143,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationStatusList", 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(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]: @@ -128,66 +161,82 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations" + } @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationStatusResult": + ) -> _models.OperationStatusResult: """Get Async Operation status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param operation_id: operation Id. + :param operation_id: operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatusResult, or the result of cls(response) + :return: OperationStatusResult or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.OperationStatusResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -195,12 +244,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/operations/_operations.py index 2113e3798fec..6eeb85ba4e05 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/operations/_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,80 +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 functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.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._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.kubernetesconfiguration.v2021_09_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.kubernetesconfiguration.v2021_09_01.aio.SourceControlConfigurationClient`'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.ResourceProviderOperationList"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceProviderOperation"]: """List all the available operations the KubernetesConfiguration resource provider supports, in this api-version. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of + :return: An iterator like instance of either ResourceProviderOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.ResourceProviderOperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.ResourceProviderOperationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - 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) @@ -89,13 +117,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ResourceProviderOperationList", 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(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]: @@ -105,8 +135,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.KubernetesConfiguration/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/models/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/models/__init__.py index 01a45e76c937..d690179db233 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/models/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/models/__init__.py @@ -27,39 +27,41 @@ from ._models_py3 import ScopeNamespace from ._models_py3 import SystemData - -from ._source_control_configuration_client_enums import ( - CreatedByType, - Enum0, - Enum1, - LevelType, - ProvisioningState, -) +from ._source_control_configuration_client_enums import CreatedByType +from ._source_control_configuration_client_enums import Enum0 +from ._source_control_configuration_client_enums import Enum1 +from ._source_control_configuration_client_enums import LevelType +from ._source_control_configuration_client_enums import ProvisioningState +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ErrorAdditionalInfo', - 'ErrorDetail', - 'ErrorResponse', - 'Extension', - 'ExtensionPropertiesAksAssignedIdentity', - 'ExtensionStatus', - 'ExtensionsList', - 'Identity', - 'OperationStatusList', - 'OperationStatusResult', - 'PatchExtension', - 'ProxyResource', - 'Resource', - 'ResourceProviderOperation', - 'ResourceProviderOperationDisplay', - 'ResourceProviderOperationList', - 'Scope', - 'ScopeCluster', - 'ScopeNamespace', - 'SystemData', - 'CreatedByType', - 'Enum0', - 'Enum1', - 'LevelType', - 'ProvisioningState', + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "Extension", + "ExtensionPropertiesAksAssignedIdentity", + "ExtensionStatus", + "ExtensionsList", + "Identity", + "OperationStatusList", + "OperationStatusResult", + "PatchExtension", + "ProxyResource", + "Resource", + "ResourceProviderOperation", + "ResourceProviderOperationDisplay", + "ResourceProviderOperationList", + "Scope", + "ScopeCluster", + "ScopeNamespace", + "SystemData", + "CreatedByType", + "Enum0", + "Enum1", + "LevelType", + "ProvisioningState", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/models/_models_py3.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/models/_models_py3.py index e60feb178697..dd3120217b98 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/models/_models_py3.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_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,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._source_control_configuration_client_enums import * +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 .. import models as _models -class ErrorAdditionalInfo(msrest.serialization.Model): + +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -23,31 +31,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -66,28 +70,24 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -95,32 +95,28 @@ def __init__( self.additional_info = None -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.ErrorDetail """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.ErrorDetail """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -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. @@ -136,31 +132,28 @@ 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: Any) -> None: + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + """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. @@ -175,27 +168,23 @@ class ProxyResource(Resource): """ _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(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) -class Extension(ProxyResource): +class Extension(ProxyResource): # pylint: disable=too-many-instance-attributes """The Extension object. Variables are only populated by the server, and will be ignored when sending a request. @@ -234,8 +223,8 @@ class Extension(ProxyResource): :ivar configuration_protected_settings: Configuration settings that are sensitive, as name-value pairs for configuring this extension. :vartype configuration_protected_settings: dict[str, str] - :ivar provisioning_state: The provisioning state of the extension resource. Possible values - include: "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting". + :ivar provisioning_state: The provisioning state of the extension resource. Known values are: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.ProvisioningState :ivar statuses: Status from this extension. @@ -252,52 +241,55 @@ class Extension(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'custom_location_settings': {'readonly': True}, - 'package_uri': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "custom_location_settings": {"readonly": True}, + "package_uri": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, - 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, - 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'Scope'}, - 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'statuses': {'key': 'properties.statuses', 'type': '[ExtensionStatus]'}, - 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDetail'}, - 'custom_location_settings': {'key': 'properties.customLocationSettings', 'type': '{str}'}, - 'package_uri': {'key': 'properties.packageUri', 'type': 'str'}, - 'aks_assigned_identity': {'key': 'properties.aksAssignedIdentity', 'type': 'ExtensionPropertiesAksAssignedIdentity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "extension_type": {"key": "properties.extensionType", "type": "str"}, + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "scope": {"key": "properties.scope", "type": "Scope"}, + "configuration_settings": {"key": "properties.configurationSettings", "type": "{str}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "statuses": {"key": "properties.statuses", "type": "[ExtensionStatus]"}, + "error_info": {"key": "properties.errorInfo", "type": "ErrorDetail"}, + "custom_location_settings": {"key": "properties.customLocationSettings", "type": "{str}"}, + "package_uri": {"key": "properties.packageUri", "type": "str"}, + "aks_assigned_identity": { + "key": "properties.aksAssignedIdentity", + "type": "ExtensionPropertiesAksAssignedIdentity", + }, } def __init__( self, *, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, extension_type: Optional[str] = None, - auto_upgrade_minor_version: Optional[bool] = True, - release_train: Optional[str] = "Stable", + auto_upgrade_minor_version: bool = True, + release_train: str = "Stable", version: Optional[str] = None, - scope: Optional["Scope"] = None, + scope: Optional["_models.Scope"] = None, configuration_settings: Optional[Dict[str, str]] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - statuses: Optional[List["ExtensionStatus"]] = None, - error_info: Optional["ErrorDetail"] = None, - aks_assigned_identity: Optional["ExtensionPropertiesAksAssignedIdentity"] = None, - **kwargs - ): + statuses: Optional[List["_models.ExtensionStatus"]] = None, + error_info: Optional["_models.ErrorDetail"] = None, + aks_assigned_identity: Optional["_models.ExtensionPropertiesAksAssignedIdentity"] = None, + **kwargs: Any + ) -> None: """ :keyword identity: Identity of the Extension resource. :paramtype identity: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Identity @@ -331,7 +323,7 @@ def __init__( :paramtype aks_assigned_identity: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.ExtensionPropertiesAksAssignedIdentity """ - super(Extension, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.system_data = None self.extension_type = extension_type @@ -349,7 +341,7 @@ def __init__( self.aks_assigned_identity = aks_assigned_identity -class ExtensionPropertiesAksAssignedIdentity(msrest.serialization.Model): +class ExtensionPropertiesAksAssignedIdentity(_serialization.Model): """Identity of the Extension resource in an AKS cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -358,41 +350,35 @@ class ExtensionPropertiesAksAssignedIdentity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :ivar type: The identity type. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: """ - :keyword type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :keyword type: The identity type. Default value is "SystemAssigned". :paramtype type: str """ - super(ExtensionPropertiesAksAssignedIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class ExtensionsList(msrest.serialization.Model): - """Result of the request to list Extensions. It contains a list of Extension objects and a URL link to get the next set of results. +class ExtensionsList(_serialization.Model): + """Result of the request to list Extensions. It contains a list of Extension objects and a URL + link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -403,35 +389,30 @@ class ExtensionsList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Extension]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Extension]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ExtensionsList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ExtensionStatus(msrest.serialization.Model): +class ExtensionStatus(_serialization.Model): """Status from the extension. :ivar code: Status code provided by the Extension. :vartype code: str :ivar display_status: Short description of status of the extension. :vartype display_status: str - :ivar level: Level of the status. Possible values include: "Error", "Warning", "Information". - Default value: "Information". + :ivar level: Level of the status. Known values are: "Error", "Warning", and "Information". :vartype level: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.LevelType :ivar message: Detailed message of the status from the Extension. :vartype message: str @@ -440,11 +421,11 @@ class ExtensionStatus(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'level': {'key': 'level', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'time': {'key': 'time', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "display_status": {"key": "displayStatus", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "time": {"key": "time", "type": "str"}, } def __init__( @@ -452,25 +433,24 @@ def __init__( *, code: Optional[str] = None, display_status: Optional[str] = None, - level: Optional[Union[str, "LevelType"]] = "Information", + level: Union[str, "_models.LevelType"] = "Information", message: Optional[str] = None, time: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword code: Status code provided by the Extension. :paramtype code: str :keyword display_status: Short description of status of the extension. :paramtype display_status: str - :keyword level: Level of the status. Possible values include: "Error", "Warning", - "Information". Default value: "Information". + :keyword level: Level of the status. Known values are: "Error", "Warning", and "Information". :paramtype level: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.LevelType :keyword message: Detailed message of the status from the Extension. :paramtype message: str :keyword time: DateLiteral (per ISO8601) noting the time of installation status. :paramtype time: str """ - super(ExtensionStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.display_status = display_status self.level = level @@ -478,7 +458,7 @@ def __init__( self.time = time -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -487,40 +467,33 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :ivar type: The identity type. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: """ - :keyword type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :keyword type: The identity type. Default value is "SystemAssigned". :paramtype type: str """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class OperationStatusList(msrest.serialization.Model): +class OperationStatusList(_serialization.Model): """The async operations in progress, in the cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -533,27 +506,23 @@ class OperationStatusList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationStatusResult]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OperationStatusResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationStatusList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class OperationStatusResult(msrest.serialization.Model): +class OperationStatusResult(_serialization.Model): """The current status of an async operation. All required parameters must be populated in order to send to Azure. @@ -562,7 +531,7 @@ class OperationStatusResult(msrest.serialization.Model): :vartype id: str :ivar name: Name of the async operation. :vartype name: str - :ivar status: Required. Operation status. + :ivar status: Operation status. Required. :vartype status: str :ivar properties: Additional information, if available. :vartype properties: dict[str, str] @@ -571,40 +540,40 @@ class OperationStatusResult(msrest.serialization.Model): """ _validation = { - 'status': {'required': True}, + "status": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, + "error": {"key": "error", "type": "ErrorDetail"}, } def __init__( self, *, status: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, properties: Optional[Dict[str, str]] = None, - error: Optional["ErrorDetail"] = None, - **kwargs - ): + error: Optional["_models.ErrorDetail"] = None, + **kwargs: Any + ) -> None: """ :keyword id: Fully qualified ID for the async operation. :paramtype id: str :keyword name: Name of the async operation. :paramtype name: str - :keyword status: Required. Operation status. + :keyword status: Operation status. Required. :paramtype status: str :keyword properties: Additional information, if available. :paramtype properties: dict[str, str] :keyword error: The error detail. :paramtype error: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.ErrorDetail """ - super(OperationStatusResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.status = status @@ -612,7 +581,7 @@ def __init__( self.error = error -class PatchExtension(msrest.serialization.Model): +class PatchExtension(_serialization.Model): """The Extension Patch Request object. :ivar auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade @@ -633,23 +602,23 @@ class PatchExtension(msrest.serialization.Model): """ _attribute_map = { - 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, - 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "configuration_settings": {"key": "properties.configurationSettings", "type": "{str}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, } def __init__( self, *, - auto_upgrade_minor_version: Optional[bool] = True, - release_train: Optional[str] = "Stable", + auto_upgrade_minor_version: bool = True, + release_train: str = "Stable", version: Optional[str] = None, configuration_settings: Optional[Dict[str, str]] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade of minor version, or not. @@ -667,7 +636,7 @@ def __init__( name-value pairs for configuring this extension. :paramtype configuration_protected_settings: dict[str, str] """ - super(PatchExtension, self).__init__(**kwargs) + super().__init__(**kwargs) self.auto_upgrade_minor_version = auto_upgrade_minor_version self.release_train = release_train self.version = version @@ -675,7 +644,7 @@ def __init__( self.configuration_protected_settings = configuration_protected_settings -class ResourceProviderOperation(msrest.serialization.Model): +class ResourceProviderOperation(_serialization.Model): """Supported operation of this resource provider. Variables are only populated by the server, and will be ignored when sending a request. @@ -692,24 +661,24 @@ class ResourceProviderOperation(msrest.serialization.Model): """ _validation = { - 'is_data_action': {'readonly': True}, - 'origin': {'readonly': True}, + "is_data_action": {"readonly": True}, + "origin": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'origin': {'key': 'origin', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "ResourceProviderOperationDisplay"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "origin": {"key": "origin", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["ResourceProviderOperationDisplay"] = None, - **kwargs - ): + display: Optional["_models.ResourceProviderOperationDisplay"] = None, + **kwargs: Any + ) -> None: """ :keyword name: Operation name, in format of {provider}/{resource}/{operation}. :paramtype name: str @@ -717,14 +686,14 @@ def __init__( :paramtype display: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.ResourceProviderOperationDisplay """ - super(ResourceProviderOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.is_data_action = None self.origin = None -class ResourceProviderOperationDisplay(msrest.serialization.Model): +class ResourceProviderOperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Resource provider: Microsoft KubernetesConfiguration. @@ -738,10 +707,10 @@ class ResourceProviderOperationDisplay(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__( @@ -751,8 +720,8 @@ def __init__( resource: Optional[str] = None, operation: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword provider: Resource provider: Microsoft KubernetesConfiguration. :paramtype provider: str @@ -763,14 +732,14 @@ def __init__( :keyword description: Description of this operation. :paramtype description: str """ - super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class ResourceProviderOperationList(msrest.serialization.Model): +class ResourceProviderOperationList(_serialization.Model): """Result of the request to list operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -783,31 +752,26 @@ class ResourceProviderOperationList(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceProviderOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceProviderOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceProviderOperation"]] = None, **kwargs: Any) -> None: """ :keyword value: List of operations supported by this resource provider. :paramtype value: list[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.ResourceProviderOperation] """ - super(ResourceProviderOperationList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class Scope(msrest.serialization.Model): +class Scope(_serialization.Model): """Scope of the extension. It can be either Cluster or Namespace; but not both. :ivar cluster: Specifies that the scope of the extension is Cluster. @@ -817,29 +781,29 @@ class Scope(msrest.serialization.Model): """ _attribute_map = { - 'cluster': {'key': 'cluster', 'type': 'ScopeCluster'}, - 'namespace': {'key': 'namespace', 'type': 'ScopeNamespace'}, + "cluster": {"key": "cluster", "type": "ScopeCluster"}, + "namespace": {"key": "namespace", "type": "ScopeNamespace"}, } def __init__( self, *, - cluster: Optional["ScopeCluster"] = None, - namespace: Optional["ScopeNamespace"] = None, - **kwargs - ): + cluster: Optional["_models.ScopeCluster"] = None, + namespace: Optional["_models.ScopeNamespace"] = None, + **kwargs: Any + ) -> None: """ :keyword cluster: Specifies that the scope of the extension is Cluster. :paramtype cluster: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.ScopeCluster :keyword namespace: Specifies that the scope of the extension is Namespace. :paramtype namespace: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.ScopeNamespace """ - super(Scope, self).__init__(**kwargs) + super().__init__(**kwargs) self.cluster = cluster self.namespace = namespace -class ScopeCluster(msrest.serialization.Model): +class ScopeCluster(_serialization.Model): """Specifies that the scope of the extension is Cluster. :ivar release_namespace: Namespace where the extension Release must be placed, for a Cluster @@ -848,25 +812,20 @@ class ScopeCluster(msrest.serialization.Model): """ _attribute_map = { - 'release_namespace': {'key': 'releaseNamespace', 'type': 'str'}, + "release_namespace": {"key": "releaseNamespace", "type": "str"}, } - def __init__( - self, - *, - release_namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, release_namespace: Optional[str] = None, **kwargs: Any) -> None: """ :keyword release_namespace: Namespace where the extension Release must be placed, for a Cluster scoped extension. If this namespace does not exist, it will be created. :paramtype release_namespace: str """ - super(ScopeCluster, self).__init__(**kwargs) + super().__init__(**kwargs) self.release_namespace = release_namespace -class ScopeNamespace(msrest.serialization.Model): +class ScopeNamespace(_serialization.Model): """Specifies that the scope of the extension is Namespace. :ivar target_namespace: Namespace where the extension will be created for an Namespace scoped @@ -875,39 +834,34 @@ class ScopeNamespace(msrest.serialization.Model): """ _attribute_map = { - 'target_namespace': {'key': 'targetNamespace', 'type': 'str'}, + "target_namespace": {"key": "targetNamespace", "type": "str"}, } - def __init__( - self, - *, - target_namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_namespace: Optional[str] = None, **kwargs: Any) -> None: """ :keyword target_namespace: Namespace where the extension will be created for an Namespace scoped extension. If this namespace does not exist, it will be created. :paramtype target_namespace: str """ - super(ScopeNamespace, self).__init__(**kwargs) + super().__init__(**kwargs) self.target_namespace = target_namespace -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.kubernetesconfiguration.v2021_09_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.kubernetesconfiguration.v2021_09_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -915,44 +869,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 - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. 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.kubernetesconfiguration.v2021_09_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.kubernetesconfiguration.v2021_09_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 diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/models/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/models/_source_control_configuration_client_enums.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/models/_source_control_configuration_client_enums.py index 48f19c25f2cf..af4a5d977654 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/models/_source_control_configuration_client_enums.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/models/_source_control_configuration_client_enums.py @@ -7,40 +7,42 @@ # -------------------------------------------------------------------------- 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 Enum0(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class Enum0(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum0.""" MICROSOFT_CONTAINER_SERVICE = "Microsoft.ContainerService" MICROSOFT_KUBERNETES = "Microsoft.Kubernetes" -class Enum1(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class Enum1(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum1.""" MANAGED_CLUSTERS = "managedClusters" CONNECTED_CLUSTERS = "connectedClusters" -class LevelType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Level of the status. - """ + +class LevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the status.""" ERROR = "Error" WARNING = "Warning" INFORMATION = "Information" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of the extension resource. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the extension resource.""" SUCCEEDED = "Succeeded" FAILED = "Failed" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/operations/__init__.py index 632ac4c1eeb9..bd1d079823a2 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/operations/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/operations/__init__.py @@ -10,8 +10,14 @@ from ._operation_status_operations import OperationStatusOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ExtensionsOperations', - 'OperationStatusOperations', - 'Operations', + "ExtensionsOperations", + "OperationStatusOperations", + "Operations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/operations/_extensions_operations.py index 4e718b52671a..003185ce4a1f 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/operations/_extensions_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/operations/_extensions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,359 +6,492 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -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 msrest import Serializer 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_create_request_initial( - subscription_id: str, + +def build_create_request( resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, + subscription_id: str, *, force_delete: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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") if force_delete is not None: - query_parameters['forceDelete'] = _SERIALIZER.query("force_delete", force_delete, 'bool') + _params["forceDelete"] = _SERIALIZER.query("force_delete", force_delete, "bool") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, +def build_update_request( resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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 - ) - -class ExtensionsOperations(object): - """ExtensionsOperations 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.kubernetesconfiguration.v2021_09_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 ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2021_09_01.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _create_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> "_models.Extension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + ) -> _models.Extension: 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 {}) - 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(extension, 'Extension') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IO, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") + + request = build_create_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + @overload + def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension + :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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> LROPoller["_models.Extension"]: + ) -> LROPoller[_models.Extension]: """Create a new Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param extension: Properties necessary to Create an Extension. - :type extension: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension + :param extension: Properties necessary to Create an Extension. Is either a Extension type or a + IO type. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension 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 @@ -369,16 +503,17 @@ def begin_create( :return: An instance of LROPoller that returns either Extension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] - 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["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -387,85 +522,108 @@ def begin_create( cluster_name=cluster_name, extension_name=extension_name, extension=extension, + 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('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, **kwargs: Any - ) -> "_models.Extension": + ) -> _models.Extension: """Gets Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Extension, or the result of cls(response) + :return: Extension or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] 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: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -473,65 +631,81 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, force_delete: Optional[bool] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, force_delete=force_delete, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(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, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, force_delete: Optional[bool] = None, @@ -541,20 +715,23 @@ def begin_delete( from the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :param force_delete: Delete the extension resource in Azure - not the normal asynchronous - delete. + delete. Default value is None. :type force_delete: bool :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. @@ -566,127 +743,268 @@ def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, force_delete=force_delete, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } def _update_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - patch_extension: "_models.PatchExtension", + patch_extension: Union[_models.PatchExtension, IO], **kwargs: Any - ) -> "_models.Extension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + ) -> _models.Extension: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 304: ResourceNotModifiedError, + 409: lambda response: ResourceExistsError( + response=response, model=self._deserialize(_models.ErrorResponse, response), error_format=ARMErrorFormat + ), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - 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(patch_extension, 'PatchExtension') + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = 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(patch_extension, (IO, bytes)): + _content = patch_extension + else: + _json = self._serialize.body(patch_extension, "PatchExtension") + + request = build_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_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(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + patch_extension: _models.PatchExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.PatchExtension + :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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + patch_extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - patch_extension: "_models.PatchExtension", + patch_extension: Union[_models.PatchExtension, IO], **kwargs: Any - ) -> LROPoller["_models.Extension"]: + ) -> LROPoller[_models.Extension]: """Patch an existing Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param patch_extension: Properties to Patch in an existing Extension. - :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.PatchExtension + :param patch_extension: Properties to Patch in an existing Extension. Is either a + PatchExtension type or a IO type. Required. + :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.PatchExtension 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 @@ -698,16 +1016,17 @@ def begin_update( :return: An instance of LROPoller that returns either Extension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] - 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["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = 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, @@ -716,91 +1035,116 @@ def begin_update( cluster_name=cluster_name, extension_name=extension_name, patch_extension=patch_extension, + 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('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.ExtensionsList"]: + ) -> Iterable["_models.Extension"]: """List all Extensions in the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionsList or the result of cls(response) + :return: An iterator like instance of either Extension or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.ExtensionsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.ExtensionsList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -811,13 +1155,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionsList", 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(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]: @@ -827,8 +1173,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/operations/_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/operations/_operation_status_operations.py index c418a705a301..743bcfb45c34 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/operations/_operation_status_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/operations/_operation_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,186 +6,219 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +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 msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, operation_id: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_name, 'str'), - "operationId": _SERIALIZER.url("operation_id", operation_id, '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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "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 - ) - -class OperationStatusOperations(object): - """OperationStatusOperations 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.kubernetesconfiguration.v2021_09_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 OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2021_09_01.SourceControlConfigurationClient`'s + :attr:`operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.OperationStatusList"]: + ) -> Iterable["_models.OperationStatusResult"]: """List Async Operations, currently in progress, in a cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationStatusList or the result of cls(response) + :return: An iterator like instance of either OperationStatusResult or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.OperationStatusList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.OperationStatusList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -195,13 +229,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationStatusList", 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(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]: @@ -211,66 +247,82 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations" + } @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationStatusResult": + ) -> _models.OperationStatusResult: """Get Async Operation status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param operation_id: operation Id. + :param operation_id: operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatusResult, or the result of cls(response) + :return: OperationStatusResult or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.OperationStatusResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -278,12 +330,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/operations/_operations.py index e18d70e2222e..c01540cb826b 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/operations/_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,129 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 msrest import Serializer 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 = "2021-09-01" - 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"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.KubernetesConfiguration/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.KubernetesConfiguration/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.kubernetesconfiguration.v2021_09_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.kubernetesconfiguration.v2021_09_01.SourceControlConfigurationClient`'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.ResourceProviderOperationList"]: + def list(self, **kwargs: Any) -> Iterable["_models.ResourceProviderOperation"]: """List all the available operations the KubernetesConfiguration resource provider supports, in this api-version. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of + :return: An iterator like instance of either ResourceProviderOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.ResourceProviderOperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_09_01.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.ResourceProviderOperationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - 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) @@ -115,13 +139,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ResourceProviderOperationList", 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(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]: @@ -131,8 +157,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.KubernetesConfiguration/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_09_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/__init__.py index e90963036337..3ad4bd8b604e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['SourceControlConfigurationClient'] -# `._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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_configuration.py index b822e7bc3188..beafdaa55396 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_configuration.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_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,30 +15,35 @@ 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 SourceControlConfigurationClientConfiguration(Configuration): +class SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SourceControlConfigurationClient. 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-11-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(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2021-11-01-preview"] = kwargs.pop("api_version", "2021-11-01-preview") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +51,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-11-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_metadata.json b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_metadata.json index 01d314d2c497..5f058333c37e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_metadata.json +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_metadata.json @@ -10,34 +10,36 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SourceControlConfigurationClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SourceControlConfigurationClientConfiguration\"]}}, \"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\": [\"SourceControlConfigurationClientConfiguration\"], \".._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\": [\"SourceControlConfigurationClientConfiguration\"], \"..._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 + "required": true, + "method_location": "positional" }, "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 + "required": true, + "method_location": "positional" } }, "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,22 +50,25 @@ "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 + "required": false, + "method_location": "positional" }, "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 + "required": false, + "method_location": "positional" }, "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 + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "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 + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -108,4 +116,4 @@ "flux_config_operation_status": "FluxConfigOperationStatusOperations", "operations": "Operations" } -} \ No newline at end of file +} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_patch.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_source_control_configuration_client.py index 7a4739e5d02d..18efbbbc2d28 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_source_control_configuration_client.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_source_control_configuration_client.py @@ -7,21 +7,33 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer -from . import models +from . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import SourceControlConfigurationClientConfiguration -from .operations import ClusterExtensionTypeOperations, ClusterExtensionTypesOperations, ExtensionTypeVersionsOperations, ExtensionsOperations, FluxConfigOperationStatusOperations, FluxConfigurationsOperations, LocationExtensionTypesOperations, OperationStatusOperations, Operations, SourceControlConfigurationsOperations +from .operations import ( + ClusterExtensionTypeOperations, + ClusterExtensionTypesOperations, + ExtensionTypeVersionsOperations, + ExtensionsOperations, + FluxConfigOperationStatusOperations, + FluxConfigurationsOperations, + LocationExtensionTypesOperations, + OperationStatusOperations, + Operations, + SourceControlConfigurationsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SourceControlConfigurationClient: + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """KubernetesConfiguration Client. :ivar extensions: ExtensionsOperations operations @@ -54,12 +66,15 @@ class SourceControlConfigurationClient: :ivar operations: Operations operations :vartype operations: azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.operations.Operations - :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'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-11-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -71,30 +86,43 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SourceControlConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SourceControlConfigurationClientConfiguration( + 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.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_status = OperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.cluster_extension_type = ClusterExtensionTypeOperations(self._client, self._config, self._serialize, self._deserialize) - self.cluster_extension_types = ClusterExtensionTypesOperations(self._client, self._config, self._serialize, self._deserialize) - self.extension_type_versions = ExtensionTypeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.location_extension_types = LocationExtensionTypesOperations(self._client, self._config, self._serialize, self._deserialize) - self.source_control_configurations = SourceControlConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.flux_configurations = FluxConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.flux_config_operation_status = FluxConfigOperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cluster_extension_type = ClusterExtensionTypeOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cluster_extension_types = ClusterExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.extension_type_versions = ExtensionTypeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.location_extension_types = LocationExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_configurations = FluxConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_config_operation_status = FluxConfigOperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request, # type: 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 @@ -103,7 +131,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 @@ -116,15 +144,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: () -> SourceControlConfigurationClient + def __enter__(self) -> "SourceControlConfigurationClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_vendor.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_vendor.py index 138f663c53a4..bd0df84f5319 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_vendor.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_vendor.py @@ -5,8 +5,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + 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,14 +17,14 @@ def _convert_request(request, files=None): 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 - ] + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_version.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_version.py index 48944bf3938a..59deb8c7263b 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_version.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.1.0" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/__init__.py index 5f583276b4ed..b95230ae03c5 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._source_control_configuration_client import SourceControlConfigurationClient -__all__ = ['SourceControlConfigurationClient'] -# `._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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/_configuration.py index b86d839a94e6..05f68fcf6ea4 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/_configuration.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_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,30 +15,35 @@ 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 SourceControlConfigurationClientConfiguration(Configuration): +class SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SourceControlConfigurationClient. 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-11-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(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2021-11-01-preview"] = kwargs.pop("api_version", "2021-11-01-preview") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +51,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-11-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/_patch.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/_source_control_configuration_client.py index e46bfe1b8855..31020329c59c 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/_source_control_configuration_client.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/_source_control_configuration_client.py @@ -7,21 +7,33 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer -from .. import models +from .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import SourceControlConfigurationClientConfiguration -from .operations import ClusterExtensionTypeOperations, ClusterExtensionTypesOperations, ExtensionTypeVersionsOperations, ExtensionsOperations, FluxConfigOperationStatusOperations, FluxConfigurationsOperations, LocationExtensionTypesOperations, OperationStatusOperations, Operations, SourceControlConfigurationsOperations +from .operations import ( + ClusterExtensionTypeOperations, + ClusterExtensionTypesOperations, + ExtensionTypeVersionsOperations, + ExtensionsOperations, + FluxConfigOperationStatusOperations, + FluxConfigurationsOperations, + LocationExtensionTypesOperations, + OperationStatusOperations, + Operations, + SourceControlConfigurationsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SourceControlConfigurationClient: + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """KubernetesConfiguration Client. :ivar extensions: ExtensionsOperations operations @@ -54,12 +66,15 @@ class SourceControlConfigurationClient: :ivar operations: Operations operations :vartype operations: azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.aio.operations.Operations - :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'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-11-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -71,30 +86,43 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SourceControlConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SourceControlConfigurationClientConfiguration( + 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.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_status = OperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.cluster_extension_type = ClusterExtensionTypeOperations(self._client, self._config, self._serialize, self._deserialize) - self.cluster_extension_types = ClusterExtensionTypesOperations(self._client, self._config, self._serialize, self._deserialize) - self.extension_type_versions = ExtensionTypeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.location_extension_types = LocationExtensionTypesOperations(self._client, self._config, self._serialize, self._deserialize) - self.source_control_configurations = SourceControlConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.flux_configurations = FluxConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.flux_config_operation_status = FluxConfigOperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cluster_extension_type = ClusterExtensionTypeOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cluster_extension_types = ClusterExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.extension_type_versions = ExtensionTypeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.location_extension_types = LocationExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_configurations = FluxConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_config_operation_status = FluxConfigOperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **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 @@ -103,7 +131,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 @@ -123,5 +151,5 @@ async def __aenter__(self) -> "SourceControlConfigurationClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/__init__.py index ee01fecd4396..3f15324c4708 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/__init__.py @@ -17,15 +17,21 @@ from ._flux_config_operation_status_operations import FluxConfigOperationStatusOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ExtensionsOperations', - 'OperationStatusOperations', - 'ClusterExtensionTypeOperations', - 'ClusterExtensionTypesOperations', - 'ExtensionTypeVersionsOperations', - 'LocationExtensionTypesOperations', - 'SourceControlConfigurationsOperations', - 'FluxConfigurationsOperations', - 'FluxConfigOperationStatusOperations', - 'Operations', + "ExtensionsOperations", + "OperationStatusOperations", + "ClusterExtensionTypeOperations", + "ClusterExtensionTypesOperations", + "ExtensionTypeVersionsOperations", + "LocationExtensionTypesOperations", + "SourceControlConfigurationsOperations", + "FluxConfigurationsOperations", + "FluxConfigOperationStatusOperations", + "Operations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_cluster_extension_type_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_cluster_extension_type_operations.py index 0f6ebc8b36af..d8c3f661419a 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_cluster_extension_type_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_cluster_extension_type_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,95 +6,123 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._cluster_extension_type_operations import build_get_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 ClusterExtensionTypeOperations: - """ClusterExtensionTypeOperations 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 ClusterExtensionTypeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_11_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.kubernetesconfiguration.v2021_11_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`cluster_extension_type` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_type_name: str, **kwargs: Any - ) -> "_models.ExtensionType": + ) -> _models.ExtensionType: """Get Extension Type details. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_type_name: Extension type name. + :param extension_type_name: Extension type name. Required. :type extension_type_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExtensionType, or the result of cls(response) + :return: ExtensionType or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ExtensionType - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionType"] 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: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.ExtensionType] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_type_name=extension_type_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -101,12 +130,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExtensionType', pipeline_response) + deserialized = self._deserialize("ExtensionType", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_cluster_extension_types_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_cluster_extension_types_operations.py index ddeddcf87c6c..a796f0dcafee 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_cluster_extension_types_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_cluster_extension_types_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +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 functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +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.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._cluster_extension_types_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 ClusterExtensionTypesOperations: - """ClusterExtensionTypesOperations 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 ClusterExtensionTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_11_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.kubernetesconfiguration.v2021_11_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`cluster_extension_types` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ExtensionTypeList"]: + ) -> AsyncIterable["_models.ExtensionType"]: """Get Extension Types. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionTypeList or the result of cls(response) + :return: An iterator like instance of either ExtensionType or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ExtensionTypeList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ExtensionType] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionTypeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.ExtensionTypeList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -112,13 +143,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionTypeList", 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(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]: @@ -128,8 +161,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_extension_type_versions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_extension_type_versions_operations.py index 2fb6a487db61..a692ca0a5632 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_extension_type_versions_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_extension_type_versions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,91 +6,117 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.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._extension_type_versions_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 ExtensionTypeVersionsOperations: - """ExtensionTypeVersionsOperations 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 ExtensionTypeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_11_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.kubernetesconfiguration.v2021_11_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`extension_type_versions` 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, - location: str, - extension_type_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ExtensionVersionList"]: + self, location: str, extension_type_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ExtensionVersionListVersionsItem"]: """List available versions for an Extension Type. - :param location: extension location. + :param location: extension location. Required. :type location: str - :param extension_type_name: Extension type name. + :param extension_type_name: Extension type name. Required. :type extension_type_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionVersionList or the result of + :return: An iterator like instance of either ExtensionVersionListVersionsItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ExtensionVersionList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ExtensionVersionListVersionsItem] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionVersionList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.ExtensionVersionList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, extension_type_name=extension_type_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - extension_type_name=extension_type_name, - 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) @@ -100,13 +127,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionVersionList", pipeline_response) list_of_elem = deserialized.versions 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(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]: @@ -116,8 +145,8 @@ 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.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_extensions_operations.py index a80a7a43909c..a81dced523d3 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_extensions_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_extensions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,132 +6,282 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +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._extensions_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._extensions_operations import ( + build_create_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 ExtensionsOperations: - """ExtensionsOperations 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 ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_11_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.kubernetesconfiguration.v2021_11_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> "_models.Extension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + ) -> _models.Extension: 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 {}) - 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(extension, 'Extension') + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IO, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension + :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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Extension"]: + ) -> AsyncLROPoller[_models.Extension]: """Create a new Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param extension: Properties necessary to Create an Extension. - :type extension: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension + :param extension: Properties necessary to Create an Extension. Is either a Extension type or a + IO type. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension 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 @@ -143,16 +294,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] - 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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-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.Extension] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -161,85 +315,111 @@ async def begin_create( cluster_name=cluster_name, extension_name=extension_name, extension=extension, + 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('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, **kwargs: Any - ) -> "_models.Extension": + ) -> _models.Extension: """Gets Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Extension, or the result of cls(response) + :return: Extension or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] 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: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -247,65 +427,83 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, force_delete: Optional[bool] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, force_delete=force_delete, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(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, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace_async async def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, force_delete: Optional[bool] = None, @@ -315,20 +513,23 @@ async def begin_delete( from the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :param force_delete: Delete the extension resource in Azure - not the normal asynchronous - delete. + delete. Default value is None. :type force_delete: bool :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. @@ -340,128 +541,276 @@ async def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, force_delete=force_delete, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } async def _update_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - patch_extension: "_models.PatchExtension", + patch_extension: Union[_models.PatchExtension, IO], **kwargs: Any - ) -> "_models.Extension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + ) -> _models.Extension: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 304: ResourceNotModifiedError, + 409: lambda response: ResourceExistsError( + response=response, model=self._deserialize(_models.ErrorResponse, response), error_format=ARMErrorFormat + ), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - 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(patch_extension, 'PatchExtension') + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(patch_extension, (IO, bytes)): + _content = patch_extension + else: + _json = self._serialize.body(patch_extension, "PatchExtension") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_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(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + patch_extension: _models.PatchExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.PatchExtension + :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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + patch_extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - patch_extension: "_models.PatchExtension", + patch_extension: Union[_models.PatchExtension, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Extension"]: + ) -> AsyncLROPoller[_models.Extension]: """Patch an existing Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param patch_extension: Properties to Patch in an existing Extension. + :param patch_extension: Properties to Patch in an existing Extension. Is either a + PatchExtension type or a IO type. Required. :type patch_extension: - ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.PatchExtension + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.PatchExtension 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 @@ -474,16 +823,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] - 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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-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.Extension] = 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, @@ -492,91 +844,119 @@ async def begin_update( cluster_name=cluster_name, extension_name=extension_name, patch_extension=patch_extension, + 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('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ExtensionsList"]: + ) -> AsyncIterable["_models.Extension"]: """List all Extensions in the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionsList or the result of cls(response) + :return: An iterator like instance of either Extension or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ExtensionsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.ExtensionsList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -587,13 +967,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionsList", 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(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]: @@ -603,8 +985,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_flux_config_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_flux_config_operation_status_operations.py index 278055cbaf8d..3d3c87c56425 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_flux_config_operation_status_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_flux_config_operation_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,99 +6,127 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._flux_config_operation_status_operations import build_get_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 FluxConfigOperationStatusOperations: - """FluxConfigOperationStatusOperations 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 FluxConfigOperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_11_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.kubernetesconfiguration.v2021_11_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`flux_config_operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationStatusResult": + ) -> _models.OperationStatusResult: """Get Async Operation status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str - :param operation_id: operation Id. + :param operation_id: operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatusResult, or the result of cls(response) + :return: OperationStatusResult or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.OperationStatusResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -105,12 +134,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_flux_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_flux_configurations_operations.py index 75827d96b95d..e5cc0f4083ea 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_flux_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_flux_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,99 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +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._flux_configurations_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._flux_configurations_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 FluxConfigurationsOperations: - """FluxConfigurationsOperations 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 FluxConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_11_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.kubernetesconfiguration.v2021_11_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`flux_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, **kwargs: Any - ) -> "_models.FluxConfiguration": + ) -> _models.FluxConfiguration: """Gets details of the Flux Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FluxConfiguration, or the result of cls(response) + :return: FluxConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] 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: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -105,100 +141,237 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } async def _create_or_update_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, - flux_configuration: "_models.FluxConfiguration", + flux_configuration: Union[_models.FluxConfiguration, IO], **kwargs: Any - ) -> "_models.FluxConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + ) -> _models.FluxConfiguration: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 304: ResourceNotModifiedError, + 409: lambda response: ResourceExistsError( + response=response, model=self._deserialize(_models.ErrorResponse, response), error_format=ARMErrorFormat + ), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - 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(flux_configuration, 'FluxConfiguration') + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration, (IO, bytes)): + _content = flux_configuration + else: + _json = self._serialize.body(flux_configuration, "FluxConfiguration") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_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(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + flux_configuration_name: str, + flux_configuration: _models.FluxConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + flux_configuration_name: str, + flux_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, - flux_configuration: "_models.FluxConfiguration", + flux_configuration: Union[_models.FluxConfiguration, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.FluxConfiguration"]: + ) -> AsyncLROPoller[_models.FluxConfiguration]: """Create a new Kubernetes Flux Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str - :param flux_configuration: Properties necessary to Create a FluxConfiguration. + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Is either a + FluxConfiguration type or a IO type. Required. :type flux_configuration: - ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration 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 @@ -211,16 +384,19 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] - 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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-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.FluxConfiguration] = 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, @@ -229,115 +405,158 @@ async def begin_create_or_update( cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, flux_configuration=flux_configuration, + 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('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } async def _update_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, - flux_configuration_patch: "_models.FluxConfigurationPatch", + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], **kwargs: Any - ) -> "_models.FluxConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + ) -> _models.FluxConfiguration: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 304: ResourceNotModifiedError, + 409: lambda response: ResourceExistsError( + response=response, model=self._deserialize(_models.ErrorResponse, response), error_format=ARMErrorFormat + ), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - 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(flux_configuration_patch, 'FluxConfigurationPatch') + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration_patch, (IO, bytes)): + _content = flux_configuration_patch + else: + _json = self._serialize.body(flux_configuration_patch, "FluxConfigurationPatch") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_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(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore - + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, - flux_configuration_patch: "_models.FluxConfigurationPatch", + flux_configuration_patch: _models.FluxConfigurationPatch, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.FluxConfiguration"]: + ) -> AsyncLROPoller[_models.FluxConfiguration]: """Update an existing Kubernetes Flux Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. :type flux_configuration_patch: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfigurationPatch + :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 @@ -350,16 +569,122 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. + :type flux_configuration_patch: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. Is + either a FluxConfigurationPatch type or a IO type. Required. + :type flux_configuration_patch: + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfigurationPatch 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-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.FluxConfiguration] = 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, @@ -368,84 +693,109 @@ async def begin_update( cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, flux_configuration_patch=flux_configuration_patch, + 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('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, force_delete: Optional[bool] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, + subscription_id=self._config.subscription_id, force_delete=force_delete, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(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, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } @distributed_trace_async async def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, force_delete: Optional[bool] = None, @@ -455,20 +805,23 @@ async def begin_delete( from the source repo. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str :param force_delete: Delete the extension resource in Azure - not the normal asynchronous - delete. + delete. Default value is None. :type force_delete: bool :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. @@ -480,105 +833,136 @@ async def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, force_delete=force_delete, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.FluxConfigurationsList"]: + ) -> AsyncIterable["_models.FluxConfiguration"]: """List all Flux Configurations. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FluxConfigurationsList or the result of - cls(response) + :return: An iterator like instance of either FluxConfiguration or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfigurationsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfigurationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.FluxConfigurationsList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -589,13 +973,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("FluxConfigurationsList", 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(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]: @@ -605,8 +991,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_location_extension_types_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_location_extension_types_operations.py index 4dfb3b692cd2..977a09635ca5 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_location_extension_types_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_location_extension_types_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,85 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.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._location_extension_types_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 LocationExtensionTypesOperations: - """LocationExtensionTypesOperations 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 LocationExtensionTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_11_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.kubernetesconfiguration.v2021_11_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`location_extension_types` 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, - location: str, - **kwargs: Any - ) -> AsyncIterable["_models.ExtensionTypeList"]: + def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.ExtensionType"]: """List all Extension Types. - :param location: extension location. + :param location: extension location. 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 ExtensionTypeList or the result of cls(response) + :return: An iterator like instance of either ExtensionType or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ExtensionTypeList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ExtensionType] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionTypeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.ExtensionTypeList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - 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) @@ -94,13 +121,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionTypeList", 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(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]: @@ -110,8 +139,8 @@ 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.KubernetesConfiguration/locations/{location}/extensionTypes'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_operation_status_operations.py index ca83ab69e8d7..6b133ba71f6d 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_operation_status_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_operation_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,130 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +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.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._operation_status_operations import build_get_request, 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 OperationStatusOperations: - """OperationStatusOperations 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 OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_11_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.kubernetesconfiguration.v2021_11_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationStatusResult": + ) -> _models.OperationStatusResult: """Get Async Operation status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param operation_id: operation Id. + :param operation_id: operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatusResult, or the result of cls(response) + :return: OperationStatusResult or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.OperationStatusResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -107,72 +137,94 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.OperationStatusList"]: + ) -> AsyncIterable["_models.OperationStatusResult"]: """List Async Operations, currently in progress, in a cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationStatusList or the result of cls(response) + :return: An iterator like instance of either OperationStatusResult or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.OperationStatusList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.OperationStatusList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -183,13 +235,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationStatusList", 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(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]: @@ -199,8 +253,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_operations.py index bff33128e433..a8184101c2f3 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,79 +6,108 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.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._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.kubernetesconfiguration.v2021_11_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.kubernetesconfiguration.v2021_11_01_preview.aio.SourceControlConfigurationClient`'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.ResourceProviderOperationList"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceProviderOperation"]: """List all the available operations the KubernetesConfiguration resource provider supports. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of + :return: An iterator like instance of either ResourceProviderOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ResourceProviderOperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.ResourceProviderOperationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - 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) @@ -88,13 +118,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ResourceProviderOperationList", 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(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]: @@ -104,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.KubernetesConfiguration/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_source_control_configurations_operations.py index 9e25d1d37963..7dbf17bd2d52 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_source_control_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/aio/operations/_source_control_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,100 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +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._source_control_configurations_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._source_control_configurations_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + 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 SourceControlConfigurationsOperations: - """SourceControlConfigurationsOperations 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 SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_11_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.kubernetesconfiguration.v2021_11_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Gets details of the Source Control Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -106,76 +141,195 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, - source_control_configuration: "_models.SourceControlConfiguration", + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Create a new Kubernetes Source Control Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. :type source_control_configuration: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceControlConfiguration + :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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceControlConfiguration 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: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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 {}) - 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(source_control_configuration, 'SourceControlConfiguration') + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -184,66 +338,84 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_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 {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self._delete_initial.metadata['url'], + 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 = await self._client._pipeline.run(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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace_async async def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any @@ -252,17 +424,20 @@ async def begin_delete( future sync from the source repo. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_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. @@ -274,104 +449,133 @@ async def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - cls=lambda x,y,z: x, + api_version=api_version, + 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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SourceControlConfigurationList"]: + ) -> AsyncIterable["_models.SourceControlConfiguration"]: """List all Source Control Configurations. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlConfigurationList or the result of + :return: An iterator like instance of either SourceControlConfiguration or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceControlConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.SourceControlConfigurationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -382,13 +586,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlConfigurationList", 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(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]: @@ -398,8 +604,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/models/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/models/__init__.py index b83d70226f0b..e4780f6d4415 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/models/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/models/__init__.py @@ -48,80 +48,82 @@ from ._models_py3 import SupportedScopes from ._models_py3 import SystemData - -from ._source_control_configuration_client_enums import ( - ClusterTypes, - ComplianceStateType, - CreatedByType, - Enum0, - Enum1, - FluxComplianceState, - KustomizationValidationType, - LevelType, - MessageLevelType, - OperatorScopeType, - OperatorType, - ProvisioningState, - ProvisioningStateType, - ScopeType, - SourceKindType, -) +from ._source_control_configuration_client_enums import ClusterTypes +from ._source_control_configuration_client_enums import ComplianceStateType +from ._source_control_configuration_client_enums import CreatedByType +from ._source_control_configuration_client_enums import Enum0 +from ._source_control_configuration_client_enums import Enum1 +from ._source_control_configuration_client_enums import FluxComplianceState +from ._source_control_configuration_client_enums import KustomizationValidationType +from ._source_control_configuration_client_enums import LevelType +from ._source_control_configuration_client_enums import MessageLevelType +from ._source_control_configuration_client_enums import OperatorScopeType +from ._source_control_configuration_client_enums import OperatorType +from ._source_control_configuration_client_enums import ProvisioningState +from ._source_control_configuration_client_enums import ProvisioningStateType +from ._source_control_configuration_client_enums import ScopeType +from ._source_control_configuration_client_enums import SourceKindType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ClusterScopeSettings', - 'ComplianceStatus', - 'DependsOnDefinition', - 'ErrorAdditionalInfo', - 'ErrorDetail', - 'ErrorResponse', - 'Extension', - 'ExtensionPropertiesAksAssignedIdentity', - 'ExtensionStatus', - 'ExtensionType', - 'ExtensionTypeList', - 'ExtensionVersionList', - 'ExtensionVersionListVersionsItem', - 'ExtensionsList', - 'FluxConfiguration', - 'FluxConfigurationPatch', - 'FluxConfigurationsList', - 'GitRepositoryDefinition', - 'HelmOperatorProperties', - 'HelmReleasePropertiesDefinition', - 'Identity', - 'KustomizationDefinition', - 'ObjectReferenceDefinition', - 'ObjectStatusConditionDefinition', - 'ObjectStatusDefinition', - 'OperationStatusList', - 'OperationStatusResult', - 'PatchExtension', - 'ProxyResource', - 'RepositoryRefDefinition', - 'Resource', - 'ResourceProviderOperation', - 'ResourceProviderOperationDisplay', - 'ResourceProviderOperationList', - 'Scope', - 'ScopeCluster', - 'ScopeNamespace', - 'SourceControlConfiguration', - 'SourceControlConfigurationList', - 'SupportedScopes', - 'SystemData', - 'ClusterTypes', - 'ComplianceStateType', - 'CreatedByType', - 'Enum0', - 'Enum1', - 'FluxComplianceState', - 'KustomizationValidationType', - 'LevelType', - 'MessageLevelType', - 'OperatorScopeType', - 'OperatorType', - 'ProvisioningState', - 'ProvisioningStateType', - 'ScopeType', - 'SourceKindType', + "ClusterScopeSettings", + "ComplianceStatus", + "DependsOnDefinition", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "Extension", + "ExtensionPropertiesAksAssignedIdentity", + "ExtensionStatus", + "ExtensionType", + "ExtensionTypeList", + "ExtensionVersionList", + "ExtensionVersionListVersionsItem", + "ExtensionsList", + "FluxConfiguration", + "FluxConfigurationPatch", + "FluxConfigurationsList", + "GitRepositoryDefinition", + "HelmOperatorProperties", + "HelmReleasePropertiesDefinition", + "Identity", + "KustomizationDefinition", + "ObjectReferenceDefinition", + "ObjectStatusConditionDefinition", + "ObjectStatusDefinition", + "OperationStatusList", + "OperationStatusResult", + "PatchExtension", + "ProxyResource", + "RepositoryRefDefinition", + "Resource", + "ResourceProviderOperation", + "ResourceProviderOperationDisplay", + "ResourceProviderOperationList", + "Scope", + "ScopeCluster", + "ScopeNamespace", + "SourceControlConfiguration", + "SourceControlConfigurationList", + "SupportedScopes", + "SystemData", + "ClusterTypes", + "ComplianceStateType", + "CreatedByType", + "Enum0", + "Enum1", + "FluxComplianceState", + "KustomizationValidationType", + "LevelType", + "MessageLevelType", + "OperatorScopeType", + "OperatorType", + "ProvisioningState", + "ProvisioningStateType", + "ScopeType", + "SourceKindType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/models/_models_py3.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/models/_models_py3.py index b7d98fd1b6d0..700bb775b91a 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/models/_models_py3.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_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,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._source_control_configuration_client_enums import * +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 .. import models as _models -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. @@ -31,31 +39,28 @@ 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: Any) -> None: + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + """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. @@ -70,24 +75,20 @@ class ProxyResource(Resource): """ _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(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) class ClusterScopeSettings(ProxyResource): @@ -110,17 +111,17 @@ class ClusterScopeSettings(ProxyResource): """ _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'}, - 'allow_multiple_instances': {'key': 'properties.allowMultipleInstances', 'type': 'bool'}, - 'default_release_namespace': {'key': 'properties.defaultReleaseNamespace', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "allow_multiple_instances": {"key": "properties.allowMultipleInstances", "type": "bool"}, + "default_release_namespace": {"key": "properties.defaultReleaseNamespace", "type": "str"}, } def __init__( @@ -128,8 +129,8 @@ def __init__( *, allow_multiple_instances: Optional[bool] = None, default_release_namespace: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword allow_multiple_instances: Describes if multiple instances of the extension are allowed. @@ -137,39 +138,39 @@ def __init__( :keyword default_release_namespace: Default extension release namespace. :paramtype default_release_namespace: str """ - super(ClusterScopeSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.allow_multiple_instances = allow_multiple_instances self.default_release_namespace = default_release_namespace -class ComplianceStatus(msrest.serialization.Model): +class ComplianceStatus(_serialization.Model): """Compliance Status details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar compliance_state: The compliance state of the configuration. Possible values include: - "Pending", "Compliant", "Noncompliant", "Installed", "Failed". + :ivar compliance_state: The compliance state of the configuration. Known values are: "Pending", + "Compliant", "Noncompliant", "Installed", and "Failed". :vartype compliance_state: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ComplianceStateType :ivar last_config_applied: Datetime the configuration was last applied. :vartype last_config_applied: ~datetime.datetime :ivar message: Message from when the configuration was applied. :vartype message: str - :ivar message_level: Level of the message. Possible values include: "Error", "Warning", + :ivar message_level: Level of the message. Known values are: "Error", "Warning", and "Information". :vartype message_level: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.MessageLevelType """ _validation = { - 'compliance_state': {'readonly': True}, + "compliance_state": {"readonly": True}, } _attribute_map = { - 'compliance_state': {'key': 'complianceState', 'type': 'str'}, - 'last_config_applied': {'key': 'lastConfigApplied', 'type': 'iso-8601'}, - 'message': {'key': 'message', 'type': 'str'}, - 'message_level': {'key': 'messageLevel', 'type': 'str'}, + "compliance_state": {"key": "complianceState", "type": "str"}, + "last_config_applied": {"key": "lastConfigApplied", "type": "iso-8601"}, + "message": {"key": "message", "type": "str"}, + "message_level": {"key": "messageLevel", "type": "str"}, } def __init__( @@ -177,52 +178,48 @@ def __init__( *, last_config_applied: Optional[datetime.datetime] = None, message: Optional[str] = None, - message_level: Optional[Union[str, "MessageLevelType"]] = None, - **kwargs - ): + message_level: Optional[Union[str, "_models.MessageLevelType"]] = None, + **kwargs: Any + ) -> None: """ :keyword last_config_applied: Datetime the configuration was last applied. :paramtype last_config_applied: ~datetime.datetime :keyword message: Message from when the configuration was applied. :paramtype message: str - :keyword message_level: Level of the message. Possible values include: "Error", "Warning", + :keyword message_level: Level of the message. Known values are: "Error", "Warning", and "Information". :paramtype message_level: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.MessageLevelType """ - super(ComplianceStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.compliance_state = None self.last_config_applied = last_config_applied self.message = message self.message_level = message_level -class DependsOnDefinition(msrest.serialization.Model): - """Specify which kustomizations must succeed reconciliation on the cluster prior to reconciling this kustomization. +class DependsOnDefinition(_serialization.Model): + """Specify which kustomizations must succeed reconciliation on the cluster prior to reconciling + this kustomization. :ivar kustomization_name: Name of the kustomization to claim dependency on. :vartype kustomization_name: str """ _attribute_map = { - 'kustomization_name': {'key': 'kustomizationName', 'type': 'str'}, + "kustomization_name": {"key": "kustomizationName", "type": "str"}, } - def __init__( - self, - *, - kustomization_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, kustomization_name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword kustomization_name: Name of the kustomization to claim dependency on. :paramtype kustomization_name: str """ - super(DependsOnDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.kustomization_name = kustomization_name -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -230,31 +227,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -274,28 +267,24 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -303,32 +292,28 @@ def __init__( self.additional_info = None -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ErrorDetail """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ErrorDetail """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class Extension(ProxyResource): +class Extension(ProxyResource): # pylint: disable=too-many-instance-attributes """The Extension object. Variables are only populated by the server, and will be ignored when sending a request. @@ -367,8 +352,8 @@ class Extension(ProxyResource): :ivar configuration_protected_settings: Configuration settings that are sensitive, as name-value pairs for configuring this extension. :vartype configuration_protected_settings: dict[str, str] - :ivar provisioning_state: Status of installation of this extension. Possible values include: - "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting". + :ivar provisioning_state: Status of installation of this extension. Known values are: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ProvisioningState :ivar statuses: Status from this extension. @@ -386,52 +371,55 @@ class Extension(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'error_info': {'readonly': True}, - 'custom_location_settings': {'readonly': True}, - 'package_uri': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "error_info": {"readonly": True}, + "custom_location_settings": {"readonly": True}, + "package_uri": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, - 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, - 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'Scope'}, - 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'statuses': {'key': 'properties.statuses', 'type': '[ExtensionStatus]'}, - 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDetail'}, - 'custom_location_settings': {'key': 'properties.customLocationSettings', 'type': '{str}'}, - 'package_uri': {'key': 'properties.packageUri', 'type': 'str'}, - 'aks_assigned_identity': {'key': 'properties.aksAssignedIdentity', 'type': 'ExtensionPropertiesAksAssignedIdentity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "extension_type": {"key": "properties.extensionType", "type": "str"}, + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "scope": {"key": "properties.scope", "type": "Scope"}, + "configuration_settings": {"key": "properties.configurationSettings", "type": "{str}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "statuses": {"key": "properties.statuses", "type": "[ExtensionStatus]"}, + "error_info": {"key": "properties.errorInfo", "type": "ErrorDetail"}, + "custom_location_settings": {"key": "properties.customLocationSettings", "type": "{str}"}, + "package_uri": {"key": "properties.packageUri", "type": "str"}, + "aks_assigned_identity": { + "key": "properties.aksAssignedIdentity", + "type": "ExtensionPropertiesAksAssignedIdentity", + }, } def __init__( self, *, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, extension_type: Optional[str] = None, - auto_upgrade_minor_version: Optional[bool] = True, - release_train: Optional[str] = "Stable", + auto_upgrade_minor_version: bool = True, + release_train: str = "Stable", version: Optional[str] = None, - scope: Optional["Scope"] = None, + scope: Optional["_models.Scope"] = None, configuration_settings: Optional[Dict[str, str]] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - statuses: Optional[List["ExtensionStatus"]] = None, - aks_assigned_identity: Optional["ExtensionPropertiesAksAssignedIdentity"] = None, - **kwargs - ): + statuses: Optional[List["_models.ExtensionStatus"]] = None, + aks_assigned_identity: Optional["_models.ExtensionPropertiesAksAssignedIdentity"] = None, + **kwargs: Any + ) -> None: """ :keyword identity: Identity of the Extension resource. :paramtype identity: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Identity @@ -463,7 +451,7 @@ def __init__( :paramtype aks_assigned_identity: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ExtensionPropertiesAksAssignedIdentity """ - super(Extension, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.system_data = None self.extension_type = extension_type @@ -481,7 +469,7 @@ def __init__( self.aks_assigned_identity = aks_assigned_identity -class ExtensionPropertiesAksAssignedIdentity(msrest.serialization.Model): +class ExtensionPropertiesAksAssignedIdentity(_serialization.Model): """Identity of the Extension resource in an AKS cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -490,41 +478,35 @@ class ExtensionPropertiesAksAssignedIdentity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :ivar type: The identity type. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: """ - :keyword type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :keyword type: The identity type. Default value is "SystemAssigned". :paramtype type: str """ - super(ExtensionPropertiesAksAssignedIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class ExtensionsList(msrest.serialization.Model): - """Result of the request to list Extensions. It contains a list of Extension objects and a URL link to get the next set of results. +class ExtensionsList(_serialization.Model): + """Result of the request to list Extensions. It contains a list of Extension objects and a URL + link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -535,35 +517,30 @@ class ExtensionsList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Extension]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Extension]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ExtensionsList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ExtensionStatus(msrest.serialization.Model): +class ExtensionStatus(_serialization.Model): """Status from the extension. :ivar code: Status code provided by the Extension. :vartype code: str :ivar display_status: Short description of status of the extension. :vartype display_status: str - :ivar level: Level of the status. Possible values include: "Error", "Warning", "Information". - Default value: "Information". + :ivar level: Level of the status. Known values are: "Error", "Warning", and "Information". :vartype level: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.LevelType :ivar message: Detailed message of the status from the Extension. :vartype message: str @@ -572,11 +549,11 @@ class ExtensionStatus(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'level': {'key': 'level', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'time': {'key': 'time', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "display_status": {"key": "displayStatus", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "time": {"key": "time", "type": "str"}, } def __init__( @@ -584,18 +561,17 @@ def __init__( *, code: Optional[str] = None, display_status: Optional[str] = None, - level: Optional[Union[str, "LevelType"]] = "Information", + level: Union[str, "_models.LevelType"] = "Information", message: Optional[str] = None, time: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword code: Status code provided by the Extension. :paramtype code: str :keyword display_status: Short description of status of the extension. :paramtype display_status: str - :keyword level: Level of the status. Possible values include: "Error", "Warning", - "Information". Default value: "Information". + :keyword level: Level of the status. Known values are: "Error", "Warning", and "Information". :paramtype level: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.LevelType :keyword message: Detailed message of the status from the Extension. @@ -603,7 +579,7 @@ def __init__( :keyword time: DateLiteral (per ISO8601) noting the time of installation status. :paramtype time: str """ - super(ExtensionStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.display_status = display_status self.level = level @@ -611,7 +587,7 @@ def __init__( self.time = time -class ExtensionType(msrest.serialization.Model): +class ExtensionType(_serialization.Model): """Represents an Extension Type. Variables are only populated by the server, and will be ignored when sending a request. @@ -620,7 +596,7 @@ class ExtensionType(msrest.serialization.Model): :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SystemData :ivar release_trains: Extension release train: preview or stable. :vartype release_trains: list[str] - :ivar cluster_types: Cluster types. Possible values include: "connectedClusters", + :ivar cluster_types: Cluster types. Known values are: "connectedClusters" and "managedClusters". :vartype cluster_types: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ClusterTypes @@ -630,33 +606,29 @@ class ExtensionType(msrest.serialization.Model): """ _validation = { - 'system_data': {'readonly': True}, - 'release_trains': {'readonly': True}, - 'cluster_types': {'readonly': True}, - 'supported_scopes': {'readonly': True}, + "system_data": {"readonly": True}, + "release_trains": {"readonly": True}, + "cluster_types": {"readonly": True}, + "supported_scopes": {"readonly": True}, } _attribute_map = { - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'release_trains': {'key': 'properties.releaseTrains', 'type': '[str]'}, - 'cluster_types': {'key': 'properties.clusterTypes', 'type': 'str'}, - 'supported_scopes': {'key': 'properties.supportedScopes', 'type': 'SupportedScopes'}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "release_trains": {"key": "properties.releaseTrains", "type": "[str]"}, + "cluster_types": {"key": "properties.clusterTypes", "type": "str"}, + "supported_scopes": {"key": "properties.supportedScopes", "type": "SupportedScopes"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ExtensionType, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.system_data = None self.release_trains = None self.cluster_types = None self.supported_scopes = None -class ExtensionTypeList(msrest.serialization.Model): +class ExtensionTypeList(_serialization.Model): """List Extension Types. :ivar value: The list of Extension Types. @@ -667,17 +639,13 @@ class ExtensionTypeList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ExtensionType]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ExtensionType]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ExtensionType"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + self, *, value: Optional[List["_models.ExtensionType"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: The list of Extension Types. :paramtype value: @@ -685,12 +653,12 @@ def __init__( :keyword next_link: The link to fetch the next page of Extension Types. :paramtype next_link: str """ - super(ExtensionTypeList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ExtensionVersionList(msrest.serialization.Model): +class ExtensionVersionList(_serialization.Model): """List versions for an Extension. Variables are only populated by the server, and will be ignored when sending a request. @@ -705,22 +673,22 @@ class ExtensionVersionList(msrest.serialization.Model): """ _validation = { - 'system_data': {'readonly': True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'versions': {'key': 'versions', 'type': '[ExtensionVersionListVersionsItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "versions": {"key": "versions", "type": "[ExtensionVersionListVersionsItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } def __init__( self, *, - versions: Optional[List["ExtensionVersionListVersionsItem"]] = None, + versions: Optional[List["_models.ExtensionVersionListVersionsItem"]] = None, next_link: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword versions: Versions available for this Extension Type. :paramtype versions: @@ -728,13 +696,13 @@ def __init__( :keyword next_link: The link to fetch the next page of Extension Types. :paramtype next_link: str """ - super(ExtensionVersionList, self).__init__(**kwargs) + super().__init__(**kwargs) self.versions = versions self.next_link = next_link self.system_data = None -class ExtensionVersionListVersionsItem(msrest.serialization.Model): +class ExtensionVersionListVersionsItem(_serialization.Model): """ExtensionVersionListVersionsItem. :ivar release_train: The release train for this Extension Type. @@ -744,29 +712,25 @@ class ExtensionVersionListVersionsItem(msrest.serialization.Model): """ _attribute_map = { - 'release_train': {'key': 'releaseTrain', 'type': 'str'}, - 'versions': {'key': 'versions', 'type': '[str]'}, + "release_train": {"key": "releaseTrain", "type": "str"}, + "versions": {"key": "versions", "type": "[str]"}, } def __init__( - self, - *, - release_train: Optional[str] = None, - versions: Optional[List[str]] = None, - **kwargs - ): + self, *, release_train: Optional[str] = None, versions: Optional[List[str]] = None, **kwargs: Any + ) -> None: """ :keyword release_train: The release train for this Extension Type. :paramtype release_train: str :keyword versions: Versions available for this Extension Type and release train. :paramtype versions: list[str] """ - super(ExtensionVersionListVersionsItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.release_train = release_train self.versions = versions -class FluxConfiguration(ProxyResource): +class FluxConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes """The Flux Configuration object returned in Get & Put response. Variables are only populated by the server, and will be ignored when sending a request. @@ -782,14 +746,13 @@ class FluxConfiguration(ProxyResource): :ivar system_data: Top level metadata https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SystemData - :ivar scope: Scope at which the operator will be installed. Possible values include: "cluster", - "namespace". Default value: "cluster". + :ivar scope: Scope at which the operator will be installed. Known values are: "cluster" and + "namespace". :vartype scope: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ScopeType :ivar namespace: The namespace to which this configuration is installed to. Maximum of 253 lower case alphanumeric characters, hyphen and period only. :vartype namespace: str - :ivar source_kind: Source Kind to pull the configuration data from. Possible values include: - "GitRepository". + :ivar source_kind: Source Kind to pull the configuration data from. "GitRepository" :vartype source_kind: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceKindType :ivar suspend: Whether this configuration should suspend its reconciliation of its @@ -819,12 +782,12 @@ class FluxConfiguration(ProxyResource): cluster. :vartype last_source_synced_at: ~datetime.datetime :ivar compliance_state: Combined status of the Flux Kubernetes resources created by the - fluxConfiguration or created by the managed objects. Possible values include: "Compliant", - "Non-Compliant", "Pending", "Suspended", "Unknown". Default value: "Unknown". + fluxConfiguration or created by the managed objects. Known values are: "Compliant", + "Non-Compliant", "Pending", "Suspended", and "Unknown". :vartype compliance_state: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxComplianceState - :ivar provisioning_state: Status of the creation of the fluxConfiguration. Possible values - include: "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting". + :ivar provisioning_state: Status of the creation of the fluxConfiguration. Known values are: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ProvisioningState :ivar error_message: Error message returned to the user in the case of provisioning failure. @@ -832,62 +795,61 @@ class FluxConfiguration(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'statuses': {'readonly': True}, - 'repository_public_key': {'readonly': True}, - 'last_source_synced_commit_id': {'readonly': True}, - 'last_source_synced_at': {'readonly': True}, - 'compliance_state': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'error_message': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "statuses": {"readonly": True}, + "repository_public_key": {"readonly": True}, + "last_source_synced_commit_id": {"readonly": True}, + "last_source_synced_at": {"readonly": True}, + "compliance_state": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "error_message": {"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'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'namespace': {'key': 'properties.namespace', 'type': 'str'}, - 'source_kind': {'key': 'properties.sourceKind', 'type': 'str'}, - 'suspend': {'key': 'properties.suspend', 'type': 'bool'}, - 'git_repository': {'key': 'properties.gitRepository', 'type': 'GitRepositoryDefinition'}, - 'kustomizations': {'key': 'properties.kustomizations', 'type': '{KustomizationDefinition}'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, - 'statuses': {'key': 'properties.statuses', 'type': '[ObjectStatusDefinition]'}, - 'repository_public_key': {'key': 'properties.repositoryPublicKey', 'type': 'str'}, - 'last_source_synced_commit_id': {'key': 'properties.lastSourceSyncedCommitId', 'type': 'str'}, - 'last_source_synced_at': {'key': 'properties.lastSourceSyncedAt', 'type': 'iso-8601'}, - 'compliance_state': {'key': 'properties.complianceState', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'error_message': {'key': 'properties.errorMessage', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "scope": {"key": "properties.scope", "type": "str"}, + "namespace": {"key": "properties.namespace", "type": "str"}, + "source_kind": {"key": "properties.sourceKind", "type": "str"}, + "suspend": {"key": "properties.suspend", "type": "bool"}, + "git_repository": {"key": "properties.gitRepository", "type": "GitRepositoryDefinition"}, + "kustomizations": {"key": "properties.kustomizations", "type": "{KustomizationDefinition}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "statuses": {"key": "properties.statuses", "type": "[ObjectStatusDefinition]"}, + "repository_public_key": {"key": "properties.repositoryPublicKey", "type": "str"}, + "last_source_synced_commit_id": {"key": "properties.lastSourceSyncedCommitId", "type": "str"}, + "last_source_synced_at": {"key": "properties.lastSourceSyncedAt", "type": "iso-8601"}, + "compliance_state": {"key": "properties.complianceState", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "error_message": {"key": "properties.errorMessage", "type": "str"}, } def __init__( self, *, - scope: Optional[Union[str, "ScopeType"]] = "cluster", - namespace: Optional[str] = "default", - source_kind: Optional[Union[str, "SourceKindType"]] = None, - suspend: Optional[bool] = False, - git_repository: Optional["GitRepositoryDefinition"] = None, - kustomizations: Optional[Dict[str, "KustomizationDefinition"]] = None, + scope: Union[str, "_models.ScopeType"] = "cluster", + namespace: str = "default", + source_kind: Optional[Union[str, "_models.SourceKindType"]] = None, + suspend: bool = False, + git_repository: Optional["_models.GitRepositoryDefinition"] = None, + kustomizations: Optional[Dict[str, "_models.KustomizationDefinition"]] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword scope: Scope at which the operator will be installed. Possible values include: - "cluster", "namespace". Default value: "cluster". + :keyword scope: Scope at which the operator will be installed. Known values are: "cluster" and + "namespace". :paramtype scope: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ScopeType :keyword namespace: The namespace to which this configuration is installed to. Maximum of 253 lower case alphanumeric characters, hyphen and period only. :paramtype namespace: str - :keyword source_kind: Source Kind to pull the configuration data from. Possible values include: - "GitRepository". + :keyword source_kind: Source Kind to pull the configuration data from. "GitRepository" :paramtype source_kind: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceKindType :keyword suspend: Whether this configuration should suspend its reconciliation of its @@ -904,7 +866,7 @@ def __init__( for the configuration. :paramtype configuration_protected_settings: dict[str, str] """ - super(FluxConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.scope = scope self.namespace = namespace @@ -922,11 +884,10 @@ def __init__( self.error_message = None -class FluxConfigurationPatch(msrest.serialization.Model): +class FluxConfigurationPatch(_serialization.Model): """The Flux Configuration Patch Request object. - :ivar source_kind: Source Kind to pull the configuration data from. Possible values include: - "GitRepository". + :ivar source_kind: Source Kind to pull the configuration data from. "GitRepository" :vartype source_kind: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceKindType :ivar suspend: Whether this configuration should suspend its reconciliation of its @@ -945,26 +906,25 @@ class FluxConfigurationPatch(msrest.serialization.Model): """ _attribute_map = { - 'source_kind': {'key': 'properties.sourceKind', 'type': 'str'}, - 'suspend': {'key': 'properties.suspend', 'type': 'bool'}, - 'git_repository': {'key': 'properties.gitRepository', 'type': 'GitRepositoryDefinition'}, - 'kustomizations': {'key': 'properties.kustomizations', 'type': '{KustomizationDefinition}'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + "source_kind": {"key": "properties.sourceKind", "type": "str"}, + "suspend": {"key": "properties.suspend", "type": "bool"}, + "git_repository": {"key": "properties.gitRepository", "type": "GitRepositoryDefinition"}, + "kustomizations": {"key": "properties.kustomizations", "type": "{KustomizationDefinition}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, } def __init__( self, *, - source_kind: Optional[Union[str, "SourceKindType"]] = None, - suspend: Optional[bool] = False, - git_repository: Optional["GitRepositoryDefinition"] = None, - kustomizations: Optional[Dict[str, "KustomizationDefinition"]] = None, + source_kind: Optional[Union[str, "_models.SourceKindType"]] = None, + suspend: bool = False, + git_repository: Optional["_models.GitRepositoryDefinition"] = None, + kustomizations: Optional[Dict[str, "_models.KustomizationDefinition"]] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword source_kind: Source Kind to pull the configuration data from. Possible values include: - "GitRepository". + :keyword source_kind: Source Kind to pull the configuration data from. "GitRepository" :paramtype source_kind: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceKindType :keyword suspend: Whether this configuration should suspend its reconciliation of its @@ -981,7 +941,7 @@ def __init__( for the configuration. :paramtype configuration_protected_settings: dict[str, str] """ - super(FluxConfigurationPatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_kind = source_kind self.suspend = suspend self.git_repository = git_repository @@ -989,8 +949,9 @@ def __init__( self.configuration_protected_settings = configuration_protected_settings -class FluxConfigurationsList(msrest.serialization.Model): - """Result of the request to list Flux Configurations. It contains a list of FluxConfiguration objects and a URL link to get the next set of results. +class FluxConfigurationsList(_serialization.Model): + """Result of the request to list Flux Configurations. It contains a list of FluxConfiguration + objects and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -1002,37 +963,33 @@ class FluxConfigurationsList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FluxConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[FluxConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FluxConfigurationsList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class GitRepositoryDefinition(msrest.serialization.Model): +class GitRepositoryDefinition(_serialization.Model): """Parameters to reconcile to the GitRepository source kind type. :ivar url: The URL to sync for the flux configuration git repository. :vartype url: str :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository source with the remote. - :vartype timeout_in_seconds: long + :vartype timeout_in_seconds: int :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster git repository source with the remote. - :vartype sync_interval_in_seconds: long + :vartype sync_interval_in_seconds: int :ivar repository_ref: The source reference for the GitRepository object. :vartype repository_ref: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.RepositoryRefDefinition @@ -1051,38 +1008,38 @@ class GitRepositoryDefinition(msrest.serialization.Model): """ _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, - 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, - 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, - 'repository_ref': {'key': 'repositoryRef', 'type': 'RepositoryRefDefinition'}, - 'ssh_known_hosts': {'key': 'sshKnownHosts', 'type': 'str'}, - 'https_user': {'key': 'httpsUser', 'type': 'str'}, - 'https_ca_file': {'key': 'httpsCAFile', 'type': 'str'}, - 'local_auth_ref': {'key': 'localAuthRef', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "repository_ref": {"key": "repositoryRef", "type": "RepositoryRefDefinition"}, + "ssh_known_hosts": {"key": "sshKnownHosts", "type": "str"}, + "https_user": {"key": "httpsUser", "type": "str"}, + "https_ca_file": {"key": "httpsCAFile", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, } def __init__( self, *, url: Optional[str] = None, - timeout_in_seconds: Optional[int] = 600, - sync_interval_in_seconds: Optional[int] = 600, - repository_ref: Optional["RepositoryRefDefinition"] = None, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, + repository_ref: Optional["_models.RepositoryRefDefinition"] = None, ssh_known_hosts: Optional[str] = None, https_user: Optional[str] = None, https_ca_file: Optional[str] = None, local_auth_ref: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword url: The URL to sync for the flux configuration git repository. :paramtype url: str :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository source with the remote. - :paramtype timeout_in_seconds: long + :paramtype timeout_in_seconds: int :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster git repository source with the remote. - :paramtype sync_interval_in_seconds: long + :paramtype sync_interval_in_seconds: int :keyword repository_ref: The source reference for the GitRepository object. :paramtype repository_ref: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.RepositoryRefDefinition @@ -1099,7 +1056,7 @@ def __init__( authentication secret rather than the managed or user-provided configuration secrets. :paramtype local_auth_ref: str """ - super(GitRepositoryDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url self.timeout_in_seconds = timeout_in_seconds self.sync_interval_in_seconds = sync_interval_in_seconds @@ -1110,7 +1067,7 @@ def __init__( self.local_auth_ref = local_auth_ref -class HelmOperatorProperties(msrest.serialization.Model): +class HelmOperatorProperties(_serialization.Model): """Properties for Helm operator. :ivar chart_version: Version of the operator Helm chart. @@ -1120,79 +1077,75 @@ class HelmOperatorProperties(msrest.serialization.Model): """ _attribute_map = { - 'chart_version': {'key': 'chartVersion', 'type': 'str'}, - 'chart_values': {'key': 'chartValues', 'type': 'str'}, + "chart_version": {"key": "chartVersion", "type": "str"}, + "chart_values": {"key": "chartValues", "type": "str"}, } def __init__( - self, - *, - chart_version: Optional[str] = None, - chart_values: Optional[str] = None, - **kwargs - ): + self, *, chart_version: Optional[str] = None, chart_values: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword chart_version: Version of the operator Helm chart. :paramtype chart_version: str :keyword chart_values: Values override for the operator Helm chart. :paramtype chart_values: str """ - super(HelmOperatorProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.chart_version = chart_version self.chart_values = chart_values -class HelmReleasePropertiesDefinition(msrest.serialization.Model): +class HelmReleasePropertiesDefinition(_serialization.Model): """HelmReleasePropertiesDefinition. :ivar last_revision_applied: The revision number of the last released object change. - :vartype last_revision_applied: long + :vartype last_revision_applied: int :ivar helm_chart_ref: The reference to the HelmChart object used as the source to this HelmRelease. :vartype helm_chart_ref: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ObjectReferenceDefinition :ivar failure_count: Total number of times that the HelmRelease failed to install or upgrade. - :vartype failure_count: long + :vartype failure_count: int :ivar install_failure_count: Number of times that the HelmRelease failed to install. - :vartype install_failure_count: long + :vartype install_failure_count: int :ivar upgrade_failure_count: Number of times that the HelmRelease failed to upgrade. - :vartype upgrade_failure_count: long + :vartype upgrade_failure_count: int """ _attribute_map = { - 'last_revision_applied': {'key': 'lastRevisionApplied', 'type': 'long'}, - 'helm_chart_ref': {'key': 'helmChartRef', 'type': 'ObjectReferenceDefinition'}, - 'failure_count': {'key': 'failureCount', 'type': 'long'}, - 'install_failure_count': {'key': 'installFailureCount', 'type': 'long'}, - 'upgrade_failure_count': {'key': 'upgradeFailureCount', 'type': 'long'}, + "last_revision_applied": {"key": "lastRevisionApplied", "type": "int"}, + "helm_chart_ref": {"key": "helmChartRef", "type": "ObjectReferenceDefinition"}, + "failure_count": {"key": "failureCount", "type": "int"}, + "install_failure_count": {"key": "installFailureCount", "type": "int"}, + "upgrade_failure_count": {"key": "upgradeFailureCount", "type": "int"}, } def __init__( self, *, last_revision_applied: Optional[int] = None, - helm_chart_ref: Optional["ObjectReferenceDefinition"] = None, + helm_chart_ref: Optional["_models.ObjectReferenceDefinition"] = None, failure_count: Optional[int] = None, install_failure_count: Optional[int] = None, upgrade_failure_count: Optional[int] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword last_revision_applied: The revision number of the last released object change. - :paramtype last_revision_applied: long + :paramtype last_revision_applied: int :keyword helm_chart_ref: The reference to the HelmChart object used as the source to this HelmRelease. :paramtype helm_chart_ref: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ObjectReferenceDefinition :keyword failure_count: Total number of times that the HelmRelease failed to install or upgrade. - :paramtype failure_count: long + :paramtype failure_count: int :keyword install_failure_count: Number of times that the HelmRelease failed to install. - :paramtype install_failure_count: long + :paramtype install_failure_count: int :keyword upgrade_failure_count: Number of times that the HelmRelease failed to upgrade. - :paramtype upgrade_failure_count: long + :paramtype upgrade_failure_count: int """ - super(HelmReleasePropertiesDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_revision_applied = last_revision_applied self.helm_chart_ref = helm_chart_ref self.failure_count = failure_count @@ -1200,7 +1153,7 @@ def __init__( self.upgrade_failure_count = upgrade_failure_count -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1209,41 +1162,35 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :ivar type: The identity type. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: """ - :keyword type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :keyword type: The identity type. Default value is "SystemAssigned". :paramtype type: str """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class KustomizationDefinition(msrest.serialization.Model): - """The Kustomization defining how to reconcile the artifact pulled by the source type on the cluster. +class KustomizationDefinition(_serialization.Model): + """The Kustomization defining how to reconcile the artifact pulled by the source type on the + cluster. :ivar path: The path in the source reference to reconcile on the cluster. :vartype path: str @@ -1253,19 +1200,19 @@ class KustomizationDefinition(msrest.serialization.Model): list[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.DependsOnDefinition] :ivar timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the cluster. - :vartype timeout_in_seconds: long + :vartype timeout_in_seconds: int :ivar sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster. - :vartype sync_interval_in_seconds: long + :vartype sync_interval_in_seconds: int :ivar retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster in the event of failure on reconciliation. - :vartype retry_interval_in_seconds: long + :vartype retry_interval_in_seconds: int :ivar prune: Enable/disable garbage collections of Kubernetes objects created by this Kustomization. :vartype prune: bool :ivar validation: Specify whether to validate the Kubernetes objects referenced in the - Kustomization before applying them to the cluster. Possible values include: "none", "client", - "server". Default value: "none". + Kustomization before applying them to the cluster. Known values are: "none", "client", and + "server". :vartype validation: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.KustomizationValidationType :ivar force: Enable/disable re-creating Kubernetes resources on the cluster when patching fails @@ -1274,29 +1221,29 @@ class KustomizationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'depends_on': {'key': 'dependsOn', 'type': '[DependsOnDefinition]'}, - 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, - 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, - 'retry_interval_in_seconds': {'key': 'retryIntervalInSeconds', 'type': 'long'}, - 'prune': {'key': 'prune', 'type': 'bool'}, - 'validation': {'key': 'validation', 'type': 'str'}, - 'force': {'key': 'force', 'type': 'bool'}, + "path": {"key": "path", "type": "str"}, + "depends_on": {"key": "dependsOn", "type": "[DependsOnDefinition]"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "retry_interval_in_seconds": {"key": "retryIntervalInSeconds", "type": "int"}, + "prune": {"key": "prune", "type": "bool"}, + "validation": {"key": "validation", "type": "str"}, + "force": {"key": "force", "type": "bool"}, } def __init__( self, *, - path: Optional[str] = "", - depends_on: Optional[List["DependsOnDefinition"]] = None, - timeout_in_seconds: Optional[int] = 600, - sync_interval_in_seconds: Optional[int] = 600, + path: str = "", + depends_on: Optional[List["_models.DependsOnDefinition"]] = None, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, retry_interval_in_seconds: Optional[int] = None, - prune: Optional[bool] = False, - validation: Optional[Union[str, "KustomizationValidationType"]] = "none", - force: Optional[bool] = False, - **kwargs - ): + prune: bool = False, + validation: Union[str, "_models.KustomizationValidationType"] = "none", + force: bool = False, + **kwargs: Any + ) -> None: """ :keyword path: The path in the source reference to reconcile on the cluster. :paramtype path: str @@ -1306,26 +1253,26 @@ def __init__( list[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.DependsOnDefinition] :keyword timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the cluster. - :paramtype timeout_in_seconds: long + :paramtype timeout_in_seconds: int :keyword sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster. - :paramtype sync_interval_in_seconds: long + :paramtype sync_interval_in_seconds: int :keyword retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster in the event of failure on reconciliation. - :paramtype retry_interval_in_seconds: long + :paramtype retry_interval_in_seconds: int :keyword prune: Enable/disable garbage collections of Kubernetes objects created by this Kustomization. :paramtype prune: bool :keyword validation: Specify whether to validate the Kubernetes objects referenced in the - Kustomization before applying them to the cluster. Possible values include: "none", "client", - "server". Default value: "none". + Kustomization before applying them to the cluster. Known values are: "none", "client", and + "server". :paramtype validation: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.KustomizationValidationType :keyword force: Enable/disable re-creating Kubernetes resources on the cluster when patching fails due to an immutable field change. :paramtype force: bool """ - super(KustomizationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.depends_on = depends_on self.timeout_in_seconds = timeout_in_seconds @@ -1336,7 +1283,7 @@ def __init__( self.force = force -class ObjectReferenceDefinition(msrest.serialization.Model): +class ObjectReferenceDefinition(_serialization.Model): """Object reference to a Kubernetes object on a cluster. :ivar name: Name of the object. @@ -1346,29 +1293,23 @@ class ObjectReferenceDefinition(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, namespace: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: Name of the object. :paramtype name: str :keyword namespace: Namespace of the object. :paramtype namespace: str """ - super(ObjectReferenceDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.namespace = namespace -class ObjectStatusConditionDefinition(msrest.serialization.Model): +class ObjectStatusConditionDefinition(_serialization.Model): """Status condition of Kubernetes object. :ivar last_transition_time: Last time this status condition has changed. @@ -1384,11 +1325,11 @@ class ObjectStatusConditionDefinition(msrest.serialization.Model): """ _attribute_map = { - 'last_transition_time': {'key': 'lastTransitionTime', 'type': 'iso-8601'}, - 'message': {'key': 'message', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "last_transition_time": {"key": "lastTransitionTime", "type": "iso-8601"}, + "message": {"key": "message", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -1399,8 +1340,8 @@ def __init__( reason: Optional[str] = None, status: Optional[str] = None, type: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword last_transition_time: Last time this status condition has changed. :paramtype last_transition_time: ~datetime.datetime @@ -1413,7 +1354,7 @@ def __init__( :keyword type: Object status condition type for this object. :paramtype type: str """ - super(ObjectStatusConditionDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_transition_time = last_transition_time self.message = message self.reason = reason @@ -1421,7 +1362,7 @@ def __init__( self.type = type -class ObjectStatusDefinition(msrest.serialization.Model): +class ObjectStatusDefinition(_serialization.Model): """Statuses of objects deployed by the user-specified kustomizations from the git repository. :ivar name: Name of the applied object. @@ -1431,8 +1372,8 @@ class ObjectStatusDefinition(msrest.serialization.Model): :ivar kind: Kind of the applied object. :vartype kind: str :ivar compliance_state: Compliance state of the applied object showing whether the applied - object has come into a ready state on the cluster. Possible values include: "Compliant", - "Non-Compliant", "Pending", "Suspended", "Unknown". Default value: "Unknown". + object has come into a ready state on the cluster. Known values are: "Compliant", + "Non-Compliant", "Pending", "Suspended", and "Unknown". :vartype compliance_state: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxComplianceState :ivar applied_by: Object reference to the Kustomization that applied this object. @@ -1448,13 +1389,13 @@ class ObjectStatusDefinition(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'compliance_state': {'key': 'complianceState', 'type': 'str'}, - 'applied_by': {'key': 'appliedBy', 'type': 'ObjectReferenceDefinition'}, - 'status_conditions': {'key': 'statusConditions', 'type': '[ObjectStatusConditionDefinition]'}, - 'helm_release_properties': {'key': 'helmReleaseProperties', 'type': 'HelmReleasePropertiesDefinition'}, + "name": {"key": "name", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "compliance_state": {"key": "complianceState", "type": "str"}, + "applied_by": {"key": "appliedBy", "type": "ObjectReferenceDefinition"}, + "status_conditions": {"key": "statusConditions", "type": "[ObjectStatusConditionDefinition]"}, + "helm_release_properties": {"key": "helmReleaseProperties", "type": "HelmReleasePropertiesDefinition"}, } def __init__( @@ -1463,12 +1404,12 @@ def __init__( name: Optional[str] = None, namespace: Optional[str] = None, kind: Optional[str] = None, - compliance_state: Optional[Union[str, "FluxComplianceState"]] = "Unknown", - applied_by: Optional["ObjectReferenceDefinition"] = None, - status_conditions: Optional[List["ObjectStatusConditionDefinition"]] = None, - helm_release_properties: Optional["HelmReleasePropertiesDefinition"] = None, - **kwargs - ): + compliance_state: Union[str, "_models.FluxComplianceState"] = "Unknown", + applied_by: Optional["_models.ObjectReferenceDefinition"] = None, + status_conditions: Optional[List["_models.ObjectStatusConditionDefinition"]] = None, + helm_release_properties: Optional["_models.HelmReleasePropertiesDefinition"] = None, + **kwargs: Any + ) -> None: """ :keyword name: Name of the applied object. :paramtype name: str @@ -1477,8 +1418,8 @@ def __init__( :keyword kind: Kind of the applied object. :paramtype kind: str :keyword compliance_state: Compliance state of the applied object showing whether the applied - object has come into a ready state on the cluster. Possible values include: "Compliant", - "Non-Compliant", "Pending", "Suspended", "Unknown". Default value: "Unknown". + object has come into a ready state on the cluster. Known values are: "Compliant", + "Non-Compliant", "Pending", "Suspended", and "Unknown". :paramtype compliance_state: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxComplianceState :keyword applied_by: Object reference to the Kustomization that applied this object. @@ -1492,7 +1433,7 @@ def __init__( :paramtype helm_release_properties: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.HelmReleasePropertiesDefinition """ - super(ObjectStatusDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.namespace = namespace self.kind = kind @@ -1502,7 +1443,7 @@ def __init__( self.helm_release_properties = helm_release_properties -class OperationStatusList(msrest.serialization.Model): +class OperationStatusList(_serialization.Model): """The async operations in progress, in the cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -1515,27 +1456,23 @@ class OperationStatusList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationStatusResult]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OperationStatusResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationStatusList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class OperationStatusResult(msrest.serialization.Model): +class OperationStatusResult(_serialization.Model): """The current status of an async operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1546,7 +1483,7 @@ class OperationStatusResult(msrest.serialization.Model): :vartype id: str :ivar name: Name of the async operation. :vartype name: str - :ivar status: Required. Operation status. + :ivar status: Operation status. Required. :vartype status: str :ivar properties: Additional information, if available. :vartype properties: dict[str, str] @@ -1555,38 +1492,38 @@ class OperationStatusResult(msrest.serialization.Model): """ _validation = { - 'status': {'required': True}, - 'error': {'readonly': True}, + "status": {"required": True}, + "error": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, + "error": {"key": "error", "type": "ErrorDetail"}, } def __init__( self, *, status: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, properties: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: Fully qualified ID for the async operation. :paramtype id: str :keyword name: Name of the async operation. :paramtype name: str - :keyword status: Required. Operation status. + :keyword status: Operation status. Required. :paramtype status: str :keyword properties: Additional information, if available. :paramtype properties: dict[str, str] """ - super(OperationStatusResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.status = status @@ -1594,7 +1531,7 @@ def __init__( self.error = None -class PatchExtension(msrest.serialization.Model): +class PatchExtension(_serialization.Model): """The Extension Patch Request object. :ivar auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade @@ -1615,23 +1552,23 @@ class PatchExtension(msrest.serialization.Model): """ _attribute_map = { - 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, - 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "configuration_settings": {"key": "properties.configurationSettings", "type": "{str}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, } def __init__( self, *, - auto_upgrade_minor_version: Optional[bool] = True, - release_train: Optional[str] = "Stable", + auto_upgrade_minor_version: bool = True, + release_train: str = "Stable", version: Optional[str] = None, configuration_settings: Optional[Dict[str, str]] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade of minor version, or not. @@ -1649,7 +1586,7 @@ def __init__( name-value pairs for configuring this extension. :paramtype configuration_protected_settings: dict[str, str] """ - super(PatchExtension, self).__init__(**kwargs) + super().__init__(**kwargs) self.auto_upgrade_minor_version = auto_upgrade_minor_version self.release_train = release_train self.version = version @@ -1657,7 +1594,7 @@ def __init__( self.configuration_protected_settings = configuration_protected_settings -class RepositoryRefDefinition(msrest.serialization.Model): +class RepositoryRefDefinition(_serialization.Model): """The source reference for the GitRepository object. :ivar branch: The git repository branch name to checkout. @@ -1673,10 +1610,10 @@ class RepositoryRefDefinition(msrest.serialization.Model): """ _attribute_map = { - 'branch': {'key': 'branch', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'semver': {'key': 'semver', 'type': 'str'}, - 'commit': {'key': 'commit', 'type': 'str'}, + "branch": {"key": "branch", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "semver": {"key": "semver", "type": "str"}, + "commit": {"key": "commit", "type": "str"}, } def __init__( @@ -1686,8 +1623,8 @@ def __init__( tag: Optional[str] = None, semver: Optional[str] = None, commit: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword branch: The git repository branch name to checkout. :paramtype branch: str @@ -1700,14 +1637,14 @@ def __init__( to be valid. This takes precedence over semver. :paramtype commit: str """ - super(RepositoryRefDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.branch = branch self.tag = tag self.semver = semver self.commit = commit -class ResourceProviderOperation(msrest.serialization.Model): +class ResourceProviderOperation(_serialization.Model): """Supported operation of this resource provider. Variables are only populated by the server, and will be ignored when sending a request. @@ -1724,24 +1661,24 @@ class ResourceProviderOperation(msrest.serialization.Model): """ _validation = { - 'is_data_action': {'readonly': True}, - 'origin': {'readonly': True}, + "is_data_action": {"readonly": True}, + "origin": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'origin': {'key': 'origin', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "ResourceProviderOperationDisplay"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "origin": {"key": "origin", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["ResourceProviderOperationDisplay"] = None, - **kwargs - ): + display: Optional["_models.ResourceProviderOperationDisplay"] = None, + **kwargs: Any + ) -> None: """ :keyword name: Operation name, in format of {provider}/{resource}/{operation}. :paramtype name: str @@ -1749,14 +1686,14 @@ def __init__( :paramtype display: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ResourceProviderOperationDisplay """ - super(ResourceProviderOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.is_data_action = None self.origin = None -class ResourceProviderOperationDisplay(msrest.serialization.Model): +class ResourceProviderOperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Resource provider: Microsoft KubernetesConfiguration. @@ -1770,10 +1707,10 @@ class ResourceProviderOperationDisplay(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__( @@ -1783,8 +1720,8 @@ def __init__( resource: Optional[str] = None, operation: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword provider: Resource provider: Microsoft KubernetesConfiguration. :paramtype provider: str @@ -1795,14 +1732,14 @@ def __init__( :keyword description: Description of this operation. :paramtype description: str """ - super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class ResourceProviderOperationList(msrest.serialization.Model): +class ResourceProviderOperationList(_serialization.Model): """Result of the request to list operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -1815,31 +1752,26 @@ class ResourceProviderOperationList(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceProviderOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceProviderOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceProviderOperation"]] = None, **kwargs: Any) -> None: """ :keyword value: List of operations supported by this resource provider. :paramtype value: list[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ResourceProviderOperation] """ - super(ResourceProviderOperationList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class Scope(msrest.serialization.Model): +class Scope(_serialization.Model): """Scope of the extension. It can be either Cluster or Namespace; but not both. :ivar cluster: Specifies that the scope of the extension is Cluster. @@ -1850,17 +1782,17 @@ class Scope(msrest.serialization.Model): """ _attribute_map = { - 'cluster': {'key': 'cluster', 'type': 'ScopeCluster'}, - 'namespace': {'key': 'namespace', 'type': 'ScopeNamespace'}, + "cluster": {"key": "cluster", "type": "ScopeCluster"}, + "namespace": {"key": "namespace", "type": "ScopeNamespace"}, } def __init__( self, *, - cluster: Optional["ScopeCluster"] = None, - namespace: Optional["ScopeNamespace"] = None, - **kwargs - ): + cluster: Optional["_models.ScopeCluster"] = None, + namespace: Optional["_models.ScopeNamespace"] = None, + **kwargs: Any + ) -> None: """ :keyword cluster: Specifies that the scope of the extension is Cluster. :paramtype cluster: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ScopeCluster @@ -1868,12 +1800,12 @@ def __init__( :paramtype namespace: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ScopeNamespace """ - super(Scope, self).__init__(**kwargs) + super().__init__(**kwargs) self.cluster = cluster self.namespace = namespace -class ScopeCluster(msrest.serialization.Model): +class ScopeCluster(_serialization.Model): """Specifies that the scope of the extension is Cluster. :ivar release_namespace: Namespace where the extension Release must be placed, for a Cluster @@ -1882,25 +1814,20 @@ class ScopeCluster(msrest.serialization.Model): """ _attribute_map = { - 'release_namespace': {'key': 'releaseNamespace', 'type': 'str'}, + "release_namespace": {"key": "releaseNamespace", "type": "str"}, } - def __init__( - self, - *, - release_namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, release_namespace: Optional[str] = None, **kwargs: Any) -> None: """ :keyword release_namespace: Namespace where the extension Release must be placed, for a Cluster scoped extension. If this namespace does not exist, it will be created. :paramtype release_namespace: str """ - super(ScopeCluster, self).__init__(**kwargs) + super().__init__(**kwargs) self.release_namespace = release_namespace -class ScopeNamespace(msrest.serialization.Model): +class ScopeNamespace(_serialization.Model): """Specifies that the scope of the extension is Namespace. :ivar target_namespace: Namespace where the extension will be created for an Namespace scoped @@ -1909,25 +1836,20 @@ class ScopeNamespace(msrest.serialization.Model): """ _attribute_map = { - 'target_namespace': {'key': 'targetNamespace', 'type': 'str'}, + "target_namespace": {"key": "targetNamespace", "type": "str"}, } - def __init__( - self, - *, - target_namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_namespace: Optional[str] = None, **kwargs: Any) -> None: """ :keyword target_namespace: Namespace where the extension will be created for an Namespace scoped extension. If this namespace does not exist, it will be created. :paramtype target_namespace: str """ - super(ScopeNamespace, self).__init__(**kwargs) + super().__init__(**kwargs) self.target_namespace = target_namespace -class SourceControlConfiguration(ProxyResource): +class SourceControlConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes """The SourceControl Configuration object returned in Get & Put response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1951,7 +1873,7 @@ class SourceControlConfiguration(ProxyResource): :ivar operator_instance_name: Instance name of the operator - identifying the specific configuration. :vartype operator_instance_name: str - :ivar operator_type: Type of the operator. Possible values include: "Flux". + :ivar operator_type: Type of the operator. "Flux" :vartype operator_type: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.OperatorType :ivar operator_params: Any Parameters for the Operator instance in string format. @@ -1959,8 +1881,8 @@ class SourceControlConfiguration(ProxyResource): :ivar configuration_protected_settings: Name-value pairs of protected configuration settings for the configuration. :vartype configuration_protected_settings: dict[str, str] - :ivar operator_scope: Scope at which the operator will be installed. Possible values include: - "cluster", "namespace". Default value: "cluster". + :ivar operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". :vartype operator_scope: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.OperatorScopeType :ivar repository_public_key: Public Key associated with this SourceControl configuration @@ -1974,8 +1896,8 @@ class SourceControlConfiguration(ProxyResource): :ivar helm_operator_properties: Properties for Helm operator. :vartype helm_operator_properties: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.HelmOperatorProperties - :ivar provisioning_state: The provisioning state of the resource provider. Possible values - include: "Accepted", "Deleting", "Running", "Succeeded", "Failed". + :ivar provisioning_state: The provisioning state of the resource provider. Known values are: + "Accepted", "Deleting", "Running", "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ProvisioningStateType :ivar compliance_status: Compliance Status of the Configuration. @@ -1984,50 +1906,50 @@ class SourceControlConfiguration(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'repository_public_key': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'compliance_status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "repository_public_key": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "compliance_status": {"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'}, - 'repository_url': {'key': 'properties.repositoryUrl', 'type': 'str'}, - 'operator_namespace': {'key': 'properties.operatorNamespace', 'type': 'str'}, - 'operator_instance_name': {'key': 'properties.operatorInstanceName', 'type': 'str'}, - 'operator_type': {'key': 'properties.operatorType', 'type': 'str'}, - 'operator_params': {'key': 'properties.operatorParams', 'type': 'str'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, - 'operator_scope': {'key': 'properties.operatorScope', 'type': 'str'}, - 'repository_public_key': {'key': 'properties.repositoryPublicKey', 'type': 'str'}, - 'ssh_known_hosts_contents': {'key': 'properties.sshKnownHostsContents', 'type': 'str'}, - 'enable_helm_operator': {'key': 'properties.enableHelmOperator', 'type': 'bool'}, - 'helm_operator_properties': {'key': 'properties.helmOperatorProperties', 'type': 'HelmOperatorProperties'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'compliance_status': {'key': 'properties.complianceStatus', 'type': 'ComplianceStatus'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "repository_url": {"key": "properties.repositoryUrl", "type": "str"}, + "operator_namespace": {"key": "properties.operatorNamespace", "type": "str"}, + "operator_instance_name": {"key": "properties.operatorInstanceName", "type": "str"}, + "operator_type": {"key": "properties.operatorType", "type": "str"}, + "operator_params": {"key": "properties.operatorParams", "type": "str"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "operator_scope": {"key": "properties.operatorScope", "type": "str"}, + "repository_public_key": {"key": "properties.repositoryPublicKey", "type": "str"}, + "ssh_known_hosts_contents": {"key": "properties.sshKnownHostsContents", "type": "str"}, + "enable_helm_operator": {"key": "properties.enableHelmOperator", "type": "bool"}, + "helm_operator_properties": {"key": "properties.helmOperatorProperties", "type": "HelmOperatorProperties"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "compliance_status": {"key": "properties.complianceStatus", "type": "ComplianceStatus"}, } def __init__( self, *, repository_url: Optional[str] = None, - operator_namespace: Optional[str] = "default", + operator_namespace: str = "default", operator_instance_name: Optional[str] = None, - operator_type: Optional[Union[str, "OperatorType"]] = None, + operator_type: Optional[Union[str, "_models.OperatorType"]] = None, operator_params: Optional[str] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - operator_scope: Optional[Union[str, "OperatorScopeType"]] = "cluster", + operator_scope: Union[str, "_models.OperatorScopeType"] = "cluster", ssh_known_hosts_contents: Optional[str] = None, enable_helm_operator: Optional[bool] = None, - helm_operator_properties: Optional["HelmOperatorProperties"] = None, - **kwargs - ): + helm_operator_properties: Optional["_models.HelmOperatorProperties"] = None, + **kwargs: Any + ) -> None: """ :keyword repository_url: Url of the SourceControl Repository. :paramtype repository_url: str @@ -2037,7 +1959,7 @@ def __init__( :keyword operator_instance_name: Instance name of the operator - identifying the specific configuration. :paramtype operator_instance_name: str - :keyword operator_type: Type of the operator. Possible values include: "Flux". + :keyword operator_type: Type of the operator. "Flux" :paramtype operator_type: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.OperatorType :keyword operator_params: Any Parameters for the Operator instance in string format. @@ -2045,8 +1967,8 @@ def __init__( :keyword configuration_protected_settings: Name-value pairs of protected configuration settings for the configuration. :paramtype configuration_protected_settings: dict[str, str] - :keyword operator_scope: Scope at which the operator will be installed. Possible values - include: "cluster", "namespace". Default value: "cluster". + :keyword operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". :paramtype operator_scope: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.OperatorScopeType :keyword ssh_known_hosts_contents: Base64-encoded known_hosts contents containing public SSH @@ -2058,7 +1980,7 @@ def __init__( :paramtype helm_operator_properties: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.HelmOperatorProperties """ - super(SourceControlConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.repository_url = repository_url self.operator_namespace = operator_namespace @@ -2075,8 +1997,9 @@ def __init__( self.compliance_status = None -class SourceControlConfigurationList(msrest.serialization.Model): - """Result of the request to list Source Control Configurations. It contains a list of SourceControlConfiguration objects and a URL link to get the next set of results. +class SourceControlConfigurationList(_serialization.Model): + """Result of the request to list Source Control Configurations. It contains a list of + SourceControlConfiguration objects and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -2088,27 +2011,23 @@ class SourceControlConfigurationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SourceControlConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SourceControlConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SourceControlConfigurationList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SupportedScopes(msrest.serialization.Model): +class SupportedScopes(_serialization.Model): """Extension scopes. :ivar default_scope: Default extension scopes: cluster or namespace. @@ -2119,17 +2038,17 @@ class SupportedScopes(msrest.serialization.Model): """ _attribute_map = { - 'default_scope': {'key': 'defaultScope', 'type': 'str'}, - 'cluster_scope_settings': {'key': 'clusterScopeSettings', 'type': 'ClusterScopeSettings'}, + "default_scope": {"key": "defaultScope", "type": "str"}, + "cluster_scope_settings": {"key": "clusterScopeSettings", "type": "ClusterScopeSettings"}, } def __init__( self, *, default_scope: Optional[str] = None, - cluster_scope_settings: Optional["ClusterScopeSettings"] = None, - **kwargs - ): + cluster_scope_settings: Optional["_models.ClusterScopeSettings"] = None, + **kwargs: Any + ) -> None: """ :keyword default_scope: Default extension scopes: cluster or namespace. :paramtype default_scope: str @@ -2137,26 +2056,26 @@ def __init__( :paramtype cluster_scope_settings: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ClusterScopeSettings """ - super(SupportedScopes, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_scope = default_scope self.cluster_scope_settings = cluster_scope_settings -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.kubernetesconfiguration.v2021_11_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.kubernetesconfiguration.v2021_11_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -2164,44 +2083,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 - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. 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.kubernetesconfiguration.v2021_11_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.kubernetesconfiguration.v2021_11_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 diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/models/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/models/_source_control_configuration_client_enums.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/models/_source_control_configuration_client_enums.py index 544b13b91c22..a93c5cb9c83f 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/models/_source_control_configuration_client_enums.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/models/_source_control_configuration_client_enums.py @@ -7,20 +7,18 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ClusterTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Cluster types - """ +class ClusterTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Cluster types.""" CONNECTED_CLUSTERS = "connectedClusters" MANAGED_CLUSTERS = "managedClusters" -class ComplianceStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The compliance state of the configuration. - """ + +class ComplianceStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The compliance state of the configuration.""" PENDING = "Pending" COMPLIANT = "Compliant" @@ -28,28 +26,32 @@ class ComplianceStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INSTALLED = "Installed" FAILED = "Failed" -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 Enum0(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class Enum0(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum0.""" MICROSOFT_CONTAINER_SERVICE = "Microsoft.ContainerService" MICROSOFT_KUBERNETES = "Microsoft.Kubernetes" -class Enum1(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class Enum1(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum1.""" MANAGED_CLUSTERS = "managedClusters" CONNECTED_CLUSTERS = "connectedClusters" -class FluxComplianceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Compliance state of the cluster object. - """ + +class FluxComplianceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Compliance state of the cluster object.""" COMPLIANT = "Compliant" NON_COMPLIANT = "Non-Compliant" @@ -57,7 +59,8 @@ class FluxComplianceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUSPENDED = "Suspended" UNKNOWN = "Unknown" -class KustomizationValidationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class KustomizationValidationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify whether to validate the Kubernetes objects referenced in the Kustomization before applying them to the cluster. """ @@ -66,38 +69,38 @@ class KustomizationValidationType(with_metaclass(CaseInsensitiveEnumMeta, str, E CLIENT = "client" SERVER = "server" -class LevelType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Level of the status. - """ + +class LevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the status.""" ERROR = "Error" WARNING = "Warning" INFORMATION = "Information" -class MessageLevelType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Level of the message. - """ + +class MessageLevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the message.""" ERROR = "Error" WARNING = "Warning" INFORMATION = "Information" -class OperatorScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Scope at which the operator will be installed. - """ + +class OperatorScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scope at which the operator will be installed.""" CLUSTER = "cluster" NAMESPACE = "namespace" -class OperatorType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the operator - """ + +class OperatorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the operator.""" FLUX = "Flux" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of the resource. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource.""" SUCCEEDED = "Succeeded" FAILED = "Failed" @@ -106,9 +109,9 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" DELETING = "Deleting" -class ProvisioningStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of the resource provider. - """ + +class ProvisioningStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource provider.""" ACCEPTED = "Accepted" DELETING = "Deleting" @@ -116,15 +119,15 @@ class ProvisioningStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" FAILED = "Failed" -class ScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Scope at which the configuration will be installed. - """ + +class ScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scope at which the configuration will be installed.""" CLUSTER = "cluster" NAMESPACE = "namespace" -class SourceKindType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Source Kind to pull the configuration data from. - """ + +class SourceKindType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Source Kind to pull the configuration data from.""" GIT_REPOSITORY = "GitRepository" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/__init__.py index ee01fecd4396..3f15324c4708 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/__init__.py @@ -17,15 +17,21 @@ from ._flux_config_operation_status_operations import FluxConfigOperationStatusOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ExtensionsOperations', - 'OperationStatusOperations', - 'ClusterExtensionTypeOperations', - 'ClusterExtensionTypesOperations', - 'ExtensionTypeVersionsOperations', - 'LocationExtensionTypesOperations', - 'SourceControlConfigurationsOperations', - 'FluxConfigurationsOperations', - 'FluxConfigOperationStatusOperations', - 'Operations', + "ExtensionsOperations", + "OperationStatusOperations", + "ClusterExtensionTypeOperations", + "ClusterExtensionTypesOperations", + "ExtensionTypeVersionsOperations", + "LocationExtensionTypesOperations", + "SourceControlConfigurationsOperations", + "FluxConfigurationsOperations", + "FluxConfigOperationStatusOperations", + "Operations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_cluster_extension_type_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_cluster_extension_type_operations.py index 3521f8a75735..dc741229de55 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_cluster_extension_type_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_cluster_extension_type_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,138 +6,170 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_type_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionTypeName": _SERIALIZER.url("extension_type_name", extension_type_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionTypeName": _SERIALIZER.url("extension_type_name", extension_type_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) -class ClusterExtensionTypeOperations(object): - """ClusterExtensionTypeOperations 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 ClusterExtensionTypeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_11_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.kubernetesconfiguration.v2021_11_01_preview.SourceControlConfigurationClient`'s + :attr:`cluster_extension_type` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_type_name: str, **kwargs: Any - ) -> "_models.ExtensionType": + ) -> _models.ExtensionType: """Get Extension Type details. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_type_name: Extension type name. + :param extension_type_name: Extension type name. Required. :type extension_type_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExtensionType, or the result of cls(response) + :return: ExtensionType or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ExtensionType - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionType"] 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: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.ExtensionType] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_type_name=extension_type_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -144,12 +177,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExtensionType', pipeline_response) + deserialized = self._deserialize("ExtensionType", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_cluster_extension_types_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_cluster_extension_types_operations.py index 7d7e58989f91..7f8b085cf91d 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_cluster_extension_types_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_cluster_extension_types_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,143 +6,178 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +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 msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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") -class ClusterExtensionTypesOperations(object): - """ClusterExtensionTypesOperations 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.kubernetesconfiguration.v2021_11_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 ClusterExtensionTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.SourceControlConfigurationClient`'s + :attr:`cluster_extension_types` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.ExtensionTypeList"]: + ) -> Iterable["_models.ExtensionType"]: """Get Extension Types. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionTypeList or the result of cls(response) + :return: An iterator like instance of either ExtensionType or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ExtensionTypeList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ExtensionType] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionTypeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.ExtensionTypeList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -152,13 +188,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionTypeList", 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(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]: @@ -168,8 +206,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_extension_type_versions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_extension_type_versions_operations.py index b9e4fd842eeb..d930c28a98f0 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_extension_type_versions_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_extension_type_versions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,127 +6,151 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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( - subscription_id: str, - location: str, - extension_type_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-11-01-preview" - accept = "application/json" + +def build_list_request(location: str, extension_type_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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions", + ) # 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'), - "extensionTypeName": _SERIALIZER.url("extension_type_name", extension_type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), + "extensionTypeName": _SERIALIZER.url("extension_type_name", extension_type_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) -class ExtensionTypeVersionsOperations(object): - """ExtensionTypeVersionsOperations 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 ExtensionTypeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_11_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.kubernetesconfiguration.v2021_11_01_preview.SourceControlConfigurationClient`'s + :attr:`extension_type_versions` 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, - location: str, - extension_type_name: str, - **kwargs: Any - ) -> Iterable["_models.ExtensionVersionList"]: + self, location: str, extension_type_name: str, **kwargs: Any + ) -> Iterable["_models.ExtensionVersionListVersionsItem"]: """List available versions for an Extension Type. - :param location: extension location. + :param location: extension location. Required. :type location: str - :param extension_type_name: Extension type name. + :param extension_type_name: Extension type name. Required. :type extension_type_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionVersionList or the result of + :return: An iterator like instance of either ExtensionVersionListVersionsItem or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ExtensionVersionList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ExtensionVersionListVersionsItem] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionVersionList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.ExtensionVersionList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, extension_type_name=extension_type_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - extension_type_name=extension_type_name, - 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) @@ -136,13 +161,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionVersionList", pipeline_response) list_of_elem = deserialized.versions 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(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]: @@ -152,8 +179,8 @@ 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.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_extensions_operations.py index 0531c0003855..a888a0dbe595 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_extensions_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_extensions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,359 +6,504 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -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 msrest import Serializer 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_create_request_initial( - subscription_id: str, + +def build_create_request( resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2021-11-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_delete_request_initial( - subscription_id: str, + +def build_delete_request( resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, + subscription_id: str, *, force_delete: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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") if force_delete is not None: - query_parameters['forceDelete'] = _SERIALIZER.query("force_delete", force_delete, 'bool') + _params["forceDelete"] = _SERIALIZER.query("force_delete", force_delete, "bool") # 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, + +def build_update_request( resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2021-11-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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") -class ExtensionsOperations(object): - """ExtensionsOperations 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.kubernetesconfiguration.v2021_11_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 ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _create_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> "_models.Extension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + ) -> _models.Extension: 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 {}) - 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(extension, 'Extension') + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IO, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension + :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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> LROPoller["_models.Extension"]: + ) -> LROPoller[_models.Extension]: """Create a new Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param extension: Properties necessary to Create an Extension. - :type extension: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension + :param extension: Properties necessary to Create an Extension. Is either a Extension type or a + IO type. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension 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 @@ -369,16 +515,19 @@ def begin_create( :return: An instance of LROPoller that returns either Extension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] - 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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-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.Extension] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -387,85 +536,110 @@ def begin_create( cluster_name=cluster_name, extension_name=extension_name, extension=extension, + 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('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, **kwargs: Any - ) -> "_models.Extension": + ) -> _models.Extension: """Gets Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Extension, or the result of cls(response) + :return: Extension or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] 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: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -473,65 +647,83 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, force_delete: Optional[bool] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, force_delete=force_delete, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(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, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, force_delete: Optional[bool] = None, @@ -541,20 +733,23 @@ def begin_delete( from the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :param force_delete: Delete the extension resource in Azure - not the normal asynchronous - delete. + delete. Default value is None. :type force_delete: bool :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. @@ -566,128 +761,273 @@ def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, force_delete=force_delete, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } def _update_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - patch_extension: "_models.PatchExtension", + patch_extension: Union[_models.PatchExtension, IO], **kwargs: Any - ) -> "_models.Extension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + ) -> _models.Extension: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 304: ResourceNotModifiedError, + 409: lambda response: ResourceExistsError( + response=response, model=self._deserialize(_models.ErrorResponse, response), error_format=ARMErrorFormat + ), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - 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(patch_extension, 'PatchExtension') + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(patch_extension, (IO, bytes)): + _content = patch_extension + else: + _json = self._serialize.body(patch_extension, "PatchExtension") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_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(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + patch_extension: _models.PatchExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.PatchExtension + :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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + extension_name: str, + patch_extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, - patch_extension: "_models.PatchExtension", + patch_extension: Union[_models.PatchExtension, IO], **kwargs: Any - ) -> LROPoller["_models.Extension"]: + ) -> LROPoller[_models.Extension]: """Patch an existing Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param patch_extension: Properties to Patch in an existing Extension. + :param patch_extension: Properties to Patch in an existing Extension. Is either a + PatchExtension type or a IO type. Required. :type patch_extension: - ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.PatchExtension + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.PatchExtension 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 @@ -699,16 +1039,19 @@ def begin_update( :return: An instance of LROPoller that returns either Extension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] - 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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-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.Extension] = 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, @@ -717,91 +1060,118 @@ def begin_update( cluster_name=cluster_name, extension_name=extension_name, patch_extension=patch_extension, + 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('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.ExtensionsList"]: + ) -> Iterable["_models.Extension"]: """List all Extensions in the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionsList or the result of cls(response) + :return: An iterator like instance of either Extension or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ExtensionsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.ExtensionsList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -812,13 +1182,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionsList", 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(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]: @@ -828,8 +1200,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_flux_config_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_flux_config_operation_status_operations.py index dea63e7dac35..c566891245d8 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_flux_config_operation_status_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_flux_config_operation_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,144 +6,176 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, operation_id: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_name, 'str'), - "operationId": _SERIALIZER.url("operation_id", operation_id, '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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "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) -class FluxConfigOperationStatusOperations(object): - """FluxConfigOperationStatusOperations 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 FluxConfigOperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_11_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.kubernetesconfiguration.v2021_11_01_preview.SourceControlConfigurationClient`'s + :attr:`flux_config_operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationStatusResult": + ) -> _models.OperationStatusResult: """Get Async Operation status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str - :param operation_id: operation Id. + :param operation_id: operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatusResult, or the result of cls(response) + :return: OperationStatusResult or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.OperationStatusResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -150,12 +183,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_flux_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_flux_configurations_operations.py index c3d3cf613baf..09957eec7c26 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_flux_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_flux_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,326 +6,358 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -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 msrest import Serializer 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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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, + +def build_create_or_update_request( resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2021-11-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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_update_request_initial( - subscription_id: str, + +def build_update_request( resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2021-11-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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_delete_request_initial( - subscription_id: str, + +def build_delete_request( resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, + subscription_id: str, *, force_delete: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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") if force_delete is not None: - query_parameters['forceDelete'] = _SERIALIZER.query("force_delete", force_delete, 'bool') + _params["forceDelete"] = _SERIALIZER.query("force_delete", force_delete, "bool") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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) -class FluxConfigurationsOperations(object): - """FluxConfigurationsOperations 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 FluxConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_11_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.kubernetesconfiguration.v2021_11_01_preview.SourceControlConfigurationClient`'s + :attr:`flux_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, **kwargs: Any - ) -> "_models.FluxConfiguration": + ) -> _models.FluxConfiguration: """Gets details of the Flux Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FluxConfiguration, or the result of cls(response) + :return: FluxConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] 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: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -332,100 +365,237 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } def _create_or_update_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, - flux_configuration: "_models.FluxConfiguration", + flux_configuration: Union[_models.FluxConfiguration, IO], **kwargs: Any - ) -> "_models.FluxConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + ) -> _models.FluxConfiguration: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 304: ResourceNotModifiedError, + 409: lambda response: ResourceExistsError( + response=response, model=self._deserialize(_models.ErrorResponse, response), error_format=ARMErrorFormat + ), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - 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(flux_configuration, 'FluxConfiguration') + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration, (IO, bytes)): + _content = flux_configuration + else: + _json = self._serialize.body(flux_configuration, "FluxConfiguration") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_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(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + flux_configuration_name: str, + flux_configuration: _models.FluxConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + flux_configuration_name: str, + flux_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, - flux_configuration: "_models.FluxConfiguration", + flux_configuration: Union[_models.FluxConfiguration, IO], **kwargs: Any - ) -> LROPoller["_models.FluxConfiguration"]: + ) -> LROPoller[_models.FluxConfiguration]: """Create a new Kubernetes Flux Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str - :param flux_configuration: Properties necessary to Create a FluxConfiguration. + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Is either a + FluxConfiguration type or a IO type. Required. :type flux_configuration: - ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration 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 @@ -438,16 +608,19 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] - 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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-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.FluxConfiguration] = 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, @@ -456,115 +629,260 @@ def begin_create_or_update( cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, flux_configuration=flux_configuration, + 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('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } def _update_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, - flux_configuration_patch: "_models.FluxConfigurationPatch", + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], **kwargs: Any - ) -> "_models.FluxConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + ) -> _models.FluxConfiguration: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 304: ResourceNotModifiedError, + 409: lambda response: ResourceExistsError( + response=response, model=self._deserialize(_models.ErrorResponse, response), error_format=ARMErrorFormat + ), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - 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(flux_configuration_patch, 'FluxConfigurationPatch') + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration_patch, (IO, bytes)): + _content = flux_configuration_patch + else: + _json = self._serialize.body(flux_configuration_patch, "FluxConfigurationPatch") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_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(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore - + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } - @distributed_trace + @overload def begin_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, - flux_configuration_patch: "_models.FluxConfigurationPatch", + flux_configuration_patch: _models.FluxConfigurationPatch, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.FluxConfiguration"]: + ) -> LROPoller[_models.FluxConfiguration]: """Update an existing Kubernetes Flux Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. :type flux_configuration_patch: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfigurationPatch + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. + :type flux_configuration_patch: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. Is + either a FluxConfigurationPatch type or a IO type. Required. + :type flux_configuration_patch: + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfigurationPatch 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 @@ -577,16 +895,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] - 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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-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.FluxConfiguration] = 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, @@ -595,84 +916,108 @@ def begin_update( cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, flux_configuration_patch=flux_configuration_patch, + 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('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, force_delete: Optional[bool] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, + subscription_id=self._config.subscription_id, force_delete=force_delete, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(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, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } @distributed_trace def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, flux_configuration_name: str, force_delete: Optional[bool] = None, @@ -682,20 +1027,23 @@ def begin_delete( from the source repo. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str :param force_delete: Delete the extension resource in Azure - not the normal asynchronous - delete. + delete. Default value is None. :type force_delete: bool :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. @@ -707,105 +1055,135 @@ def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, force_delete=force_delete, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.FluxConfigurationsList"]: + ) -> Iterable["_models.FluxConfiguration"]: """List all Flux Configurations. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FluxConfigurationsList or the result of - cls(response) + :return: An iterator like instance of either FluxConfiguration or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfigurationsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfigurationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.FluxConfigurationsList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -816,13 +1194,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("FluxConfigurationsList", 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(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]: @@ -832,8 +1212,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_location_extension_types_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_location_extension_types_operations.py index 6e8be79c0612..0a82e1c6d1f3 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_location_extension_types_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_location_extension_types_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,119 +6,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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( - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-11-01-preview" - accept = "application/json" + +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["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes", + ) # 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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "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) -class LocationExtensionTypesOperations(object): - """LocationExtensionTypesOperations 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 LocationExtensionTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2021_11_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.kubernetesconfiguration.v2021_11_01_preview.SourceControlConfigurationClient`'s + :attr:`location_extension_types` 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, - location: str, - **kwargs: Any - ) -> Iterable["_models.ExtensionTypeList"]: + def list(self, location: str, **kwargs: Any) -> Iterable["_models.ExtensionType"]: """List all Extension Types. - :param location: extension location. + :param location: extension location. 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 ExtensionTypeList or the result of cls(response) + :return: An iterator like instance of either ExtensionType or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ExtensionTypeList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ExtensionType] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionTypeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.ExtensionTypeList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - 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) @@ -128,13 +154,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionTypeList", 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(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]: @@ -144,8 +172,8 @@ 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.KubernetesConfiguration/locations/{location}/extensionTypes'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_operation_status_operations.py index 99b73b720389..8428a1d67da9 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_operation_status_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_operation_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,184 +6,220 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +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 msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, operation_id: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_name, 'str'), - "operationId": _SERIALIZER.url("operation_id", operation_id, '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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "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_list_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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") -class OperationStatusOperations(object): - """OperationStatusOperations 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.kubernetesconfiguration.v2021_11_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 OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.SourceControlConfigurationClient`'s + :attr:`operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, extension_name: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationStatusResult": + ) -> _models.OperationStatusResult: """Get Async Operation status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param operation_id: operation Id. + :param operation_id: operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatusResult, or the result of cls(response) + :return: OperationStatusResult or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.OperationStatusResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -190,72 +227,94 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.OperationStatusList"]: + ) -> Iterable["_models.OperationStatusResult"]: """List Async Operations, currently in progress, in a cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationStatusList or the result of cls(response) + :return: An iterator like instance of either OperationStatusResult or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.OperationStatusList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.OperationStatusList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -266,13 +325,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationStatusList", 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(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]: @@ -282,8 +343,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_operations.py index c047a8d76ca0..a650d447fe2b 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,132 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 msrest import Serializer 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 = "2021-11-01-preview" - 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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.KubernetesConfiguration/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.KubernetesConfiguration/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.kubernetesconfiguration.v2021_11_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.kubernetesconfiguration.v2021_11_01_preview.SourceControlConfigurationClient`'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.ResourceProviderOperationList"]: + def list(self, **kwargs: Any) -> Iterable["_models.ResourceProviderOperation"]: """List all the available operations the KubernetesConfiguration resource provider supports. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of + :return: An iterator like instance of either ResourceProviderOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ResourceProviderOperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.ResourceProviderOperationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - 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) @@ -114,13 +142,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ResourceProviderOperationList", 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(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]: @@ -130,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.KubernetesConfiguration/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_source_control_configurations_operations.py index 4fe01af82205..38acf2f53f9e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_source_control_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2021_11_01_preview/operations/_source_control_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,273 +6,314 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -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 msrest import Serializer 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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2021-11-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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, + +def build_delete_request( resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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_list_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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") -class SourceControlConfigurationsOperations(object): - """SourceControlConfigurationsOperations 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.kubernetesconfiguration.v2021_11_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 SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Gets details of the Source Control Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -279,76 +321,195 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, - source_control_configuration: "_models.SourceControlConfiguration", + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Create a new Kubernetes Source Control Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. :type source_control_configuration: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceControlConfiguration + :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: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceControlConfiguration 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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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 {}) - 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(source_control_configuration, 'SourceControlConfiguration') + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -357,66 +518,84 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_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 {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self._delete_initial.metadata['url'], + 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 = self._client._pipeline.run(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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, source_control_configuration_name: str, **kwargs: Any @@ -425,17 +604,20 @@ def begin_delete( future sync from the source repo. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_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. @@ -447,104 +629,133 @@ def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - cls=lambda x,y,z: x, + api_version=api_version, + 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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.Enum0"], - cluster_resource_name: Union[str, "_models.Enum1"], + cluster_rp: Union[str, _models.Enum0], + cluster_resource_name: Union[str, _models.Enum1], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.SourceControlConfigurationList"]: + ) -> Iterable["_models.SourceControlConfiguration"]: """List all Source Control Configurations. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum0 :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.Enum1 - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlConfigurationList or the result of + :return: An iterator like instance of either SourceControlConfiguration or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceControlConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2021_11_01_preview.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-11-01-preview") + ) + cls: ClsType[_models.SourceControlConfigurationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -555,13 +766,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlConfigurationList", 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(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]: @@ -571,8 +784,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/__init__.py index e90963036337..3ad4bd8b604e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['SourceControlConfigurationClient'] -# `._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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_configuration.py index 79ca1e2de574..486b76193a8b 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_configuration.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_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,30 +15,35 @@ 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 SourceControlConfigurationClientConfiguration(Configuration): +class SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SourceControlConfigurationClient. 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-01-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(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2022-01-01-preview"] = kwargs.pop("api_version", "2022-01-01-preview") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +51,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2022-01-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_metadata.json b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_metadata.json index 24b43e0c3e46..1c9617ffe431 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_metadata.json +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_metadata.json @@ -10,34 +10,36 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SourceControlConfigurationClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SourceControlConfigurationClientConfiguration\"]}}, \"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\": [\"SourceControlConfigurationClientConfiguration\"], \".._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\": [\"SourceControlConfigurationClientConfiguration\"], \"..._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 + "required": true, + "method_location": "positional" }, "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 + "required": true, + "method_location": "positional" } }, "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,22 +50,25 @@ "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 + "required": false, + "method_location": "positional" }, "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 + "required": false, + "method_location": "positional" }, "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 + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "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 + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -108,4 +116,4 @@ "source_control_configurations": "SourceControlConfigurationsOperations", "operations": "Operations" } -} \ No newline at end of file +} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_patch.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_source_control_configuration_client.py index 7a271a306916..cf119ea50036 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_source_control_configuration_client.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_source_control_configuration_client.py @@ -7,21 +7,33 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer -from . import models +from . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import SourceControlConfigurationClientConfiguration -from .operations import ClusterExtensionTypeOperations, ClusterExtensionTypesOperations, ExtensionTypeVersionsOperations, ExtensionsOperations, FluxConfigOperationStatusOperations, FluxConfigurationsOperations, LocationExtensionTypesOperations, OperationStatusOperations, Operations, SourceControlConfigurationsOperations +from .operations import ( + ClusterExtensionTypeOperations, + ClusterExtensionTypesOperations, + ExtensionTypeVersionsOperations, + ExtensionsOperations, + FluxConfigOperationStatusOperations, + FluxConfigurationsOperations, + LocationExtensionTypesOperations, + OperationStatusOperations, + Operations, + SourceControlConfigurationsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SourceControlConfigurationClient: + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """KubernetesConfiguration Client. :ivar cluster_extension_type: ClusterExtensionTypeOperations operations @@ -54,12 +66,15 @@ class SourceControlConfigurationClient: :ivar operations: Operations operations :vartype operations: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.operations.Operations - :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'. + :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-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -71,30 +86,43 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SourceControlConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SourceControlConfigurationClientConfiguration( + 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.cluster_extension_type = ClusterExtensionTypeOperations(self._client, self._config, self._serialize, self._deserialize) - self.cluster_extension_types = ClusterExtensionTypesOperations(self._client, self._config, self._serialize, self._deserialize) - self.extension_type_versions = ExtensionTypeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.location_extension_types = LocationExtensionTypesOperations(self._client, self._config, self._serialize, self._deserialize) + self.cluster_extension_type = ClusterExtensionTypeOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cluster_extension_types = ClusterExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.extension_type_versions = ExtensionTypeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.location_extension_types = LocationExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_status = OperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.flux_configurations = FluxConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.flux_config_operation_status = FluxConfigOperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.source_control_configurations = SourceControlConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_configurations = FluxConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_config_operation_status = FluxConfigOperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request, # type: 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 @@ -103,7 +131,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 @@ -116,15 +144,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: () -> SourceControlConfigurationClient + def __enter__(self) -> "SourceControlConfigurationClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_vendor.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_vendor.py index 138f663c53a4..bd0df84f5319 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_vendor.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_vendor.py @@ -5,8 +5,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + 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,14 +17,14 @@ def _convert_request(request, files=None): 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 - ] + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_version.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_version.py index 48944bf3938a..59deb8c7263b 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_version.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.1.0" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/__init__.py index 5f583276b4ed..b95230ae03c5 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._source_control_configuration_client import SourceControlConfigurationClient -__all__ = ['SourceControlConfigurationClient'] -# `._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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/_configuration.py index c39cb2de0a3e..89a7b1e786d2 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/_configuration.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_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,30 +15,35 @@ 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 SourceControlConfigurationClientConfiguration(Configuration): +class SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SourceControlConfigurationClient. 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-01-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(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2022-01-01-preview"] = kwargs.pop("api_version", "2022-01-01-preview") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +51,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2022-01-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/_patch.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/_source_control_configuration_client.py index d2a714a63785..d1c9594d0cc6 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/_source_control_configuration_client.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/_source_control_configuration_client.py @@ -7,21 +7,33 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer -from .. import models +from .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import SourceControlConfigurationClientConfiguration -from .operations import ClusterExtensionTypeOperations, ClusterExtensionTypesOperations, ExtensionTypeVersionsOperations, ExtensionsOperations, FluxConfigOperationStatusOperations, FluxConfigurationsOperations, LocationExtensionTypesOperations, OperationStatusOperations, Operations, SourceControlConfigurationsOperations +from .operations import ( + ClusterExtensionTypeOperations, + ClusterExtensionTypesOperations, + ExtensionTypeVersionsOperations, + ExtensionsOperations, + FluxConfigOperationStatusOperations, + FluxConfigurationsOperations, + LocationExtensionTypesOperations, + OperationStatusOperations, + Operations, + SourceControlConfigurationsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SourceControlConfigurationClient: + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """KubernetesConfiguration Client. :ivar cluster_extension_type: ClusterExtensionTypeOperations operations @@ -54,12 +66,15 @@ class SourceControlConfigurationClient: :ivar operations: Operations operations :vartype operations: azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.aio.operations.Operations - :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'. + :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-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -71,30 +86,43 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SourceControlConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SourceControlConfigurationClientConfiguration( + 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.cluster_extension_type = ClusterExtensionTypeOperations(self._client, self._config, self._serialize, self._deserialize) - self.cluster_extension_types = ClusterExtensionTypesOperations(self._client, self._config, self._serialize, self._deserialize) - self.extension_type_versions = ExtensionTypeVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.location_extension_types = LocationExtensionTypesOperations(self._client, self._config, self._serialize, self._deserialize) + self.cluster_extension_type = ClusterExtensionTypeOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cluster_extension_types = ClusterExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.extension_type_versions = ExtensionTypeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.location_extension_types = LocationExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_status = OperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.flux_configurations = FluxConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.flux_config_operation_status = FluxConfigOperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.source_control_configurations = SourceControlConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_configurations = FluxConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_config_operation_status = FluxConfigOperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **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 @@ -103,7 +131,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 @@ -123,5 +151,5 @@ async def __aenter__(self) -> "SourceControlConfigurationClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/__init__.py index 37008240af35..ccd968835618 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/__init__.py @@ -17,15 +17,21 @@ from ._source_control_configurations_operations import SourceControlConfigurationsOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ClusterExtensionTypeOperations', - 'ClusterExtensionTypesOperations', - 'ExtensionTypeVersionsOperations', - 'LocationExtensionTypesOperations', - 'ExtensionsOperations', - 'OperationStatusOperations', - 'FluxConfigurationsOperations', - 'FluxConfigOperationStatusOperations', - 'SourceControlConfigurationsOperations', - 'Operations', + "ClusterExtensionTypeOperations", + "ClusterExtensionTypesOperations", + "ExtensionTypeVersionsOperations", + "LocationExtensionTypesOperations", + "ExtensionsOperations", + "OperationStatusOperations", + "FluxConfigurationsOperations", + "FluxConfigOperationStatusOperations", + "SourceControlConfigurationsOperations", + "Operations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_cluster_extension_type_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_cluster_extension_type_operations.py index ef07f9a9e3ce..66ad039ad609 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_cluster_extension_type_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_cluster_extension_type_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,96 +6,124 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._cluster_extension_type_operations import build_get_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 ClusterExtensionTypeOperations: - """ClusterExtensionTypeOperations 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 ClusterExtensionTypeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`cluster_extension_type` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_type_name: str, **kwargs: Any - ) -> "_models.ExtensionType": + ) -> _models.ExtensionType: """Get Extension Type details. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_type_name: Extension type name. + :param extension_type_name: Extension type name. Required. :type extension_type_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExtensionType, or the result of cls(response) + :return: ExtensionType or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionType - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionType"] 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ExtensionType] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_type_name=extension_type_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -102,12 +131,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExtensionType', pipeline_response) + deserialized = self._deserialize("ExtensionType", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_cluster_extension_types_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_cluster_extension_types_operations.py index 4cb9726a0174..b7dd8729ab23 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_cluster_extension_types_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_cluster_extension_types_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,104 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +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.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._cluster_extension_types_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 ClusterExtensionTypesOperations: - """ClusterExtensionTypesOperations 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 ClusterExtensionTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`cluster_extension_types` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ExtensionTypeList"]: + ) -> AsyncIterable["_models.ExtensionType"]: """Get Extension Types. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionTypeList or the result of cls(response) + :return: An iterator like instance of either ExtensionType or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionTypeList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionType] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionTypeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ExtensionTypeList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -113,13 +144,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionTypeList", 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(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]: @@ -129,8 +162,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_extension_type_versions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_extension_type_versions_operations.py index 8c3770819b1c..9e2c8116d566 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_extension_type_versions_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_extension_type_versions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,91 +6,117 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.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._extension_type_versions_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 ExtensionTypeVersionsOperations: - """ExtensionTypeVersionsOperations 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 ExtensionTypeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`extension_type_versions` 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, - location: str, - extension_type_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ExtensionVersionList"]: + self, location: str, extension_type_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ExtensionVersionListVersionsItem"]: """List available versions for an Extension Type. - :param location: extension location. + :param location: extension location. Required. :type location: str - :param extension_type_name: Extension type name. + :param extension_type_name: Extension type name. Required. :type extension_type_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionVersionList or the result of + :return: An iterator like instance of either ExtensionVersionListVersionsItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionVersionList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionVersionListVersionsItem] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionVersionList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ExtensionVersionList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, extension_type_name=extension_type_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - extension_type_name=extension_type_name, - 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) @@ -100,13 +127,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionVersionList", pipeline_response) list_of_elem = deserialized.versions 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(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]: @@ -116,8 +145,8 @@ 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.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_extensions_operations.py index 12f782fcec9e..2a6446595f17 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_extensions_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_extensions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,133 +6,285 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +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._extensions_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._extensions_operations import ( + build_create_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 ExtensionsOperations: - """ExtensionsOperations 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 ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> "_models.Extension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + ) -> _models.Extension: 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 {}) - 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(extension, 'Extension') + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IO, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension + :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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Extension"]: + ) -> AsyncLROPoller[_models.Extension]: """Create a new Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param extension: Properties necessary to Create an Extension. - :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension + :param extension: Properties necessary to Create an Extension. Is either a Extension type or a + IO type. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension 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 @@ -144,16 +297,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] - 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["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-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.Extension] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -162,86 +318,112 @@ async def begin_create( cluster_name=cluster_name, extension_name=extension_name, extension=extension, + 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('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, **kwargs: Any - ) -> "_models.Extension": + ) -> _models.Extension: """Gets Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Extension, or the result of cls(response) + :return: Extension or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -249,65 +431,83 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, force_delete: Optional[bool] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, force_delete=force_delete, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(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, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace_async async def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, force_delete: Optional[bool] = None, @@ -317,21 +517,24 @@ async def begin_delete( from the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :param force_delete: Delete the extension resource in Azure - not the normal asynchronous - delete. + delete. Default value is None. :type force_delete: bool :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. @@ -343,129 +546,277 @@ async def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, force_delete=force_delete, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } async def _update_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, - patch_extension: "_models.PatchExtension", + patch_extension: Union[_models.PatchExtension, IO], **kwargs: Any - ) -> "_models.Extension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + ) -> _models.Extension: 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 {}) - 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(patch_extension, 'PatchExtension') + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(patch_extension, (IO, bytes)): + _content = patch_extension + else: + _json = self._serialize.body(patch_extension, "PatchExtension") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_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(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + patch_extension: _models.PatchExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.PatchExtension + :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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + patch_extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, - patch_extension: "_models.PatchExtension", + patch_extension: Union[_models.PatchExtension, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Extension"]: + ) -> AsyncLROPoller[_models.Extension]: """Patch an existing Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param patch_extension: Properties to Patch in an existing Extension. + :param patch_extension: Properties to Patch in an existing Extension. Is either a + PatchExtension type or a IO type. Required. :type patch_extension: - ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.PatchExtension + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.PatchExtension 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 @@ -478,16 +829,19 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] - 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["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-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.Extension] = 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, @@ -496,92 +850,120 @@ async def begin_update( cluster_name=cluster_name, extension_name=extension_name, patch_extension=patch_extension, + 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('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ExtensionsList"]: + ) -> AsyncIterable["_models.Extension"]: """List all Extensions in the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionsList or the result of cls(response) + :return: An iterator like instance of either Extension or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ExtensionsList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -592,13 +974,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionsList", 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(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]: @@ -608,8 +992,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_flux_config_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_flux_config_operation_status_operations.py index e1cd85a2f49f..c9463a9880ec 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_flux_config_operation_status_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_flux_config_operation_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,100 +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 functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._flux_config_operation_status_operations import build_get_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 FluxConfigOperationStatusOperations: - """FluxConfigOperationStatusOperations 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 FluxConfigOperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`flux_config_operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationStatusResult": + ) -> _models.OperationStatusResult: """Get Async Operation status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str - :param operation_id: operation Id. + :param operation_id: operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatusResult, or the result of cls(response) + :return: OperationStatusResult or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperationStatusResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -106,12 +135,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_flux_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_flux_configurations_operations.py index 92088a6cd74b..466d5bdb70ff 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_flux_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_flux_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,100 +6,135 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +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._flux_configurations_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._flux_configurations_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 FluxConfigurationsOperations: - """FluxConfigurationsOperations 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 FluxConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`flux_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, **kwargs: Any - ) -> "_models.FluxConfiguration": + ) -> _models.FluxConfiguration: """Gets details of the Flux Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FluxConfiguration, or the result of cls(response) + :return: FluxConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -106,101 +142,238 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } async def _create_or_update_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, - flux_configuration: "_models.FluxConfiguration", + flux_configuration: Union[_models.FluxConfiguration, IO], **kwargs: Any - ) -> "_models.FluxConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + ) -> _models.FluxConfiguration: 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 {}) - 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(flux_configuration, 'FluxConfiguration') + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration, (IO, bytes)): + _content = flux_configuration + else: + _json = self._serialize.body(flux_configuration, "FluxConfiguration") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_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(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration: _models.FluxConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, - flux_configuration: "_models.FluxConfiguration", + flux_configuration: Union[_models.FluxConfiguration, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.FluxConfiguration"]: + ) -> AsyncLROPoller[_models.FluxConfiguration]: """Create a new Kubernetes Flux Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str - :param flux_configuration: Properties necessary to Create a FluxConfiguration. + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Is either a + FluxConfiguration type or a IO type. Required. :type flux_configuration: - ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration 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 @@ -213,16 +386,19 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] - 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["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-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.FluxConfiguration] = 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, @@ -231,116 +407,157 @@ async def begin_create_or_update( cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, flux_configuration=flux_configuration, + 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('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } async def _update_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, - flux_configuration_patch: "_models.FluxConfigurationPatch", + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], **kwargs: Any - ) -> "_models.FluxConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + ) -> _models.FluxConfiguration: 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 {}) - 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(flux_configuration_patch, 'FluxConfigurationPatch') + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration_patch, (IO, bytes)): + _content = flux_configuration_patch + else: + _json = self._serialize.body(flux_configuration_patch, "FluxConfigurationPatch") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_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(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore - + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, - flux_configuration_patch: "_models.FluxConfigurationPatch", + flux_configuration_patch: _models.FluxConfigurationPatch, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.FluxConfiguration"]: + ) -> AsyncLROPoller[_models.FluxConfiguration]: """Update an existing Kubernetes Flux Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. :type flux_configuration_patch: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfigurationPatch + :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 @@ -353,16 +570,124 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. + :type flux_configuration_patch: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. Is + either a FluxConfigurationPatch type or a IO type. Required. + :type flux_configuration_patch: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfigurationPatch 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-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.FluxConfiguration] = 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, @@ -371,84 +696,109 @@ async def begin_update( cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, flux_configuration_patch=flux_configuration_patch, + 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('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, force_delete: Optional[bool] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, + subscription_id=self._config.subscription_id, force_delete=force_delete, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(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, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } @distributed_trace_async async def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, force_delete: Optional[bool] = None, @@ -458,21 +808,24 @@ async def begin_delete( from the source repo. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str :param force_delete: Delete the extension resource in Azure - not the normal asynchronous - delete. + delete. Default value is None. :type force_delete: bool :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. @@ -484,106 +837,137 @@ async def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, force_delete=force_delete, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.FluxConfigurationsList"]: + ) -> AsyncIterable["_models.FluxConfiguration"]: """List all Flux Configurations. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FluxConfigurationsList or the result of - cls(response) + :return: An iterator like instance of either FluxConfiguration or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfigurationsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfigurationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.FluxConfigurationsList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -594,13 +978,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("FluxConfigurationsList", 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(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]: @@ -610,8 +996,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_location_extension_types_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_location_extension_types_operations.py index 9b9f60426e20..d65a8d4600e3 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_location_extension_types_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_location_extension_types_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,85 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.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._location_extension_types_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 LocationExtensionTypesOperations: - """LocationExtensionTypesOperations 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 LocationExtensionTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`location_extension_types` 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, - location: str, - **kwargs: Any - ) -> AsyncIterable["_models.ExtensionTypeList"]: + def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.ExtensionType"]: """List all Extension Types. - :param location: extension location. + :param location: extension location. 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 ExtensionTypeList or the result of cls(response) + :return: An iterator like instance of either ExtensionType or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionTypeList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionType] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionTypeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ExtensionTypeList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - 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) @@ -94,13 +121,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionTypeList", 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(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]: @@ -110,8 +139,8 @@ 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.KubernetesConfiguration/locations/{location}/extensionTypes'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_operation_status_operations.py index 24011064962e..e481f6a8500d 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_operation_status_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_operation_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,102 +6,131 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +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.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._operation_status_operations import build_get_request, 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 OperationStatusOperations: - """OperationStatusOperations 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 OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationStatusResult": + ) -> _models.OperationStatusResult: """Get Async Operation status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param operation_id: operation Id. + :param operation_id: operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatusResult, or the result of cls(response) + :return: OperationStatusResult or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperationStatusResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -108,73 +138,95 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.OperationStatusList"]: + ) -> AsyncIterable["_models.OperationStatusResult"]: """List Async Operations, currently in progress, in a cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationStatusList or the result of cls(response) + :return: An iterator like instance of either OperationStatusResult or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperationStatusList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.OperationStatusList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -185,13 +237,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationStatusList", 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(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,8 +255,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_operations.py index 8fce071678e5..8ea6e60d4fee 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,79 +6,108 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.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._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.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_01_preview.aio.SourceControlConfigurationClient`'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.ResourceProviderOperationList"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceProviderOperation"]: """List all the available operations the KubernetesConfiguration resource provider supports. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of + :return: An iterator like instance of either ResourceProviderOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ResourceProviderOperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ResourceProviderOperationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - 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) @@ -88,13 +118,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ResourceProviderOperationList", 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(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]: @@ -104,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.KubernetesConfiguration/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_source_control_configurations_operations.py index 4c903fd96e63..24b038f4ed8d 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_source_control_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/aio/operations/_source_control_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,135 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +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._source_control_configurations_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._source_control_configurations_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + 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 SourceControlConfigurationsOperations: - """SourceControlConfigurationsOperations 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 SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_01_preview.aio.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, source_control_configuration_name: str, **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Gets details of the Source Control Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -107,77 +142,198 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, source_control_configuration_name: str, - source_control_configuration: "_models.SourceControlConfiguration", + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Create a new Kubernetes Source Control Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. :type source_control_configuration: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration + :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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration 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: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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 {}) - 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(source_control_configuration, 'SourceControlConfiguration') + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -186,66 +342,84 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, source_control_configuration_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 {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self._delete_initial.metadata['url'], + 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 = await self._client._pipeline.run(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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace_async async def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, source_control_configuration_name: str, **kwargs: Any @@ -254,18 +428,21 @@ async def begin_delete( future sync from the source repo. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_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. @@ -277,105 +454,134 @@ async def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - cls=lambda x,y,z: x, + api_version=api_version, + 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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SourceControlConfigurationList"]: + ) -> AsyncIterable["_models.SourceControlConfiguration"]: """List all Source Control Configurations. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlConfigurationList or the result of + :return: An iterator like instance of either SourceControlConfiguration or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SourceControlConfigurationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -386,13 +592,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlConfigurationList", 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(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]: @@ -402,8 +610,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/models/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/models/__init__.py index 32ad88439d17..1a246be64535 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/models/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/models/__init__.py @@ -52,84 +52,86 @@ from ._models_py3 import SupportedScopes from ._models_py3 import SystemData - -from ._source_control_configuration_client_enums import ( - ClusterTypes, - ComplianceStateType, - CreatedByType, - ExtensionsClusterResourceName, - ExtensionsClusterRp, - FluxComplianceState, - KustomizationValidationType, - LevelType, - MessageLevelType, - OperatorScopeType, - OperatorType, - ProvisioningState, - ProvisioningStateType, - ScopeType, - SourceKindType, -) +from ._source_control_configuration_client_enums import ClusterTypes +from ._source_control_configuration_client_enums import ComplianceStateType +from ._source_control_configuration_client_enums import CreatedByType +from ._source_control_configuration_client_enums import ExtensionsClusterResourceName +from ._source_control_configuration_client_enums import ExtensionsClusterRp +from ._source_control_configuration_client_enums import FluxComplianceState +from ._source_control_configuration_client_enums import KustomizationValidationType +from ._source_control_configuration_client_enums import LevelType +from ._source_control_configuration_client_enums import MessageLevelType +from ._source_control_configuration_client_enums import OperatorScopeType +from ._source_control_configuration_client_enums import OperatorType +from ._source_control_configuration_client_enums import ProvisioningState +from ._source_control_configuration_client_enums import ProvisioningStateType +from ._source_control_configuration_client_enums import ScopeType +from ._source_control_configuration_client_enums import SourceKindType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'BucketDefinition', - 'BucketPatchDefinition', - 'ClusterScopeSettings', - 'ComplianceStatus', - 'DependsOnDefinition', - 'ErrorAdditionalInfo', - 'ErrorDetail', - 'ErrorResponse', - 'Extension', - 'ExtensionPropertiesAksAssignedIdentity', - 'ExtensionStatus', - 'ExtensionType', - 'ExtensionTypeList', - 'ExtensionVersionList', - 'ExtensionVersionListVersionsItem', - 'ExtensionsList', - 'FluxConfiguration', - 'FluxConfigurationPatch', - 'FluxConfigurationsList', - 'GitRepositoryDefinition', - 'GitRepositoryPatchDefinition', - 'HelmOperatorProperties', - 'HelmReleasePropertiesDefinition', - 'Identity', - 'KustomizationDefinition', - 'KustomizationPatchDefinition', - 'ObjectReferenceDefinition', - 'ObjectStatusConditionDefinition', - 'ObjectStatusDefinition', - 'OperationStatusList', - 'OperationStatusResult', - 'PatchExtension', - 'ProxyResource', - 'RepositoryRefDefinition', - 'Resource', - 'ResourceProviderOperation', - 'ResourceProviderOperationDisplay', - 'ResourceProviderOperationList', - 'Scope', - 'ScopeCluster', - 'ScopeNamespace', - 'SourceControlConfiguration', - 'SourceControlConfigurationList', - 'SupportedScopes', - 'SystemData', - 'ClusterTypes', - 'ComplianceStateType', - 'CreatedByType', - 'ExtensionsClusterResourceName', - 'ExtensionsClusterRp', - 'FluxComplianceState', - 'KustomizationValidationType', - 'LevelType', - 'MessageLevelType', - 'OperatorScopeType', - 'OperatorType', - 'ProvisioningState', - 'ProvisioningStateType', - 'ScopeType', - 'SourceKindType', + "BucketDefinition", + "BucketPatchDefinition", + "ClusterScopeSettings", + "ComplianceStatus", + "DependsOnDefinition", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "Extension", + "ExtensionPropertiesAksAssignedIdentity", + "ExtensionStatus", + "ExtensionType", + "ExtensionTypeList", + "ExtensionVersionList", + "ExtensionVersionListVersionsItem", + "ExtensionsList", + "FluxConfiguration", + "FluxConfigurationPatch", + "FluxConfigurationsList", + "GitRepositoryDefinition", + "GitRepositoryPatchDefinition", + "HelmOperatorProperties", + "HelmReleasePropertiesDefinition", + "Identity", + "KustomizationDefinition", + "KustomizationPatchDefinition", + "ObjectReferenceDefinition", + "ObjectStatusConditionDefinition", + "ObjectStatusDefinition", + "OperationStatusList", + "OperationStatusResult", + "PatchExtension", + "ProxyResource", + "RepositoryRefDefinition", + "Resource", + "ResourceProviderOperation", + "ResourceProviderOperationDisplay", + "ResourceProviderOperationList", + "Scope", + "ScopeCluster", + "ScopeNamespace", + "SourceControlConfiguration", + "SourceControlConfigurationList", + "SupportedScopes", + "SystemData", + "ClusterTypes", + "ComplianceStateType", + "CreatedByType", + "ExtensionsClusterResourceName", + "ExtensionsClusterRp", + "FluxComplianceState", + "KustomizationValidationType", + "LevelType", + "MessageLevelType", + "OperatorScopeType", + "OperatorType", + "ProvisioningState", + "ProvisioningStateType", + "ScopeType", + "SourceKindType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/models/_models_py3.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/models/_models_py3.py index 97d3533d40dc..e234708e30ac 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/models/_models_py3.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_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,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._source_control_configuration_client_enums import * +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 .. import models as _models -class BucketDefinition(msrest.serialization.Model): + +class BucketDefinition(_serialization.Model): """Parameters to reconcile to the GitRepository source kind type. :ivar url: The URL to sync for the flux configuration S3 bucket. @@ -27,10 +35,10 @@ class BucketDefinition(msrest.serialization.Model): :vartype insecure: bool :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository source with the remote. - :vartype timeout_in_seconds: long + :vartype timeout_in_seconds: int :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster git repository source with the remote. - :vartype sync_interval_in_seconds: long + :vartype sync_interval_in_seconds: int :ivar access_key: Plaintext access key used to securely access the S3 bucket. :vartype access_key: str :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the @@ -39,13 +47,13 @@ class BucketDefinition(msrest.serialization.Model): """ _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, - 'bucket_name': {'key': 'bucketName', 'type': 'str'}, - 'insecure': {'key': 'insecure', 'type': 'bool'}, - 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, - 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, - 'access_key': {'key': 'accessKey', 'type': 'str'}, - 'local_auth_ref': {'key': 'localAuthRef', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, + "bucket_name": {"key": "bucketName", "type": "str"}, + "insecure": {"key": "insecure", "type": "bool"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "access_key": {"key": "accessKey", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, } def __init__( @@ -53,13 +61,13 @@ def __init__( *, url: Optional[str] = None, bucket_name: Optional[str] = None, - insecure: Optional[bool] = True, - timeout_in_seconds: Optional[int] = 600, - sync_interval_in_seconds: Optional[int] = 600, + insecure: bool = True, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, access_key: Optional[str] = None, local_auth_ref: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword url: The URL to sync for the flux configuration S3 bucket. :paramtype url: str @@ -70,17 +78,17 @@ def __init__( :paramtype insecure: bool :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository source with the remote. - :paramtype timeout_in_seconds: long + :paramtype timeout_in_seconds: int :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster git repository source with the remote. - :paramtype sync_interval_in_seconds: long + :paramtype sync_interval_in_seconds: int :keyword access_key: Plaintext access key used to securely access the S3 bucket. :paramtype access_key: str :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the authentication secret rather than the managed or user-provided configuration secrets. :paramtype local_auth_ref: str """ - super(BucketDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url self.bucket_name = bucket_name self.insecure = insecure @@ -90,7 +98,7 @@ def __init__( self.local_auth_ref = local_auth_ref -class BucketPatchDefinition(msrest.serialization.Model): +class BucketPatchDefinition(_serialization.Model): """Parameters to reconcile to the GitRepository source kind type. :ivar url: The URL to sync for the flux configuration S3 bucket. @@ -102,10 +110,10 @@ class BucketPatchDefinition(msrest.serialization.Model): :vartype insecure: bool :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository source with the remote. - :vartype timeout_in_seconds: long + :vartype timeout_in_seconds: int :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster git repository source with the remote. - :vartype sync_interval_in_seconds: long + :vartype sync_interval_in_seconds: int :ivar access_key: Plaintext access key used to securely access the S3 bucket. :vartype access_key: str :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the @@ -114,13 +122,13 @@ class BucketPatchDefinition(msrest.serialization.Model): """ _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, - 'bucket_name': {'key': 'bucketName', 'type': 'str'}, - 'insecure': {'key': 'insecure', 'type': 'bool'}, - 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, - 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, - 'access_key': {'key': 'accessKey', 'type': 'str'}, - 'local_auth_ref': {'key': 'localAuthRef', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, + "bucket_name": {"key": "bucketName", "type": "str"}, + "insecure": {"key": "insecure", "type": "bool"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "access_key": {"key": "accessKey", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, } def __init__( @@ -133,8 +141,8 @@ def __init__( sync_interval_in_seconds: Optional[int] = None, access_key: Optional[str] = None, local_auth_ref: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword url: The URL to sync for the flux configuration S3 bucket. :paramtype url: str @@ -145,17 +153,17 @@ def __init__( :paramtype insecure: bool :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository source with the remote. - :paramtype timeout_in_seconds: long + :paramtype timeout_in_seconds: int :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster git repository source with the remote. - :paramtype sync_interval_in_seconds: long + :paramtype sync_interval_in_seconds: int :keyword access_key: Plaintext access key used to securely access the S3 bucket. :paramtype access_key: str :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the authentication secret rather than the managed or user-provided configuration secrets. :paramtype local_auth_ref: str """ - super(BucketPatchDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url self.bucket_name = bucket_name self.insecure = insecure @@ -165,7 +173,7 @@ def __init__( self.local_auth_ref = local_auth_ref -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. @@ -181,31 +189,28 @@ 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: Any) -> None: + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + """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. @@ -220,24 +225,20 @@ class ProxyResource(Resource): """ _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(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) class ClusterScopeSettings(ProxyResource): @@ -260,17 +261,17 @@ class ClusterScopeSettings(ProxyResource): """ _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'}, - 'allow_multiple_instances': {'key': 'properties.allowMultipleInstances', 'type': 'bool'}, - 'default_release_namespace': {'key': 'properties.defaultReleaseNamespace', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "allow_multiple_instances": {"key": "properties.allowMultipleInstances", "type": "bool"}, + "default_release_namespace": {"key": "properties.defaultReleaseNamespace", "type": "str"}, } def __init__( @@ -278,8 +279,8 @@ def __init__( *, allow_multiple_instances: Optional[bool] = None, default_release_namespace: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword allow_multiple_instances: Describes if multiple instances of the extension are allowed. @@ -287,39 +288,39 @@ def __init__( :keyword default_release_namespace: Default extension release namespace. :paramtype default_release_namespace: str """ - super(ClusterScopeSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.allow_multiple_instances = allow_multiple_instances self.default_release_namespace = default_release_namespace -class ComplianceStatus(msrest.serialization.Model): +class ComplianceStatus(_serialization.Model): """Compliance Status details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar compliance_state: The compliance state of the configuration. Possible values include: - "Pending", "Compliant", "Noncompliant", "Installed", "Failed". + :ivar compliance_state: The compliance state of the configuration. Known values are: "Pending", + "Compliant", "Noncompliant", "Installed", and "Failed". :vartype compliance_state: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ComplianceStateType :ivar last_config_applied: Datetime the configuration was last applied. :vartype last_config_applied: ~datetime.datetime :ivar message: Message from when the configuration was applied. :vartype message: str - :ivar message_level: Level of the message. Possible values include: "Error", "Warning", + :ivar message_level: Level of the message. Known values are: "Error", "Warning", and "Information". :vartype message_level: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.MessageLevelType """ _validation = { - 'compliance_state': {'readonly': True}, + "compliance_state": {"readonly": True}, } _attribute_map = { - 'compliance_state': {'key': 'complianceState', 'type': 'str'}, - 'last_config_applied': {'key': 'lastConfigApplied', 'type': 'iso-8601'}, - 'message': {'key': 'message', 'type': 'str'}, - 'message_level': {'key': 'messageLevel', 'type': 'str'}, + "compliance_state": {"key": "complianceState", "type": "str"}, + "last_config_applied": {"key": "lastConfigApplied", "type": "iso-8601"}, + "message": {"key": "message", "type": "str"}, + "message_level": {"key": "messageLevel", "type": "str"}, } def __init__( @@ -327,52 +328,48 @@ def __init__( *, last_config_applied: Optional[datetime.datetime] = None, message: Optional[str] = None, - message_level: Optional[Union[str, "MessageLevelType"]] = None, - **kwargs - ): + message_level: Optional[Union[str, "_models.MessageLevelType"]] = None, + **kwargs: Any + ) -> None: """ :keyword last_config_applied: Datetime the configuration was last applied. :paramtype last_config_applied: ~datetime.datetime :keyword message: Message from when the configuration was applied. :paramtype message: str - :keyword message_level: Level of the message. Possible values include: "Error", "Warning", + :keyword message_level: Level of the message. Known values are: "Error", "Warning", and "Information". :paramtype message_level: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.MessageLevelType """ - super(ComplianceStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.compliance_state = None self.last_config_applied = last_config_applied self.message = message self.message_level = message_level -class DependsOnDefinition(msrest.serialization.Model): - """Specify which kustomizations must succeed reconciliation on the cluster prior to reconciling this kustomization. +class DependsOnDefinition(_serialization.Model): + """Specify which kustomizations must succeed reconciliation on the cluster prior to reconciling + this kustomization. :ivar kustomization_name: Name of the kustomization to claim dependency on. :vartype kustomization_name: str """ _attribute_map = { - 'kustomization_name': {'key': 'kustomizationName', 'type': 'str'}, + "kustomization_name": {"key": "kustomizationName", "type": "str"}, } - def __init__( - self, - *, - kustomization_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, kustomization_name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword kustomization_name: Name of the kustomization to claim dependency on. :paramtype kustomization_name: str """ - super(DependsOnDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.kustomization_name = kustomization_name -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -380,31 +377,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -424,28 +417,24 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -453,32 +442,28 @@ def __init__( self.additional_info = None -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ErrorDetail """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ErrorDetail """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class Extension(ProxyResource): +class Extension(ProxyResource): # pylint: disable=too-many-instance-attributes """The Extension object. Variables are only populated by the server, and will be ignored when sending a request. @@ -517,8 +502,8 @@ class Extension(ProxyResource): :ivar configuration_protected_settings: Configuration settings that are sensitive, as name-value pairs for configuring this extension. :vartype configuration_protected_settings: dict[str, str] - :ivar provisioning_state: Status of installation of this extension. Possible values include: - "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting". + :ivar provisioning_state: Status of installation of this extension. Known values are: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ProvisioningState :ivar statuses: Status from this extension. @@ -536,52 +521,55 @@ class Extension(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'error_info': {'readonly': True}, - 'custom_location_settings': {'readonly': True}, - 'package_uri': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "error_info": {"readonly": True}, + "custom_location_settings": {"readonly": True}, + "package_uri": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, - 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, - 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'Scope'}, - 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'statuses': {'key': 'properties.statuses', 'type': '[ExtensionStatus]'}, - 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDetail'}, - 'custom_location_settings': {'key': 'properties.customLocationSettings', 'type': '{str}'}, - 'package_uri': {'key': 'properties.packageUri', 'type': 'str'}, - 'aks_assigned_identity': {'key': 'properties.aksAssignedIdentity', 'type': 'ExtensionPropertiesAksAssignedIdentity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "extension_type": {"key": "properties.extensionType", "type": "str"}, + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "scope": {"key": "properties.scope", "type": "Scope"}, + "configuration_settings": {"key": "properties.configurationSettings", "type": "{str}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "statuses": {"key": "properties.statuses", "type": "[ExtensionStatus]"}, + "error_info": {"key": "properties.errorInfo", "type": "ErrorDetail"}, + "custom_location_settings": {"key": "properties.customLocationSettings", "type": "{str}"}, + "package_uri": {"key": "properties.packageUri", "type": "str"}, + "aks_assigned_identity": { + "key": "properties.aksAssignedIdentity", + "type": "ExtensionPropertiesAksAssignedIdentity", + }, } def __init__( self, *, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, extension_type: Optional[str] = None, - auto_upgrade_minor_version: Optional[bool] = True, - release_train: Optional[str] = "Stable", + auto_upgrade_minor_version: bool = True, + release_train: str = "Stable", version: Optional[str] = None, - scope: Optional["Scope"] = None, + scope: Optional["_models.Scope"] = None, configuration_settings: Optional[Dict[str, str]] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - statuses: Optional[List["ExtensionStatus"]] = None, - aks_assigned_identity: Optional["ExtensionPropertiesAksAssignedIdentity"] = None, - **kwargs - ): + statuses: Optional[List["_models.ExtensionStatus"]] = None, + aks_assigned_identity: Optional["_models.ExtensionPropertiesAksAssignedIdentity"] = None, + **kwargs: Any + ) -> None: """ :keyword identity: Identity of the Extension resource. :paramtype identity: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Identity @@ -613,7 +601,7 @@ def __init__( :paramtype aks_assigned_identity: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionPropertiesAksAssignedIdentity """ - super(Extension, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.system_data = None self.extension_type = extension_type @@ -631,7 +619,7 @@ def __init__( self.aks_assigned_identity = aks_assigned_identity -class ExtensionPropertiesAksAssignedIdentity(msrest.serialization.Model): +class ExtensionPropertiesAksAssignedIdentity(_serialization.Model): """Identity of the Extension resource in an AKS cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -640,41 +628,35 @@ class ExtensionPropertiesAksAssignedIdentity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :ivar type: The identity type. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: """ - :keyword type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :keyword type: The identity type. Default value is "SystemAssigned". :paramtype type: str """ - super(ExtensionPropertiesAksAssignedIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class ExtensionsList(msrest.serialization.Model): - """Result of the request to list Extensions. It contains a list of Extension objects and a URL link to get the next set of results. +class ExtensionsList(_serialization.Model): + """Result of the request to list Extensions. It contains a list of Extension objects and a URL + link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -685,35 +667,30 @@ class ExtensionsList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Extension]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Extension]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ExtensionsList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ExtensionStatus(msrest.serialization.Model): +class ExtensionStatus(_serialization.Model): """Status from the extension. :ivar code: Status code provided by the Extension. :vartype code: str :ivar display_status: Short description of status of the extension. :vartype display_status: str - :ivar level: Level of the status. Possible values include: "Error", "Warning", "Information". - Default value: "Information". + :ivar level: Level of the status. Known values are: "Error", "Warning", and "Information". :vartype level: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.LevelType :ivar message: Detailed message of the status from the Extension. :vartype message: str @@ -722,11 +699,11 @@ class ExtensionStatus(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'level': {'key': 'level', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'time': {'key': 'time', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "display_status": {"key": "displayStatus", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "time": {"key": "time", "type": "str"}, } def __init__( @@ -734,18 +711,17 @@ def __init__( *, code: Optional[str] = None, display_status: Optional[str] = None, - level: Optional[Union[str, "LevelType"]] = "Information", + level: Union[str, "_models.LevelType"] = "Information", message: Optional[str] = None, time: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword code: Status code provided by the Extension. :paramtype code: str :keyword display_status: Short description of status of the extension. :paramtype display_status: str - :keyword level: Level of the status. Possible values include: "Error", "Warning", - "Information". Default value: "Information". + :keyword level: Level of the status. Known values are: "Error", "Warning", and "Information". :paramtype level: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.LevelType :keyword message: Detailed message of the status from the Extension. @@ -753,7 +729,7 @@ def __init__( :keyword time: DateLiteral (per ISO8601) noting the time of installation status. :paramtype time: str """ - super(ExtensionStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.display_status = display_status self.level = level @@ -761,7 +737,7 @@ def __init__( self.time = time -class ExtensionType(msrest.serialization.Model): +class ExtensionType(_serialization.Model): """Represents an Extension Type. Variables are only populated by the server, and will be ignored when sending a request. @@ -770,7 +746,7 @@ class ExtensionType(msrest.serialization.Model): :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SystemData :ivar release_trains: Extension release train: preview or stable. :vartype release_trains: list[str] - :ivar cluster_types: Cluster types. Possible values include: "connectedClusters", + :ivar cluster_types: Cluster types. Known values are: "connectedClusters" and "managedClusters". :vartype cluster_types: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ClusterTypes @@ -780,33 +756,29 @@ class ExtensionType(msrest.serialization.Model): """ _validation = { - 'system_data': {'readonly': True}, - 'release_trains': {'readonly': True}, - 'cluster_types': {'readonly': True}, - 'supported_scopes': {'readonly': True}, + "system_data": {"readonly": True}, + "release_trains": {"readonly": True}, + "cluster_types": {"readonly": True}, + "supported_scopes": {"readonly": True}, } _attribute_map = { - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'release_trains': {'key': 'properties.releaseTrains', 'type': '[str]'}, - 'cluster_types': {'key': 'properties.clusterTypes', 'type': 'str'}, - 'supported_scopes': {'key': 'properties.supportedScopes', 'type': 'SupportedScopes'}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "release_trains": {"key": "properties.releaseTrains", "type": "[str]"}, + "cluster_types": {"key": "properties.clusterTypes", "type": "str"}, + "supported_scopes": {"key": "properties.supportedScopes", "type": "SupportedScopes"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ExtensionType, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.system_data = None self.release_trains = None self.cluster_types = None self.supported_scopes = None -class ExtensionTypeList(msrest.serialization.Model): +class ExtensionTypeList(_serialization.Model): """List Extension Types. :ivar value: The list of Extension Types. @@ -817,17 +789,13 @@ class ExtensionTypeList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ExtensionType]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ExtensionType]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["ExtensionType"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + self, *, value: Optional[List["_models.ExtensionType"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: The list of Extension Types. :paramtype value: @@ -835,12 +803,12 @@ def __init__( :keyword next_link: The link to fetch the next page of Extension Types. :paramtype next_link: str """ - super(ExtensionTypeList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ExtensionVersionList(msrest.serialization.Model): +class ExtensionVersionList(_serialization.Model): """List versions for an Extension. Variables are only populated by the server, and will be ignored when sending a request. @@ -855,22 +823,22 @@ class ExtensionVersionList(msrest.serialization.Model): """ _validation = { - 'system_data': {'readonly': True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'versions': {'key': 'versions', 'type': '[ExtensionVersionListVersionsItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "versions": {"key": "versions", "type": "[ExtensionVersionListVersionsItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } def __init__( self, *, - versions: Optional[List["ExtensionVersionListVersionsItem"]] = None, + versions: Optional[List["_models.ExtensionVersionListVersionsItem"]] = None, next_link: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword versions: Versions available for this Extension Type. :paramtype versions: @@ -878,13 +846,13 @@ def __init__( :keyword next_link: The link to fetch the next page of Extension Types. :paramtype next_link: str """ - super(ExtensionVersionList, self).__init__(**kwargs) + super().__init__(**kwargs) self.versions = versions self.next_link = next_link self.system_data = None -class ExtensionVersionListVersionsItem(msrest.serialization.Model): +class ExtensionVersionListVersionsItem(_serialization.Model): """ExtensionVersionListVersionsItem. :ivar release_train: The release train for this Extension Type. @@ -894,29 +862,25 @@ class ExtensionVersionListVersionsItem(msrest.serialization.Model): """ _attribute_map = { - 'release_train': {'key': 'releaseTrain', 'type': 'str'}, - 'versions': {'key': 'versions', 'type': '[str]'}, + "release_train": {"key": "releaseTrain", "type": "str"}, + "versions": {"key": "versions", "type": "[str]"}, } def __init__( - self, - *, - release_train: Optional[str] = None, - versions: Optional[List[str]] = None, - **kwargs - ): + self, *, release_train: Optional[str] = None, versions: Optional[List[str]] = None, **kwargs: Any + ) -> None: """ :keyword release_train: The release train for this Extension Type. :paramtype release_train: str :keyword versions: Versions available for this Extension Type and release train. :paramtype versions: list[str] """ - super(ExtensionVersionListVersionsItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.release_train = release_train self.versions = versions -class FluxConfiguration(ProxyResource): +class FluxConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes """The Flux Configuration object returned in Get & Put response. Variables are only populated by the server, and will be ignored when sending a request. @@ -932,14 +896,14 @@ class FluxConfiguration(ProxyResource): :ivar system_data: Top level metadata https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SystemData - :ivar scope: Scope at which the operator will be installed. Possible values include: "cluster", - "namespace". Default value: "cluster". + :ivar scope: Scope at which the operator will be installed. Known values are: "cluster" and + "namespace". :vartype scope: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ScopeType :ivar namespace: The namespace to which this configuration is installed to. Maximum of 253 lower case alphanumeric characters, hyphen and period only. :vartype namespace: str - :ivar source_kind: Source Kind to pull the configuration data from. Possible values include: - "GitRepository", "Bucket". + :ivar source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository" and "Bucket". :vartype source_kind: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceKindType :ivar suspend: Whether this configuration should suspend its reconciliation of its @@ -972,12 +936,12 @@ class FluxConfiguration(ProxyResource): cluster. :vartype last_source_updated_at: ~datetime.datetime :ivar compliance_state: Combined status of the Flux Kubernetes resources created by the - fluxConfiguration or created by the managed objects. Possible values include: "Compliant", - "Non-Compliant", "Pending", "Suspended", "Unknown". Default value: "Unknown". + fluxConfiguration or created by the managed objects. Known values are: "Compliant", + "Non-Compliant", "Pending", "Suspended", and "Unknown". :vartype compliance_state: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxComplianceState - :ivar provisioning_state: Status of the creation of the fluxConfiguration. Possible values - include: "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting". + :ivar provisioning_state: Status of the creation of the fluxConfiguration. Known values are: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ProvisioningState :ivar error_message: Error message returned to the user in the case of provisioning failure. @@ -985,64 +949,64 @@ class FluxConfiguration(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'statuses': {'readonly': True}, - 'repository_public_key': {'readonly': True}, - 'last_source_updated_commit_id': {'readonly': True}, - 'last_source_updated_at': {'readonly': True}, - 'compliance_state': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'error_message': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "statuses": {"readonly": True}, + "repository_public_key": {"readonly": True}, + "last_source_updated_commit_id": {"readonly": True}, + "last_source_updated_at": {"readonly": True}, + "compliance_state": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "error_message": {"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'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'namespace': {'key': 'properties.namespace', 'type': 'str'}, - 'source_kind': {'key': 'properties.sourceKind', 'type': 'str'}, - 'suspend': {'key': 'properties.suspend', 'type': 'bool'}, - 'git_repository': {'key': 'properties.gitRepository', 'type': 'GitRepositoryDefinition'}, - 'bucket': {'key': 'properties.bucket', 'type': 'BucketDefinition'}, - 'kustomizations': {'key': 'properties.kustomizations', 'type': '{KustomizationDefinition}'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, - 'statuses': {'key': 'properties.statuses', 'type': '[ObjectStatusDefinition]'}, - 'repository_public_key': {'key': 'properties.repositoryPublicKey', 'type': 'str'}, - 'last_source_updated_commit_id': {'key': 'properties.lastSourceUpdatedCommitId', 'type': 'str'}, - 'last_source_updated_at': {'key': 'properties.lastSourceUpdatedAt', 'type': 'iso-8601'}, - 'compliance_state': {'key': 'properties.complianceState', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'error_message': {'key': 'properties.errorMessage', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "scope": {"key": "properties.scope", "type": "str"}, + "namespace": {"key": "properties.namespace", "type": "str"}, + "source_kind": {"key": "properties.sourceKind", "type": "str"}, + "suspend": {"key": "properties.suspend", "type": "bool"}, + "git_repository": {"key": "properties.gitRepository", "type": "GitRepositoryDefinition"}, + "bucket": {"key": "properties.bucket", "type": "BucketDefinition"}, + "kustomizations": {"key": "properties.kustomizations", "type": "{KustomizationDefinition}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "statuses": {"key": "properties.statuses", "type": "[ObjectStatusDefinition]"}, + "repository_public_key": {"key": "properties.repositoryPublicKey", "type": "str"}, + "last_source_updated_commit_id": {"key": "properties.lastSourceUpdatedCommitId", "type": "str"}, + "last_source_updated_at": {"key": "properties.lastSourceUpdatedAt", "type": "iso-8601"}, + "compliance_state": {"key": "properties.complianceState", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "error_message": {"key": "properties.errorMessage", "type": "str"}, } def __init__( self, *, - scope: Optional[Union[str, "ScopeType"]] = "cluster", - namespace: Optional[str] = "default", - source_kind: Optional[Union[str, "SourceKindType"]] = None, - suspend: Optional[bool] = False, - git_repository: Optional["GitRepositoryDefinition"] = None, - bucket: Optional["BucketDefinition"] = None, - kustomizations: Optional[Dict[str, "KustomizationDefinition"]] = None, + scope: Union[str, "_models.ScopeType"] = "cluster", + namespace: str = "default", + source_kind: Optional[Union[str, "_models.SourceKindType"]] = None, + suspend: bool = False, + git_repository: Optional["_models.GitRepositoryDefinition"] = None, + bucket: Optional["_models.BucketDefinition"] = None, + kustomizations: Optional[Dict[str, "_models.KustomizationDefinition"]] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword scope: Scope at which the operator will be installed. Possible values include: - "cluster", "namespace". Default value: "cluster". + :keyword scope: Scope at which the operator will be installed. Known values are: "cluster" and + "namespace". :paramtype scope: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ScopeType :keyword namespace: The namespace to which this configuration is installed to. Maximum of 253 lower case alphanumeric characters, hyphen and period only. :paramtype namespace: str - :keyword source_kind: Source Kind to pull the configuration data from. Possible values include: - "GitRepository", "Bucket". + :keyword source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository" and "Bucket". :paramtype source_kind: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceKindType :keyword suspend: Whether this configuration should suspend its reconciliation of its @@ -1062,7 +1026,7 @@ def __init__( for the configuration. :paramtype configuration_protected_settings: dict[str, str] """ - super(FluxConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.scope = scope self.namespace = namespace @@ -1081,11 +1045,11 @@ def __init__( self.error_message = None -class FluxConfigurationPatch(msrest.serialization.Model): +class FluxConfigurationPatch(_serialization.Model): """The Flux Configuration Patch Request object. - :ivar source_kind: Source Kind to pull the configuration data from. Possible values include: - "GitRepository", "Bucket". + :ivar source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository" and "Bucket". :vartype source_kind: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceKindType :ivar suspend: Whether this configuration should suspend its reconciliation of its @@ -1107,28 +1071,28 @@ class FluxConfigurationPatch(msrest.serialization.Model): """ _attribute_map = { - 'source_kind': {'key': 'properties.sourceKind', 'type': 'str'}, - 'suspend': {'key': 'properties.suspend', 'type': 'bool'}, - 'git_repository': {'key': 'properties.gitRepository', 'type': 'GitRepositoryPatchDefinition'}, - 'bucket': {'key': 'properties.bucket', 'type': 'BucketDefinition'}, - 'kustomizations': {'key': 'properties.kustomizations', 'type': '{KustomizationPatchDefinition}'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + "source_kind": {"key": "properties.sourceKind", "type": "str"}, + "suspend": {"key": "properties.suspend", "type": "bool"}, + "git_repository": {"key": "properties.gitRepository", "type": "GitRepositoryPatchDefinition"}, + "bucket": {"key": "properties.bucket", "type": "BucketDefinition"}, + "kustomizations": {"key": "properties.kustomizations", "type": "{KustomizationPatchDefinition}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, } def __init__( self, *, - source_kind: Optional[Union[str, "SourceKindType"]] = None, + source_kind: Optional[Union[str, "_models.SourceKindType"]] = None, suspend: Optional[bool] = None, - git_repository: Optional["GitRepositoryPatchDefinition"] = None, - bucket: Optional["BucketDefinition"] = None, - kustomizations: Optional[Dict[str, "KustomizationPatchDefinition"]] = None, + git_repository: Optional["_models.GitRepositoryPatchDefinition"] = None, + bucket: Optional["_models.BucketDefinition"] = None, + kustomizations: Optional[Dict[str, "_models.KustomizationPatchDefinition"]] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword source_kind: Source Kind to pull the configuration data from. Possible values include: - "GitRepository", "Bucket". + :keyword source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository" and "Bucket". :paramtype source_kind: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceKindType :keyword suspend: Whether this configuration should suspend its reconciliation of its @@ -1148,7 +1112,7 @@ def __init__( for the configuration. :paramtype configuration_protected_settings: dict[str, str] """ - super(FluxConfigurationPatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_kind = source_kind self.suspend = suspend self.git_repository = git_repository @@ -1157,8 +1121,9 @@ def __init__( self.configuration_protected_settings = configuration_protected_settings -class FluxConfigurationsList(msrest.serialization.Model): - """Result of the request to list Flux Configurations. It contains a list of FluxConfiguration objects and a URL link to get the next set of results. +class FluxConfigurationsList(_serialization.Model): + """Result of the request to list Flux Configurations. It contains a list of FluxConfiguration + objects and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -1170,37 +1135,33 @@ class FluxConfigurationsList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FluxConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[FluxConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FluxConfigurationsList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class GitRepositoryDefinition(msrest.serialization.Model): +class GitRepositoryDefinition(_serialization.Model): """Parameters to reconcile to the GitRepository source kind type. :ivar url: The URL to sync for the flux configuration git repository. :vartype url: str :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository source with the remote. - :vartype timeout_in_seconds: long + :vartype timeout_in_seconds: int :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster git repository source with the remote. - :vartype sync_interval_in_seconds: long + :vartype sync_interval_in_seconds: int :ivar repository_ref: The source reference for the GitRepository object. :vartype repository_ref: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.RepositoryRefDefinition @@ -1218,38 +1179,38 @@ class GitRepositoryDefinition(msrest.serialization.Model): """ _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, - 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, - 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, - 'repository_ref': {'key': 'repositoryRef', 'type': 'RepositoryRefDefinition'}, - 'ssh_known_hosts': {'key': 'sshKnownHosts', 'type': 'str'}, - 'https_user': {'key': 'httpsUser', 'type': 'str'}, - 'https_ca_cert': {'key': 'httpsCACert', 'type': 'str'}, - 'local_auth_ref': {'key': 'localAuthRef', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "repository_ref": {"key": "repositoryRef", "type": "RepositoryRefDefinition"}, + "ssh_known_hosts": {"key": "sshKnownHosts", "type": "str"}, + "https_user": {"key": "httpsUser", "type": "str"}, + "https_ca_cert": {"key": "httpsCACert", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, } def __init__( self, *, url: Optional[str] = None, - timeout_in_seconds: Optional[int] = 600, - sync_interval_in_seconds: Optional[int] = 600, - repository_ref: Optional["RepositoryRefDefinition"] = None, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, + repository_ref: Optional["_models.RepositoryRefDefinition"] = None, ssh_known_hosts: Optional[str] = None, https_user: Optional[str] = None, https_ca_cert: Optional[str] = None, local_auth_ref: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword url: The URL to sync for the flux configuration git repository. :paramtype url: str :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository source with the remote. - :paramtype timeout_in_seconds: long + :paramtype timeout_in_seconds: int :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster git repository source with the remote. - :paramtype sync_interval_in_seconds: long + :paramtype sync_interval_in_seconds: int :keyword repository_ref: The source reference for the GitRepository object. :paramtype repository_ref: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.RepositoryRefDefinition @@ -1266,7 +1227,7 @@ def __init__( authentication secret rather than the managed or user-provided configuration secrets. :paramtype local_auth_ref: str """ - super(GitRepositoryDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url self.timeout_in_seconds = timeout_in_seconds self.sync_interval_in_seconds = sync_interval_in_seconds @@ -1277,17 +1238,17 @@ def __init__( self.local_auth_ref = local_auth_ref -class GitRepositoryPatchDefinition(msrest.serialization.Model): +class GitRepositoryPatchDefinition(_serialization.Model): """Parameters to reconcile to the GitRepository source kind type. :ivar url: The URL to sync for the flux configuration git repository. :vartype url: str :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository source with the remote. - :vartype timeout_in_seconds: long + :vartype timeout_in_seconds: int :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster git repository source with the remote. - :vartype sync_interval_in_seconds: long + :vartype sync_interval_in_seconds: int :ivar repository_ref: The source reference for the GitRepository object. :vartype repository_ref: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.RepositoryRefDefinition @@ -1305,14 +1266,14 @@ class GitRepositoryPatchDefinition(msrest.serialization.Model): """ _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, - 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, - 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, - 'repository_ref': {'key': 'repositoryRef', 'type': 'RepositoryRefDefinition'}, - 'ssh_known_hosts': {'key': 'sshKnownHosts', 'type': 'str'}, - 'https_user': {'key': 'httpsUser', 'type': 'str'}, - 'https_ca_cert': {'key': 'httpsCACert', 'type': 'str'}, - 'local_auth_ref': {'key': 'localAuthRef', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "repository_ref": {"key": "repositoryRef", "type": "RepositoryRefDefinition"}, + "ssh_known_hosts": {"key": "sshKnownHosts", "type": "str"}, + "https_user": {"key": "httpsUser", "type": "str"}, + "https_ca_cert": {"key": "httpsCACert", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, } def __init__( @@ -1321,22 +1282,22 @@ def __init__( url: Optional[str] = None, timeout_in_seconds: Optional[int] = None, sync_interval_in_seconds: Optional[int] = None, - repository_ref: Optional["RepositoryRefDefinition"] = None, + repository_ref: Optional["_models.RepositoryRefDefinition"] = None, ssh_known_hosts: Optional[str] = None, https_user: Optional[str] = None, https_ca_cert: Optional[str] = None, local_auth_ref: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword url: The URL to sync for the flux configuration git repository. :paramtype url: str :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository source with the remote. - :paramtype timeout_in_seconds: long + :paramtype timeout_in_seconds: int :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster git repository source with the remote. - :paramtype sync_interval_in_seconds: long + :paramtype sync_interval_in_seconds: int :keyword repository_ref: The source reference for the GitRepository object. :paramtype repository_ref: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.RepositoryRefDefinition @@ -1353,7 +1314,7 @@ def __init__( authentication secret rather than the managed or user-provided configuration secrets. :paramtype local_auth_ref: str """ - super(GitRepositoryPatchDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url self.timeout_in_seconds = timeout_in_seconds self.sync_interval_in_seconds = sync_interval_in_seconds @@ -1364,7 +1325,7 @@ def __init__( self.local_auth_ref = local_auth_ref -class HelmOperatorProperties(msrest.serialization.Model): +class HelmOperatorProperties(_serialization.Model): """Properties for Helm operator. :ivar chart_version: Version of the operator Helm chart. @@ -1374,79 +1335,75 @@ class HelmOperatorProperties(msrest.serialization.Model): """ _attribute_map = { - 'chart_version': {'key': 'chartVersion', 'type': 'str'}, - 'chart_values': {'key': 'chartValues', 'type': 'str'}, + "chart_version": {"key": "chartVersion", "type": "str"}, + "chart_values": {"key": "chartValues", "type": "str"}, } def __init__( - self, - *, - chart_version: Optional[str] = None, - chart_values: Optional[str] = None, - **kwargs - ): + self, *, chart_version: Optional[str] = None, chart_values: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword chart_version: Version of the operator Helm chart. :paramtype chart_version: str :keyword chart_values: Values override for the operator Helm chart. :paramtype chart_values: str """ - super(HelmOperatorProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.chart_version = chart_version self.chart_values = chart_values -class HelmReleasePropertiesDefinition(msrest.serialization.Model): +class HelmReleasePropertiesDefinition(_serialization.Model): """HelmReleasePropertiesDefinition. :ivar last_revision_applied: The revision number of the last released object change. - :vartype last_revision_applied: long + :vartype last_revision_applied: int :ivar helm_chart_ref: The reference to the HelmChart object used as the source to this HelmRelease. :vartype helm_chart_ref: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ObjectReferenceDefinition :ivar failure_count: Total number of times that the HelmRelease failed to install or upgrade. - :vartype failure_count: long + :vartype failure_count: int :ivar install_failure_count: Number of times that the HelmRelease failed to install. - :vartype install_failure_count: long + :vartype install_failure_count: int :ivar upgrade_failure_count: Number of times that the HelmRelease failed to upgrade. - :vartype upgrade_failure_count: long + :vartype upgrade_failure_count: int """ _attribute_map = { - 'last_revision_applied': {'key': 'lastRevisionApplied', 'type': 'long'}, - 'helm_chart_ref': {'key': 'helmChartRef', 'type': 'ObjectReferenceDefinition'}, - 'failure_count': {'key': 'failureCount', 'type': 'long'}, - 'install_failure_count': {'key': 'installFailureCount', 'type': 'long'}, - 'upgrade_failure_count': {'key': 'upgradeFailureCount', 'type': 'long'}, + "last_revision_applied": {"key": "lastRevisionApplied", "type": "int"}, + "helm_chart_ref": {"key": "helmChartRef", "type": "ObjectReferenceDefinition"}, + "failure_count": {"key": "failureCount", "type": "int"}, + "install_failure_count": {"key": "installFailureCount", "type": "int"}, + "upgrade_failure_count": {"key": "upgradeFailureCount", "type": "int"}, } def __init__( self, *, last_revision_applied: Optional[int] = None, - helm_chart_ref: Optional["ObjectReferenceDefinition"] = None, + helm_chart_ref: Optional["_models.ObjectReferenceDefinition"] = None, failure_count: Optional[int] = None, install_failure_count: Optional[int] = None, upgrade_failure_count: Optional[int] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword last_revision_applied: The revision number of the last released object change. - :paramtype last_revision_applied: long + :paramtype last_revision_applied: int :keyword helm_chart_ref: The reference to the HelmChart object used as the source to this HelmRelease. :paramtype helm_chart_ref: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ObjectReferenceDefinition :keyword failure_count: Total number of times that the HelmRelease failed to install or upgrade. - :paramtype failure_count: long + :paramtype failure_count: int :keyword install_failure_count: Number of times that the HelmRelease failed to install. - :paramtype install_failure_count: long + :paramtype install_failure_count: int :keyword upgrade_failure_count: Number of times that the HelmRelease failed to upgrade. - :paramtype upgrade_failure_count: long + :paramtype upgrade_failure_count: int """ - super(HelmReleasePropertiesDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_revision_applied = last_revision_applied self.helm_chart_ref = helm_chart_ref self.failure_count = failure_count @@ -1454,7 +1411,7 @@ def __init__( self.upgrade_failure_count = upgrade_failure_count -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1463,41 +1420,35 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :ivar type: The identity type. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: """ - :keyword type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :keyword type: The identity type. Default value is "SystemAssigned". :paramtype type: str """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class KustomizationDefinition(msrest.serialization.Model): - """The Kustomization defining how to reconcile the artifact pulled by the source type on the cluster. +class KustomizationDefinition(_serialization.Model): + """The Kustomization defining how to reconcile the artifact pulled by the source type on the + cluster. :ivar path: The path in the source reference to reconcile on the cluster. :vartype path: str @@ -1507,13 +1458,13 @@ class KustomizationDefinition(msrest.serialization.Model): list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.DependsOnDefinition] :ivar timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the cluster. - :vartype timeout_in_seconds: long + :vartype timeout_in_seconds: int :ivar sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster. - :vartype sync_interval_in_seconds: long + :vartype sync_interval_in_seconds: int :ivar retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster in the event of failure on reconciliation. - :vartype retry_interval_in_seconds: long + :vartype retry_interval_in_seconds: int :ivar prune: Enable/disable garbage collections of Kubernetes objects created by this Kustomization. :vartype prune: bool @@ -1523,27 +1474,27 @@ class KustomizationDefinition(msrest.serialization.Model): """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'depends_on': {'key': 'dependsOn', 'type': '[DependsOnDefinition]'}, - 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, - 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, - 'retry_interval_in_seconds': {'key': 'retryIntervalInSeconds', 'type': 'long'}, - 'prune': {'key': 'prune', 'type': 'bool'}, - 'force': {'key': 'force', 'type': 'bool'}, + "path": {"key": "path", "type": "str"}, + "depends_on": {"key": "dependsOn", "type": "[DependsOnDefinition]"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "retry_interval_in_seconds": {"key": "retryIntervalInSeconds", "type": "int"}, + "prune": {"key": "prune", "type": "bool"}, + "force": {"key": "force", "type": "bool"}, } def __init__( self, *, - path: Optional[str] = "", - depends_on: Optional[List["DependsOnDefinition"]] = None, - timeout_in_seconds: Optional[int] = 600, - sync_interval_in_seconds: Optional[int] = 600, + path: str = "", + depends_on: Optional[List["_models.DependsOnDefinition"]] = None, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, retry_interval_in_seconds: Optional[int] = None, - prune: Optional[bool] = False, - force: Optional[bool] = False, - **kwargs - ): + prune: bool = False, + force: bool = False, + **kwargs: Any + ) -> None: """ :keyword path: The path in the source reference to reconcile on the cluster. :paramtype path: str @@ -1553,13 +1504,13 @@ def __init__( list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.DependsOnDefinition] :keyword timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the cluster. - :paramtype timeout_in_seconds: long + :paramtype timeout_in_seconds: int :keyword sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster. - :paramtype sync_interval_in_seconds: long + :paramtype sync_interval_in_seconds: int :keyword retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster in the event of failure on reconciliation. - :paramtype retry_interval_in_seconds: long + :paramtype retry_interval_in_seconds: int :keyword prune: Enable/disable garbage collections of Kubernetes objects created by this Kustomization. :paramtype prune: bool @@ -1567,7 +1518,7 @@ def __init__( fails due to an immutable field change. :paramtype force: bool """ - super(KustomizationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.depends_on = depends_on self.timeout_in_seconds = timeout_in_seconds @@ -1577,8 +1528,9 @@ def __init__( self.force = force -class KustomizationPatchDefinition(msrest.serialization.Model): - """The Kustomization defining how to reconcile the artifact pulled by the source type on the cluster. +class KustomizationPatchDefinition(_serialization.Model): + """The Kustomization defining how to reconcile the artifact pulled by the source type on the + cluster. :ivar path: The path in the source reference to reconcile on the cluster. :vartype path: str @@ -1588,13 +1540,13 @@ class KustomizationPatchDefinition(msrest.serialization.Model): list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.DependsOnDefinition] :ivar timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the cluster. - :vartype timeout_in_seconds: long + :vartype timeout_in_seconds: int :ivar sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster. - :vartype sync_interval_in_seconds: long + :vartype sync_interval_in_seconds: int :ivar retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster in the event of failure on reconciliation. - :vartype retry_interval_in_seconds: long + :vartype retry_interval_in_seconds: int :ivar prune: Enable/disable garbage collections of Kubernetes objects created by this Kustomization. :vartype prune: bool @@ -1604,27 +1556,27 @@ class KustomizationPatchDefinition(msrest.serialization.Model): """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'depends_on': {'key': 'dependsOn', 'type': '[DependsOnDefinition]'}, - 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, - 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, - 'retry_interval_in_seconds': {'key': 'retryIntervalInSeconds', 'type': 'long'}, - 'prune': {'key': 'prune', 'type': 'bool'}, - 'force': {'key': 'force', 'type': 'bool'}, + "path": {"key": "path", "type": "str"}, + "depends_on": {"key": "dependsOn", "type": "[DependsOnDefinition]"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "retry_interval_in_seconds": {"key": "retryIntervalInSeconds", "type": "int"}, + "prune": {"key": "prune", "type": "bool"}, + "force": {"key": "force", "type": "bool"}, } def __init__( self, *, path: Optional[str] = None, - depends_on: Optional[List["DependsOnDefinition"]] = None, + depends_on: Optional[List["_models.DependsOnDefinition"]] = None, timeout_in_seconds: Optional[int] = None, sync_interval_in_seconds: Optional[int] = None, retry_interval_in_seconds: Optional[int] = None, prune: Optional[bool] = None, force: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword path: The path in the source reference to reconcile on the cluster. :paramtype path: str @@ -1634,13 +1586,13 @@ def __init__( list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.DependsOnDefinition] :keyword timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the cluster. - :paramtype timeout_in_seconds: long + :paramtype timeout_in_seconds: int :keyword sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster. - :paramtype sync_interval_in_seconds: long + :paramtype sync_interval_in_seconds: int :keyword retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster in the event of failure on reconciliation. - :paramtype retry_interval_in_seconds: long + :paramtype retry_interval_in_seconds: int :keyword prune: Enable/disable garbage collections of Kubernetes objects created by this Kustomization. :paramtype prune: bool @@ -1648,7 +1600,7 @@ def __init__( fails due to an immutable field change. :paramtype force: bool """ - super(KustomizationPatchDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.depends_on = depends_on self.timeout_in_seconds = timeout_in_seconds @@ -1658,7 +1610,7 @@ def __init__( self.force = force -class ObjectReferenceDefinition(msrest.serialization.Model): +class ObjectReferenceDefinition(_serialization.Model): """Object reference to a Kubernetes object on a cluster. :ivar name: Name of the object. @@ -1668,29 +1620,23 @@ class ObjectReferenceDefinition(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, namespace: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: Name of the object. :paramtype name: str :keyword namespace: Namespace of the object. :paramtype namespace: str """ - super(ObjectReferenceDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.namespace = namespace -class ObjectStatusConditionDefinition(msrest.serialization.Model): +class ObjectStatusConditionDefinition(_serialization.Model): """Status condition of Kubernetes object. :ivar last_transition_time: Last time this status condition has changed. @@ -1706,11 +1652,11 @@ class ObjectStatusConditionDefinition(msrest.serialization.Model): """ _attribute_map = { - 'last_transition_time': {'key': 'lastTransitionTime', 'type': 'iso-8601'}, - 'message': {'key': 'message', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "last_transition_time": {"key": "lastTransitionTime", "type": "iso-8601"}, + "message": {"key": "message", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -1721,8 +1667,8 @@ def __init__( reason: Optional[str] = None, status: Optional[str] = None, type: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword last_transition_time: Last time this status condition has changed. :paramtype last_transition_time: ~datetime.datetime @@ -1735,7 +1681,7 @@ def __init__( :keyword type: Object status condition type for this object. :paramtype type: str """ - super(ObjectStatusConditionDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_transition_time = last_transition_time self.message = message self.reason = reason @@ -1743,7 +1689,7 @@ def __init__( self.type = type -class ObjectStatusDefinition(msrest.serialization.Model): +class ObjectStatusDefinition(_serialization.Model): """Statuses of objects deployed by the user-specified kustomizations from the git repository. :ivar name: Name of the applied object. @@ -1753,8 +1699,8 @@ class ObjectStatusDefinition(msrest.serialization.Model): :ivar kind: Kind of the applied object. :vartype kind: str :ivar compliance_state: Compliance state of the applied object showing whether the applied - object has come into a ready state on the cluster. Possible values include: "Compliant", - "Non-Compliant", "Pending", "Suspended", "Unknown". Default value: "Unknown". + object has come into a ready state on the cluster. Known values are: "Compliant", + "Non-Compliant", "Pending", "Suspended", and "Unknown". :vartype compliance_state: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxComplianceState :ivar applied_by: Object reference to the Kustomization that applied this object. @@ -1770,13 +1716,13 @@ class ObjectStatusDefinition(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'compliance_state': {'key': 'complianceState', 'type': 'str'}, - 'applied_by': {'key': 'appliedBy', 'type': 'ObjectReferenceDefinition'}, - 'status_conditions': {'key': 'statusConditions', 'type': '[ObjectStatusConditionDefinition]'}, - 'helm_release_properties': {'key': 'helmReleaseProperties', 'type': 'HelmReleasePropertiesDefinition'}, + "name": {"key": "name", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "compliance_state": {"key": "complianceState", "type": "str"}, + "applied_by": {"key": "appliedBy", "type": "ObjectReferenceDefinition"}, + "status_conditions": {"key": "statusConditions", "type": "[ObjectStatusConditionDefinition]"}, + "helm_release_properties": {"key": "helmReleaseProperties", "type": "HelmReleasePropertiesDefinition"}, } def __init__( @@ -1785,12 +1731,12 @@ def __init__( name: Optional[str] = None, namespace: Optional[str] = None, kind: Optional[str] = None, - compliance_state: Optional[Union[str, "FluxComplianceState"]] = "Unknown", - applied_by: Optional["ObjectReferenceDefinition"] = None, - status_conditions: Optional[List["ObjectStatusConditionDefinition"]] = None, - helm_release_properties: Optional["HelmReleasePropertiesDefinition"] = None, - **kwargs - ): + compliance_state: Union[str, "_models.FluxComplianceState"] = "Unknown", + applied_by: Optional["_models.ObjectReferenceDefinition"] = None, + status_conditions: Optional[List["_models.ObjectStatusConditionDefinition"]] = None, + helm_release_properties: Optional["_models.HelmReleasePropertiesDefinition"] = None, + **kwargs: Any + ) -> None: """ :keyword name: Name of the applied object. :paramtype name: str @@ -1799,8 +1745,8 @@ def __init__( :keyword kind: Kind of the applied object. :paramtype kind: str :keyword compliance_state: Compliance state of the applied object showing whether the applied - object has come into a ready state on the cluster. Possible values include: "Compliant", - "Non-Compliant", "Pending", "Suspended", "Unknown". Default value: "Unknown". + object has come into a ready state on the cluster. Known values are: "Compliant", + "Non-Compliant", "Pending", "Suspended", and "Unknown". :paramtype compliance_state: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxComplianceState :keyword applied_by: Object reference to the Kustomization that applied this object. @@ -1814,7 +1760,7 @@ def __init__( :paramtype helm_release_properties: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.HelmReleasePropertiesDefinition """ - super(ObjectStatusDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.namespace = namespace self.kind = kind @@ -1824,7 +1770,7 @@ def __init__( self.helm_release_properties = helm_release_properties -class OperationStatusList(msrest.serialization.Model): +class OperationStatusList(_serialization.Model): """The async operations in progress, in the cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -1837,27 +1783,23 @@ class OperationStatusList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationStatusResult]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OperationStatusResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationStatusList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class OperationStatusResult(msrest.serialization.Model): +class OperationStatusResult(_serialization.Model): """The current status of an async operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1868,7 +1810,7 @@ class OperationStatusResult(msrest.serialization.Model): :vartype id: str :ivar name: Name of the async operation. :vartype name: str - :ivar status: Required. Operation status. + :ivar status: Operation status. Required. :vartype status: str :ivar properties: Additional information, if available. :vartype properties: dict[str, str] @@ -1877,38 +1819,38 @@ class OperationStatusResult(msrest.serialization.Model): """ _validation = { - 'status': {'required': True}, - 'error': {'readonly': True}, + "status": {"required": True}, + "error": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, + "error": {"key": "error", "type": "ErrorDetail"}, } def __init__( self, *, status: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, properties: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: Fully qualified ID for the async operation. :paramtype id: str :keyword name: Name of the async operation. :paramtype name: str - :keyword status: Required. Operation status. + :keyword status: Operation status. Required. :paramtype status: str :keyword properties: Additional information, if available. :paramtype properties: dict[str, str] """ - super(OperationStatusResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.status = status @@ -1916,7 +1858,7 @@ def __init__( self.error = None -class PatchExtension(msrest.serialization.Model): +class PatchExtension(_serialization.Model): """The Extension Patch Request object. :ivar auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade @@ -1937,23 +1879,23 @@ class PatchExtension(msrest.serialization.Model): """ _attribute_map = { - 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, - 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "configuration_settings": {"key": "properties.configurationSettings", "type": "{str}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, } def __init__( self, *, - auto_upgrade_minor_version: Optional[bool] = True, - release_train: Optional[str] = "Stable", + auto_upgrade_minor_version: bool = True, + release_train: str = "Stable", version: Optional[str] = None, configuration_settings: Optional[Dict[str, str]] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade of minor version, or not. @@ -1971,7 +1913,7 @@ def __init__( name-value pairs for configuring this extension. :paramtype configuration_protected_settings: dict[str, str] """ - super(PatchExtension, self).__init__(**kwargs) + super().__init__(**kwargs) self.auto_upgrade_minor_version = auto_upgrade_minor_version self.release_train = release_train self.version = version @@ -1979,7 +1921,7 @@ def __init__( self.configuration_protected_settings = configuration_protected_settings -class RepositoryRefDefinition(msrest.serialization.Model): +class RepositoryRefDefinition(_serialization.Model): """The source reference for the GitRepository object. :ivar branch: The git repository branch name to checkout. @@ -1995,10 +1937,10 @@ class RepositoryRefDefinition(msrest.serialization.Model): """ _attribute_map = { - 'branch': {'key': 'branch', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'semver': {'key': 'semver', 'type': 'str'}, - 'commit': {'key': 'commit', 'type': 'str'}, + "branch": {"key": "branch", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "semver": {"key": "semver", "type": "str"}, + "commit": {"key": "commit", "type": "str"}, } def __init__( @@ -2008,8 +1950,8 @@ def __init__( tag: Optional[str] = None, semver: Optional[str] = None, commit: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword branch: The git repository branch name to checkout. :paramtype branch: str @@ -2022,14 +1964,14 @@ def __init__( to be valid. This takes precedence over semver. :paramtype commit: str """ - super(RepositoryRefDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.branch = branch self.tag = tag self.semver = semver self.commit = commit -class ResourceProviderOperation(msrest.serialization.Model): +class ResourceProviderOperation(_serialization.Model): """Supported operation of this resource provider. Variables are only populated by the server, and will be ignored when sending a request. @@ -2046,24 +1988,24 @@ class ResourceProviderOperation(msrest.serialization.Model): """ _validation = { - 'is_data_action': {'readonly': True}, - 'origin': {'readonly': True}, + "is_data_action": {"readonly": True}, + "origin": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'origin': {'key': 'origin', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "ResourceProviderOperationDisplay"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "origin": {"key": "origin", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["ResourceProviderOperationDisplay"] = None, - **kwargs - ): + display: Optional["_models.ResourceProviderOperationDisplay"] = None, + **kwargs: Any + ) -> None: """ :keyword name: Operation name, in format of {provider}/{resource}/{operation}. :paramtype name: str @@ -2071,14 +2013,14 @@ def __init__( :paramtype display: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ResourceProviderOperationDisplay """ - super(ResourceProviderOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.is_data_action = None self.origin = None -class ResourceProviderOperationDisplay(msrest.serialization.Model): +class ResourceProviderOperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Resource provider: Microsoft KubernetesConfiguration. @@ -2092,10 +2034,10 @@ class ResourceProviderOperationDisplay(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__( @@ -2105,8 +2047,8 @@ def __init__( resource: Optional[str] = None, operation: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword provider: Resource provider: Microsoft KubernetesConfiguration. :paramtype provider: str @@ -2117,14 +2059,14 @@ def __init__( :keyword description: Description of this operation. :paramtype description: str """ - super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class ResourceProviderOperationList(msrest.serialization.Model): +class ResourceProviderOperationList(_serialization.Model): """Result of the request to list operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -2137,31 +2079,26 @@ class ResourceProviderOperationList(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceProviderOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceProviderOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceProviderOperation"]] = None, **kwargs: Any) -> None: """ :keyword value: List of operations supported by this resource provider. :paramtype value: list[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ResourceProviderOperation] """ - super(ResourceProviderOperationList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class Scope(msrest.serialization.Model): +class Scope(_serialization.Model): """Scope of the extension. It can be either Cluster or Namespace; but not both. :ivar cluster: Specifies that the scope of the extension is Cluster. @@ -2172,17 +2109,17 @@ class Scope(msrest.serialization.Model): """ _attribute_map = { - 'cluster': {'key': 'cluster', 'type': 'ScopeCluster'}, - 'namespace': {'key': 'namespace', 'type': 'ScopeNamespace'}, + "cluster": {"key": "cluster", "type": "ScopeCluster"}, + "namespace": {"key": "namespace", "type": "ScopeNamespace"}, } def __init__( self, *, - cluster: Optional["ScopeCluster"] = None, - namespace: Optional["ScopeNamespace"] = None, - **kwargs - ): + cluster: Optional["_models.ScopeCluster"] = None, + namespace: Optional["_models.ScopeNamespace"] = None, + **kwargs: Any + ) -> None: """ :keyword cluster: Specifies that the scope of the extension is Cluster. :paramtype cluster: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ScopeCluster @@ -2190,12 +2127,12 @@ def __init__( :paramtype namespace: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ScopeNamespace """ - super(Scope, self).__init__(**kwargs) + super().__init__(**kwargs) self.cluster = cluster self.namespace = namespace -class ScopeCluster(msrest.serialization.Model): +class ScopeCluster(_serialization.Model): """Specifies that the scope of the extension is Cluster. :ivar release_namespace: Namespace where the extension Release must be placed, for a Cluster @@ -2204,25 +2141,20 @@ class ScopeCluster(msrest.serialization.Model): """ _attribute_map = { - 'release_namespace': {'key': 'releaseNamespace', 'type': 'str'}, + "release_namespace": {"key": "releaseNamespace", "type": "str"}, } - def __init__( - self, - *, - release_namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, release_namespace: Optional[str] = None, **kwargs: Any) -> None: """ :keyword release_namespace: Namespace where the extension Release must be placed, for a Cluster scoped extension. If this namespace does not exist, it will be created. :paramtype release_namespace: str """ - super(ScopeCluster, self).__init__(**kwargs) + super().__init__(**kwargs) self.release_namespace = release_namespace -class ScopeNamespace(msrest.serialization.Model): +class ScopeNamespace(_serialization.Model): """Specifies that the scope of the extension is Namespace. :ivar target_namespace: Namespace where the extension will be created for an Namespace scoped @@ -2231,25 +2163,20 @@ class ScopeNamespace(msrest.serialization.Model): """ _attribute_map = { - 'target_namespace': {'key': 'targetNamespace', 'type': 'str'}, + "target_namespace": {"key": "targetNamespace", "type": "str"}, } - def __init__( - self, - *, - target_namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_namespace: Optional[str] = None, **kwargs: Any) -> None: """ :keyword target_namespace: Namespace where the extension will be created for an Namespace scoped extension. If this namespace does not exist, it will be created. :paramtype target_namespace: str """ - super(ScopeNamespace, self).__init__(**kwargs) + super().__init__(**kwargs) self.target_namespace = target_namespace -class SourceControlConfiguration(ProxyResource): +class SourceControlConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes """The SourceControl Configuration object returned in Get & Put response. Variables are only populated by the server, and will be ignored when sending a request. @@ -2273,7 +2200,7 @@ class SourceControlConfiguration(ProxyResource): :ivar operator_instance_name: Instance name of the operator - identifying the specific configuration. :vartype operator_instance_name: str - :ivar operator_type: Type of the operator. Possible values include: "Flux". + :ivar operator_type: Type of the operator. "Flux" :vartype operator_type: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperatorType :ivar operator_params: Any Parameters for the Operator instance in string format. @@ -2281,8 +2208,8 @@ class SourceControlConfiguration(ProxyResource): :ivar configuration_protected_settings: Name-value pairs of protected configuration settings for the configuration. :vartype configuration_protected_settings: dict[str, str] - :ivar operator_scope: Scope at which the operator will be installed. Possible values include: - "cluster", "namespace". Default value: "cluster". + :ivar operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". :vartype operator_scope: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperatorScopeType :ivar repository_public_key: Public Key associated with this SourceControl configuration @@ -2296,8 +2223,8 @@ class SourceControlConfiguration(ProxyResource): :ivar helm_operator_properties: Properties for Helm operator. :vartype helm_operator_properties: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.HelmOperatorProperties - :ivar provisioning_state: The provisioning state of the resource provider. Possible values - include: "Accepted", "Deleting", "Running", "Succeeded", "Failed". + :ivar provisioning_state: The provisioning state of the resource provider. Known values are: + "Accepted", "Deleting", "Running", "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ProvisioningStateType :ivar compliance_status: Compliance Status of the Configuration. @@ -2306,50 +2233,50 @@ class SourceControlConfiguration(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'repository_public_key': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'compliance_status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "repository_public_key": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "compliance_status": {"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'}, - 'repository_url': {'key': 'properties.repositoryUrl', 'type': 'str'}, - 'operator_namespace': {'key': 'properties.operatorNamespace', 'type': 'str'}, - 'operator_instance_name': {'key': 'properties.operatorInstanceName', 'type': 'str'}, - 'operator_type': {'key': 'properties.operatorType', 'type': 'str'}, - 'operator_params': {'key': 'properties.operatorParams', 'type': 'str'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, - 'operator_scope': {'key': 'properties.operatorScope', 'type': 'str'}, - 'repository_public_key': {'key': 'properties.repositoryPublicKey', 'type': 'str'}, - 'ssh_known_hosts_contents': {'key': 'properties.sshKnownHostsContents', 'type': 'str'}, - 'enable_helm_operator': {'key': 'properties.enableHelmOperator', 'type': 'bool'}, - 'helm_operator_properties': {'key': 'properties.helmOperatorProperties', 'type': 'HelmOperatorProperties'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'compliance_status': {'key': 'properties.complianceStatus', 'type': 'ComplianceStatus'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "repository_url": {"key": "properties.repositoryUrl", "type": "str"}, + "operator_namespace": {"key": "properties.operatorNamespace", "type": "str"}, + "operator_instance_name": {"key": "properties.operatorInstanceName", "type": "str"}, + "operator_type": {"key": "properties.operatorType", "type": "str"}, + "operator_params": {"key": "properties.operatorParams", "type": "str"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "operator_scope": {"key": "properties.operatorScope", "type": "str"}, + "repository_public_key": {"key": "properties.repositoryPublicKey", "type": "str"}, + "ssh_known_hosts_contents": {"key": "properties.sshKnownHostsContents", "type": "str"}, + "enable_helm_operator": {"key": "properties.enableHelmOperator", "type": "bool"}, + "helm_operator_properties": {"key": "properties.helmOperatorProperties", "type": "HelmOperatorProperties"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "compliance_status": {"key": "properties.complianceStatus", "type": "ComplianceStatus"}, } def __init__( self, *, repository_url: Optional[str] = None, - operator_namespace: Optional[str] = "default", + operator_namespace: str = "default", operator_instance_name: Optional[str] = None, - operator_type: Optional[Union[str, "OperatorType"]] = None, + operator_type: Optional[Union[str, "_models.OperatorType"]] = None, operator_params: Optional[str] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - operator_scope: Optional[Union[str, "OperatorScopeType"]] = "cluster", + operator_scope: Union[str, "_models.OperatorScopeType"] = "cluster", ssh_known_hosts_contents: Optional[str] = None, enable_helm_operator: Optional[bool] = None, - helm_operator_properties: Optional["HelmOperatorProperties"] = None, - **kwargs - ): + helm_operator_properties: Optional["_models.HelmOperatorProperties"] = None, + **kwargs: Any + ) -> None: """ :keyword repository_url: Url of the SourceControl Repository. :paramtype repository_url: str @@ -2359,7 +2286,7 @@ def __init__( :keyword operator_instance_name: Instance name of the operator - identifying the specific configuration. :paramtype operator_instance_name: str - :keyword operator_type: Type of the operator. Possible values include: "Flux". + :keyword operator_type: Type of the operator. "Flux" :paramtype operator_type: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperatorType :keyword operator_params: Any Parameters for the Operator instance in string format. @@ -2367,8 +2294,8 @@ def __init__( :keyword configuration_protected_settings: Name-value pairs of protected configuration settings for the configuration. :paramtype configuration_protected_settings: dict[str, str] - :keyword operator_scope: Scope at which the operator will be installed. Possible values - include: "cluster", "namespace". Default value: "cluster". + :keyword operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". :paramtype operator_scope: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperatorScopeType :keyword ssh_known_hosts_contents: Base64-encoded known_hosts contents containing public SSH @@ -2380,7 +2307,7 @@ def __init__( :paramtype helm_operator_properties: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.HelmOperatorProperties """ - super(SourceControlConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.repository_url = repository_url self.operator_namespace = operator_namespace @@ -2397,8 +2324,9 @@ def __init__( self.compliance_status = None -class SourceControlConfigurationList(msrest.serialization.Model): - """Result of the request to list Source Control Configurations. It contains a list of SourceControlConfiguration objects and a URL link to get the next set of results. +class SourceControlConfigurationList(_serialization.Model): + """Result of the request to list Source Control Configurations. It contains a list of + SourceControlConfiguration objects and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -2410,27 +2338,23 @@ class SourceControlConfigurationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SourceControlConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SourceControlConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SourceControlConfigurationList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SupportedScopes(msrest.serialization.Model): +class SupportedScopes(_serialization.Model): """Extension scopes. :ivar default_scope: Default extension scopes: cluster or namespace. @@ -2441,17 +2365,17 @@ class SupportedScopes(msrest.serialization.Model): """ _attribute_map = { - 'default_scope': {'key': 'defaultScope', 'type': 'str'}, - 'cluster_scope_settings': {'key': 'clusterScopeSettings', 'type': 'ClusterScopeSettings'}, + "default_scope": {"key": "defaultScope", "type": "str"}, + "cluster_scope_settings": {"key": "clusterScopeSettings", "type": "ClusterScopeSettings"}, } def __init__( self, *, default_scope: Optional[str] = None, - cluster_scope_settings: Optional["ClusterScopeSettings"] = None, - **kwargs - ): + cluster_scope_settings: Optional["_models.ClusterScopeSettings"] = None, + **kwargs: Any + ) -> None: """ :keyword default_scope: Default extension scopes: cluster or namespace. :paramtype default_scope: str @@ -2459,26 +2383,26 @@ def __init__( :paramtype cluster_scope_settings: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ClusterScopeSettings """ - super(SupportedScopes, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_scope = default_scope self.cluster_scope_settings = cluster_scope_settings -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.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -2486,44 +2410,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 - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. 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.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_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 diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/models/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/models/_source_control_configuration_client_enums.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/models/_source_control_configuration_client_enums.py index 9c16b8178503..dee3ff40b3db 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/models/_source_control_configuration_client_enums.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/models/_source_control_configuration_client_enums.py @@ -7,20 +7,18 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ClusterTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Cluster types - """ +class ClusterTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Cluster types.""" CONNECTED_CLUSTERS = "connectedClusters" MANAGED_CLUSTERS = "managedClusters" -class ComplianceStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The compliance state of the configuration. - """ + +class ComplianceStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The compliance state of the configuration.""" PENDING = "Pending" COMPLIANT = "Compliant" @@ -28,28 +26,32 @@ class ComplianceStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INSTALLED = "Installed" FAILED = "Failed" -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 ExtensionsClusterResourceName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ExtensionsClusterResourceName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ExtensionsClusterResourceName.""" MANAGED_CLUSTERS = "managedClusters" CONNECTED_CLUSTERS = "connectedClusters" -class ExtensionsClusterRp(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ExtensionsClusterRp(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ExtensionsClusterRp.""" MICROSOFT_CONTAINER_SERVICE = "Microsoft.ContainerService" MICROSOFT_KUBERNETES = "Microsoft.Kubernetes" -class FluxComplianceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Compliance state of the cluster object. - """ + +class FluxComplianceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Compliance state of the cluster object.""" COMPLIANT = "Compliant" NON_COMPLIANT = "Non-Compliant" @@ -57,7 +59,8 @@ class FluxComplianceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUSPENDED = "Suspended" UNKNOWN = "Unknown" -class KustomizationValidationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class KustomizationValidationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify whether to validate the Kubernetes objects referenced in the Kustomization before applying them to the cluster. """ @@ -66,38 +69,38 @@ class KustomizationValidationType(with_metaclass(CaseInsensitiveEnumMeta, str, E CLIENT = "client" SERVER = "server" -class LevelType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Level of the status. - """ + +class LevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the status.""" ERROR = "Error" WARNING = "Warning" INFORMATION = "Information" -class MessageLevelType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Level of the message. - """ + +class MessageLevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the message.""" ERROR = "Error" WARNING = "Warning" INFORMATION = "Information" -class OperatorScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Scope at which the operator will be installed. - """ + +class OperatorScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scope at which the operator will be installed.""" CLUSTER = "cluster" NAMESPACE = "namespace" -class OperatorType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the operator - """ + +class OperatorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the operator.""" FLUX = "Flux" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of the resource. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource.""" SUCCEEDED = "Succeeded" FAILED = "Failed" @@ -106,9 +109,9 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" DELETING = "Deleting" -class ProvisioningStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of the resource provider. - """ + +class ProvisioningStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource provider.""" ACCEPTED = "Accepted" DELETING = "Deleting" @@ -116,16 +119,16 @@ class ProvisioningStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" FAILED = "Failed" -class ScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Scope at which the configuration will be installed. - """ + +class ScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scope at which the configuration will be installed.""" CLUSTER = "cluster" NAMESPACE = "namespace" -class SourceKindType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Source Kind to pull the configuration data from. - """ + +class SourceKindType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Source Kind to pull the configuration data from.""" GIT_REPOSITORY = "GitRepository" BUCKET = "Bucket" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/__init__.py index 37008240af35..ccd968835618 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/__init__.py @@ -17,15 +17,21 @@ from ._source_control_configurations_operations import SourceControlConfigurationsOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ClusterExtensionTypeOperations', - 'ClusterExtensionTypesOperations', - 'ExtensionTypeVersionsOperations', - 'LocationExtensionTypesOperations', - 'ExtensionsOperations', - 'OperationStatusOperations', - 'FluxConfigurationsOperations', - 'FluxConfigOperationStatusOperations', - 'SourceControlConfigurationsOperations', - 'Operations', + "ClusterExtensionTypeOperations", + "ClusterExtensionTypesOperations", + "ExtensionTypeVersionsOperations", + "LocationExtensionTypesOperations", + "ExtensionsOperations", + "OperationStatusOperations", + "FluxConfigurationsOperations", + "FluxConfigOperationStatusOperations", + "SourceControlConfigurationsOperations", + "Operations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_cluster_extension_type_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_cluster_extension_type_operations.py index 93725f6313e4..49cbcc3a6e6d 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_cluster_extension_type_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_cluster_extension_type_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,139 +6,171 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_type_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionTypeName": _SERIALIZER.url("extension_type_name", extension_type_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionTypeName": _SERIALIZER.url("extension_type_name", extension_type_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) -class ClusterExtensionTypeOperations(object): - """ClusterExtensionTypeOperations 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 ClusterExtensionTypeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_01_preview.SourceControlConfigurationClient`'s + :attr:`cluster_extension_type` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_type_name: str, **kwargs: Any - ) -> "_models.ExtensionType": + ) -> _models.ExtensionType: """Get Extension Type details. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_type_name: Extension type name. + :param extension_type_name: Extension type name. Required. :type extension_type_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExtensionType, or the result of cls(response) + :return: ExtensionType or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionType - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionType"] 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ExtensionType] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_type_name=extension_type_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -145,12 +178,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExtensionType', pipeline_response) + deserialized = self._deserialize("ExtensionType", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_cluster_extension_types_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_cluster_extension_types_operations.py index 3169d2147445..757f87feafe6 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_cluster_extension_types_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_cluster_extension_types_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,144 +6,179 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +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 msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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") -class ClusterExtensionTypesOperations(object): - """ClusterExtensionTypesOperations 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.kubernetesconfiguration.v2022_01_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 ClusterExtensionTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.SourceControlConfigurationClient`'s + :attr:`cluster_extension_types` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.ExtensionTypeList"]: + ) -> Iterable["_models.ExtensionType"]: """Get Extension Types. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionTypeList or the result of cls(response) + :return: An iterator like instance of either ExtensionType or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionTypeList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionType] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionTypeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ExtensionTypeList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -153,13 +189,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionTypeList", 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(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]: @@ -169,8 +207,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_extension_type_versions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_extension_type_versions_operations.py index e377f2282604..94c5bab4bfd4 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_extension_type_versions_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_extension_type_versions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,127 +6,151 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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( - subscription_id: str, - location: str, - extension_type_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2022-01-01-preview" - accept = "application/json" + +def build_list_request(location: str, extension_type_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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions", + ) # 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'), - "extensionTypeName": _SERIALIZER.url("extension_type_name", extension_type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), + "extensionTypeName": _SERIALIZER.url("extension_type_name", extension_type_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) -class ExtensionTypeVersionsOperations(object): - """ExtensionTypeVersionsOperations 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 ExtensionTypeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_01_preview.SourceControlConfigurationClient`'s + :attr:`extension_type_versions` 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, - location: str, - extension_type_name: str, - **kwargs: Any - ) -> Iterable["_models.ExtensionVersionList"]: + self, location: str, extension_type_name: str, **kwargs: Any + ) -> Iterable["_models.ExtensionVersionListVersionsItem"]: """List available versions for an Extension Type. - :param location: extension location. + :param location: extension location. Required. :type location: str - :param extension_type_name: Extension type name. + :param extension_type_name: Extension type name. Required. :type extension_type_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionVersionList or the result of + :return: An iterator like instance of either ExtensionVersionListVersionsItem or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionVersionList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionVersionListVersionsItem] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionVersionList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ExtensionVersionList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, extension_type_name=extension_type_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - extension_type_name=extension_type_name, - 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) @@ -136,13 +161,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionVersionList", pipeline_response) list_of_elem = deserialized.versions 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(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]: @@ -152,8 +179,8 @@ 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.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_extensions_operations.py index 05b12aea1279..8bc020fd9dc6 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_extensions_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_extensions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,360 +6,507 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -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 msrest import Serializer 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_create_request_initial( - subscription_id: str, + +def build_create_request( resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2022-01-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_delete_request_initial( - subscription_id: str, + +def build_delete_request( resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, + subscription_id: str, *, force_delete: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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") if force_delete is not None: - query_parameters['forceDelete'] = _SERIALIZER.query("force_delete", force_delete, 'bool') + _params["forceDelete"] = _SERIALIZER.query("force_delete", force_delete, "bool") # 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, + +def build_update_request( resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2022-01-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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") -class ExtensionsOperations(object): - """ExtensionsOperations 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.kubernetesconfiguration.v2022_01_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 ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _create_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> "_models.Extension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + ) -> _models.Extension: 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 {}) - 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(extension, 'Extension') + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IO, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension + :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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> LROPoller["_models.Extension"]: + ) -> LROPoller[_models.Extension]: """Create a new Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param extension: Properties necessary to Create an Extension. - :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension + :param extension: Properties necessary to Create an Extension. Is either a Extension type or a + IO type. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension 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 @@ -370,16 +518,19 @@ def begin_create( :return: An instance of LROPoller that returns either Extension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] - 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["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-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.Extension] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -388,86 +539,111 @@ def begin_create( cluster_name=cluster_name, extension_name=extension_name, extension=extension, + 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('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, **kwargs: Any - ) -> "_models.Extension": + ) -> _models.Extension: """Gets Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Extension, or the result of cls(response) + :return: Extension or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -475,65 +651,83 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, force_delete: Optional[bool] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, force_delete=force_delete, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(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, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, force_delete: Optional[bool] = None, @@ -543,21 +737,24 @@ def begin_delete( from the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :param force_delete: Delete the extension resource in Azure - not the normal asynchronous - delete. + delete. Default value is None. :type force_delete: bool :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. @@ -569,129 +766,274 @@ def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, force_delete=force_delete, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } def _update_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, - patch_extension: "_models.PatchExtension", + patch_extension: Union[_models.PatchExtension, IO], **kwargs: Any - ) -> "_models.Extension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + ) -> _models.Extension: 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 {}) - 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(patch_extension, 'PatchExtension') + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(patch_extension, (IO, bytes)): + _content = patch_extension + else: + _json = self._serialize.body(patch_extension, "PatchExtension") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_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(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + patch_extension: _models.PatchExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.PatchExtension + :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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + patch_extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, - patch_extension: "_models.PatchExtension", + patch_extension: Union[_models.PatchExtension, IO], **kwargs: Any - ) -> LROPoller["_models.Extension"]: + ) -> LROPoller[_models.Extension]: """Patch an existing Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param patch_extension: Properties to Patch in an existing Extension. + :param patch_extension: Properties to Patch in an existing Extension. Is either a + PatchExtension type or a IO type. Required. :type patch_extension: - ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.PatchExtension + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.PatchExtension 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 @@ -703,16 +1045,19 @@ def begin_update( :return: An instance of LROPoller that returns either Extension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] - 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["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-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.Extension] = 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, @@ -721,92 +1066,119 @@ def begin_update( cluster_name=cluster_name, extension_name=extension_name, patch_extension=patch_extension, + 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('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.ExtensionsList"]: + ) -> Iterable["_models.Extension"]: """List all Extensions in the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionsList or the result of cls(response) + :return: An iterator like instance of either Extension or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ExtensionsList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -817,13 +1189,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionsList", 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(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]: @@ -833,8 +1207,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_flux_config_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_flux_config_operation_status_operations.py index c27704439644..0261ed505e63 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_flux_config_operation_status_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_flux_config_operation_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,145 +6,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, operation_id: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_name, 'str'), - "operationId": _SERIALIZER.url("operation_id", operation_id, '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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "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) -class FluxConfigOperationStatusOperations(object): - """FluxConfigOperationStatusOperations 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 FluxConfigOperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_01_preview.SourceControlConfigurationClient`'s + :attr:`flux_config_operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationStatusResult": + ) -> _models.OperationStatusResult: """Get Async Operation status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str - :param operation_id: operation Id. + :param operation_id: operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatusResult, or the result of cls(response) + :return: OperationStatusResult or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperationStatusResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -151,12 +184,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_flux_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_flux_configurations_operations.py index 581995baf23f..218302a1483d 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_flux_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_flux_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,327 +6,359 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -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 msrest import Serializer 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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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, + +def build_create_or_update_request( resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2022-01-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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_update_request_initial( - subscription_id: str, + +def build_update_request( resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2022-01-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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_delete_request_initial( - subscription_id: str, + +def build_delete_request( resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, + subscription_id: str, *, force_delete: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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") if force_delete is not None: - query_parameters['forceDelete'] = _SERIALIZER.query("force_delete", force_delete, 'bool') + _params["forceDelete"] = _SERIALIZER.query("force_delete", force_delete, "bool") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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) -class FluxConfigurationsOperations(object): - """FluxConfigurationsOperations 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 FluxConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_01_preview.SourceControlConfigurationClient`'s + :attr:`flux_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, **kwargs: Any - ) -> "_models.FluxConfiguration": + ) -> _models.FluxConfiguration: """Gets details of the Flux Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FluxConfiguration, or the result of cls(response) + :return: FluxConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -333,101 +366,238 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } def _create_or_update_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, - flux_configuration: "_models.FluxConfiguration", + flux_configuration: Union[_models.FluxConfiguration, IO], **kwargs: Any - ) -> "_models.FluxConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + ) -> _models.FluxConfiguration: 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 {}) - 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(flux_configuration, 'FluxConfiguration') + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration, (IO, bytes)): + _content = flux_configuration + else: + _json = self._serialize.body(flux_configuration, "FluxConfiguration") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_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(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration: _models.FluxConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, - flux_configuration: "_models.FluxConfiguration", + flux_configuration: Union[_models.FluxConfiguration, IO], **kwargs: Any - ) -> LROPoller["_models.FluxConfiguration"]: + ) -> LROPoller[_models.FluxConfiguration]: """Create a new Kubernetes Flux Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str - :param flux_configuration: Properties necessary to Create a FluxConfiguration. + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Is either a + FluxConfiguration type or a IO type. Required. :type flux_configuration: - ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration 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 @@ -440,16 +610,19 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] - 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["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-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.FluxConfiguration] = 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, @@ -458,116 +631,261 @@ def begin_create_or_update( cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, flux_configuration=flux_configuration, + 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('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } def _update_initial( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, - flux_configuration_patch: "_models.FluxConfigurationPatch", + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], **kwargs: Any - ) -> "_models.FluxConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + ) -> _models.FluxConfiguration: 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 {}) - 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(flux_configuration_patch, 'FluxConfigurationPatch') + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration_patch, (IO, bytes)): + _content = flux_configuration_patch + else: + _json = self._serialize.body(flux_configuration_patch, "FluxConfigurationPatch") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_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(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore - + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } - @distributed_trace + @overload def begin_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, - flux_configuration_patch: "_models.FluxConfigurationPatch", + flux_configuration_patch: _models.FluxConfigurationPatch, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.FluxConfiguration"]: + ) -> LROPoller[_models.FluxConfiguration]: """Update an existing Kubernetes Flux Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. :type flux_configuration_patch: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfigurationPatch + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. + :type flux_configuration_patch: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. Is + either a FluxConfigurationPatch type or a IO type. Required. + :type flux_configuration_patch: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfigurationPatch 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 @@ -580,16 +898,19 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] - 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["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-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.FluxConfiguration] = 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, @@ -598,84 +919,108 @@ def begin_update( cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, flux_configuration_patch=flux_configuration_patch, + 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('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, force_delete: Optional[bool] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, + subscription_id=self._config.subscription_id, force_delete=force_delete, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(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, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } @distributed_trace def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, flux_configuration_name: str, force_delete: Optional[bool] = None, @@ -685,21 +1030,24 @@ def begin_delete( from the source repo. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str :param force_delete: Delete the extension resource in Azure - not the normal asynchronous - delete. + delete. Default value is None. :type force_delete: bool :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. @@ -711,106 +1059,136 @@ def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, force_delete=force_delete, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.FluxConfigurationsList"]: + ) -> Iterable["_models.FluxConfiguration"]: """List all Flux Configurations. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FluxConfigurationsList or the result of - cls(response) + :return: An iterator like instance of either FluxConfiguration or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfigurationsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfigurationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.FluxConfigurationsList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -821,13 +1199,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("FluxConfigurationsList", 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(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]: @@ -837,8 +1217,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_location_extension_types_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_location_extension_types_operations.py index 42c18809e53c..99fd06f8c777 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_location_extension_types_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_location_extension_types_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,119 +6,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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( - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2022-01-01-preview" - accept = "application/json" + +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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes", + ) # 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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "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) -class LocationExtensionTypesOperations(object): - """LocationExtensionTypesOperations 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 LocationExtensionTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_01_preview.SourceControlConfigurationClient`'s + :attr:`location_extension_types` 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, - location: str, - **kwargs: Any - ) -> Iterable["_models.ExtensionTypeList"]: + def list(self, location: str, **kwargs: Any) -> Iterable["_models.ExtensionType"]: """List all Extension Types. - :param location: extension location. + :param location: extension location. 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 ExtensionTypeList or the result of cls(response) + :return: An iterator like instance of either ExtensionType or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionTypeList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionType] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionTypeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ExtensionTypeList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - 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) @@ -128,13 +154,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionTypeList", 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(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]: @@ -144,8 +172,8 @@ 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.KubernetesConfiguration/locations/{location}/extensionTypes'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_operation_status_operations.py index f4a859d24eb5..3ffd44f4faef 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_operation_status_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_operation_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,185 +6,221 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +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 msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, operation_id: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_name, 'str'), - "operationId": _SERIALIZER.url("operation_id", operation_id, '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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "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_list_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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") -class OperationStatusOperations(object): - """OperationStatusOperations 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.kubernetesconfiguration.v2022_01_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 OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.SourceControlConfigurationClient`'s + :attr:`operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, extension_name: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationStatusResult": + ) -> _models.OperationStatusResult: """Get Async Operation status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param operation_id: operation Id. + :param operation_id: operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatusResult, or the result of cls(response) + :return: OperationStatusResult or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperationStatusResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -191,73 +228,95 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.OperationStatusList"]: + ) -> Iterable["_models.OperationStatusResult"]: """List Async Operations, currently in progress, in a cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationStatusList or the result of cls(response) + :return: An iterator like instance of either OperationStatusResult or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperationStatusList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.OperationStatusList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -268,13 +327,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationStatusList", 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(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]: @@ -284,8 +345,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_operations.py index ba30bb536152..6346b26c56aa 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,132 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 msrest import Serializer 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 = "2022-01-01-preview" - 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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.KubernetesConfiguration/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.KubernetesConfiguration/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.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_01_preview.SourceControlConfigurationClient`'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.ResourceProviderOperationList"]: + def list(self, **kwargs: Any) -> Iterable["_models.ResourceProviderOperation"]: """List all the available operations the KubernetesConfiguration resource provider supports. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of + :return: An iterator like instance of either ResourceProviderOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ResourceProviderOperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ResourceProviderOperationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - 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) @@ -114,13 +142,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ResourceProviderOperationList", 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(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]: @@ -130,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.KubernetesConfiguration/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_source_control_configurations_operations.py index fe3ef877c91e..a3f538144358 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_source_control_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_01_preview/operations/_source_control_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,274 +6,315 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -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 msrest import Serializer 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_get_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, source_control_configuration_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, source_control_configuration_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2022-01-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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, + +def build_delete_request( resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, source_control_configuration_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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_list_request( - subscription_id: str, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-01-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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) -class SourceControlConfigurationsOperations(object): - """SourceControlConfigurationsOperations 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 SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_01_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.kubernetesconfiguration.v2022_01_01_preview.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, source_control_configuration_name: str, **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Gets details of the Source Control Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -280,77 +322,198 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, source_control_configuration_name: str, - source_control_configuration: "_models.SourceControlConfiguration", + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Create a new Kubernetes Source Control Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. :type source_control_configuration: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration + :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: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration 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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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 {}) - 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(source_control_configuration, 'SourceControlConfiguration') + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -359,66 +522,84 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, source_control_configuration_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 {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self._delete_initial.metadata['url'], + 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 = self._client._pipeline.run(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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def begin_delete( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, source_control_configuration_name: str, **kwargs: Any @@ -427,18 +608,21 @@ def begin_delete( future sync from the source repo. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_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. @@ -450,105 +634,134 @@ def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - cls=lambda x,y,z: x, + api_version=api_version, + 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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def list( self, resource_group_name: str, - cluster_rp: Union[str, "_models.ExtensionsClusterRp"], - cluster_resource_name: Union[str, "_models.ExtensionsClusterResourceName"], + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], cluster_name: str, **kwargs: Any - ) -> Iterable["_models.SourceControlConfigurationList"]: + ) -> Iterable["_models.SourceControlConfiguration"]: """List all Source Control Configurations. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS - clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. :type cluster_rp: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterRp :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters - (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. :type cluster_resource_name: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.ExtensionsClusterResourceName - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlConfigurationList or the result of + :return: An iterator like instance of either SourceControlConfiguration or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_01_preview.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SourceControlConfigurationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -559,13 +772,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlConfigurationList", 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(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]: @@ -575,8 +790,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/__init__.py new file mode 100644 index 000000000000..3ad4bd8b604e --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/__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 ._source_control_configuration_client import SourceControlConfigurationClient +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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/_configuration.py new file mode 100644 index 000000000000..0ae72980e5c1 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/_configuration.py @@ -0,0 +1,60 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for SourceControlConfigurationClient. + + 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 + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + 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.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/_metadata.json b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/_metadata.json new file mode 100644 index 000000000000..983913e5520e --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/_metadata.json @@ -0,0 +1,119 @@ +{ + "chosen_version": "2022-01-15-preview", + "total_api_version_list": ["2022-01-01-preview", "2022-01-15-preview"], + "client": { + "name": "SourceControlConfigurationClient", + "filename": "_source_control_configuration_client", + "description": "KubernetesConfiguration Client.", + "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\": [\"SourceControlConfigurationClientConfiguration\"], \".._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\": [\"SourceControlConfigurationClientConfiguration\"], \"..._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, + "method_location": "positional" + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", + "docstring_type": "str", + "required": true, + "method_location": "positional" + } + }, + "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, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + }, + "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, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + } + } + }, + "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": { + "cluster_extension_type": "ClusterExtensionTypeOperations", + "cluster_extension_types": "ClusterExtensionTypesOperations", + "extension_type_versions": "ExtensionTypeVersionsOperations", + "location_extension_types": "LocationExtensionTypesOperations", + "extensions": "ExtensionsOperations", + "operation_status": "OperationStatusOperations", + "flux_configurations": "FluxConfigurationsOperations", + "flux_config_operation_status": "FluxConfigOperationStatusOperations", + "source_control_configurations": "SourceControlConfigurationsOperations", + "operations": "Operations" + } +} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/_source_control_configuration_client.py new file mode 100644 index 000000000000..c841a14ce472 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/_source_control_configuration_client.py @@ -0,0 +1,152 @@ +# 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 SourceControlConfigurationClientConfiguration +from .operations import ( + ClusterExtensionTypeOperations, + ClusterExtensionTypesOperations, + ExtensionTypeVersionsOperations, + ExtensionsOperations, + FluxConfigOperationStatusOperations, + FluxConfigurationsOperations, + LocationExtensionTypesOperations, + OperationStatusOperations, + Operations, + SourceControlConfigurationsOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """KubernetesConfiguration Client. + + :ivar cluster_extension_type: ClusterExtensionTypeOperations operations + :vartype cluster_extension_type: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.operations.ClusterExtensionTypeOperations + :ivar cluster_extension_types: ClusterExtensionTypesOperations operations + :vartype cluster_extension_types: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.operations.ClusterExtensionTypesOperations + :ivar extension_type_versions: ExtensionTypeVersionsOperations operations + :vartype extension_type_versions: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.operations.ExtensionTypeVersionsOperations + :ivar location_extension_types: LocationExtensionTypesOperations operations + :vartype location_extension_types: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.operations.LocationExtensionTypesOperations + :ivar extensions: ExtensionsOperations operations + :vartype extensions: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.operations.ExtensionsOperations + :ivar operation_status: OperationStatusOperations operations + :vartype operation_status: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.operations.OperationStatusOperations + :ivar flux_configurations: FluxConfigurationsOperations operations + :vartype flux_configurations: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.operations.FluxConfigurationsOperations + :ivar flux_config_operation_status: FluxConfigOperationStatusOperations operations + :vartype flux_config_operation_status: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.operations.FluxConfigOperationStatusOperations + :ivar source_control_configurations: SourceControlConfigurationsOperations operations + :vartype source_control_configurations: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.operations.SourceControlConfigurationsOperations + :ivar operations: Operations operations + :vartype operations: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.operations.Operations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword 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 = SourceControlConfigurationClientConfiguration( + 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.cluster_extension_type = ClusterExtensionTypeOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cluster_extension_types = ClusterExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.extension_type_versions = ExtensionTypeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.location_extension_types = LocationExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_configurations = FluxConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_config_operation_status = FluxConfigOperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **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) -> "SourceControlConfigurationClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/_vendor.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/_vendor.py new file mode 100644 index 000000000000..bd0df84f5319 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/_vendor.py @@ -0,0 +1,30 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import List, cast + +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: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/_version.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/_version.py new file mode 100644 index 000000000000..59deb8c7263b --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/_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.1.0" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/__init__.py new file mode 100644 index 000000000000..b95230ae03c5 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/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 ._source_control_configuration_client import SourceControlConfigurationClient + +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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/_configuration.py new file mode 100644 index 000000000000..1b9507ff31fc --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/_configuration.py @@ -0,0 +1,60 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for SourceControlConfigurationClient. + + 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 + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + 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.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/_source_control_configuration_client.py new file mode 100644 index 000000000000..5291558962c1 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/_source_control_configuration_client.py @@ -0,0 +1,152 @@ +# 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 SourceControlConfigurationClientConfiguration +from .operations import ( + ClusterExtensionTypeOperations, + ClusterExtensionTypesOperations, + ExtensionTypeVersionsOperations, + ExtensionsOperations, + FluxConfigOperationStatusOperations, + FluxConfigurationsOperations, + LocationExtensionTypesOperations, + OperationStatusOperations, + Operations, + SourceControlConfigurationsOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """KubernetesConfiguration Client. + + :ivar cluster_extension_type: ClusterExtensionTypeOperations operations + :vartype cluster_extension_type: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.operations.ClusterExtensionTypeOperations + :ivar cluster_extension_types: ClusterExtensionTypesOperations operations + :vartype cluster_extension_types: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.operations.ClusterExtensionTypesOperations + :ivar extension_type_versions: ExtensionTypeVersionsOperations operations + :vartype extension_type_versions: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.operations.ExtensionTypeVersionsOperations + :ivar location_extension_types: LocationExtensionTypesOperations operations + :vartype location_extension_types: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.operations.LocationExtensionTypesOperations + :ivar extensions: ExtensionsOperations operations + :vartype extensions: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.operations.ExtensionsOperations + :ivar operation_status: OperationStatusOperations operations + :vartype operation_status: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.operations.OperationStatusOperations + :ivar flux_configurations: FluxConfigurationsOperations operations + :vartype flux_configurations: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.operations.FluxConfigurationsOperations + :ivar flux_config_operation_status: FluxConfigOperationStatusOperations operations + :vartype flux_config_operation_status: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.operations.FluxConfigOperationStatusOperations + :ivar source_control_configurations: SourceControlConfigurationsOperations operations + :vartype source_control_configurations: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.operations.SourceControlConfigurationsOperations + :ivar operations: Operations operations + :vartype operations: + azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.operations.Operations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword 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 = SourceControlConfigurationClientConfiguration( + 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.cluster_extension_type = ClusterExtensionTypeOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cluster_extension_types = ClusterExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.extension_type_versions = ExtensionTypeVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.location_extension_types = LocationExtensionTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_configurations = FluxConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_config_operation_status = FluxConfigOperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **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) -> "SourceControlConfigurationClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..ccd968835618 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/__init__.py @@ -0,0 +1,37 @@ +# 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 ._cluster_extension_type_operations import ClusterExtensionTypeOperations +from ._cluster_extension_types_operations import ClusterExtensionTypesOperations +from ._extension_type_versions_operations import ExtensionTypeVersionsOperations +from ._location_extension_types_operations import LocationExtensionTypesOperations +from ._extensions_operations import ExtensionsOperations +from ._operation_status_operations import OperationStatusOperations +from ._flux_configurations_operations import FluxConfigurationsOperations +from ._flux_config_operation_status_operations import FluxConfigOperationStatusOperations +from ._source_control_configurations_operations import SourceControlConfigurationsOperations +from ._operations import Operations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ClusterExtensionTypeOperations", + "ClusterExtensionTypesOperations", + "ExtensionTypeVersionsOperations", + "LocationExtensionTypesOperations", + "ExtensionsOperations", + "OperationStatusOperations", + "FluxConfigurationsOperations", + "FluxConfigOperationStatusOperations", + "SourceControlConfigurationsOperations", + "Operations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_cluster_extension_type_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_cluster_extension_type_operations.py new file mode 100644 index 000000000000..8fad4e78040c --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_cluster_extension_type_operations.py @@ -0,0 +1,143 @@ +# 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, Optional, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._cluster_extension_type_operations import build_get_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 ClusterExtensionTypeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.SourceControlConfigurationClient`'s + :attr:`cluster_extension_type` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_type_name: str, + **kwargs: Any + ) -> _models.ExtensionType: + """Get Extension Type details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_type_name: Extension type name. Required. + :type extension_type_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ExtensionType or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionType + :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-01-15-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-15-preview") + ) + cls: ClsType[_models.ExtensionType] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_type_name=extension_type_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ExtensionType", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_cluster_extension_types_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_cluster_extension_types_operations.py new file mode 100644 index 000000000000..9dbeb971ce4c --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_cluster_extension_types_operations.py @@ -0,0 +1,157 @@ +# 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, Union + +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._cluster_extension_types_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 ClusterExtensionTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.SourceControlConfigurationClient`'s + :attr:`cluster_extension_types` 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, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ExtensionType"]: + """Get Extension Types. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExtensionType or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionType] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-15-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-15-preview") + ) + cls: ClsType[_models.ExtensionTypeList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ExtensionTypeList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_extension_type_versions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_extension_type_versions_operations.py new file mode 100644 index 000000000000..d899b81468ad --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_extension_type_versions_operations.py @@ -0,0 +1,140 @@ +# 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 + +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._extension_type_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 ExtensionTypeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.SourceControlConfigurationClient`'s + :attr:`extension_type_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, extension_type_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ExtensionVersionListValueItem"]: + """List available versions for an Extension Type. + + :param location: extension location. Required. + :type location: str + :param extension_type_name: Extension type name. Required. + :type extension_type_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExtensionVersionListValueItem or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionVersionListValueItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-15-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-15-preview") + ) + cls: ClsType[_models.ExtensionVersionList] = 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, + extension_type_name=extension_type_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: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ExtensionVersionList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_extensions_operations.py new file mode 100644 index 000000000000..632a91223132 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_extensions_operations.py @@ -0,0 +1,987 @@ +# 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 + +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._extensions_operations import ( + build_create_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 ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_initial( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + extension: Union[_models.Extension, IO], + **kwargs: Any + ) -> _models.Extension: + 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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IO, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") + + request = build_create_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Extension", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension + :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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + extension: Union[_models.Extension, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Is either a Extension type or a + IO type. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension] + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + extension=extension, + 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("Extension", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + **kwargs: Any + ) -> _models.Extension: + """Gets Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Extension or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + force_delete: Optional[bool] = None, + **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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + force_delete=force_delete, + 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 [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a Kubernetes Cluster Extension. This will cause the Agent to Uninstall the extension + from the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param force_delete: Delete the extension resource in Azure - not the normal asynchronous + delete. Default value is None. + :type force_delete: bool + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + force_delete=force_delete, + 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, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + async def _update_initial( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + patch_extension: Union[_models.PatchExtension, IO], + **kwargs: Any + ) -> _models.Extension: + 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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(patch_extension, (IO, bytes)): + _content = patch_extension + else: + _json = self._serialize.body(patch_extension, "PatchExtension") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + patch_extension: _models.PatchExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.PatchExtension + :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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + patch_extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + patch_extension: Union[_models.PatchExtension, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Is either a + PatchExtension type or a IO type. Required. + :type patch_extension: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.PatchExtension 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension] + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + patch_extension=patch_extension, + 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("Extension", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace + def list( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.Extension"]: + """List all Extensions in the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Extension or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ExtensionsList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ExtensionsList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_flux_config_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_flux_config_operation_status_operations.py new file mode 100644 index 000000000000..857b26ca274f --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_flux_config_operation_status_operations.py @@ -0,0 +1,147 @@ +# 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, Optional, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._flux_config_operation_status_operations import build_get_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 FluxConfigOperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.SourceControlConfigurationClient`'s + :attr:`flux_config_operation_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + operation_id: str, + **kwargs: Any + ) -> _models.OperationStatusResult: + """Get Async Operation status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param operation_id: operation Id. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.OperationStatusResult + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + operation_id=operation_id, + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_flux_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_flux_configurations_operations.py new file mode 100644 index 000000000000..54635baa0ce4 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_flux_configurations_operations.py @@ -0,0 +1,991 @@ +# 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 + +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._flux_configurations_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 FluxConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.SourceControlConfigurationClient`'s + :attr:`flux_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + **kwargs: Any + ) -> _models.FluxConfiguration: + """Gets details of the Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FluxConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration: Union[_models.FluxConfiguration, IO], + **kwargs: Any + ) -> _models.FluxConfiguration: + 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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration, (IO, bytes)): + _content = flux_configuration + else: + _json = self._serialize.body(flux_configuration, "FluxConfiguration") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("FluxConfiguration", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration: _models.FluxConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration: Union[_models.FluxConfiguration, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Is either a + FluxConfiguration type or a IO type. Required. + :type flux_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration] + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + flux_configuration=flux_configuration, + 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("FluxConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + async def _update_initial( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], + **kwargs: Any + ) -> _models.FluxConfiguration: + 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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration_patch, (IO, bytes)): + _content = flux_configuration_patch + else: + _json = self._serialize.body(flux_configuration_patch, "FluxConfigurationPatch") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: _models.FluxConfigurationPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. + :type flux_configuration_patch: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfigurationPatch + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. + :type flux_configuration_patch: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. Is + either a FluxConfigurationPatch type or a IO type. Required. + :type flux_configuration_patch: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfigurationPatch 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration] + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + flux_configuration_patch=flux_configuration_patch, + 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("FluxConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + force_delete: Optional[bool] = None, + **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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + subscription_id=self._config.subscription_id, + force_delete=force_delete, + 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 [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """This will delete the YAML file used to set up the Flux Configuration, thus stopping future sync + from the source repo. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param force_delete: Delete the extension resource in Azure - not the normal asynchronous + delete. Default value is None. + :type force_delete: bool + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + force_delete=force_delete, + 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, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @distributed_trace + def list( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.FluxConfiguration"]: + """List all Flux Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FluxConfiguration or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.FluxConfigurationsList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("FluxConfigurationsList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_location_extension_types_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_location_extension_types_operations.py new file mode 100644 index 000000000000..44e5b27e6f9b --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_location_extension_types_operations.py @@ -0,0 +1,134 @@ +# 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 + +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._location_extension_types_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 LocationExtensionTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.SourceControlConfigurationClient`'s + :attr:`location_extension_types` 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.ExtensionType"]: + """List all Extension Types. + + :param location: extension location. 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 ExtensionType or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionType] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-15-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-15-preview") + ) + cls: ClsType[_models.ExtensionTypeList] = 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: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ExtensionTypeList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_operation_status_operations.py new file mode 100644 index 000000000000..33e231751c3c --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_operation_status_operations.py @@ -0,0 +1,250 @@ +# 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, Union + +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._operation_status_operations import build_get_request, 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 OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.SourceControlConfigurationClient`'s + :attr:`operation_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + operation_id: str, + **kwargs: Any + ) -> _models.OperationStatusResult: + """Get Async Operation status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param operation_id: operation Id. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.OperationStatusResult + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + operation_id=operation_id, + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + } + + @distributed_trace + def list( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.OperationStatusResult"]: + """List Async Operations, currently in progress, in a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.OperationStatusList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationStatusList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_operations.py new file mode 100644 index 000000000000..19442ebacae9 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_operations.py @@ -0,0 +1,129 @@ +# 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 + +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.kubernetesconfiguration.v2022_01_15_preview.aio.SourceControlConfigurationClient`'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.ResourceProviderOperation"]: + """List all the available operations the KubernetesConfiguration resource provider supports. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceProviderOperation or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ResourceProviderOperationList] = 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: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ResourceProviderOperationList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_source_control_configurations_operations.py new file mode 100644 index 000000000000..e9f5baba8fa3 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/aio/operations/_source_control_configurations_operations.py @@ -0,0 +1,605 @@ +# 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 + +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._source_control_configurations_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + 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 SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.aio.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_name: str, + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Gets details of the Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceControlConfiguration + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceControlConfiguration + :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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceControlConfiguration 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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceControlConfiguration + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SourceControlConfiguration", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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 [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """This will delete the YAML file used to set up the Source control configuration, thus stopping + future sync from the source repo. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + @distributed_trace + def list( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.SourceControlConfiguration"]: + """List all Source Control Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SourceControlConfiguration or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SourceControlConfigurationList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SourceControlConfigurationList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/models/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/models/__init__.py new file mode 100644 index 000000000000..b4c0804ee04e --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/models/__init__.py @@ -0,0 +1,135 @@ +# 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 BucketDefinition +from ._models_py3 import BucketPatchDefinition +from ._models_py3 import ClusterScopeSettings +from ._models_py3 import ComplianceStatus +from ._models_py3 import DependsOnDefinition +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import Extension +from ._models_py3 import ExtensionPropertiesAksAssignedIdentity +from ._models_py3 import ExtensionStatus +from ._models_py3 import ExtensionType +from ._models_py3 import ExtensionTypeList +from ._models_py3 import ExtensionVersionList +from ._models_py3 import ExtensionVersionListValueItem +from ._models_py3 import ExtensionsList +from ._models_py3 import FluxConfiguration +from ._models_py3 import FluxConfigurationPatch +from ._models_py3 import FluxConfigurationsList +from ._models_py3 import GitRepositoryDefinition +from ._models_py3 import GitRepositoryPatchDefinition +from ._models_py3 import HelmOperatorProperties +from ._models_py3 import HelmReleasePropertiesDefinition +from ._models_py3 import Identity +from ._models_py3 import KustomizationDefinition +from ._models_py3 import KustomizationPatchDefinition +from ._models_py3 import ObjectReferenceDefinition +from ._models_py3 import ObjectStatusConditionDefinition +from ._models_py3 import ObjectStatusDefinition +from ._models_py3 import OperationStatusList +from ._models_py3 import OperationStatusResult +from ._models_py3 import PatchExtension +from ._models_py3 import ProxyResource +from ._models_py3 import RepositoryRefDefinition +from ._models_py3 import Resource +from ._models_py3 import ResourceProviderOperation +from ._models_py3 import ResourceProviderOperationDisplay +from ._models_py3 import ResourceProviderOperationList +from ._models_py3 import Scope +from ._models_py3 import ScopeCluster +from ._models_py3 import ScopeNamespace +from ._models_py3 import SourceControlConfiguration +from ._models_py3 import SourceControlConfigurationList +from ._models_py3 import SupportedScopes +from ._models_py3 import SystemData + +from ._source_control_configuration_client_enums import ComplianceStateType +from ._source_control_configuration_client_enums import CreatedByType +from ._source_control_configuration_client_enums import ExtensionsClusterResourceName +from ._source_control_configuration_client_enums import ExtensionsClusterRp +from ._source_control_configuration_client_enums import FluxComplianceState +from ._source_control_configuration_client_enums import KustomizationValidationType +from ._source_control_configuration_client_enums import LevelType +from ._source_control_configuration_client_enums import MessageLevelType +from ._source_control_configuration_client_enums import OperatorScopeType +from ._source_control_configuration_client_enums import OperatorType +from ._source_control_configuration_client_enums import ProvisioningState +from ._source_control_configuration_client_enums import ProvisioningStateType +from ._source_control_configuration_client_enums import ScopeType +from ._source_control_configuration_client_enums import SourceKindType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "BucketDefinition", + "BucketPatchDefinition", + "ClusterScopeSettings", + "ComplianceStatus", + "DependsOnDefinition", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "Extension", + "ExtensionPropertiesAksAssignedIdentity", + "ExtensionStatus", + "ExtensionType", + "ExtensionTypeList", + "ExtensionVersionList", + "ExtensionVersionListValueItem", + "ExtensionsList", + "FluxConfiguration", + "FluxConfigurationPatch", + "FluxConfigurationsList", + "GitRepositoryDefinition", + "GitRepositoryPatchDefinition", + "HelmOperatorProperties", + "HelmReleasePropertiesDefinition", + "Identity", + "KustomizationDefinition", + "KustomizationPatchDefinition", + "ObjectReferenceDefinition", + "ObjectStatusConditionDefinition", + "ObjectStatusDefinition", + "OperationStatusList", + "OperationStatusResult", + "PatchExtension", + "ProxyResource", + "RepositoryRefDefinition", + "Resource", + "ResourceProviderOperation", + "ResourceProviderOperationDisplay", + "ResourceProviderOperationList", + "Scope", + "ScopeCluster", + "ScopeNamespace", + "SourceControlConfiguration", + "SourceControlConfigurationList", + "SupportedScopes", + "SystemData", + "ComplianceStateType", + "CreatedByType", + "ExtensionsClusterResourceName", + "ExtensionsClusterRp", + "FluxComplianceState", + "KustomizationValidationType", + "LevelType", + "MessageLevelType", + "OperatorScopeType", + "OperatorType", + "ProvisioningState", + "ProvisioningStateType", + "ScopeType", + "SourceKindType", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/models/_models_py3.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/models/_models_py3.py new file mode 100644 index 000000000000..0a2edfa73e80 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/models/_models_py3.py @@ -0,0 +1,2449 @@ +# 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 +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +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 .. import models as _models + + +class BucketDefinition(_serialization.Model): + """Parameters to reconcile to the GitRepository source kind type. + + :ivar url: The URL to sync for the flux configuration S3 bucket. + :vartype url: str + :ivar bucket_name: The bucket name to sync from the url endpoint for the flux configuration. + :vartype bucket_name: str + :ivar insecure: Specify whether to use insecure communication when puling data from the S3 + bucket. + :vartype insecure: bool + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository + source with the remote. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :vartype sync_interval_in_seconds: int + :ivar access_key: Plaintext access key used to securely access the S3 bucket. + :vartype access_key: str + :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :vartype local_auth_ref: str + """ + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + "bucket_name": {"key": "bucketName", "type": "str"}, + "insecure": {"key": "insecure", "type": "bool"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "access_key": {"key": "accessKey", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + bucket_name: Optional[str] = None, + insecure: bool = True, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, + access_key: Optional[str] = None, + local_auth_ref: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword url: The URL to sync for the flux configuration S3 bucket. + :paramtype url: str + :keyword bucket_name: The bucket name to sync from the url endpoint for the flux configuration. + :paramtype bucket_name: str + :keyword insecure: Specify whether to use insecure communication when puling data from the S3 + bucket. + :paramtype insecure: bool + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster git + repository source with the remote. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :paramtype sync_interval_in_seconds: int + :keyword access_key: Plaintext access key used to securely access the S3 bucket. + :paramtype access_key: str + :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :paramtype local_auth_ref: str + """ + super().__init__(**kwargs) + self.url = url + self.bucket_name = bucket_name + self.insecure = insecure + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.access_key = access_key + self.local_auth_ref = local_auth_ref + + +class BucketPatchDefinition(_serialization.Model): + """Parameters to reconcile to the GitRepository source kind type. + + :ivar url: The URL to sync for the flux configuration S3 bucket. + :vartype url: str + :ivar bucket_name: The bucket name to sync from the url endpoint for the flux configuration. + :vartype bucket_name: str + :ivar insecure: Specify whether to use insecure communication when puling data from the S3 + bucket. + :vartype insecure: bool + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository + source with the remote. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :vartype sync_interval_in_seconds: int + :ivar access_key: Plaintext access key used to securely access the S3 bucket. + :vartype access_key: str + :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :vartype local_auth_ref: str + """ + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + "bucket_name": {"key": "bucketName", "type": "str"}, + "insecure": {"key": "insecure", "type": "bool"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "access_key": {"key": "accessKey", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + bucket_name: Optional[str] = None, + insecure: Optional[bool] = None, + timeout_in_seconds: Optional[int] = None, + sync_interval_in_seconds: Optional[int] = None, + access_key: Optional[str] = None, + local_auth_ref: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword url: The URL to sync for the flux configuration S3 bucket. + :paramtype url: str + :keyword bucket_name: The bucket name to sync from the url endpoint for the flux configuration. + :paramtype bucket_name: str + :keyword insecure: Specify whether to use insecure communication when puling data from the S3 + bucket. + :paramtype insecure: bool + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster git + repository source with the remote. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :paramtype sync_interval_in_seconds: int + :keyword access_key: Plaintext access key used to securely access the S3 bucket. + :paramtype access_key: str + :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :paramtype local_auth_ref: str + """ + super().__init__(**kwargs) + self.url = url + self.bucket_name = bucket_name + self.insecure = insecure + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.access_key = access_key + self.local_auth_ref = local_auth_ref + + +class ClusterScopeSettings(_serialization.Model): + """Extension scope settings. + + :ivar allow_multiple_instances: Describes if multiple instances of the extension are allowed. + :vartype allow_multiple_instances: bool + :ivar default_release_namespace: Default extension release namespace. + :vartype default_release_namespace: str + """ + + _attribute_map = { + "allow_multiple_instances": {"key": "allowMultipleInstances", "type": "bool"}, + "default_release_namespace": {"key": "defaultReleaseNamespace", "type": "str"}, + } + + def __init__( + self, + *, + allow_multiple_instances: Optional[bool] = None, + default_release_namespace: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword allow_multiple_instances: Describes if multiple instances of the extension are + allowed. + :paramtype allow_multiple_instances: bool + :keyword default_release_namespace: Default extension release namespace. + :paramtype default_release_namespace: str + """ + super().__init__(**kwargs) + self.allow_multiple_instances = allow_multiple_instances + self.default_release_namespace = default_release_namespace + + +class ComplianceStatus(_serialization.Model): + """Compliance Status details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar compliance_state: The compliance state of the configuration. Known values are: "Pending", + "Compliant", "Noncompliant", "Installed", and "Failed". + :vartype compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ComplianceStateType + :ivar last_config_applied: Datetime the configuration was last applied. + :vartype last_config_applied: ~datetime.datetime + :ivar message: Message from when the configuration was applied. + :vartype message: str + :ivar message_level: Level of the message. Known values are: "Error", "Warning", and + "Information". + :vartype message_level: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.MessageLevelType + """ + + _validation = { + "compliance_state": {"readonly": True}, + } + + _attribute_map = { + "compliance_state": {"key": "complianceState", "type": "str"}, + "last_config_applied": {"key": "lastConfigApplied", "type": "iso-8601"}, + "message": {"key": "message", "type": "str"}, + "message_level": {"key": "messageLevel", "type": "str"}, + } + + def __init__( + self, + *, + last_config_applied: Optional[datetime.datetime] = None, + message: Optional[str] = None, + message_level: Optional[Union[str, "_models.MessageLevelType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword last_config_applied: Datetime the configuration was last applied. + :paramtype last_config_applied: ~datetime.datetime + :keyword message: Message from when the configuration was applied. + :paramtype message: str + :keyword message_level: Level of the message. Known values are: "Error", "Warning", and + "Information". + :paramtype message_level: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.MessageLevelType + """ + super().__init__(**kwargs) + self.compliance_state = None + self.last_config_applied = last_config_applied + self.message = message + self.message_level = message_level + + +class DependsOnDefinition(_serialization.Model): + """Specify which kustomizations must succeed reconciliation on the cluster prior to reconciling + this kustomization. + + :ivar kustomization_name: Name of the kustomization to claim dependency on. + :vartype kustomization_name: str + """ + + _attribute_map = { + "kustomization_name": {"key": "kustomizationName", "type": "str"}, + } + + def __init__(self, *, kustomization_name: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword kustomization_name: Name of the kustomization to claim dependency on. + :paramtype kustomization_name: str + """ + super().__init__(**kwargs) + self.kustomization_name = kustomization_name + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +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 + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + + +class Extension(ProxyResource): # pylint: disable=too-many-instance-attributes + """The Extension object. + + 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 identity: Identity of the Extension resource. + :vartype identity: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Identity + :ivar system_data: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SystemData + :ivar extension_type: Type of the Extension, of which this resource is an instance of. It must + be one of the Extension Types registered with Microsoft.KubernetesConfiguration by the + Extension publisher. + :vartype extension_type: str + :ivar auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade + of minor version, or not. + :vartype auto_upgrade_minor_version: bool + :ivar release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. Stable, + Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :vartype release_train: str + :ivar version: Version of the extension for this extension, if it is 'pinned' to a specific + version. autoUpgradeMinorVersion must be 'false'. + :vartype version: str + :ivar scope: Scope at which the extension is installed. + :vartype scope: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Scope + :ivar configuration_settings: Configuration settings, as name-value pairs for configuring this + extension. + :vartype configuration_settings: dict[str, str] + :ivar configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :vartype configuration_protected_settings: dict[str, str] + :ivar provisioning_state: Status of installation of this extension. Known values are: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ProvisioningState + :ivar statuses: Status from this extension. + :vartype statuses: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionStatus] + :ivar error_info: Error information from the Agent - e.g. errors during installation. + :vartype error_info: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ErrorDetail + :ivar custom_location_settings: Custom Location settings properties. + :vartype custom_location_settings: dict[str, str] + :ivar package_uri: Uri of the Helm package. + :vartype package_uri: str + :ivar aks_assigned_identity: Identity of the Extension resource in an AKS cluster. + :vartype aks_assigned_identity: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionPropertiesAksAssignedIdentity + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "error_info": {"readonly": True}, + "custom_location_settings": {"readonly": True}, + "package_uri": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "extension_type": {"key": "properties.extensionType", "type": "str"}, + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "scope": {"key": "properties.scope", "type": "Scope"}, + "configuration_settings": {"key": "properties.configurationSettings", "type": "{str}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "statuses": {"key": "properties.statuses", "type": "[ExtensionStatus]"}, + "error_info": {"key": "properties.errorInfo", "type": "ErrorDetail"}, + "custom_location_settings": {"key": "properties.customLocationSettings", "type": "{str}"}, + "package_uri": {"key": "properties.packageUri", "type": "str"}, + "aks_assigned_identity": { + "key": "properties.aksAssignedIdentity", + "type": "ExtensionPropertiesAksAssignedIdentity", + }, + } + + def __init__( + self, + *, + identity: Optional["_models.Identity"] = None, + extension_type: Optional[str] = None, + auto_upgrade_minor_version: bool = True, + release_train: str = "Stable", + version: Optional[str] = None, + scope: Optional["_models.Scope"] = None, + configuration_settings: Optional[Dict[str, str]] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + statuses: Optional[List["_models.ExtensionStatus"]] = None, + aks_assigned_identity: Optional["_models.ExtensionPropertiesAksAssignedIdentity"] = None, + **kwargs: Any + ) -> None: + """ + :keyword identity: Identity of the Extension resource. + :paramtype identity: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Identity + :keyword extension_type: Type of the Extension, of which this resource is an instance of. It + must be one of the Extension Types registered with Microsoft.KubernetesConfiguration by the + Extension publisher. + :paramtype extension_type: str + :keyword auto_upgrade_minor_version: Flag to note if this extension participates in auto + upgrade of minor version, or not. + :paramtype auto_upgrade_minor_version: bool + :keyword release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. + Stable, Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :paramtype release_train: str + :keyword version: Version of the extension for this extension, if it is 'pinned' to a specific + version. autoUpgradeMinorVersion must be 'false'. + :paramtype version: str + :keyword scope: Scope at which the extension is installed. + :paramtype scope: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Scope + :keyword configuration_settings: Configuration settings, as name-value pairs for configuring + this extension. + :paramtype configuration_settings: dict[str, str] + :keyword configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :paramtype configuration_protected_settings: dict[str, str] + :keyword statuses: Status from this extension. + :paramtype statuses: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionStatus] + :keyword aks_assigned_identity: Identity of the Extension resource in an AKS cluster. + :paramtype aks_assigned_identity: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionPropertiesAksAssignedIdentity + """ + super().__init__(**kwargs) + self.identity = identity + self.system_data = None + self.extension_type = extension_type + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.release_train = release_train + self.version = version + self.scope = scope + self.configuration_settings = configuration_settings + self.configuration_protected_settings = configuration_protected_settings + self.provisioning_state = None + self.statuses = statuses + self.error_info = None + self.custom_location_settings = None + self.package_uri = None + self.aks_assigned_identity = aks_assigned_identity + + +class ExtensionPropertiesAksAssignedIdentity(_serialization.Model): + """Identity of the Extension resource in an AKS cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Default value is "SystemAssigned". + :vartype type: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: + """ + :keyword type: The identity type. Default value is "SystemAssigned". + :paramtype type: str + """ + super().__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + + +class ExtensionsList(_serialization.Model): + """Result of the request to list Extensions. It contains a list of Extension objects and a URL + link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Extensions within a Kubernetes cluster. + :vartype value: list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension] + :ivar next_link: URL to get the next set of extension objects, if any. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Extension]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class ExtensionStatus(_serialization.Model): + """Status from the extension. + + :ivar code: Status code provided by the Extension. + :vartype code: str + :ivar display_status: Short description of status of the extension. + :vartype display_status: str + :ivar level: Level of the status. Known values are: "Error", "Warning", and "Information". + :vartype level: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.LevelType + :ivar message: Detailed message of the status from the Extension. + :vartype message: str + :ivar time: DateLiteral (per ISO8601) noting the time of installation status. + :vartype time: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "display_status": {"key": "displayStatus", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "time": {"key": "time", "type": "str"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + display_status: Optional[str] = None, + level: Union[str, "_models.LevelType"] = "Information", + message: Optional[str] = None, + time: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: Status code provided by the Extension. + :paramtype code: str + :keyword display_status: Short description of status of the extension. + :paramtype display_status: str + :keyword level: Level of the status. Known values are: "Error", "Warning", and "Information". + :paramtype level: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.LevelType + :keyword message: Detailed message of the status from the Extension. + :paramtype message: str + :keyword time: DateLiteral (per ISO8601) noting the time of installation status. + :paramtype time: str + """ + super().__init__(**kwargs) + self.code = code + self.display_status = display_status + self.level = level + self.message = message + self.time = time + + +class ExtensionType(ProxyResource): + """Represents an Extension Type. + + 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: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SystemData + :ivar release_trains: Extension release train: preview or stable. + :vartype release_trains: list[str] + :ivar cluster_types: Cluster types. + :vartype cluster_types: list[str] + :ivar supported_scopes: Extension scopes. + :vartype supported_scopes: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SupportedScopes + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "release_trains": {"readonly": True}, + "cluster_types": {"readonly": True}, + "supported_scopes": {"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"}, + "release_trains": {"key": "properties.releaseTrains", "type": "[str]"}, + "cluster_types": {"key": "properties.clusterTypes", "type": "[str]"}, + "supported_scopes": {"key": "properties.supportedScopes", "type": "SupportedScopes"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.system_data = None + self.release_trains = None + self.cluster_types = None + self.supported_scopes = None + + +class ExtensionTypeList(_serialization.Model): + """List Extension Types. + + :ivar value: The list of Extension Types. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionType] + :ivar next_link: The link to fetch the next page of Extension Types. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ExtensionType]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.ExtensionType"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The list of Extension Types. + :paramtype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionType] + :keyword next_link: The link to fetch the next page of Extension Types. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ExtensionVersionList(_serialization.Model): + """List versions for an Extension. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Versions available for this Extension Type. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionVersionListValueItem] + :ivar next_link: The link to fetch the next page of Extension Types. + :vartype next_link: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SystemData + """ + + _validation = { + "system_data": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ExtensionVersionListValueItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ExtensionVersionListValueItem"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Versions available for this Extension Type. + :paramtype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionVersionListValueItem] + :keyword next_link: The link to fetch the next page of Extension Types. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + self.system_data = None + + +class ExtensionVersionListValueItem(_serialization.Model): + """ExtensionVersionListValueItem. + + :ivar release_train: The release train for this Extension Type. + :vartype release_train: str + :ivar versions: Versions available for this Extension Type and release train. + :vartype versions: list[str] + """ + + _attribute_map = { + "release_train": {"key": "releaseTrain", "type": "str"}, + "versions": {"key": "versions", "type": "[str]"}, + } + + def __init__( + self, *, release_train: Optional[str] = None, versions: Optional[List[str]] = None, **kwargs: Any + ) -> None: + """ + :keyword release_train: The release train for this Extension Type. + :paramtype release_train: str + :keyword versions: Versions available for this Extension Type and release train. + :paramtype versions: list[str] + """ + super().__init__(**kwargs) + self.release_train = release_train + self.versions = versions + + +class FluxConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes + """The Flux Configuration object returned in Get & Put response. + + 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: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SystemData + :ivar scope: Scope at which the operator will be installed. Known values are: "cluster" and + "namespace". + :vartype scope: str or ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ScopeType + :ivar namespace: The namespace to which this configuration is installed to. Maximum of 253 + lower case alphanumeric characters, hyphen and period only. + :vartype namespace: str + :ivar source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository" and "Bucket". + :vartype source_kind: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceKindType + :ivar suspend: Whether this configuration should suspend its reconciliation of its + kustomizations and sources. + :vartype suspend: bool + :ivar git_repository: Parameters to reconcile to the GitRepository source kind type. + :vartype git_repository: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.GitRepositoryDefinition + :ivar bucket: Parameters to reconcile to the Bucket source kind type. + :vartype bucket: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.BucketDefinition + :ivar kustomizations: Array of kustomizations used to reconcile the artifact pulled by the + source type on the cluster. + :vartype kustomizations: dict[str, + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.KustomizationDefinition] + :ivar configuration_protected_settings: Key-value pairs of protected configuration settings for + the configuration. + :vartype configuration_protected_settings: dict[str, str] + :ivar statuses: Statuses of the Flux Kubernetes resources created by the fluxConfiguration or + created by the managed objects provisioned by the fluxConfiguration. + :vartype statuses: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ObjectStatusDefinition] + :ivar repository_public_key: Public Key associated with this fluxConfiguration (either + generated within the cluster or provided by the user). + :vartype repository_public_key: str + :ivar last_source_updated_commit_id: Branch and SHA of the last source commit synced with the + cluster. + :vartype last_source_updated_commit_id: str + :ivar last_source_updated_at: Datetime the fluxConfiguration last synced its source on the + cluster. + :vartype last_source_updated_at: ~datetime.datetime + :ivar compliance_state: Combined status of the Flux Kubernetes resources created by the + fluxConfiguration or created by the managed objects. Known values are: "Compliant", + "Non-Compliant", "Pending", "Suspended", and "Unknown". + :vartype compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxComplianceState + :ivar provisioning_state: Status of the creation of the fluxConfiguration. Known values are: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ProvisioningState + :ivar error_message: Error message returned to the user in the case of provisioning failure. + :vartype error_message: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "statuses": {"readonly": True}, + "repository_public_key": {"readonly": True}, + "last_source_updated_commit_id": {"readonly": True}, + "last_source_updated_at": {"readonly": True}, + "compliance_state": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "error_message": {"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"}, + "scope": {"key": "properties.scope", "type": "str"}, + "namespace": {"key": "properties.namespace", "type": "str"}, + "source_kind": {"key": "properties.sourceKind", "type": "str"}, + "suspend": {"key": "properties.suspend", "type": "bool"}, + "git_repository": {"key": "properties.gitRepository", "type": "GitRepositoryDefinition"}, + "bucket": {"key": "properties.bucket", "type": "BucketDefinition"}, + "kustomizations": {"key": "properties.kustomizations", "type": "{KustomizationDefinition}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "statuses": {"key": "properties.statuses", "type": "[ObjectStatusDefinition]"}, + "repository_public_key": {"key": "properties.repositoryPublicKey", "type": "str"}, + "last_source_updated_commit_id": {"key": "properties.lastSourceUpdatedCommitId", "type": "str"}, + "last_source_updated_at": {"key": "properties.lastSourceUpdatedAt", "type": "iso-8601"}, + "compliance_state": {"key": "properties.complianceState", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "error_message": {"key": "properties.errorMessage", "type": "str"}, + } + + def __init__( + self, + *, + scope: Union[str, "_models.ScopeType"] = "cluster", + namespace: str = "default", + source_kind: Optional[Union[str, "_models.SourceKindType"]] = None, + suspend: bool = False, + git_repository: Optional["_models.GitRepositoryDefinition"] = None, + bucket: Optional["_models.BucketDefinition"] = None, + kustomizations: Optional[Dict[str, "_models.KustomizationDefinition"]] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword scope: Scope at which the operator will be installed. Known values are: "cluster" and + "namespace". + :paramtype scope: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ScopeType + :keyword namespace: The namespace to which this configuration is installed to. Maximum of 253 + lower case alphanumeric characters, hyphen and period only. + :paramtype namespace: str + :keyword source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository" and "Bucket". + :paramtype source_kind: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceKindType + :keyword suspend: Whether this configuration should suspend its reconciliation of its + kustomizations and sources. + :paramtype suspend: bool + :keyword git_repository: Parameters to reconcile to the GitRepository source kind type. + :paramtype git_repository: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.GitRepositoryDefinition + :keyword bucket: Parameters to reconcile to the Bucket source kind type. + :paramtype bucket: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.BucketDefinition + :keyword kustomizations: Array of kustomizations used to reconcile the artifact pulled by the + source type on the cluster. + :paramtype kustomizations: dict[str, + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.KustomizationDefinition] + :keyword configuration_protected_settings: Key-value pairs of protected configuration settings + for the configuration. + :paramtype configuration_protected_settings: dict[str, str] + """ + super().__init__(**kwargs) + self.system_data = None + self.scope = scope + self.namespace = namespace + self.source_kind = source_kind + self.suspend = suspend + self.git_repository = git_repository + self.bucket = bucket + self.kustomizations = kustomizations + self.configuration_protected_settings = configuration_protected_settings + self.statuses = None + self.repository_public_key = None + self.last_source_updated_commit_id = None + self.last_source_updated_at = None + self.compliance_state = None + self.provisioning_state = None + self.error_message = None + + +class FluxConfigurationPatch(_serialization.Model): + """The Flux Configuration Patch Request object. + + :ivar source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository" and "Bucket". + :vartype source_kind: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceKindType + :ivar suspend: Whether this configuration should suspend its reconciliation of its + kustomizations and sources. + :vartype suspend: bool + :ivar git_repository: Parameters to reconcile to the GitRepository source kind type. + :vartype git_repository: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.GitRepositoryPatchDefinition + :ivar bucket: Parameters to reconcile to the Bucket source kind type. + :vartype bucket: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.BucketDefinition + :ivar kustomizations: Array of kustomizations used to reconcile the artifact pulled by the + source type on the cluster. + :vartype kustomizations: dict[str, + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.KustomizationPatchDefinition] + :ivar configuration_protected_settings: Key-value pairs of protected configuration settings for + the configuration. + :vartype configuration_protected_settings: dict[str, str] + """ + + _attribute_map = { + "source_kind": {"key": "properties.sourceKind", "type": "str"}, + "suspend": {"key": "properties.suspend", "type": "bool"}, + "git_repository": {"key": "properties.gitRepository", "type": "GitRepositoryPatchDefinition"}, + "bucket": {"key": "properties.bucket", "type": "BucketDefinition"}, + "kustomizations": {"key": "properties.kustomizations", "type": "{KustomizationPatchDefinition}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + } + + def __init__( + self, + *, + source_kind: Optional[Union[str, "_models.SourceKindType"]] = None, + suspend: Optional[bool] = None, + git_repository: Optional["_models.GitRepositoryPatchDefinition"] = None, + bucket: Optional["_models.BucketDefinition"] = None, + kustomizations: Optional[Dict[str, "_models.KustomizationPatchDefinition"]] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository" and "Bucket". + :paramtype source_kind: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceKindType + :keyword suspend: Whether this configuration should suspend its reconciliation of its + kustomizations and sources. + :paramtype suspend: bool + :keyword git_repository: Parameters to reconcile to the GitRepository source kind type. + :paramtype git_repository: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.GitRepositoryPatchDefinition + :keyword bucket: Parameters to reconcile to the Bucket source kind type. + :paramtype bucket: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.BucketDefinition + :keyword kustomizations: Array of kustomizations used to reconcile the artifact pulled by the + source type on the cluster. + :paramtype kustomizations: dict[str, + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.KustomizationPatchDefinition] + :keyword configuration_protected_settings: Key-value pairs of protected configuration settings + for the configuration. + :paramtype configuration_protected_settings: dict[str, str] + """ + super().__init__(**kwargs) + self.source_kind = source_kind + self.suspend = suspend + self.git_repository = git_repository + self.bucket = bucket + self.kustomizations = kustomizations + self.configuration_protected_settings = configuration_protected_settings + + +class FluxConfigurationsList(_serialization.Model): + """Result of the request to list Flux Configurations. It contains a list of FluxConfiguration + objects and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Flux Configurations within a Kubernetes cluster. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration] + :ivar next_link: URL to get the next set of configuration objects, if any. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[FluxConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class GitRepositoryDefinition(_serialization.Model): + """Parameters to reconcile to the GitRepository source kind type. + + :ivar url: The URL to sync for the flux configuration git repository. + :vartype url: str + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository + source with the remote. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :vartype sync_interval_in_seconds: int + :ivar repository_ref: The source reference for the GitRepository object. + :vartype repository_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.RepositoryRefDefinition + :ivar ssh_known_hosts: Base64-encoded known_hosts value containing public SSH keys required to + access private git repositories over SSH. + :vartype ssh_known_hosts: str + :ivar https_user: Plaintext HTTPS username used to access private git repositories over HTTPS. + :vartype https_user: str + :ivar https_ca_cert: Base64-encoded HTTPS certificate authority contents used to access git + private git repositories over HTTPS. + :vartype https_ca_cert: str + :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :vartype local_auth_ref: str + """ + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "repository_ref": {"key": "repositoryRef", "type": "RepositoryRefDefinition"}, + "ssh_known_hosts": {"key": "sshKnownHosts", "type": "str"}, + "https_user": {"key": "httpsUser", "type": "str"}, + "https_ca_cert": {"key": "httpsCACert", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, + repository_ref: Optional["_models.RepositoryRefDefinition"] = None, + ssh_known_hosts: Optional[str] = None, + https_user: Optional[str] = None, + https_ca_cert: Optional[str] = None, + local_auth_ref: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword url: The URL to sync for the flux configuration git repository. + :paramtype url: str + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster git + repository source with the remote. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :paramtype sync_interval_in_seconds: int + :keyword repository_ref: The source reference for the GitRepository object. + :paramtype repository_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.RepositoryRefDefinition + :keyword ssh_known_hosts: Base64-encoded known_hosts value containing public SSH keys required + to access private git repositories over SSH. + :paramtype ssh_known_hosts: str + :keyword https_user: Plaintext HTTPS username used to access private git repositories over + HTTPS. + :paramtype https_user: str + :keyword https_ca_cert: Base64-encoded HTTPS certificate authority contents used to access git + private git repositories over HTTPS. + :paramtype https_ca_cert: str + :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :paramtype local_auth_ref: str + """ + super().__init__(**kwargs) + self.url = url + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.repository_ref = repository_ref + self.ssh_known_hosts = ssh_known_hosts + self.https_user = https_user + self.https_ca_cert = https_ca_cert + self.local_auth_ref = local_auth_ref + + +class GitRepositoryPatchDefinition(_serialization.Model): + """Parameters to reconcile to the GitRepository source kind type. + + :ivar url: The URL to sync for the flux configuration git repository. + :vartype url: str + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository + source with the remote. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :vartype sync_interval_in_seconds: int + :ivar repository_ref: The source reference for the GitRepository object. + :vartype repository_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.RepositoryRefDefinition + :ivar ssh_known_hosts: Base64-encoded known_hosts value containing public SSH keys required to + access private git repositories over SSH. + :vartype ssh_known_hosts: str + :ivar https_user: Plaintext HTTPS username used to access private git repositories over HTTPS. + :vartype https_user: str + :ivar https_ca_cert: Base64-encoded HTTPS certificate authority contents used to access git + private git repositories over HTTPS. + :vartype https_ca_cert: str + :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :vartype local_auth_ref: str + """ + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "repository_ref": {"key": "repositoryRef", "type": "RepositoryRefDefinition"}, + "ssh_known_hosts": {"key": "sshKnownHosts", "type": "str"}, + "https_user": {"key": "httpsUser", "type": "str"}, + "https_ca_cert": {"key": "httpsCACert", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + timeout_in_seconds: Optional[int] = None, + sync_interval_in_seconds: Optional[int] = None, + repository_ref: Optional["_models.RepositoryRefDefinition"] = None, + ssh_known_hosts: Optional[str] = None, + https_user: Optional[str] = None, + https_ca_cert: Optional[str] = None, + local_auth_ref: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword url: The URL to sync for the flux configuration git repository. + :paramtype url: str + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster git + repository source with the remote. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :paramtype sync_interval_in_seconds: int + :keyword repository_ref: The source reference for the GitRepository object. + :paramtype repository_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.RepositoryRefDefinition + :keyword ssh_known_hosts: Base64-encoded known_hosts value containing public SSH keys required + to access private git repositories over SSH. + :paramtype ssh_known_hosts: str + :keyword https_user: Plaintext HTTPS username used to access private git repositories over + HTTPS. + :paramtype https_user: str + :keyword https_ca_cert: Base64-encoded HTTPS certificate authority contents used to access git + private git repositories over HTTPS. + :paramtype https_ca_cert: str + :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :paramtype local_auth_ref: str + """ + super().__init__(**kwargs) + self.url = url + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.repository_ref = repository_ref + self.ssh_known_hosts = ssh_known_hosts + self.https_user = https_user + self.https_ca_cert = https_ca_cert + self.local_auth_ref = local_auth_ref + + +class HelmOperatorProperties(_serialization.Model): + """Properties for Helm operator. + + :ivar chart_version: Version of the operator Helm chart. + :vartype chart_version: str + :ivar chart_values: Values override for the operator Helm chart. + :vartype chart_values: str + """ + + _attribute_map = { + "chart_version": {"key": "chartVersion", "type": "str"}, + "chart_values": {"key": "chartValues", "type": "str"}, + } + + def __init__( + self, *, chart_version: Optional[str] = None, chart_values: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword chart_version: Version of the operator Helm chart. + :paramtype chart_version: str + :keyword chart_values: Values override for the operator Helm chart. + :paramtype chart_values: str + """ + super().__init__(**kwargs) + self.chart_version = chart_version + self.chart_values = chart_values + + +class HelmReleasePropertiesDefinition(_serialization.Model): + """HelmReleasePropertiesDefinition. + + :ivar last_revision_applied: The revision number of the last released object change. + :vartype last_revision_applied: int + :ivar helm_chart_ref: The reference to the HelmChart object used as the source to this + HelmRelease. + :vartype helm_chart_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ObjectReferenceDefinition + :ivar failure_count: Total number of times that the HelmRelease failed to install or upgrade. + :vartype failure_count: int + :ivar install_failure_count: Number of times that the HelmRelease failed to install. + :vartype install_failure_count: int + :ivar upgrade_failure_count: Number of times that the HelmRelease failed to upgrade. + :vartype upgrade_failure_count: int + """ + + _attribute_map = { + "last_revision_applied": {"key": "lastRevisionApplied", "type": "int"}, + "helm_chart_ref": {"key": "helmChartRef", "type": "ObjectReferenceDefinition"}, + "failure_count": {"key": "failureCount", "type": "int"}, + "install_failure_count": {"key": "installFailureCount", "type": "int"}, + "upgrade_failure_count": {"key": "upgradeFailureCount", "type": "int"}, + } + + def __init__( + self, + *, + last_revision_applied: Optional[int] = None, + helm_chart_ref: Optional["_models.ObjectReferenceDefinition"] = None, + failure_count: Optional[int] = None, + install_failure_count: Optional[int] = None, + upgrade_failure_count: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword last_revision_applied: The revision number of the last released object change. + :paramtype last_revision_applied: int + :keyword helm_chart_ref: The reference to the HelmChart object used as the source to this + HelmRelease. + :paramtype helm_chart_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ObjectReferenceDefinition + :keyword failure_count: Total number of times that the HelmRelease failed to install or + upgrade. + :paramtype failure_count: int + :keyword install_failure_count: Number of times that the HelmRelease failed to install. + :paramtype install_failure_count: int + :keyword upgrade_failure_count: Number of times that the HelmRelease failed to upgrade. + :paramtype upgrade_failure_count: int + """ + super().__init__(**kwargs) + self.last_revision_applied = last_revision_applied + self.helm_chart_ref = helm_chart_ref + self.failure_count = failure_count + self.install_failure_count = install_failure_count + self.upgrade_failure_count = upgrade_failure_count + + +class Identity(_serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Default value is "SystemAssigned". + :vartype type: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: + """ + :keyword type: The identity type. Default value is "SystemAssigned". + :paramtype type: str + """ + super().__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + + +class KustomizationDefinition(_serialization.Model): + """The Kustomization defining how to reconcile the artifact pulled by the source type on the + cluster. + + :ivar path: The path in the source reference to reconcile on the cluster. + :vartype path: str + :ivar depends_on: Specifies other Kustomizations that this Kustomization depends on. This + Kustomization will not reconcile until all dependencies have completed their reconciliation. + :vartype depends_on: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.DependsOnDefinition] + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the + cluster. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the + cluster. + :vartype sync_interval_in_seconds: int + :ivar retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the + cluster in the event of failure on reconciliation. + :vartype retry_interval_in_seconds: int + :ivar prune: Enable/disable garbage collections of Kubernetes objects created by this + Kustomization. + :vartype prune: bool + :ivar force: Enable/disable re-creating Kubernetes resources on the cluster when patching fails + due to an immutable field change. + :vartype force: bool + """ + + _attribute_map = { + "path": {"key": "path", "type": "str"}, + "depends_on": {"key": "dependsOn", "type": "[DependsOnDefinition]"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "retry_interval_in_seconds": {"key": "retryIntervalInSeconds", "type": "int"}, + "prune": {"key": "prune", "type": "bool"}, + "force": {"key": "force", "type": "bool"}, + } + + def __init__( + self, + *, + path: str = "", + depends_on: Optional[List["_models.DependsOnDefinition"]] = None, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, + retry_interval_in_seconds: Optional[int] = None, + prune: bool = False, + force: bool = False, + **kwargs: Any + ) -> None: + """ + :keyword path: The path in the source reference to reconcile on the cluster. + :paramtype path: str + :keyword depends_on: Specifies other Kustomizations that this Kustomization depends on. This + Kustomization will not reconcile until all dependencies have completed their reconciliation. + :paramtype depends_on: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.DependsOnDefinition] + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the + cluster. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on + the cluster. + :paramtype sync_interval_in_seconds: int + :keyword retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on + the cluster in the event of failure on reconciliation. + :paramtype retry_interval_in_seconds: int + :keyword prune: Enable/disable garbage collections of Kubernetes objects created by this + Kustomization. + :paramtype prune: bool + :keyword force: Enable/disable re-creating Kubernetes resources on the cluster when patching + fails due to an immutable field change. + :paramtype force: bool + """ + super().__init__(**kwargs) + self.path = path + self.depends_on = depends_on + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.retry_interval_in_seconds = retry_interval_in_seconds + self.prune = prune + self.force = force + + +class KustomizationPatchDefinition(_serialization.Model): + """The Kustomization defining how to reconcile the artifact pulled by the source type on the + cluster. + + :ivar path: The path in the source reference to reconcile on the cluster. + :vartype path: str + :ivar depends_on: Specifies other Kustomizations that this Kustomization depends on. This + Kustomization will not reconcile until all dependencies have completed their reconciliation. + :vartype depends_on: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.DependsOnDefinition] + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the + cluster. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the + cluster. + :vartype sync_interval_in_seconds: int + :ivar retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the + cluster in the event of failure on reconciliation. + :vartype retry_interval_in_seconds: int + :ivar prune: Enable/disable garbage collections of Kubernetes objects created by this + Kustomization. + :vartype prune: bool + :ivar force: Enable/disable re-creating Kubernetes resources on the cluster when patching fails + due to an immutable field change. + :vartype force: bool + """ + + _attribute_map = { + "path": {"key": "path", "type": "str"}, + "depends_on": {"key": "dependsOn", "type": "[DependsOnDefinition]"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "retry_interval_in_seconds": {"key": "retryIntervalInSeconds", "type": "int"}, + "prune": {"key": "prune", "type": "bool"}, + "force": {"key": "force", "type": "bool"}, + } + + def __init__( + self, + *, + path: Optional[str] = None, + depends_on: Optional[List["_models.DependsOnDefinition"]] = None, + timeout_in_seconds: Optional[int] = None, + sync_interval_in_seconds: Optional[int] = None, + retry_interval_in_seconds: Optional[int] = None, + prune: Optional[bool] = None, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword path: The path in the source reference to reconcile on the cluster. + :paramtype path: str + :keyword depends_on: Specifies other Kustomizations that this Kustomization depends on. This + Kustomization will not reconcile until all dependencies have completed their reconciliation. + :paramtype depends_on: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.DependsOnDefinition] + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the + cluster. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on + the cluster. + :paramtype sync_interval_in_seconds: int + :keyword retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on + the cluster in the event of failure on reconciliation. + :paramtype retry_interval_in_seconds: int + :keyword prune: Enable/disable garbage collections of Kubernetes objects created by this + Kustomization. + :paramtype prune: bool + :keyword force: Enable/disable re-creating Kubernetes resources on the cluster when patching + fails due to an immutable field change. + :paramtype force: bool + """ + super().__init__(**kwargs) + self.path = path + self.depends_on = depends_on + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.retry_interval_in_seconds = retry_interval_in_seconds + self.prune = prune + self.force = force + + +class ObjectReferenceDefinition(_serialization.Model): + """Object reference to a Kubernetes object on a cluster. + + :ivar name: Name of the object. + :vartype name: str + :ivar namespace: Namespace of the object. + :vartype namespace: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, namespace: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: Name of the object. + :paramtype name: str + :keyword namespace: Namespace of the object. + :paramtype namespace: str + """ + super().__init__(**kwargs) + self.name = name + self.namespace = namespace + + +class ObjectStatusConditionDefinition(_serialization.Model): + """Status condition of Kubernetes object. + + :ivar last_transition_time: Last time this status condition has changed. + :vartype last_transition_time: ~datetime.datetime + :ivar message: A more verbose description of the object status condition. + :vartype message: str + :ivar reason: Reason for the specified status condition type status. + :vartype reason: str + :ivar status: Status of the Kubernetes object condition type. + :vartype status: str + :ivar type: Object status condition type for this object. + :vartype type: str + """ + + _attribute_map = { + "last_transition_time": {"key": "lastTransitionTime", "type": "iso-8601"}, + "message": {"key": "message", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + last_transition_time: Optional[datetime.datetime] = None, + message: Optional[str] = None, + reason: Optional[str] = None, + status: Optional[str] = None, + type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword last_transition_time: Last time this status condition has changed. + :paramtype last_transition_time: ~datetime.datetime + :keyword message: A more verbose description of the object status condition. + :paramtype message: str + :keyword reason: Reason for the specified status condition type status. + :paramtype reason: str + :keyword status: Status of the Kubernetes object condition type. + :paramtype status: str + :keyword type: Object status condition type for this object. + :paramtype type: str + """ + super().__init__(**kwargs) + self.last_transition_time = last_transition_time + self.message = message + self.reason = reason + self.status = status + self.type = type + + +class ObjectStatusDefinition(_serialization.Model): + """Statuses of objects deployed by the user-specified kustomizations from the git repository. + + :ivar name: Name of the applied object. + :vartype name: str + :ivar namespace: Namespace of the applied object. + :vartype namespace: str + :ivar kind: Kind of the applied object. + :vartype kind: str + :ivar compliance_state: Compliance state of the applied object showing whether the applied + object has come into a ready state on the cluster. Known values are: "Compliant", + "Non-Compliant", "Pending", "Suspended", and "Unknown". + :vartype compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxComplianceState + :ivar applied_by: Object reference to the Kustomization that applied this object. + :vartype applied_by: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ObjectReferenceDefinition + :ivar status_conditions: List of Kubernetes object status conditions present on the cluster. + :vartype status_conditions: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ObjectStatusConditionDefinition] + :ivar helm_release_properties: Additional properties that are provided from objects of the + HelmRelease kind. + :vartype helm_release_properties: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.HelmReleasePropertiesDefinition + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "compliance_state": {"key": "complianceState", "type": "str"}, + "applied_by": {"key": "appliedBy", "type": "ObjectReferenceDefinition"}, + "status_conditions": {"key": "statusConditions", "type": "[ObjectStatusConditionDefinition]"}, + "helm_release_properties": {"key": "helmReleaseProperties", "type": "HelmReleasePropertiesDefinition"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + namespace: Optional[str] = None, + kind: Optional[str] = None, + compliance_state: Union[str, "_models.FluxComplianceState"] = "Unknown", + applied_by: Optional["_models.ObjectReferenceDefinition"] = None, + status_conditions: Optional[List["_models.ObjectStatusConditionDefinition"]] = None, + helm_release_properties: Optional["_models.HelmReleasePropertiesDefinition"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the applied object. + :paramtype name: str + :keyword namespace: Namespace of the applied object. + :paramtype namespace: str + :keyword kind: Kind of the applied object. + :paramtype kind: str + :keyword compliance_state: Compliance state of the applied object showing whether the applied + object has come into a ready state on the cluster. Known values are: "Compliant", + "Non-Compliant", "Pending", "Suspended", and "Unknown". + :paramtype compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxComplianceState + :keyword applied_by: Object reference to the Kustomization that applied this object. + :paramtype applied_by: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ObjectReferenceDefinition + :keyword status_conditions: List of Kubernetes object status conditions present on the cluster. + :paramtype status_conditions: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ObjectStatusConditionDefinition] + :keyword helm_release_properties: Additional properties that are provided from objects of the + HelmRelease kind. + :paramtype helm_release_properties: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.HelmReleasePropertiesDefinition + """ + super().__init__(**kwargs) + self.name = name + self.namespace = namespace + self.kind = kind + self.compliance_state = compliance_state + self.applied_by = applied_by + self.status_conditions = status_conditions + self.helm_release_properties = helm_release_properties + + +class OperationStatusList(_serialization.Model): + """The async operations in progress, in the cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of async operations in progress, in the cluster. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.OperationStatusResult] + :ivar next_link: URL to get the next set of Operation Result objects, if any. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[OperationStatusResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class OperationStatusResult(_serialization.Model): + """The current status of an async operation. + + 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 ID for the async operation. + :vartype id: str + :ivar name: Name of the async operation. + :vartype name: str + :ivar status: Operation status. Required. + :vartype status: str + :ivar properties: Additional information, if available. + :vartype properties: dict[str, str] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ErrorDetail + """ + + _validation = { + "status": {"required": True}, + "error": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__( + self, + *, + status: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Fully qualified ID for the async operation. + :paramtype id: str + :keyword name: Name of the async operation. + :paramtype name: str + :keyword status: Operation status. Required. + :paramtype status: str + :keyword properties: Additional information, if available. + :paramtype properties: dict[str, str] + """ + super().__init__(**kwargs) + self.id = id + self.name = name + self.status = status + self.properties = properties + self.error = None + + +class PatchExtension(_serialization.Model): + """The Extension Patch Request object. + + :ivar auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade + of minor version, or not. + :vartype auto_upgrade_minor_version: bool + :ivar release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. Stable, + Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :vartype release_train: str + :ivar version: Version of the extension for this extension, if it is 'pinned' to a specific + version. autoUpgradeMinorVersion must be 'false'. + :vartype version: str + :ivar configuration_settings: Configuration settings, as name-value pairs for configuring this + extension. + :vartype configuration_settings: dict[str, str] + :ivar configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :vartype configuration_protected_settings: dict[str, str] + """ + + _attribute_map = { + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "configuration_settings": {"key": "properties.configurationSettings", "type": "{str}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + } + + def __init__( + self, + *, + auto_upgrade_minor_version: bool = True, + release_train: str = "Stable", + version: Optional[str] = None, + configuration_settings: Optional[Dict[str, str]] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword auto_upgrade_minor_version: Flag to note if this extension participates in auto + upgrade of minor version, or not. + :paramtype auto_upgrade_minor_version: bool + :keyword release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. + Stable, Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :paramtype release_train: str + :keyword version: Version of the extension for this extension, if it is 'pinned' to a specific + version. autoUpgradeMinorVersion must be 'false'. + :paramtype version: str + :keyword configuration_settings: Configuration settings, as name-value pairs for configuring + this extension. + :paramtype configuration_settings: dict[str, str] + :keyword configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :paramtype configuration_protected_settings: dict[str, str] + """ + super().__init__(**kwargs) + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.release_train = release_train + self.version = version + self.configuration_settings = configuration_settings + self.configuration_protected_settings = configuration_protected_settings + + +class RepositoryRefDefinition(_serialization.Model): + """The source reference for the GitRepository object. + + :ivar branch: The git repository branch name to checkout. + :vartype branch: str + :ivar tag: The git repository tag name to checkout. This takes precedence over branch. + :vartype tag: str + :ivar semver: The semver range used to match against git repository tags. This takes precedence + over tag. + :vartype semver: str + :ivar commit: The commit SHA to checkout. This value must be combined with the branch name to + be valid. This takes precedence over semver. + :vartype commit: str + """ + + _attribute_map = { + "branch": {"key": "branch", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "semver": {"key": "semver", "type": "str"}, + "commit": {"key": "commit", "type": "str"}, + } + + def __init__( + self, + *, + branch: Optional[str] = None, + tag: Optional[str] = None, + semver: Optional[str] = None, + commit: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword branch: The git repository branch name to checkout. + :paramtype branch: str + :keyword tag: The git repository tag name to checkout. This takes precedence over branch. + :paramtype tag: str + :keyword semver: The semver range used to match against git repository tags. This takes + precedence over tag. + :paramtype semver: str + :keyword commit: The commit SHA to checkout. This value must be combined with the branch name + to be valid. This takes precedence over semver. + :paramtype commit: str + """ + super().__init__(**kwargs) + self.branch = branch + self.tag = tag + self.semver = semver + self.commit = commit + + +class ResourceProviderOperation(_serialization.Model): + """Supported operation of this resource provider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Operation name, in format of {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: Display metadata associated with the operation. + :vartype display: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ResourceProviderOperationDisplay + :ivar is_data_action: The flag that indicates whether the operation applies to data plane. + :vartype is_data_action: bool + :ivar origin: Origin of the operation. + :vartype origin: str + """ + + _validation = { + "is_data_action": {"readonly": True}, + "origin": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "ResourceProviderOperationDisplay"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "origin": {"key": "origin", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["_models.ResourceProviderOperationDisplay"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Operation name, in format of {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: Display metadata associated with the operation. + :paramtype display: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ResourceProviderOperationDisplay + """ + super().__init__(**kwargs) + self.name = name + self.display = display + self.is_data_action = None + self.origin = None + + +class ResourceProviderOperationDisplay(_serialization.Model): + """Display metadata associated with the operation. + + :ivar provider: Resource provider: Microsoft KubernetesConfiguration. + :vartype provider: str + :ivar resource: Resource on which the operation is performed. + :vartype resource: str + :ivar operation: Type of operation: get, read, delete, etc. + :vartype operation: str + :ivar description: Description of this 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: Any + ) -> None: + """ + :keyword provider: Resource provider: Microsoft KubernetesConfiguration. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed. + :paramtype resource: str + :keyword operation: Type of operation: get, read, delete, etc. + :paramtype operation: str + :keyword description: Description of this operation. + :paramtype description: str + """ + super().__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class ResourceProviderOperationList(_serialization.Model): + """Result of the request to list operations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by this resource provider. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ResourceProviderOperation] + :ivar next_link: URL to the next set of results, if any. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ResourceProviderOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ResourceProviderOperation"]] = None, **kwargs: Any) -> None: + """ + :keyword value: List of operations supported by this resource provider. + :paramtype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ResourceProviderOperation] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class Scope(_serialization.Model): + """Scope of the extension. It can be either Cluster or Namespace; but not both. + + :ivar cluster: Specifies that the scope of the extension is Cluster. + :vartype cluster: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ScopeCluster + :ivar namespace: Specifies that the scope of the extension is Namespace. + :vartype namespace: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ScopeNamespace + """ + + _attribute_map = { + "cluster": {"key": "cluster", "type": "ScopeCluster"}, + "namespace": {"key": "namespace", "type": "ScopeNamespace"}, + } + + def __init__( + self, + *, + cluster: Optional["_models.ScopeCluster"] = None, + namespace: Optional["_models.ScopeNamespace"] = None, + **kwargs: Any + ) -> None: + """ + :keyword cluster: Specifies that the scope of the extension is Cluster. + :paramtype cluster: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ScopeCluster + :keyword namespace: Specifies that the scope of the extension is Namespace. + :paramtype namespace: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ScopeNamespace + """ + super().__init__(**kwargs) + self.cluster = cluster + self.namespace = namespace + + +class ScopeCluster(_serialization.Model): + """Specifies that the scope of the extension is Cluster. + + :ivar release_namespace: Namespace where the extension Release must be placed, for a Cluster + scoped extension. If this namespace does not exist, it will be created. + :vartype release_namespace: str + """ + + _attribute_map = { + "release_namespace": {"key": "releaseNamespace", "type": "str"}, + } + + def __init__(self, *, release_namespace: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword release_namespace: Namespace where the extension Release must be placed, for a Cluster + scoped extension. If this namespace does not exist, it will be created. + :paramtype release_namespace: str + """ + super().__init__(**kwargs) + self.release_namespace = release_namespace + + +class ScopeNamespace(_serialization.Model): + """Specifies that the scope of the extension is Namespace. + + :ivar target_namespace: Namespace where the extension will be created for an Namespace scoped + extension. If this namespace does not exist, it will be created. + :vartype target_namespace: str + """ + + _attribute_map = { + "target_namespace": {"key": "targetNamespace", "type": "str"}, + } + + def __init__(self, *, target_namespace: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword target_namespace: Namespace where the extension will be created for an Namespace + scoped extension. If this namespace does not exist, it will be created. + :paramtype target_namespace: str + """ + super().__init__(**kwargs) + self.target_namespace = target_namespace + + +class SourceControlConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes + """The SourceControl Configuration object returned in Get & Put response. + + 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: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SystemData + :ivar repository_url: Url of the SourceControl Repository. + :vartype repository_url: str + :ivar operator_namespace: The namespace to which this operator is installed to. Maximum of 253 + lower case alphanumeric characters, hyphen and period only. + :vartype operator_namespace: str + :ivar operator_instance_name: Instance name of the operator - identifying the specific + configuration. + :vartype operator_instance_name: str + :ivar operator_type: Type of the operator. "Flux" + :vartype operator_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.OperatorType + :ivar operator_params: Any Parameters for the Operator instance in string format. + :vartype operator_params: str + :ivar configuration_protected_settings: Name-value pairs of protected configuration settings + for the configuration. + :vartype configuration_protected_settings: dict[str, str] + :ivar operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". + :vartype operator_scope: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.OperatorScopeType + :ivar repository_public_key: Public Key associated with this SourceControl configuration + (either generated within the cluster or provided by the user). + :vartype repository_public_key: str + :ivar ssh_known_hosts_contents: Base64-encoded known_hosts contents containing public SSH keys + required to access private Git instances. + :vartype ssh_known_hosts_contents: str + :ivar enable_helm_operator: Option to enable Helm Operator for this git configuration. + :vartype enable_helm_operator: bool + :ivar helm_operator_properties: Properties for Helm operator. + :vartype helm_operator_properties: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.HelmOperatorProperties + :ivar provisioning_state: The provisioning state of the resource provider. Known values are: + "Accepted", "Deleting", "Running", "Succeeded", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ProvisioningStateType + :ivar compliance_status: Compliance Status of the Configuration. + :vartype compliance_status: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ComplianceStatus + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "repository_public_key": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "compliance_status": {"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"}, + "repository_url": {"key": "properties.repositoryUrl", "type": "str"}, + "operator_namespace": {"key": "properties.operatorNamespace", "type": "str"}, + "operator_instance_name": {"key": "properties.operatorInstanceName", "type": "str"}, + "operator_type": {"key": "properties.operatorType", "type": "str"}, + "operator_params": {"key": "properties.operatorParams", "type": "str"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "operator_scope": {"key": "properties.operatorScope", "type": "str"}, + "repository_public_key": {"key": "properties.repositoryPublicKey", "type": "str"}, + "ssh_known_hosts_contents": {"key": "properties.sshKnownHostsContents", "type": "str"}, + "enable_helm_operator": {"key": "properties.enableHelmOperator", "type": "bool"}, + "helm_operator_properties": {"key": "properties.helmOperatorProperties", "type": "HelmOperatorProperties"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "compliance_status": {"key": "properties.complianceStatus", "type": "ComplianceStatus"}, + } + + def __init__( + self, + *, + repository_url: Optional[str] = None, + operator_namespace: str = "default", + operator_instance_name: Optional[str] = None, + operator_type: Optional[Union[str, "_models.OperatorType"]] = None, + operator_params: Optional[str] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + operator_scope: Union[str, "_models.OperatorScopeType"] = "cluster", + ssh_known_hosts_contents: Optional[str] = None, + enable_helm_operator: Optional[bool] = None, + helm_operator_properties: Optional["_models.HelmOperatorProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword repository_url: Url of the SourceControl Repository. + :paramtype repository_url: str + :keyword operator_namespace: The namespace to which this operator is installed to. Maximum of + 253 lower case alphanumeric characters, hyphen and period only. + :paramtype operator_namespace: str + :keyword operator_instance_name: Instance name of the operator - identifying the specific + configuration. + :paramtype operator_instance_name: str + :keyword operator_type: Type of the operator. "Flux" + :paramtype operator_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.OperatorType + :keyword operator_params: Any Parameters for the Operator instance in string format. + :paramtype operator_params: str + :keyword configuration_protected_settings: Name-value pairs of protected configuration settings + for the configuration. + :paramtype configuration_protected_settings: dict[str, str] + :keyword operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". + :paramtype operator_scope: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.OperatorScopeType + :keyword ssh_known_hosts_contents: Base64-encoded known_hosts contents containing public SSH + keys required to access private Git instances. + :paramtype ssh_known_hosts_contents: str + :keyword enable_helm_operator: Option to enable Helm Operator for this git configuration. + :paramtype enable_helm_operator: bool + :keyword helm_operator_properties: Properties for Helm operator. + :paramtype helm_operator_properties: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.HelmOperatorProperties + """ + super().__init__(**kwargs) + self.system_data = None + self.repository_url = repository_url + self.operator_namespace = operator_namespace + self.operator_instance_name = operator_instance_name + self.operator_type = operator_type + self.operator_params = operator_params + self.configuration_protected_settings = configuration_protected_settings + self.operator_scope = operator_scope + self.repository_public_key = None + self.ssh_known_hosts_contents = ssh_known_hosts_contents + self.enable_helm_operator = enable_helm_operator + self.helm_operator_properties = helm_operator_properties + self.provisioning_state = None + self.compliance_status = None + + +class SourceControlConfigurationList(_serialization.Model): + """Result of the request to list Source Control Configurations. It contains a list of + SourceControlConfiguration objects and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Source Control Configurations within a Kubernetes cluster. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceControlConfiguration] + :ivar next_link: URL to get the next set of configuration objects, if any. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SourceControlConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class SupportedScopes(_serialization.Model): + """Extension scopes. + + :ivar default_scope: Default extension scopes: cluster or namespace. + :vartype default_scope: str + :ivar cluster_scope_settings: Scope settings. + :vartype cluster_scope_settings: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ClusterScopeSettings + """ + + _attribute_map = { + "default_scope": {"key": "defaultScope", "type": "str"}, + "cluster_scope_settings": {"key": "clusterScopeSettings", "type": "ClusterScopeSettings"}, + } + + def __init__( + self, + *, + default_scope: Optional[str] = None, + cluster_scope_settings: Optional["_models.ClusterScopeSettings"] = None, + **kwargs: Any + ) -> None: + """ + :keyword default_scope: Default extension scopes: cluster or namespace. + :paramtype default_scope: str + :keyword cluster_scope_settings: Scope settings. + :paramtype cluster_scope_settings: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ClusterScopeSettings + """ + super().__init__(**kwargs) + self.default_scope = default_scope + self.cluster_scope_settings = cluster_scope_settings + + +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.kubernetesconfiguration.v2022_01_15_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. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_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. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.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 diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/models/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/models/_source_control_configuration_client_enums.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/models/_source_control_configuration_client_enums.py new file mode 100644 index 000000000000..d4ee4e93afbc --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/models/_source_control_configuration_client_enums.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 enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class ComplianceStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The compliance state of the configuration.""" + + PENDING = "Pending" + COMPLIANT = "Compliant" + NONCOMPLIANT = "Noncompliant" + INSTALLED = "Installed" + FAILED = "Failed" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class ExtensionsClusterResourceName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ExtensionsClusterResourceName.""" + + MANAGED_CLUSTERS = "managedClusters" + CONNECTED_CLUSTERS = "connectedClusters" + + +class ExtensionsClusterRp(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ExtensionsClusterRp.""" + + MICROSOFT_CONTAINER_SERVICE = "Microsoft.ContainerService" + MICROSOFT_KUBERNETES = "Microsoft.Kubernetes" + + +class FluxComplianceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Compliance state of the cluster object.""" + + COMPLIANT = "Compliant" + NON_COMPLIANT = "Non-Compliant" + PENDING = "Pending" + SUSPENDED = "Suspended" + UNKNOWN = "Unknown" + + +class KustomizationValidationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specify whether to validate the Kubernetes objects referenced in the Kustomization before + applying them to the cluster. + """ + + NONE = "none" + CLIENT = "client" + SERVER = "server" + + +class LevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the status.""" + + ERROR = "Error" + WARNING = "Warning" + INFORMATION = "Information" + + +class MessageLevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the message.""" + + ERROR = "Error" + WARNING = "Warning" + INFORMATION = "Information" + + +class OperatorScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scope at which the operator will be installed.""" + + CLUSTER = "cluster" + NAMESPACE = "namespace" + + +class OperatorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the operator.""" + + FLUX = "Flux" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource.""" + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + + +class ProvisioningStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource provider.""" + + ACCEPTED = "Accepted" + DELETING = "Deleting" + RUNNING = "Running" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + + +class ScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scope at which the configuration will be installed.""" + + CLUSTER = "cluster" + NAMESPACE = "namespace" + + +class SourceKindType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Source Kind to pull the configuration data from.""" + + GIT_REPOSITORY = "GitRepository" + BUCKET = "Bucket" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/__init__.py new file mode 100644 index 000000000000..ccd968835618 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/__init__.py @@ -0,0 +1,37 @@ +# 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 ._cluster_extension_type_operations import ClusterExtensionTypeOperations +from ._cluster_extension_types_operations import ClusterExtensionTypesOperations +from ._extension_type_versions_operations import ExtensionTypeVersionsOperations +from ._location_extension_types_operations import LocationExtensionTypesOperations +from ._extensions_operations import ExtensionsOperations +from ._operation_status_operations import OperationStatusOperations +from ._flux_configurations_operations import FluxConfigurationsOperations +from ._flux_config_operation_status_operations import FluxConfigOperationStatusOperations +from ._source_control_configurations_operations import SourceControlConfigurationsOperations +from ._operations import Operations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ClusterExtensionTypeOperations", + "ClusterExtensionTypesOperations", + "ExtensionTypeVersionsOperations", + "LocationExtensionTypesOperations", + "ExtensionsOperations", + "OperationStatusOperations", + "FluxConfigurationsOperations", + "FluxConfigOperationStatusOperations", + "SourceControlConfigurationsOperations", + "Operations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_cluster_extension_type_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_cluster_extension_type_operations.py new file mode 100644 index 000000000000..3883104ba90a --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_cluster_extension_type_operations.py @@ -0,0 +1,190 @@ +# 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, Optional, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_type_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-01-15-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-15-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionTypeName": _SERIALIZER.url("extension_type_name", extension_type_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) + + +class ClusterExtensionTypeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.SourceControlConfigurationClient`'s + :attr:`cluster_extension_type` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_type_name: str, + **kwargs: Any + ) -> _models.ExtensionType: + """Get Extension Type details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_type_name: Extension type name. Required. + :type extension_type_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ExtensionType or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionType + :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-01-15-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-15-preview") + ) + cls: ClsType[_models.ExtensionType] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_type_name=extension_type_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ExtensionType", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes/{extensionTypeName}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_cluster_extension_types_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_cluster_extension_types_operations.py new file mode 100644 index 000000000000..304a276e0441 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_cluster_extension_types_operations.py @@ -0,0 +1,202 @@ +# 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, Union + +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, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_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-01-15-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-15-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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) + + +class ClusterExtensionTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.SourceControlConfigurationClient`'s + :attr:`cluster_extension_types` 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, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + **kwargs: Any + ) -> Iterable["_models.ExtensionType"]: + """Get Extension Types. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExtensionType or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionType] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-15-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-15-preview") + ) + cls: ClsType[_models.ExtensionTypeList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ExtensionTypeList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensionTypes" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_extension_type_versions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_extension_type_versions_operations.py new file mode 100644 index 000000000000..597d69b9a920 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_extension_type_versions_operations.py @@ -0,0 +1,174 @@ +# 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 + +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, extension_type_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-01-15-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-15-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions", + ) # 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"), + "extensionTypeName": _SERIALIZER.url("extension_type_name", extension_type_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) + + +class ExtensionTypeVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.SourceControlConfigurationClient`'s + :attr:`extension_type_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, extension_type_name: str, **kwargs: Any + ) -> Iterable["_models.ExtensionVersionListValueItem"]: + """List available versions for an Extension Type. + + :param location: extension location. Required. + :type location: str + :param extension_type_name: Extension type name. Required. + :type extension_type_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExtensionVersionListValueItem or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionVersionListValueItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-15-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-15-preview") + ) + cls: ClsType[_models.ExtensionVersionList] = 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, + extension_type_name=extension_type_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: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ExtensionVersionList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes/{extensionTypeName}/versions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_extensions_operations.py new file mode 100644 index 000000000000..2915666955d3 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_extensions_operations.py @@ -0,0 +1,1202 @@ +# 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 + +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_create_request( + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_get_request( + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_delete_request( + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + subscription_id: str, + *, + force_delete: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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") + if force_delete is not None: + _params["forceDelete"] = _SERIALIZER.query("force_delete", force_delete, "bool") + + # 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, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_request( + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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) + + +class ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_initial( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + extension: Union[_models.Extension, IO], + **kwargs: Any + ) -> _models.Extension: + 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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IO, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") + + request = build_create_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Extension", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension + :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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + extension: Union[_models.Extension, IO], + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Is either a Extension type or a + IO type. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension] + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + extension=extension, + 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("Extension", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + **kwargs: Any + ) -> _models.Extension: + """Gets Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Extension or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + force_delete: Optional[bool] = None, + **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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + force_delete=force_delete, + 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 [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Delete a Kubernetes Cluster Extension. This will cause the Agent to Uninstall the extension + from the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param force_delete: Delete the extension resource in Azure - not the normal asynchronous + delete. Default value is None. + :type force_delete: bool + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + force_delete=force_delete, + 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, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + def _update_initial( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + patch_extension: Union[_models.PatchExtension, IO], + **kwargs: Any + ) -> _models.Extension: + 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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(patch_extension, (IO, bytes)): + _content = patch_extension + else: + _json = self._serialize.body(patch_extension, "PatchExtension") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + patch_extension: _models.PatchExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.PatchExtension + :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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + patch_extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + patch_extension: Union[_models.PatchExtension, IO], + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Is either a + PatchExtension type or a IO type. Required. + :type patch_extension: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.PatchExtension 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension] + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + patch_extension=patch_extension, + 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("Extension", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace + def list( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + **kwargs: Any + ) -> Iterable["_models.Extension"]: + """List all Extensions in the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Extension or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ExtensionsList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ExtensionsList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_flux_config_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_flux_config_operation_status_operations.py new file mode 100644 index 000000000000..87003fe3e08c --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_flux_config_operation_status_operations.py @@ -0,0 +1,196 @@ +# 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, Optional, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + operation_id: 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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "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) + + +class FluxConfigOperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.SourceControlConfigurationClient`'s + :attr:`flux_config_operation_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + operation_id: str, + **kwargs: Any + ) -> _models.OperationStatusResult: + """Get Async Operation status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param operation_id: operation Id. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.OperationStatusResult + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + operation_id=operation_id, + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_flux_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_flux_configurations_operations.py new file mode 100644 index 000000000000..ddeab1614321 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_flux_configurations_operations.py @@ -0,0 +1,1212 @@ +# 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 + +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_get_request( + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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_update_request( + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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_delete_request( + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + subscription_id: str, + *, + force_delete: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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") + if force_delete is not None: + _params["forceDelete"] = _SERIALIZER.query("force_delete", force_delete, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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) + + +class FluxConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.SourceControlConfigurationClient`'s + :attr:`flux_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + **kwargs: Any + ) -> _models.FluxConfiguration: + """Gets details of the Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FluxConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration: Union[_models.FluxConfiguration, IO], + **kwargs: Any + ) -> _models.FluxConfiguration: + 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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration, (IO, bytes)): + _content = flux_configuration + else: + _json = self._serialize.body(flux_configuration, "FluxConfiguration") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("FluxConfiguration", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration: _models.FluxConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration: Union[_models.FluxConfiguration, IO], + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Is either a + FluxConfiguration type or a IO type. Required. + :type flux_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration] + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + flux_configuration=flux_configuration, + 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("FluxConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + def _update_initial( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], + **kwargs: Any + ) -> _models.FluxConfiguration: + 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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration_patch, (IO, bytes)): + _content = flux_configuration_patch + else: + _json = self._serialize.body(flux_configuration_patch, "FluxConfigurationPatch") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: _models.FluxConfigurationPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. + :type flux_configuration_patch: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfigurationPatch + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. + :type flux_configuration_patch: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. Is + either a FluxConfigurationPatch type or a IO type. Required. + :type flux_configuration_patch: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfigurationPatch 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration] + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + flux_configuration_patch=flux_configuration_patch, + 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("FluxConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + force_delete: Optional[bool] = None, + **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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + subscription_id=self._config.subscription_id, + force_delete=force_delete, + 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 [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + flux_configuration_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """This will delete the YAML file used to set up the Flux Configuration, thus stopping future sync + from the source repo. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param force_delete: Delete the extension resource in Azure - not the normal asynchronous + delete. Default value is None. + :type force_delete: bool + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + force_delete=force_delete, + 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, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @distributed_trace + def list( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + **kwargs: Any + ) -> Iterable["_models.FluxConfiguration"]: + """List all Flux Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FluxConfiguration or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.FluxConfigurationsList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("FluxConfigurationsList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_location_extension_types_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_location_extension_types_operations.py new file mode 100644 index 000000000000..7f11effa55d3 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_location_extension_types_operations.py @@ -0,0 +1,167 @@ +# 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 + +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-01-15-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-15-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes", + ) # 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"), + } + + _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 LocationExtensionTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.SourceControlConfigurationClient`'s + :attr:`location_extension_types` 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.ExtensionType"]: + """List all Extension Types. + + :param location: extension location. 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 ExtensionType or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionType] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-15-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-15-preview") + ) + cls: ClsType[_models.ExtensionTypeList] = 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: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ExtensionTypeList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/locations/{location}/extensionTypes" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_operation_status_operations.py new file mode 100644 index 000000000000..a87405b5982e --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_operation_status_operations.py @@ -0,0 +1,340 @@ +# 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, Union + +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_get_request( + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + operation_id: 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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "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_list_request( + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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) + + +class OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.SourceControlConfigurationClient`'s + :attr:`operation_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + extension_name: str, + operation_id: str, + **kwargs: Any + ) -> _models.OperationStatusResult: + """Get Async Operation status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param operation_id: operation Id. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.OperationStatusResult + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + operation_id=operation_id, + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + } + + @distributed_trace + def list( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + **kwargs: Any + ) -> Iterable["_models.OperationStatusResult"]: + """List Async Operations, currently in progress, in a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.OperationStatusList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationStatusList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_operations.py new file mode 100644 index 000000000000..7cba14777c73 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_operations.py @@ -0,0 +1,153 @@ +# 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 + +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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.KubernetesConfiguration/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.kubernetesconfiguration.v2022_01_15_preview.SourceControlConfigurationClient`'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.ResourceProviderOperation"]: + """List all the available operations the KubernetesConfiguration resource provider supports. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceProviderOperation or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ResourceProviderOperationList] = 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: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ResourceProviderOperationList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_source_control_configurations_operations.py new file mode 100644 index 000000000000..7329a78a95d3 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/operations/_source_control_configurations_operations.py @@ -0,0 +1,785 @@ +# 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 + +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_get_request( + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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_list_request( + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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) + + +class SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_name: str, + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Gets details of the Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceControlConfiguration + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceControlConfiguration + :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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceControlConfiguration 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: SourceControlConfiguration or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceControlConfiguration + :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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SourceControlConfiguration", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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 [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + source_control_configuration_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """This will delete the YAML file used to set up the Source control configuration, thus stopping + future sync from the source repo. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_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-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + @distributed_trace + def list( + self, + resource_group_name: str, + cluster_rp: Union[str, _models.ExtensionsClusterRp], + cluster_resource_name: Union[str, _models.ExtensionsClusterResourceName], + cluster_name: str, + **kwargs: Any + ) -> Iterable["_models.SourceControlConfiguration"]: + """List all Source Control Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS + clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Known values are: + "Microsoft.ContainerService" and "Microsoft.Kubernetes". Required. + :type cluster_rp: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterRp + :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters + (for AKS clusters) or connectedClusters (for OnPrem K8S clusters). Known values are: + "managedClusters" and "connectedClusters". Required. + :type cluster_resource_name: str or + ~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.ExtensionsClusterResourceName + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SourceControlConfiguration or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_01_15_preview.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SourceControlConfigurationList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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: + request = HttpRequest("GET", next_link) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SourceControlConfigurationList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/py.typed b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_01_15_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/__init__.py index e90963036337..3ad4bd8b604e 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['SourceControlConfigurationClient'] -# `._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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_configuration.py index 370fdc18d17f..e72cd57ee5f7 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_configuration.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_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,30 +15,35 @@ 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 SourceControlConfigurationClientConfiguration(Configuration): +class SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SourceControlConfigurationClient. 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-03-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(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", "2022-03-01") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +51,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2022-03-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_metadata.json b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_metadata.json index 0f12089657fa..017fa56adc28 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_metadata.json +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_metadata.json @@ -10,34 +10,36 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SourceControlConfigurationClientConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SourceControlConfigurationClientConfiguration\"]}}, \"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\": [\"SourceControlConfigurationClientConfiguration\"], \".._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\": [\"SourceControlConfigurationClientConfiguration\"], \"..._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 + "required": true, + "method_location": "positional" }, "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 + "required": true, + "method_location": "positional" } }, "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,22 +50,25 @@ "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 + "required": false, + "method_location": "positional" }, "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 + "required": false, + "method_location": "positional" }, "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 + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "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 + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -104,4 +112,4 @@ "source_control_configurations": "SourceControlConfigurationsOperations", "operations": "Operations" } -} \ No newline at end of file +} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_patch.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_source_control_configuration_client.py index afe78f7c5abf..edefcb2dec3a 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_source_control_configuration_client.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_source_control_configuration_client.py @@ -7,21 +7,29 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer -from . import models +from . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import SourceControlConfigurationClientConfiguration -from .operations import ExtensionsOperations, FluxConfigOperationStatusOperations, FluxConfigurationsOperations, OperationStatusOperations, Operations, SourceControlConfigurationsOperations +from .operations import ( + ExtensionsOperations, + FluxConfigOperationStatusOperations, + FluxConfigurationsOperations, + OperationStatusOperations, + Operations, + SourceControlConfigurationsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SourceControlConfigurationClient: + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword """KubernetesConfiguration Client. :ivar extensions: ExtensionsOperations operations @@ -41,12 +49,15 @@ class SourceControlConfigurationClient: azure.mgmt.kubernetesconfiguration.v2022_03_01.operations.SourceControlConfigurationsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.kubernetesconfiguration.v2022_03_01.operations.Operations - :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'. + :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-03-01". 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. """ @@ -58,26 +69,31 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SourceControlConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SourceControlConfigurationClientConfiguration( + 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.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_status = OperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.flux_configurations = FluxConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.flux_config_operation_status = FluxConfigOperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.source_control_configurations = SourceControlConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_configurations = FluxConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_config_operation_status = FluxConfigOperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request, # type: 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 @@ -86,7 +102,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 @@ -99,15 +115,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: () -> SourceControlConfigurationClient + def __enter__(self) -> "SourceControlConfigurationClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_vendor.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_vendor.py index 138f663c53a4..bd0df84f5319 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_vendor.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_vendor.py @@ -5,8 +5,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + 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,14 +17,14 @@ def _convert_request(request, files=None): 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 - ] + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_version.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_version.py index 48944bf3938a..59deb8c7263b 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_version.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.1.0" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/__init__.py index 5f583276b4ed..b95230ae03c5 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._source_control_configuration_client import SourceControlConfigurationClient -__all__ = ['SourceControlConfigurationClient'] -# `._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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/_configuration.py index 5bb69c4da53d..b0fd0b2e4762 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/_configuration.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_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,30 +15,35 @@ 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 SourceControlConfigurationClientConfiguration(Configuration): +class SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SourceControlConfigurationClient. 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-03-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(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", "2022-03-01") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +51,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2022-03-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/_patch.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/_source_control_configuration_client.py index 9a5a755578b6..55228c52a8cf 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/_source_control_configuration_client.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/_source_control_configuration_client.py @@ -7,21 +7,29 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer -from .. import models +from .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import SourceControlConfigurationClientConfiguration -from .operations import ExtensionsOperations, FluxConfigOperationStatusOperations, FluxConfigurationsOperations, OperationStatusOperations, Operations, SourceControlConfigurationsOperations +from .operations import ( + ExtensionsOperations, + FluxConfigOperationStatusOperations, + FluxConfigurationsOperations, + OperationStatusOperations, + Operations, + SourceControlConfigurationsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SourceControlConfigurationClient: + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword """KubernetesConfiguration Client. :ivar extensions: ExtensionsOperations operations @@ -41,12 +49,15 @@ class SourceControlConfigurationClient: azure.mgmt.kubernetesconfiguration.v2022_03_01.aio.operations.SourceControlConfigurationsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.kubernetesconfiguration.v2022_03_01.aio.operations.Operations - :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'. + :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-03-01". 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. """ @@ -58,26 +69,31 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SourceControlConfigurationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SourceControlConfigurationClientConfiguration( + 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.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_status = OperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.flux_configurations = FluxConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.flux_config_operation_status = FluxConfigOperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.source_control_configurations = SourceControlConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_configurations = FluxConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_config_operation_status = FluxConfigOperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **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 @@ -86,7 +102,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 @@ -106,5 +122,5 @@ async def __aenter__(self) -> "SourceControlConfigurationClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/__init__.py index e18b201b5dc3..9d58b5443a05 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/__init__.py @@ -13,11 +13,17 @@ from ._source_control_configurations_operations import SourceControlConfigurationsOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ExtensionsOperations', - 'OperationStatusOperations', - 'FluxConfigurationsOperations', - 'FluxConfigOperationStatusOperations', - 'SourceControlConfigurationsOperations', - 'Operations', + "ExtensionsOperations", + "OperationStatusOperations", + "FluxConfigurationsOperations", + "FluxConfigOperationStatusOperations", + "SourceControlConfigurationsOperations", + "Operations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_extensions_operations.py index bba4b3105d5b..4c3f3dfe7ac6 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_extensions_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_extensions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,65 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +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._extensions_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._extensions_operations import ( + build_create_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 ExtensionsOperations: - """ExtensionsOperations 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 ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_03_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.kubernetesconfiguration.v2022_03_01.aio.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_initial( self, @@ -55,53 +73,171 @@ async def _create_initial( cluster_resource_name: str, cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> "_models.Extension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + ) -> _models.Extension: 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 {}) - 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(extension, 'Extension') + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IO, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") + + request = build_create_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension + :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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -111,25 +247,30 @@ async def begin_create( cluster_resource_name: str, cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Extension"]: + ) -> AsyncLROPoller[_models.Extension]: """Create a new Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param extension: Properties necessary to Create an Extension. - :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension + :param extension: Properties necessary to Create an Extension. Is either a Extension type or a + IO type. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension 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 @@ -142,16 +283,17 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] - 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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_initial( resource_group_name=resource_group_name, @@ -160,34 +302,42 @@ async def begin_create( cluster_name=cluster_name, extension_name=extension_name, extension=extension, + 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('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace_async async def get( @@ -198,46 +348,60 @@ async def get( cluster_name: str, extension_name: str, **kwargs: Any - ) -> "_models.Extension": + ) -> _models.Extension: """Gets Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Extension, or the result of cls(response) + :return: Extension or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] 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: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -245,17 +409,18 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_rp: str, @@ -265,38 +430,53 @@ async def _delete_initial( force_delete: Optional[bool] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, force_delete=force_delete, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(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, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace_async async def begin_delete( @@ -313,19 +493,20 @@ async def begin_delete( from the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :param force_delete: Delete the extension resource in Azure - not the normal asynchronous - delete. + delete. Default value is None. :type force_delete: bool :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. @@ -337,47 +518,57 @@ async def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, force_delete=force_delete, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } async def _update_initial( self, @@ -386,49 +577,171 @@ async def _update_initial( cluster_resource_name: str, cluster_name: str, extension_name: str, - patch_extension: "_models.PatchExtension", + patch_extension: Union[_models.PatchExtension, IO], **kwargs: Any - ) -> "_models.Extension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + ) -> _models.Extension: 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 {}) - 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(patch_extension, 'PatchExtension') + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = 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(patch_extension, (IO, bytes)): + _content = patch_extension + else: + _json = self._serialize.body(patch_extension, "PatchExtension") + + request = build_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_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(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]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Extension", pipeline_response) - deserialized = self._deserialize('Extension', pipeline_response) + if response.status_code == 202: + deserialized = self._deserialize("Extension", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: _models.PatchExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.PatchExtension + :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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -438,25 +751,31 @@ async def begin_update( cluster_resource_name: str, cluster_name: str, extension_name: str, - patch_extension: "_models.PatchExtension", + patch_extension: Union[_models.PatchExtension, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Extension"]: + ) -> AsyncLROPoller[_models.Extension]: """Patch an existing Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param patch_extension: Properties to Patch in an existing Extension. - :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.PatchExtension + :param patch_extension: Properties to Patch in an existing Extension. Is either a + PatchExtension type or a IO type. Required. + :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.PatchExtension 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 @@ -469,16 +788,17 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] - 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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = 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, @@ -487,90 +807,109 @@ async def begin_update( cluster_name=cluster_name, extension_name=extension_name, patch_extension=patch_extension, + 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('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def list( - self, - resource_group_name: str, - cluster_rp: str, - cluster_resource_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ExtensionsList"]: + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Extension"]: """List all Extensions in the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionsList or the result of cls(response) + :return: An iterator like instance of either Extension or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ExtensionsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.ExtensionsList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -581,13 +920,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionsList", 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(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]: @@ -597,8 +938,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_flux_config_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_flux_config_operation_status_operations.py index 53766735ba9d..3d6ee50a3f98 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_flux_config_operation_status_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_flux_config_operation_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,44 +6,54 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._flux_config_operation_status_operations import build_get_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 FluxConfigOperationStatusOperations: - """FluxConfigOperationStatusOperations 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 FluxConfigOperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_03_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.kubernetesconfiguration.v2022_03_01.aio.SourceControlConfigurationClient`'s + :attr:`flux_config_operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -54,49 +65,63 @@ async def get( flux_configuration_name: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationStatusResult": + ) -> _models.OperationStatusResult: """Get Async Operation status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str - :param operation_id: operation Id. + :param operation_id: operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatusResult, or the result of cls(response) + :return: OperationStatusResult or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.OperationStatusResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -104,12 +129,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_flux_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_flux_configurations_operations.py index 80b175ce087f..5f996ceae48c 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_flux_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_flux_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,65 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +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._flux_configurations_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._flux_configurations_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 FluxConfigurationsOperations: - """FluxConfigurationsOperations 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 FluxConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_03_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.kubernetesconfiguration.v2022_03_01.aio.SourceControlConfigurationClient`'s + :attr:`flux_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -57,46 +75,60 @@ async def get( cluster_name: str, flux_configuration_name: str, **kwargs: Any - ) -> "_models.FluxConfiguration": + ) -> _models.FluxConfiguration: """Gets details of the Flux Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FluxConfiguration, or the result of cls(response) + :return: FluxConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] 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: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -104,15 +136,16 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } async def _create_or_update_initial( self, @@ -121,53 +154,172 @@ async def _create_or_update_initial( cluster_resource_name: str, cluster_name: str, flux_configuration_name: str, - flux_configuration: "_models.FluxConfiguration", + flux_configuration: Union[_models.FluxConfiguration, IO], **kwargs: Any - ) -> "_models.FluxConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + ) -> _models.FluxConfiguration: 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 {}) - 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(flux_configuration, 'FluxConfiguration') + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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(flux_configuration, (IO, bytes)): + _content = flux_configuration + else: + _json = self._serialize.body(flux_configuration, "FluxConfiguration") + + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_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(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: _models.FluxConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -177,26 +329,31 @@ async def begin_create_or_update( cluster_resource_name: str, cluster_name: str, flux_configuration_name: str, - flux_configuration: "_models.FluxConfiguration", + flux_configuration: Union[_models.FluxConfiguration, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.FluxConfiguration"]: + ) -> AsyncLROPoller[_models.FluxConfiguration]: """Create a new Kubernetes Flux Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str - :param flux_configuration: Properties necessary to Create a FluxConfiguration. + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Is either a + FluxConfiguration type or a IO type. Required. :type flux_configuration: - ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration + ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration 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 @@ -209,16 +366,17 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] - 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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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, @@ -227,34 +385,42 @@ async def begin_create_or_update( cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, flux_configuration=flux_configuration, + 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('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } async def _update_initial( self, @@ -263,51 +429,77 @@ async def _update_initial( cluster_resource_name: str, cluster_name: str, flux_configuration_name: str, - flux_configuration_patch: "_models.FluxConfigurationPatch", + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], **kwargs: Any - ) -> "_models.FluxConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + ) -> _models.FluxConfiguration: 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 {}) - 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(flux_configuration_patch, 'FluxConfigurationPatch') + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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(flux_configuration_patch, (IO, bytes)): + _content = flux_configuration_patch + else: + _json = self._serialize.body(flux_configuration_patch, "FluxConfigurationPatch") + + request = build_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_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(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]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("FluxConfiguration", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) + if response.status_code == 202: + deserialized = self._deserialize("FluxConfiguration", pipeline_response) - return deserialized + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + return deserialized # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, @@ -315,26 +507,33 @@ async def begin_update( cluster_resource_name: str, cluster_name: str, flux_configuration_name: str, - flux_configuration_patch: "_models.FluxConfigurationPatch", + flux_configuration_patch: _models.FluxConfigurationPatch, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.FluxConfiguration"]: + ) -> AsyncLROPoller[_models.FluxConfiguration]: """Update an existing Kubernetes Flux Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. :type flux_configuration_patch: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfigurationPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -347,16 +546,114 @@ async def begin_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. + :type flux_configuration_patch: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. Is + either a FluxConfigurationPatch type or a IO type. Required. + :type flux_configuration_patch: + ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfigurationPatch 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration] + :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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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, @@ -365,36 +662,44 @@ async def begin_update( cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, flux_configuration_patch=flux_configuration_patch, + 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('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_rp: str, @@ -404,38 +709,53 @@ async def _delete_initial( force_delete: Optional[bool] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, + subscription_id=self._config.subscription_id, force_delete=force_delete, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(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, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } @distributed_trace_async async def begin_delete( @@ -452,19 +772,20 @@ async def begin_delete( from the source repo. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str :param force_delete: Delete the extension resource in Azure - not the normal asynchronous - delete. + delete. Default value is None. :type force_delete: bool :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. @@ -476,104 +797,124 @@ async def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, force_delete=force_delete, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } @distributed_trace def list( - self, - resource_group_name: str, - cluster_rp: str, - cluster_resource_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.FluxConfigurationsList"]: + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.FluxConfiguration"]: """List all Flux Configurations. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FluxConfigurationsList or the result of - cls(response) + :return: An iterator like instance of either FluxConfiguration or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfigurationsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfigurationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.FluxConfigurationsList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -584,13 +925,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("FluxConfigurationsList", 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(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]: @@ -600,8 +943,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_operation_status_operations.py index c190ec1e38b5..087c4a5fbc30 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_operation_status_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_operation_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,57 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.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._operation_status_operations import build_get_request, 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 OperationStatusOperations: - """OperationStatusOperations 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 OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_03_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.kubernetesconfiguration.v2022_03_01.aio.SourceControlConfigurationClient`'s + :attr:`operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -56,49 +68,63 @@ async def get( extension_name: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationStatusResult": + ) -> _models.OperationStatusResult: """Get Async Operation status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param operation_id: operation Id. + :param operation_id: operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatusResult, or the result of cls(response) + :return: OperationStatusResult or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.OperationStatusResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -106,71 +132,84 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + } @distributed_trace def list( - self, - resource_group_name: str, - cluster_rp: str, - cluster_resource_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.OperationStatusList"]: + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.OperationStatusResult"]: """List Async Operations, currently in progress, in a cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationStatusList or the result of cls(response) + :return: An iterator like instance of either OperationStatusResult or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.OperationStatusList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.OperationStatusList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -181,13 +220,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationStatusList", 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(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]: @@ -197,8 +238,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_operations.py index 3131058170ae..cbe7971fa2b0 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,79 +6,106 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.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._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.kubernetesconfiguration.v2022_03_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.kubernetesconfiguration.v2022_03_01.aio.SourceControlConfigurationClient`'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.ResourceProviderOperationList"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceProviderOperation"]: """List all the available operations the KubernetesConfiguration resource provider supports. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of + :return: An iterator like instance of either ResourceProviderOperation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ResourceProviderOperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.ResourceProviderOperationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - 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) @@ -88,13 +116,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ResourceProviderOperationList", 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(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]: @@ -104,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.KubernetesConfiguration/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_source_control_configurations_operations.py index 71375d427f2e..b5bb383790ed 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_source_control_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/aio/operations/_source_control_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,64 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +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._source_control_configurations_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._source_control_configurations_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + 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 SourceControlConfigurationsOperations: - """SourceControlConfigurationsOperations 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 SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.kubernetesconfiguration.v2022_03_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.kubernetesconfiguration.v2022_03_01.aio.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -57,46 +74,60 @@ async def get( cluster_name: str, source_control_configuration_name: str, **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Gets details of the Source Control Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self.get.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -104,17 +135,18 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, @@ -122,56 +154,162 @@ async def create_or_update( cluster_resource_name: str, cluster_name: str, source_control_configuration_name: str, - source_control_configuration: "_models.SourceControlConfiguration", + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Create a new Kubernetes Source Control Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. :type source_control_configuration: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceControlConfiguration + :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: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceControlConfiguration 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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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 {}) - 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(source_control_configuration, 'SourceControlConfiguration') + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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 = await self._client._pipeline.run(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]: @@ -180,20 +318,21 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_rp: str, @@ -202,37 +341,52 @@ async def _delete_initial( source_control_configuration_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 {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self._delete_initial.metadata['url'], + 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 = await self._client._pipeline.run(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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace_async async def begin_delete( @@ -248,16 +402,17 @@ async def begin_delete( future sync from the source repo. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_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. @@ -269,103 +424,121 @@ async def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - cls=lambda x,y,z: x, + api_version=api_version, + 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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def list( - self, - resource_group_name: str, - cluster_rp: str, - cluster_resource_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SourceControlConfigurationList"]: + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SourceControlConfiguration"]: """List all Source Control Configurations. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlConfigurationList or the result of + :return: An iterator like instance of either SourceControlConfiguration or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceControlConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.SourceControlConfigurationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -376,13 +549,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlConfigurationList", 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(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]: @@ -392,8 +567,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/models/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/models/__init__.py index 2bd4f2cd929e..ff57672e9e1a 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/models/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/models/__init__.py @@ -45,73 +45,75 @@ from ._models_py3 import SourceControlConfigurationList from ._models_py3 import SystemData - -from ._source_control_configuration_client_enums import ( - AKSIdentityType, - ComplianceStateType, - CreatedByType, - FluxComplianceState, - KustomizationValidationType, - LevelType, - MessageLevelType, - OperatorScopeType, - OperatorType, - ProvisioningState, - ProvisioningStateType, - ScopeType, - SourceKindType, -) +from ._source_control_configuration_client_enums import AKSIdentityType +from ._source_control_configuration_client_enums import ComplianceStateType +from ._source_control_configuration_client_enums import CreatedByType +from ._source_control_configuration_client_enums import FluxComplianceState +from ._source_control_configuration_client_enums import KustomizationValidationType +from ._source_control_configuration_client_enums import LevelType +from ._source_control_configuration_client_enums import MessageLevelType +from ._source_control_configuration_client_enums import OperatorScopeType +from ._source_control_configuration_client_enums import OperatorType +from ._source_control_configuration_client_enums import ProvisioningState +from ._source_control_configuration_client_enums import ProvisioningStateType +from ._source_control_configuration_client_enums import ScopeType +from ._source_control_configuration_client_enums import SourceKindType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'BucketDefinition', - 'BucketPatchDefinition', - 'ComplianceStatus', - 'ErrorAdditionalInfo', - 'ErrorDetail', - 'ErrorResponse', - 'Extension', - 'ExtensionPropertiesAksAssignedIdentity', - 'ExtensionStatus', - 'ExtensionsList', - 'FluxConfiguration', - 'FluxConfigurationPatch', - 'FluxConfigurationsList', - 'GitRepositoryDefinition', - 'GitRepositoryPatchDefinition', - 'HelmOperatorProperties', - 'HelmReleasePropertiesDefinition', - 'Identity', - 'KustomizationDefinition', - 'KustomizationPatchDefinition', - 'ObjectReferenceDefinition', - 'ObjectStatusConditionDefinition', - 'ObjectStatusDefinition', - 'OperationStatusList', - 'OperationStatusResult', - 'PatchExtension', - 'ProxyResource', - 'RepositoryRefDefinition', - 'Resource', - 'ResourceProviderOperation', - 'ResourceProviderOperationDisplay', - 'ResourceProviderOperationList', - 'Scope', - 'ScopeCluster', - 'ScopeNamespace', - 'SourceControlConfiguration', - 'SourceControlConfigurationList', - 'SystemData', - 'AKSIdentityType', - 'ComplianceStateType', - 'CreatedByType', - 'FluxComplianceState', - 'KustomizationValidationType', - 'LevelType', - 'MessageLevelType', - 'OperatorScopeType', - 'OperatorType', - 'ProvisioningState', - 'ProvisioningStateType', - 'ScopeType', - 'SourceKindType', + "BucketDefinition", + "BucketPatchDefinition", + "ComplianceStatus", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "Extension", + "ExtensionPropertiesAksAssignedIdentity", + "ExtensionStatus", + "ExtensionsList", + "FluxConfiguration", + "FluxConfigurationPatch", + "FluxConfigurationsList", + "GitRepositoryDefinition", + "GitRepositoryPatchDefinition", + "HelmOperatorProperties", + "HelmReleasePropertiesDefinition", + "Identity", + "KustomizationDefinition", + "KustomizationPatchDefinition", + "ObjectReferenceDefinition", + "ObjectStatusConditionDefinition", + "ObjectStatusDefinition", + "OperationStatusList", + "OperationStatusResult", + "PatchExtension", + "ProxyResource", + "RepositoryRefDefinition", + "Resource", + "ResourceProviderOperation", + "ResourceProviderOperationDisplay", + "ResourceProviderOperationList", + "Scope", + "ScopeCluster", + "ScopeNamespace", + "SourceControlConfiguration", + "SourceControlConfigurationList", + "SystemData", + "AKSIdentityType", + "ComplianceStateType", + "CreatedByType", + "FluxComplianceState", + "KustomizationValidationType", + "LevelType", + "MessageLevelType", + "OperatorScopeType", + "OperatorType", + "ProvisioningState", + "ProvisioningStateType", + "ScopeType", + "SourceKindType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/models/_models_py3.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/models/_models_py3.py index 6378d3e0d25b..e208891ff731 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/models/_models_py3.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_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,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -from ._source_control_configuration_client_enums import * +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 .. import models as _models -class BucketDefinition(msrest.serialization.Model): + +class BucketDefinition(_serialization.Model): """Parameters to reconcile to the GitRepository source kind type. :ivar url: The URL to sync for the flux configuration S3 bucket. @@ -27,10 +35,10 @@ class BucketDefinition(msrest.serialization.Model): :vartype insecure: bool :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository source with the remote. - :vartype timeout_in_seconds: long + :vartype timeout_in_seconds: int :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster git repository source with the remote. - :vartype sync_interval_in_seconds: long + :vartype sync_interval_in_seconds: int :ivar access_key: Plaintext access key used to securely access the S3 bucket. :vartype access_key: str :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the @@ -39,13 +47,13 @@ class BucketDefinition(msrest.serialization.Model): """ _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, - 'bucket_name': {'key': 'bucketName', 'type': 'str'}, - 'insecure': {'key': 'insecure', 'type': 'bool'}, - 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, - 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, - 'access_key': {'key': 'accessKey', 'type': 'str'}, - 'local_auth_ref': {'key': 'localAuthRef', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, + "bucket_name": {"key": "bucketName", "type": "str"}, + "insecure": {"key": "insecure", "type": "bool"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "access_key": {"key": "accessKey", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, } def __init__( @@ -53,13 +61,13 @@ def __init__( *, url: Optional[str] = None, bucket_name: Optional[str] = None, - insecure: Optional[bool] = True, - timeout_in_seconds: Optional[int] = 600, - sync_interval_in_seconds: Optional[int] = 600, + insecure: bool = True, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, access_key: Optional[str] = None, local_auth_ref: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword url: The URL to sync for the flux configuration S3 bucket. :paramtype url: str @@ -70,17 +78,17 @@ def __init__( :paramtype insecure: bool :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository source with the remote. - :paramtype timeout_in_seconds: long + :paramtype timeout_in_seconds: int :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster git repository source with the remote. - :paramtype sync_interval_in_seconds: long + :paramtype sync_interval_in_seconds: int :keyword access_key: Plaintext access key used to securely access the S3 bucket. :paramtype access_key: str :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the authentication secret rather than the managed or user-provided configuration secrets. :paramtype local_auth_ref: str """ - super(BucketDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url self.bucket_name = bucket_name self.insecure = insecure @@ -90,7 +98,7 @@ def __init__( self.local_auth_ref = local_auth_ref -class BucketPatchDefinition(msrest.serialization.Model): +class BucketPatchDefinition(_serialization.Model): """Parameters to reconcile to the GitRepository source kind type. :ivar url: The URL to sync for the flux configuration S3 bucket. @@ -102,10 +110,10 @@ class BucketPatchDefinition(msrest.serialization.Model): :vartype insecure: bool :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository source with the remote. - :vartype timeout_in_seconds: long + :vartype timeout_in_seconds: int :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster git repository source with the remote. - :vartype sync_interval_in_seconds: long + :vartype sync_interval_in_seconds: int :ivar access_key: Plaintext access key used to securely access the S3 bucket. :vartype access_key: str :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the @@ -114,13 +122,13 @@ class BucketPatchDefinition(msrest.serialization.Model): """ _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, - 'bucket_name': {'key': 'bucketName', 'type': 'str'}, - 'insecure': {'key': 'insecure', 'type': 'bool'}, - 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, - 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, - 'access_key': {'key': 'accessKey', 'type': 'str'}, - 'local_auth_ref': {'key': 'localAuthRef', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, + "bucket_name": {"key": "bucketName", "type": "str"}, + "insecure": {"key": "insecure", "type": "bool"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "access_key": {"key": "accessKey", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, } def __init__( @@ -133,8 +141,8 @@ def __init__( sync_interval_in_seconds: Optional[int] = None, access_key: Optional[str] = None, local_auth_ref: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword url: The URL to sync for the flux configuration S3 bucket. :paramtype url: str @@ -145,17 +153,17 @@ def __init__( :paramtype insecure: bool :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository source with the remote. - :paramtype timeout_in_seconds: long + :paramtype timeout_in_seconds: int :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster git repository source with the remote. - :paramtype sync_interval_in_seconds: long + :paramtype sync_interval_in_seconds: int :keyword access_key: Plaintext access key used to securely access the S3 bucket. :paramtype access_key: str :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the authentication secret rather than the managed or user-provided configuration secrets. :paramtype local_auth_ref: str """ - super(BucketPatchDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url self.bucket_name = bucket_name self.insecure = insecure @@ -165,34 +173,34 @@ def __init__( self.local_auth_ref = local_auth_ref -class ComplianceStatus(msrest.serialization.Model): +class ComplianceStatus(_serialization.Model): """Compliance Status details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar compliance_state: The compliance state of the configuration. Possible values include: - "Pending", "Compliant", "Noncompliant", "Installed", "Failed". + :ivar compliance_state: The compliance state of the configuration. Known values are: "Pending", + "Compliant", "Noncompliant", "Installed", and "Failed". :vartype compliance_state: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ComplianceStateType :ivar last_config_applied: Datetime the configuration was last applied. :vartype last_config_applied: ~datetime.datetime :ivar message: Message from when the configuration was applied. :vartype message: str - :ivar message_level: Level of the message. Possible values include: "Error", "Warning", + :ivar message_level: Level of the message. Known values are: "Error", "Warning", and "Information". :vartype message_level: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.MessageLevelType """ _validation = { - 'compliance_state': {'readonly': True}, + "compliance_state": {"readonly": True}, } _attribute_map = { - 'compliance_state': {'key': 'complianceState', 'type': 'str'}, - 'last_config_applied': {'key': 'lastConfigApplied', 'type': 'iso-8601'}, - 'message': {'key': 'message', 'type': 'str'}, - 'message_level': {'key': 'messageLevel', 'type': 'str'}, + "compliance_state": {"key": "complianceState", "type": "str"}, + "last_config_applied": {"key": "lastConfigApplied", "type": "iso-8601"}, + "message": {"key": "message", "type": "str"}, + "message_level": {"key": "messageLevel", "type": "str"}, } def __init__( @@ -200,27 +208,27 @@ def __init__( *, last_config_applied: Optional[datetime.datetime] = None, message: Optional[str] = None, - message_level: Optional[Union[str, "MessageLevelType"]] = None, - **kwargs - ): + message_level: Optional[Union[str, "_models.MessageLevelType"]] = None, + **kwargs: Any + ) -> None: """ :keyword last_config_applied: Datetime the configuration was last applied. :paramtype last_config_applied: ~datetime.datetime :keyword message: Message from when the configuration was applied. :paramtype message: str - :keyword message_level: Level of the message. Possible values include: "Error", "Warning", + :keyword message_level: Level of the message. Known values are: "Error", "Warning", and "Information". :paramtype message_level: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.MessageLevelType """ - super(ComplianceStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.compliance_state = None self.last_config_applied = last_config_applied self.message = message self.message_level = message_level -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -228,31 +236,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -271,28 +275,24 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -300,32 +300,28 @@ def __init__( self.additional_info = None -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ErrorDetail """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ErrorDetail """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -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. @@ -341,31 +337,28 @@ 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: Any) -> None: + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + """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. @@ -380,27 +373,23 @@ class ProxyResource(Resource): """ _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(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) -class Extension(ProxyResource): +class Extension(ProxyResource): # pylint: disable=too-many-instance-attributes """The Extension object. Variables are only populated by the server, and will be ignored when sending a request. @@ -441,8 +430,8 @@ class Extension(ProxyResource): :vartype configuration_protected_settings: dict[str, str] :ivar installed_version: Installed version of the extension. :vartype installed_version: str - :ivar provisioning_state: Status of installation of this extension. Possible values include: - "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting". + :ivar provisioning_state: Status of installation of this extension. Known values are: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ProvisioningState :ivar statuses: Status from this extension. @@ -459,54 +448,57 @@ class Extension(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'installed_version': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'error_info': {'readonly': True}, - 'custom_location_settings': {'readonly': True}, - 'package_uri': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "installed_version": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "error_info": {"readonly": True}, + "custom_location_settings": {"readonly": True}, + "package_uri": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, - 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, - 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'Scope'}, - 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, - 'installed_version': {'key': 'properties.installedVersion', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'statuses': {'key': 'properties.statuses', 'type': '[ExtensionStatus]'}, - 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDetail'}, - 'custom_location_settings': {'key': 'properties.customLocationSettings', 'type': '{str}'}, - 'package_uri': {'key': 'properties.packageUri', 'type': 'str'}, - 'aks_assigned_identity': {'key': 'properties.aksAssignedIdentity', 'type': 'ExtensionPropertiesAksAssignedIdentity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "extension_type": {"key": "properties.extensionType", "type": "str"}, + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "scope": {"key": "properties.scope", "type": "Scope"}, + "configuration_settings": {"key": "properties.configurationSettings", "type": "{str}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "installed_version": {"key": "properties.installedVersion", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "statuses": {"key": "properties.statuses", "type": "[ExtensionStatus]"}, + "error_info": {"key": "properties.errorInfo", "type": "ErrorDetail"}, + "custom_location_settings": {"key": "properties.customLocationSettings", "type": "{str}"}, + "package_uri": {"key": "properties.packageUri", "type": "str"}, + "aks_assigned_identity": { + "key": "properties.aksAssignedIdentity", + "type": "ExtensionPropertiesAksAssignedIdentity", + }, } def __init__( self, *, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, extension_type: Optional[str] = None, - auto_upgrade_minor_version: Optional[bool] = True, - release_train: Optional[str] = "Stable", + auto_upgrade_minor_version: bool = True, + release_train: str = "Stable", version: Optional[str] = None, - scope: Optional["Scope"] = None, + scope: Optional["_models.Scope"] = None, configuration_settings: Optional[Dict[str, str]] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - statuses: Optional[List["ExtensionStatus"]] = None, - aks_assigned_identity: Optional["ExtensionPropertiesAksAssignedIdentity"] = None, - **kwargs - ): + statuses: Optional[List["_models.ExtensionStatus"]] = None, + aks_assigned_identity: Optional["_models.ExtensionPropertiesAksAssignedIdentity"] = None, + **kwargs: Any + ) -> None: """ :keyword identity: Identity of the Extension resource. :paramtype identity: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Identity @@ -538,7 +530,7 @@ def __init__( :paramtype aks_assigned_identity: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ExtensionPropertiesAksAssignedIdentity """ - super(Extension, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.system_data = None self.extension_type = extension_type @@ -557,7 +549,7 @@ def __init__( self.aks_assigned_identity = aks_assigned_identity -class ExtensionPropertiesAksAssignedIdentity(msrest.serialization.Model): +class ExtensionPropertiesAksAssignedIdentity(_serialization.Model): """Identity of the Extension resource in an AKS cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -566,39 +558,35 @@ class ExtensionPropertiesAksAssignedIdentity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned". + :ivar type: The identity type. Known values are: "SystemAssigned" and "UserAssigned". :vartype type: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.AKSIdentityType """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[Union[str, "AKSIdentityType"]] = None, - **kwargs - ): + def __init__(self, *, type: Optional[Union[str, "_models.AKSIdentityType"]] = None, **kwargs: Any) -> None: """ - :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned". + :keyword type: The identity type. Known values are: "SystemAssigned" and "UserAssigned". :paramtype type: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.AKSIdentityType """ - super(ExtensionPropertiesAksAssignedIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class ExtensionsList(msrest.serialization.Model): - """Result of the request to list Extensions. It contains a list of Extension objects and a URL link to get the next set of results. +class ExtensionsList(_serialization.Model): + """Result of the request to list Extensions. It contains a list of Extension objects and a URL + link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -609,35 +597,30 @@ class ExtensionsList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Extension]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Extension]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ExtensionsList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ExtensionStatus(msrest.serialization.Model): +class ExtensionStatus(_serialization.Model): """Status from the extension. :ivar code: Status code provided by the Extension. :vartype code: str :ivar display_status: Short description of status of the extension. :vartype display_status: str - :ivar level: Level of the status. Possible values include: "Error", "Warning", "Information". - Default value: "Information". + :ivar level: Level of the status. Known values are: "Error", "Warning", and "Information". :vartype level: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.LevelType :ivar message: Detailed message of the status from the Extension. :vartype message: str @@ -646,11 +629,11 @@ class ExtensionStatus(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'level': {'key': 'level', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'time': {'key': 'time', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "display_status": {"key": "displayStatus", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "time": {"key": "time", "type": "str"}, } def __init__( @@ -658,25 +641,24 @@ def __init__( *, code: Optional[str] = None, display_status: Optional[str] = None, - level: Optional[Union[str, "LevelType"]] = "Information", + level: Union[str, "_models.LevelType"] = "Information", message: Optional[str] = None, time: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword code: Status code provided by the Extension. :paramtype code: str :keyword display_status: Short description of status of the extension. :paramtype display_status: str - :keyword level: Level of the status. Possible values include: "Error", "Warning", - "Information". Default value: "Information". + :keyword level: Level of the status. Known values are: "Error", "Warning", and "Information". :paramtype level: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.LevelType :keyword message: Detailed message of the status from the Extension. :paramtype message: str :keyword time: DateLiteral (per ISO8601) noting the time of installation status. :paramtype time: str """ - super(ExtensionStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.display_status = display_status self.level = level @@ -684,7 +666,7 @@ def __init__( self.time = time -class FluxConfiguration(ProxyResource): +class FluxConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes """The Flux Configuration object returned in Get & Put response. Variables are only populated by the server, and will be ignored when sending a request. @@ -700,14 +682,14 @@ class FluxConfiguration(ProxyResource): :ivar system_data: Top level metadata https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SystemData - :ivar scope: Scope at which the operator will be installed. Possible values include: "cluster", - "namespace". Default value: "cluster". + :ivar scope: Scope at which the operator will be installed. Known values are: "cluster" and + "namespace". :vartype scope: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ScopeType :ivar namespace: The namespace to which this configuration is installed to. Maximum of 253 lower case alphanumeric characters, hyphen and period only. :vartype namespace: str - :ivar source_kind: Source Kind to pull the configuration data from. Possible values include: - "GitRepository", "Bucket". + :ivar source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository" and "Bucket". :vartype source_kind: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceKindType :ivar suspend: Whether this configuration should suspend its reconciliation of its @@ -740,12 +722,12 @@ class FluxConfiguration(ProxyResource): Azure. :vartype status_updated_at: ~datetime.datetime :ivar compliance_state: Combined status of the Flux Kubernetes resources created by the - fluxConfiguration or created by the managed objects. Possible values include: "Compliant", - "Non-Compliant", "Pending", "Suspended", "Unknown". Default value: "Unknown". + fluxConfiguration or created by the managed objects. Known values are: "Compliant", + "Non-Compliant", "Pending", "Suspended", and "Unknown". :vartype compliance_state: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxComplianceState - :ivar provisioning_state: Status of the creation of the fluxConfiguration. Possible values - include: "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting". + :ivar provisioning_state: Status of the creation of the fluxConfiguration. Known values are: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ProvisioningState :ivar error_message: Error message returned to the user in the case of provisioning failure. @@ -753,65 +735,65 @@ class FluxConfiguration(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'statuses': {'readonly': True}, - 'repository_public_key': {'readonly': True}, - 'source_synced_commit_id': {'readonly': True}, - 'source_updated_at': {'readonly': True}, - 'status_updated_at': {'readonly': True}, - 'compliance_state': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'error_message': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "statuses": {"readonly": True}, + "repository_public_key": {"readonly": True}, + "source_synced_commit_id": {"readonly": True}, + "source_updated_at": {"readonly": True}, + "status_updated_at": {"readonly": True}, + "compliance_state": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "error_message": {"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'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'namespace': {'key': 'properties.namespace', 'type': 'str'}, - 'source_kind': {'key': 'properties.sourceKind', 'type': 'str'}, - 'suspend': {'key': 'properties.suspend', 'type': 'bool'}, - 'git_repository': {'key': 'properties.gitRepository', 'type': 'GitRepositoryDefinition'}, - 'bucket': {'key': 'properties.bucket', 'type': 'BucketDefinition'}, - 'kustomizations': {'key': 'properties.kustomizations', 'type': '{KustomizationDefinition}'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, - 'statuses': {'key': 'properties.statuses', 'type': '[ObjectStatusDefinition]'}, - 'repository_public_key': {'key': 'properties.repositoryPublicKey', 'type': 'str'}, - 'source_synced_commit_id': {'key': 'properties.sourceSyncedCommitId', 'type': 'str'}, - 'source_updated_at': {'key': 'properties.sourceUpdatedAt', 'type': 'iso-8601'}, - 'status_updated_at': {'key': 'properties.statusUpdatedAt', 'type': 'iso-8601'}, - 'compliance_state': {'key': 'properties.complianceState', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'error_message': {'key': 'properties.errorMessage', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "scope": {"key": "properties.scope", "type": "str"}, + "namespace": {"key": "properties.namespace", "type": "str"}, + "source_kind": {"key": "properties.sourceKind", "type": "str"}, + "suspend": {"key": "properties.suspend", "type": "bool"}, + "git_repository": {"key": "properties.gitRepository", "type": "GitRepositoryDefinition"}, + "bucket": {"key": "properties.bucket", "type": "BucketDefinition"}, + "kustomizations": {"key": "properties.kustomizations", "type": "{KustomizationDefinition}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "statuses": {"key": "properties.statuses", "type": "[ObjectStatusDefinition]"}, + "repository_public_key": {"key": "properties.repositoryPublicKey", "type": "str"}, + "source_synced_commit_id": {"key": "properties.sourceSyncedCommitId", "type": "str"}, + "source_updated_at": {"key": "properties.sourceUpdatedAt", "type": "iso-8601"}, + "status_updated_at": {"key": "properties.statusUpdatedAt", "type": "iso-8601"}, + "compliance_state": {"key": "properties.complianceState", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "error_message": {"key": "properties.errorMessage", "type": "str"}, } def __init__( self, *, - scope: Optional[Union[str, "ScopeType"]] = "cluster", - namespace: Optional[str] = "default", - source_kind: Optional[Union[str, "SourceKindType"]] = None, - suspend: Optional[bool] = False, - git_repository: Optional["GitRepositoryDefinition"] = None, - bucket: Optional["BucketDefinition"] = None, - kustomizations: Optional[Dict[str, "KustomizationDefinition"]] = None, + scope: Union[str, "_models.ScopeType"] = "cluster", + namespace: str = "default", + source_kind: Optional[Union[str, "_models.SourceKindType"]] = None, + suspend: bool = False, + git_repository: Optional["_models.GitRepositoryDefinition"] = None, + bucket: Optional["_models.BucketDefinition"] = None, + kustomizations: Optional[Dict[str, "_models.KustomizationDefinition"]] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword scope: Scope at which the operator will be installed. Possible values include: - "cluster", "namespace". Default value: "cluster". + :keyword scope: Scope at which the operator will be installed. Known values are: "cluster" and + "namespace". :paramtype scope: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ScopeType :keyword namespace: The namespace to which this configuration is installed to. Maximum of 253 lower case alphanumeric characters, hyphen and period only. :paramtype namespace: str - :keyword source_kind: Source Kind to pull the configuration data from. Possible values include: - "GitRepository", "Bucket". + :keyword source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository" and "Bucket". :paramtype source_kind: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceKindType :keyword suspend: Whether this configuration should suspend its reconciliation of its @@ -830,7 +812,7 @@ def __init__( for the configuration. :paramtype configuration_protected_settings: dict[str, str] """ - super(FluxConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.scope = scope self.namespace = namespace @@ -850,11 +832,11 @@ def __init__( self.error_message = None -class FluxConfigurationPatch(msrest.serialization.Model): +class FluxConfigurationPatch(_serialization.Model): """The Flux Configuration Patch Request object. - :ivar source_kind: Source Kind to pull the configuration data from. Possible values include: - "GitRepository", "Bucket". + :ivar source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository" and "Bucket". :vartype source_kind: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceKindType :ivar suspend: Whether this configuration should suspend its reconciliation of its @@ -875,28 +857,28 @@ class FluxConfigurationPatch(msrest.serialization.Model): """ _attribute_map = { - 'source_kind': {'key': 'properties.sourceKind', 'type': 'str'}, - 'suspend': {'key': 'properties.suspend', 'type': 'bool'}, - 'git_repository': {'key': 'properties.gitRepository', 'type': 'GitRepositoryPatchDefinition'}, - 'bucket': {'key': 'properties.bucket', 'type': 'BucketPatchDefinition'}, - 'kustomizations': {'key': 'properties.kustomizations', 'type': '{KustomizationPatchDefinition}'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + "source_kind": {"key": "properties.sourceKind", "type": "str"}, + "suspend": {"key": "properties.suspend", "type": "bool"}, + "git_repository": {"key": "properties.gitRepository", "type": "GitRepositoryPatchDefinition"}, + "bucket": {"key": "properties.bucket", "type": "BucketPatchDefinition"}, + "kustomizations": {"key": "properties.kustomizations", "type": "{KustomizationPatchDefinition}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, } def __init__( self, *, - source_kind: Optional[Union[str, "SourceKindType"]] = None, + source_kind: Optional[Union[str, "_models.SourceKindType"]] = None, suspend: Optional[bool] = None, - git_repository: Optional["GitRepositoryPatchDefinition"] = None, - bucket: Optional["BucketPatchDefinition"] = None, - kustomizations: Optional[Dict[str, "KustomizationPatchDefinition"]] = None, + git_repository: Optional["_models.GitRepositoryPatchDefinition"] = None, + bucket: Optional["_models.BucketPatchDefinition"] = None, + kustomizations: Optional[Dict[str, "_models.KustomizationPatchDefinition"]] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword source_kind: Source Kind to pull the configuration data from. Possible values include: - "GitRepository", "Bucket". + :keyword source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository" and "Bucket". :paramtype source_kind: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceKindType :keyword suspend: Whether this configuration should suspend its reconciliation of its @@ -915,7 +897,7 @@ def __init__( for the configuration. :paramtype configuration_protected_settings: dict[str, str] """ - super(FluxConfigurationPatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_kind = source_kind self.suspend = suspend self.git_repository = git_repository @@ -924,8 +906,9 @@ def __init__( self.configuration_protected_settings = configuration_protected_settings -class FluxConfigurationsList(msrest.serialization.Model): - """Result of the request to list Flux Configurations. It contains a list of FluxConfiguration objects and a URL link to get the next set of results. +class FluxConfigurationsList(_serialization.Model): + """Result of the request to list Flux Configurations. It contains a list of FluxConfiguration + objects and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -936,37 +919,33 @@ class FluxConfigurationsList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FluxConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[FluxConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FluxConfigurationsList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class GitRepositoryDefinition(msrest.serialization.Model): +class GitRepositoryDefinition(_serialization.Model): """Parameters to reconcile to the GitRepository source kind type. :ivar url: The URL to sync for the flux configuration git repository. :vartype url: str :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository source with the remote. - :vartype timeout_in_seconds: long + :vartype timeout_in_seconds: int :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster git repository source with the remote. - :vartype sync_interval_in_seconds: long + :vartype sync_interval_in_seconds: int :ivar repository_ref: The source reference for the GitRepository object. :vartype repository_ref: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.RepositoryRefDefinition @@ -984,38 +963,38 @@ class GitRepositoryDefinition(msrest.serialization.Model): """ _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, - 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, - 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, - 'repository_ref': {'key': 'repositoryRef', 'type': 'RepositoryRefDefinition'}, - 'ssh_known_hosts': {'key': 'sshKnownHosts', 'type': 'str'}, - 'https_user': {'key': 'httpsUser', 'type': 'str'}, - 'https_ca_cert': {'key': 'httpsCACert', 'type': 'str'}, - 'local_auth_ref': {'key': 'localAuthRef', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "repository_ref": {"key": "repositoryRef", "type": "RepositoryRefDefinition"}, + "ssh_known_hosts": {"key": "sshKnownHosts", "type": "str"}, + "https_user": {"key": "httpsUser", "type": "str"}, + "https_ca_cert": {"key": "httpsCACert", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, } def __init__( self, *, url: Optional[str] = None, - timeout_in_seconds: Optional[int] = 600, - sync_interval_in_seconds: Optional[int] = 600, - repository_ref: Optional["RepositoryRefDefinition"] = None, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, + repository_ref: Optional["_models.RepositoryRefDefinition"] = None, ssh_known_hosts: Optional[str] = None, https_user: Optional[str] = None, https_ca_cert: Optional[str] = None, local_auth_ref: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword url: The URL to sync for the flux configuration git repository. :paramtype url: str :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository source with the remote. - :paramtype timeout_in_seconds: long + :paramtype timeout_in_seconds: int :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster git repository source with the remote. - :paramtype sync_interval_in_seconds: long + :paramtype sync_interval_in_seconds: int :keyword repository_ref: The source reference for the GitRepository object. :paramtype repository_ref: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.RepositoryRefDefinition @@ -1032,7 +1011,7 @@ def __init__( authentication secret rather than the managed or user-provided configuration secrets. :paramtype local_auth_ref: str """ - super(GitRepositoryDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url self.timeout_in_seconds = timeout_in_seconds self.sync_interval_in_seconds = sync_interval_in_seconds @@ -1043,17 +1022,17 @@ def __init__( self.local_auth_ref = local_auth_ref -class GitRepositoryPatchDefinition(msrest.serialization.Model): +class GitRepositoryPatchDefinition(_serialization.Model): """Parameters to reconcile to the GitRepository source kind type. :ivar url: The URL to sync for the flux configuration git repository. :vartype url: str :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository source with the remote. - :vartype timeout_in_seconds: long + :vartype timeout_in_seconds: int :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster git repository source with the remote. - :vartype sync_interval_in_seconds: long + :vartype sync_interval_in_seconds: int :ivar repository_ref: The source reference for the GitRepository object. :vartype repository_ref: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.RepositoryRefDefinition @@ -1071,14 +1050,14 @@ class GitRepositoryPatchDefinition(msrest.serialization.Model): """ _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, - 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, - 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, - 'repository_ref': {'key': 'repositoryRef', 'type': 'RepositoryRefDefinition'}, - 'ssh_known_hosts': {'key': 'sshKnownHosts', 'type': 'str'}, - 'https_user': {'key': 'httpsUser', 'type': 'str'}, - 'https_ca_cert': {'key': 'httpsCACert', 'type': 'str'}, - 'local_auth_ref': {'key': 'localAuthRef', 'type': 'str'}, + "url": {"key": "url", "type": "str"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "repository_ref": {"key": "repositoryRef", "type": "RepositoryRefDefinition"}, + "ssh_known_hosts": {"key": "sshKnownHosts", "type": "str"}, + "https_user": {"key": "httpsUser", "type": "str"}, + "https_ca_cert": {"key": "httpsCACert", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, } def __init__( @@ -1087,22 +1066,22 @@ def __init__( url: Optional[str] = None, timeout_in_seconds: Optional[int] = None, sync_interval_in_seconds: Optional[int] = None, - repository_ref: Optional["RepositoryRefDefinition"] = None, + repository_ref: Optional["_models.RepositoryRefDefinition"] = None, ssh_known_hosts: Optional[str] = None, https_user: Optional[str] = None, https_ca_cert: Optional[str] = None, local_auth_ref: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword url: The URL to sync for the flux configuration git repository. :paramtype url: str :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository source with the remote. - :paramtype timeout_in_seconds: long + :paramtype timeout_in_seconds: int :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster git repository source with the remote. - :paramtype sync_interval_in_seconds: long + :paramtype sync_interval_in_seconds: int :keyword repository_ref: The source reference for the GitRepository object. :paramtype repository_ref: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.RepositoryRefDefinition @@ -1119,7 +1098,7 @@ def __init__( authentication secret rather than the managed or user-provided configuration secrets. :paramtype local_auth_ref: str """ - super(GitRepositoryPatchDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.url = url self.timeout_in_seconds = timeout_in_seconds self.sync_interval_in_seconds = sync_interval_in_seconds @@ -1130,7 +1109,7 @@ def __init__( self.local_auth_ref = local_auth_ref -class HelmOperatorProperties(msrest.serialization.Model): +class HelmOperatorProperties(_serialization.Model): """Properties for Helm operator. :ivar chart_version: Version of the operator Helm chart. @@ -1140,79 +1119,75 @@ class HelmOperatorProperties(msrest.serialization.Model): """ _attribute_map = { - 'chart_version': {'key': 'chartVersion', 'type': 'str'}, - 'chart_values': {'key': 'chartValues', 'type': 'str'}, + "chart_version": {"key": "chartVersion", "type": "str"}, + "chart_values": {"key": "chartValues", "type": "str"}, } def __init__( - self, - *, - chart_version: Optional[str] = None, - chart_values: Optional[str] = None, - **kwargs - ): + self, *, chart_version: Optional[str] = None, chart_values: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword chart_version: Version of the operator Helm chart. :paramtype chart_version: str :keyword chart_values: Values override for the operator Helm chart. :paramtype chart_values: str """ - super(HelmOperatorProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.chart_version = chart_version self.chart_values = chart_values -class HelmReleasePropertiesDefinition(msrest.serialization.Model): +class HelmReleasePropertiesDefinition(_serialization.Model): """Properties for HelmRelease objects. :ivar last_revision_applied: The revision number of the last released object change. - :vartype last_revision_applied: long + :vartype last_revision_applied: int :ivar helm_chart_ref: The reference to the HelmChart object used as the source to this HelmRelease. :vartype helm_chart_ref: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ObjectReferenceDefinition :ivar failure_count: Total number of times that the HelmRelease failed to install or upgrade. - :vartype failure_count: long + :vartype failure_count: int :ivar install_failure_count: Number of times that the HelmRelease failed to install. - :vartype install_failure_count: long + :vartype install_failure_count: int :ivar upgrade_failure_count: Number of times that the HelmRelease failed to upgrade. - :vartype upgrade_failure_count: long + :vartype upgrade_failure_count: int """ _attribute_map = { - 'last_revision_applied': {'key': 'lastRevisionApplied', 'type': 'long'}, - 'helm_chart_ref': {'key': 'helmChartRef', 'type': 'ObjectReferenceDefinition'}, - 'failure_count': {'key': 'failureCount', 'type': 'long'}, - 'install_failure_count': {'key': 'installFailureCount', 'type': 'long'}, - 'upgrade_failure_count': {'key': 'upgradeFailureCount', 'type': 'long'}, + "last_revision_applied": {"key": "lastRevisionApplied", "type": "int"}, + "helm_chart_ref": {"key": "helmChartRef", "type": "ObjectReferenceDefinition"}, + "failure_count": {"key": "failureCount", "type": "int"}, + "install_failure_count": {"key": "installFailureCount", "type": "int"}, + "upgrade_failure_count": {"key": "upgradeFailureCount", "type": "int"}, } def __init__( self, *, last_revision_applied: Optional[int] = None, - helm_chart_ref: Optional["ObjectReferenceDefinition"] = None, + helm_chart_ref: Optional["_models.ObjectReferenceDefinition"] = None, failure_count: Optional[int] = None, install_failure_count: Optional[int] = None, upgrade_failure_count: Optional[int] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword last_revision_applied: The revision number of the last released object change. - :paramtype last_revision_applied: long + :paramtype last_revision_applied: int :keyword helm_chart_ref: The reference to the HelmChart object used as the source to this HelmRelease. :paramtype helm_chart_ref: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ObjectReferenceDefinition :keyword failure_count: Total number of times that the HelmRelease failed to install or upgrade. - :paramtype failure_count: long + :paramtype failure_count: int :keyword install_failure_count: Number of times that the HelmRelease failed to install. - :paramtype install_failure_count: long + :paramtype install_failure_count: int :keyword upgrade_failure_count: Number of times that the HelmRelease failed to upgrade. - :paramtype upgrade_failure_count: long + :paramtype upgrade_failure_count: int """ - super(HelmReleasePropertiesDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_revision_applied = last_revision_applied self.helm_chart_ref = helm_chart_ref self.failure_count = failure_count @@ -1220,7 +1195,7 @@ def __init__( self.upgrade_failure_count = upgrade_failure_count -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1229,41 +1204,35 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :ivar type: The identity type. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: """ - :keyword type: The identity type. The only acceptable values to pass in are None and - "SystemAssigned". The default value is None. + :keyword type: The identity type. Default value is "SystemAssigned". :paramtype type: str """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class KustomizationDefinition(msrest.serialization.Model): - """The Kustomization defining how to reconcile the artifact pulled by the source type on the cluster. +class KustomizationDefinition(_serialization.Model): + """The Kustomization defining how to reconcile the artifact pulled by the source type on the + cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -1276,13 +1245,13 @@ class KustomizationDefinition(msrest.serialization.Model): :vartype depends_on: list[str] :ivar timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the cluster. - :vartype timeout_in_seconds: long + :vartype timeout_in_seconds: int :ivar sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster. - :vartype sync_interval_in_seconds: long + :vartype sync_interval_in_seconds: int :ivar retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster in the event of failure on reconciliation. - :vartype retry_interval_in_seconds: long + :vartype retry_interval_in_seconds: int :ivar prune: Enable/disable garbage collections of Kubernetes objects created by this Kustomization. :vartype prune: bool @@ -1292,32 +1261,32 @@ class KustomizationDefinition(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'path': {'key': 'path', 'type': 'str'}, - 'depends_on': {'key': 'dependsOn', 'type': '[str]'}, - 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, - 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, - 'retry_interval_in_seconds': {'key': 'retryIntervalInSeconds', 'type': 'long'}, - 'prune': {'key': 'prune', 'type': 'bool'}, - 'force': {'key': 'force', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "path": {"key": "path", "type": "str"}, + "depends_on": {"key": "dependsOn", "type": "[str]"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "retry_interval_in_seconds": {"key": "retryIntervalInSeconds", "type": "int"}, + "prune": {"key": "prune", "type": "bool"}, + "force": {"key": "force", "type": "bool"}, } def __init__( self, *, - path: Optional[str] = "", + path: str = "", depends_on: Optional[List[str]] = None, - timeout_in_seconds: Optional[int] = 600, - sync_interval_in_seconds: Optional[int] = 600, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, retry_interval_in_seconds: Optional[int] = None, - prune: Optional[bool] = False, - force: Optional[bool] = False, - **kwargs - ): + prune: bool = False, + force: bool = False, + **kwargs: Any + ) -> None: """ :keyword path: The path in the source reference to reconcile on the cluster. :paramtype path: str @@ -1326,13 +1295,13 @@ def __init__( :paramtype depends_on: list[str] :keyword timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the cluster. - :paramtype timeout_in_seconds: long + :paramtype timeout_in_seconds: int :keyword sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster. - :paramtype sync_interval_in_seconds: long + :paramtype sync_interval_in_seconds: int :keyword retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster in the event of failure on reconciliation. - :paramtype retry_interval_in_seconds: long + :paramtype retry_interval_in_seconds: int :keyword prune: Enable/disable garbage collections of Kubernetes objects created by this Kustomization. :paramtype prune: bool @@ -1340,7 +1309,7 @@ def __init__( fails due to an immutable field change. :paramtype force: bool """ - super(KustomizationDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.path = path self.depends_on = depends_on @@ -1351,8 +1320,9 @@ def __init__( self.force = force -class KustomizationPatchDefinition(msrest.serialization.Model): - """The Kustomization defining how to reconcile the artifact pulled by the source type on the cluster. +class KustomizationPatchDefinition(_serialization.Model): + """The Kustomization defining how to reconcile the artifact pulled by the source type on the + cluster. :ivar path: The path in the source reference to reconcile on the cluster. :vartype path: str @@ -1361,13 +1331,13 @@ class KustomizationPatchDefinition(msrest.serialization.Model): :vartype depends_on: list[str] :ivar timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the cluster. - :vartype timeout_in_seconds: long + :vartype timeout_in_seconds: int :ivar sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster. - :vartype sync_interval_in_seconds: long + :vartype sync_interval_in_seconds: int :ivar retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster in the event of failure on reconciliation. - :vartype retry_interval_in_seconds: long + :vartype retry_interval_in_seconds: int :ivar prune: Enable/disable garbage collections of Kubernetes objects created by this Kustomization. :vartype prune: bool @@ -1377,13 +1347,13 @@ class KustomizationPatchDefinition(msrest.serialization.Model): """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'depends_on': {'key': 'dependsOn', 'type': '[str]'}, - 'timeout_in_seconds': {'key': 'timeoutInSeconds', 'type': 'long'}, - 'sync_interval_in_seconds': {'key': 'syncIntervalInSeconds', 'type': 'long'}, - 'retry_interval_in_seconds': {'key': 'retryIntervalInSeconds', 'type': 'long'}, - 'prune': {'key': 'prune', 'type': 'bool'}, - 'force': {'key': 'force', 'type': 'bool'}, + "path": {"key": "path", "type": "str"}, + "depends_on": {"key": "dependsOn", "type": "[str]"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "retry_interval_in_seconds": {"key": "retryIntervalInSeconds", "type": "int"}, + "prune": {"key": "prune", "type": "bool"}, + "force": {"key": "force", "type": "bool"}, } def __init__( @@ -1396,8 +1366,8 @@ def __init__( retry_interval_in_seconds: Optional[int] = None, prune: Optional[bool] = None, force: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword path: The path in the source reference to reconcile on the cluster. :paramtype path: str @@ -1406,13 +1376,13 @@ def __init__( :paramtype depends_on: list[str] :keyword timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the cluster. - :paramtype timeout_in_seconds: long + :paramtype timeout_in_seconds: int :keyword sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster. - :paramtype sync_interval_in_seconds: long + :paramtype sync_interval_in_seconds: int :keyword retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the cluster in the event of failure on reconciliation. - :paramtype retry_interval_in_seconds: long + :paramtype retry_interval_in_seconds: int :keyword prune: Enable/disable garbage collections of Kubernetes objects created by this Kustomization. :paramtype prune: bool @@ -1420,7 +1390,7 @@ def __init__( fails due to an immutable field change. :paramtype force: bool """ - super(KustomizationPatchDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.depends_on = depends_on self.timeout_in_seconds = timeout_in_seconds @@ -1430,7 +1400,7 @@ def __init__( self.force = force -class ObjectReferenceDefinition(msrest.serialization.Model): +class ObjectReferenceDefinition(_serialization.Model): """Object reference to a Kubernetes object on a cluster. :ivar name: Name of the object. @@ -1440,29 +1410,23 @@ class ObjectReferenceDefinition(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, namespace: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: Name of the object. :paramtype name: str :keyword namespace: Namespace of the object. :paramtype namespace: str """ - super(ObjectReferenceDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.namespace = namespace -class ObjectStatusConditionDefinition(msrest.serialization.Model): +class ObjectStatusConditionDefinition(_serialization.Model): """Status condition of Kubernetes object. :ivar last_transition_time: Last time this status condition has changed. @@ -1478,11 +1442,11 @@ class ObjectStatusConditionDefinition(msrest.serialization.Model): """ _attribute_map = { - 'last_transition_time': {'key': 'lastTransitionTime', 'type': 'iso-8601'}, - 'message': {'key': 'message', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "last_transition_time": {"key": "lastTransitionTime", "type": "iso-8601"}, + "message": {"key": "message", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -1493,8 +1457,8 @@ def __init__( reason: Optional[str] = None, status: Optional[str] = None, type: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword last_transition_time: Last time this status condition has changed. :paramtype last_transition_time: ~datetime.datetime @@ -1507,7 +1471,7 @@ def __init__( :keyword type: Object status condition type for this object. :paramtype type: str """ - super(ObjectStatusConditionDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_transition_time = last_transition_time self.message = message self.reason = reason @@ -1515,7 +1479,7 @@ def __init__( self.type = type -class ObjectStatusDefinition(msrest.serialization.Model): +class ObjectStatusDefinition(_serialization.Model): """Statuses of objects deployed by the user-specified kustomizations from the git repository. :ivar name: Name of the applied object. @@ -1525,8 +1489,8 @@ class ObjectStatusDefinition(msrest.serialization.Model): :ivar kind: Kind of the applied object. :vartype kind: str :ivar compliance_state: Compliance state of the applied object showing whether the applied - object has come into a ready state on the cluster. Possible values include: "Compliant", - "Non-Compliant", "Pending", "Suspended", "Unknown". Default value: "Unknown". + object has come into a ready state on the cluster. Known values are: "Compliant", + "Non-Compliant", "Pending", "Suspended", and "Unknown". :vartype compliance_state: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxComplianceState :ivar applied_by: Object reference to the Kustomization that applied this object. @@ -1542,13 +1506,13 @@ class ObjectStatusDefinition(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'compliance_state': {'key': 'complianceState', 'type': 'str'}, - 'applied_by': {'key': 'appliedBy', 'type': 'ObjectReferenceDefinition'}, - 'status_conditions': {'key': 'statusConditions', 'type': '[ObjectStatusConditionDefinition]'}, - 'helm_release_properties': {'key': 'helmReleaseProperties', 'type': 'HelmReleasePropertiesDefinition'}, + "name": {"key": "name", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "compliance_state": {"key": "complianceState", "type": "str"}, + "applied_by": {"key": "appliedBy", "type": "ObjectReferenceDefinition"}, + "status_conditions": {"key": "statusConditions", "type": "[ObjectStatusConditionDefinition]"}, + "helm_release_properties": {"key": "helmReleaseProperties", "type": "HelmReleasePropertiesDefinition"}, } def __init__( @@ -1557,12 +1521,12 @@ def __init__( name: Optional[str] = None, namespace: Optional[str] = None, kind: Optional[str] = None, - compliance_state: Optional[Union[str, "FluxComplianceState"]] = "Unknown", - applied_by: Optional["ObjectReferenceDefinition"] = None, - status_conditions: Optional[List["ObjectStatusConditionDefinition"]] = None, - helm_release_properties: Optional["HelmReleasePropertiesDefinition"] = None, - **kwargs - ): + compliance_state: Union[str, "_models.FluxComplianceState"] = "Unknown", + applied_by: Optional["_models.ObjectReferenceDefinition"] = None, + status_conditions: Optional[List["_models.ObjectStatusConditionDefinition"]] = None, + helm_release_properties: Optional["_models.HelmReleasePropertiesDefinition"] = None, + **kwargs: Any + ) -> None: """ :keyword name: Name of the applied object. :paramtype name: str @@ -1571,8 +1535,8 @@ def __init__( :keyword kind: Kind of the applied object. :paramtype kind: str :keyword compliance_state: Compliance state of the applied object showing whether the applied - object has come into a ready state on the cluster. Possible values include: "Compliant", - "Non-Compliant", "Pending", "Suspended", "Unknown". Default value: "Unknown". + object has come into a ready state on the cluster. Known values are: "Compliant", + "Non-Compliant", "Pending", "Suspended", and "Unknown". :paramtype compliance_state: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxComplianceState :keyword applied_by: Object reference to the Kustomization that applied this object. @@ -1586,7 +1550,7 @@ def __init__( :paramtype helm_release_properties: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.HelmReleasePropertiesDefinition """ - super(ObjectStatusDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.namespace = namespace self.kind = kind @@ -1596,7 +1560,7 @@ def __init__( self.helm_release_properties = helm_release_properties -class OperationStatusList(msrest.serialization.Model): +class OperationStatusList(_serialization.Model): """The async operations in progress, in the cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -1609,27 +1573,23 @@ class OperationStatusList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationStatusResult]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OperationStatusResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationStatusList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class OperationStatusResult(msrest.serialization.Model): +class OperationStatusResult(_serialization.Model): """The current status of an async operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1640,7 +1600,7 @@ class OperationStatusResult(msrest.serialization.Model): :vartype id: str :ivar name: Name of the async operation. :vartype name: str - :ivar status: Required. Operation status. + :ivar status: Operation status. Required. :vartype status: str :ivar properties: Additional information, if available. :vartype properties: dict[str, str] @@ -1649,38 +1609,38 @@ class OperationStatusResult(msrest.serialization.Model): """ _validation = { - 'status': {'required': True}, - 'error': {'readonly': True}, + "status": {"required": True}, + "error": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, + "error": {"key": "error", "type": "ErrorDetail"}, } def __init__( self, *, status: str, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, properties: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: Fully qualified ID for the async operation. :paramtype id: str :keyword name: Name of the async operation. :paramtype name: str - :keyword status: Required. Operation status. + :keyword status: Operation status. Required. :paramtype status: str :keyword properties: Additional information, if available. :paramtype properties: dict[str, str] """ - super(OperationStatusResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.status = status @@ -1688,7 +1648,7 @@ def __init__( self.error = None -class PatchExtension(msrest.serialization.Model): +class PatchExtension(_serialization.Model): """The Extension Patch Request object. :ivar auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade @@ -1709,23 +1669,23 @@ class PatchExtension(msrest.serialization.Model): """ _attribute_map = { - 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, - 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "configuration_settings": {"key": "properties.configurationSettings", "type": "{str}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, } def __init__( self, *, - auto_upgrade_minor_version: Optional[bool] = True, - release_train: Optional[str] = "Stable", + auto_upgrade_minor_version: bool = True, + release_train: str = "Stable", version: Optional[str] = None, configuration_settings: Optional[Dict[str, str]] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade of minor version, or not. @@ -1743,7 +1703,7 @@ def __init__( name-value pairs for configuring this extension. :paramtype configuration_protected_settings: dict[str, str] """ - super(PatchExtension, self).__init__(**kwargs) + super().__init__(**kwargs) self.auto_upgrade_minor_version = auto_upgrade_minor_version self.release_train = release_train self.version = version @@ -1751,7 +1711,7 @@ def __init__( self.configuration_protected_settings = configuration_protected_settings -class RepositoryRefDefinition(msrest.serialization.Model): +class RepositoryRefDefinition(_serialization.Model): """The source reference for the GitRepository object. :ivar branch: The git repository branch name to checkout. @@ -1767,10 +1727,10 @@ class RepositoryRefDefinition(msrest.serialization.Model): """ _attribute_map = { - 'branch': {'key': 'branch', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'semver': {'key': 'semver', 'type': 'str'}, - 'commit': {'key': 'commit', 'type': 'str'}, + "branch": {"key": "branch", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "semver": {"key": "semver", "type": "str"}, + "commit": {"key": "commit", "type": "str"}, } def __init__( @@ -1780,8 +1740,8 @@ def __init__( tag: Optional[str] = None, semver: Optional[str] = None, commit: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword branch: The git repository branch name to checkout. :paramtype branch: str @@ -1794,14 +1754,14 @@ def __init__( to be valid. This takes precedence over semver. :paramtype commit: str """ - super(RepositoryRefDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.branch = branch self.tag = tag self.semver = semver self.commit = commit -class ResourceProviderOperation(msrest.serialization.Model): +class ResourceProviderOperation(_serialization.Model): """Supported operation of this resource provider. Variables are only populated by the server, and will be ignored when sending a request. @@ -1818,24 +1778,24 @@ class ResourceProviderOperation(msrest.serialization.Model): """ _validation = { - 'is_data_action': {'readonly': True}, - 'origin': {'readonly': True}, + "is_data_action": {"readonly": True}, + "origin": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'origin': {'key': 'origin', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "ResourceProviderOperationDisplay"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "origin": {"key": "origin", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["ResourceProviderOperationDisplay"] = None, - **kwargs - ): + display: Optional["_models.ResourceProviderOperationDisplay"] = None, + **kwargs: Any + ) -> None: """ :keyword name: Operation name, in format of {provider}/{resource}/{operation}. :paramtype name: str @@ -1843,14 +1803,14 @@ def __init__( :paramtype display: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ResourceProviderOperationDisplay """ - super(ResourceProviderOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.is_data_action = None self.origin = None -class ResourceProviderOperationDisplay(msrest.serialization.Model): +class ResourceProviderOperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Resource provider: Microsoft KubernetesConfiguration. @@ -1864,10 +1824,10 @@ class ResourceProviderOperationDisplay(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__( @@ -1877,8 +1837,8 @@ def __init__( resource: Optional[str] = None, operation: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword provider: Resource provider: Microsoft KubernetesConfiguration. :paramtype provider: str @@ -1889,14 +1849,14 @@ def __init__( :keyword description: Description of this operation. :paramtype description: str """ - super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class ResourceProviderOperationList(msrest.serialization.Model): +class ResourceProviderOperationList(_serialization.Model): """Result of the request to list operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -1909,31 +1869,26 @@ class ResourceProviderOperationList(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceProviderOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ResourceProviderOperation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ResourceProviderOperation"]] = None, **kwargs: Any) -> None: """ :keyword value: List of operations supported by this resource provider. :paramtype value: list[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ResourceProviderOperation] """ - super(ResourceProviderOperationList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class Scope(msrest.serialization.Model): +class Scope(_serialization.Model): """Scope of the extension. It can be either Cluster or Namespace; but not both. :ivar cluster: Specifies that the scope of the extension is Cluster. @@ -1943,29 +1898,29 @@ class Scope(msrest.serialization.Model): """ _attribute_map = { - 'cluster': {'key': 'cluster', 'type': 'ScopeCluster'}, - 'namespace': {'key': 'namespace', 'type': 'ScopeNamespace'}, + "cluster": {"key": "cluster", "type": "ScopeCluster"}, + "namespace": {"key": "namespace", "type": "ScopeNamespace"}, } def __init__( self, *, - cluster: Optional["ScopeCluster"] = None, - namespace: Optional["ScopeNamespace"] = None, - **kwargs - ): + cluster: Optional["_models.ScopeCluster"] = None, + namespace: Optional["_models.ScopeNamespace"] = None, + **kwargs: Any + ) -> None: """ :keyword cluster: Specifies that the scope of the extension is Cluster. :paramtype cluster: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ScopeCluster :keyword namespace: Specifies that the scope of the extension is Namespace. :paramtype namespace: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ScopeNamespace """ - super(Scope, self).__init__(**kwargs) + super().__init__(**kwargs) self.cluster = cluster self.namespace = namespace -class ScopeCluster(msrest.serialization.Model): +class ScopeCluster(_serialization.Model): """Specifies that the scope of the extension is Cluster. :ivar release_namespace: Namespace where the extension Release must be placed, for a Cluster @@ -1974,25 +1929,20 @@ class ScopeCluster(msrest.serialization.Model): """ _attribute_map = { - 'release_namespace': {'key': 'releaseNamespace', 'type': 'str'}, + "release_namespace": {"key": "releaseNamespace", "type": "str"}, } - def __init__( - self, - *, - release_namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, release_namespace: Optional[str] = None, **kwargs: Any) -> None: """ :keyword release_namespace: Namespace where the extension Release must be placed, for a Cluster scoped extension. If this namespace does not exist, it will be created. :paramtype release_namespace: str """ - super(ScopeCluster, self).__init__(**kwargs) + super().__init__(**kwargs) self.release_namespace = release_namespace -class ScopeNamespace(msrest.serialization.Model): +class ScopeNamespace(_serialization.Model): """Specifies that the scope of the extension is Namespace. :ivar target_namespace: Namespace where the extension will be created for an Namespace scoped @@ -2001,25 +1951,20 @@ class ScopeNamespace(msrest.serialization.Model): """ _attribute_map = { - 'target_namespace': {'key': 'targetNamespace', 'type': 'str'}, + "target_namespace": {"key": "targetNamespace", "type": "str"}, } - def __init__( - self, - *, - target_namespace: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_namespace: Optional[str] = None, **kwargs: Any) -> None: """ :keyword target_namespace: Namespace where the extension will be created for an Namespace scoped extension. If this namespace does not exist, it will be created. :paramtype target_namespace: str """ - super(ScopeNamespace, self).__init__(**kwargs) + super().__init__(**kwargs) self.target_namespace = target_namespace -class SourceControlConfiguration(ProxyResource): +class SourceControlConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes """The SourceControl Configuration object returned in Get & Put response. Variables are only populated by the server, and will be ignored when sending a request. @@ -2043,7 +1988,7 @@ class SourceControlConfiguration(ProxyResource): :ivar operator_instance_name: Instance name of the operator - identifying the specific configuration. :vartype operator_instance_name: str - :ivar operator_type: Type of the operator. Possible values include: "Flux". + :ivar operator_type: Type of the operator. "Flux" :vartype operator_type: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.OperatorType :ivar operator_params: Any Parameters for the Operator instance in string format. @@ -2051,8 +1996,8 @@ class SourceControlConfiguration(ProxyResource): :ivar configuration_protected_settings: Name-value pairs of protected configuration settings for the configuration. :vartype configuration_protected_settings: dict[str, str] - :ivar operator_scope: Scope at which the operator will be installed. Possible values include: - "cluster", "namespace". Default value: "cluster". + :ivar operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". :vartype operator_scope: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.OperatorScopeType :ivar repository_public_key: Public Key associated with this SourceControl configuration @@ -2066,8 +2011,8 @@ class SourceControlConfiguration(ProxyResource): :ivar helm_operator_properties: Properties for Helm operator. :vartype helm_operator_properties: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.HelmOperatorProperties - :ivar provisioning_state: The provisioning state of the resource provider. Possible values - include: "Accepted", "Deleting", "Running", "Succeeded", "Failed". + :ivar provisioning_state: The provisioning state of the resource provider. Known values are: + "Accepted", "Deleting", "Running", "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ProvisioningStateType :ivar compliance_status: Compliance Status of the Configuration. @@ -2076,50 +2021,50 @@ class SourceControlConfiguration(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'repository_public_key': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'compliance_status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "repository_public_key": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "compliance_status": {"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'}, - 'repository_url': {'key': 'properties.repositoryUrl', 'type': 'str'}, - 'operator_namespace': {'key': 'properties.operatorNamespace', 'type': 'str'}, - 'operator_instance_name': {'key': 'properties.operatorInstanceName', 'type': 'str'}, - 'operator_type': {'key': 'properties.operatorType', 'type': 'str'}, - 'operator_params': {'key': 'properties.operatorParams', 'type': 'str'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, - 'operator_scope': {'key': 'properties.operatorScope', 'type': 'str'}, - 'repository_public_key': {'key': 'properties.repositoryPublicKey', 'type': 'str'}, - 'ssh_known_hosts_contents': {'key': 'properties.sshKnownHostsContents', 'type': 'str'}, - 'enable_helm_operator': {'key': 'properties.enableHelmOperator', 'type': 'bool'}, - 'helm_operator_properties': {'key': 'properties.helmOperatorProperties', 'type': 'HelmOperatorProperties'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'compliance_status': {'key': 'properties.complianceStatus', 'type': 'ComplianceStatus'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "repository_url": {"key": "properties.repositoryUrl", "type": "str"}, + "operator_namespace": {"key": "properties.operatorNamespace", "type": "str"}, + "operator_instance_name": {"key": "properties.operatorInstanceName", "type": "str"}, + "operator_type": {"key": "properties.operatorType", "type": "str"}, + "operator_params": {"key": "properties.operatorParams", "type": "str"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "operator_scope": {"key": "properties.operatorScope", "type": "str"}, + "repository_public_key": {"key": "properties.repositoryPublicKey", "type": "str"}, + "ssh_known_hosts_contents": {"key": "properties.sshKnownHostsContents", "type": "str"}, + "enable_helm_operator": {"key": "properties.enableHelmOperator", "type": "bool"}, + "helm_operator_properties": {"key": "properties.helmOperatorProperties", "type": "HelmOperatorProperties"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "compliance_status": {"key": "properties.complianceStatus", "type": "ComplianceStatus"}, } def __init__( self, *, repository_url: Optional[str] = None, - operator_namespace: Optional[str] = "default", + operator_namespace: str = "default", operator_instance_name: Optional[str] = None, - operator_type: Optional[Union[str, "OperatorType"]] = None, + operator_type: Optional[Union[str, "_models.OperatorType"]] = None, operator_params: Optional[str] = None, configuration_protected_settings: Optional[Dict[str, str]] = None, - operator_scope: Optional[Union[str, "OperatorScopeType"]] = "cluster", + operator_scope: Union[str, "_models.OperatorScopeType"] = "cluster", ssh_known_hosts_contents: Optional[str] = None, enable_helm_operator: Optional[bool] = None, - helm_operator_properties: Optional["HelmOperatorProperties"] = None, - **kwargs - ): + helm_operator_properties: Optional["_models.HelmOperatorProperties"] = None, + **kwargs: Any + ) -> None: """ :keyword repository_url: Url of the SourceControl Repository. :paramtype repository_url: str @@ -2129,7 +2074,7 @@ def __init__( :keyword operator_instance_name: Instance name of the operator - identifying the specific configuration. :paramtype operator_instance_name: str - :keyword operator_type: Type of the operator. Possible values include: "Flux". + :keyword operator_type: Type of the operator. "Flux" :paramtype operator_type: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.OperatorType :keyword operator_params: Any Parameters for the Operator instance in string format. @@ -2137,8 +2082,8 @@ def __init__( :keyword configuration_protected_settings: Name-value pairs of protected configuration settings for the configuration. :paramtype configuration_protected_settings: dict[str, str] - :keyword operator_scope: Scope at which the operator will be installed. Possible values - include: "cluster", "namespace". Default value: "cluster". + :keyword operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". :paramtype operator_scope: str or ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.OperatorScopeType :keyword ssh_known_hosts_contents: Base64-encoded known_hosts contents containing public SSH @@ -2150,7 +2095,7 @@ def __init__( :paramtype helm_operator_properties: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.HelmOperatorProperties """ - super(SourceControlConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.repository_url = repository_url self.operator_namespace = operator_namespace @@ -2167,8 +2112,9 @@ def __init__( self.compliance_status = None -class SourceControlConfigurationList(msrest.serialization.Model): - """Result of the request to list Source Control Configurations. It contains a list of SourceControlConfiguration objects and a URL link to get the next set of results. +class SourceControlConfigurationList(_serialization.Model): + """Result of the request to list Source Control Configurations. It contains a list of + SourceControlConfiguration objects and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -2180,41 +2126,37 @@ class SourceControlConfigurationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SourceControlConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SourceControlConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SourceControlConfigurationList, self).__init__(**kwargs) + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -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.kubernetesconfiguration.v2022_03_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.kubernetesconfiguration.v2022_03_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -2222,44 +2164,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 - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. 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.kubernetesconfiguration.v2022_03_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.kubernetesconfiguration.v2022_03_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 diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/models/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/models/_source_control_configuration_client_enums.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/models/_source_control_configuration_client_enums.py index 928602199b07..d62a270930ed 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/models/_source_control_configuration_client_enums.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/models/_source_control_configuration_client_enums.py @@ -7,20 +7,18 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AKSIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The identity type. - """ +class AKSIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" -class ComplianceStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The compliance state of the configuration. - """ + +class ComplianceStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The compliance state of the configuration.""" PENDING = "Pending" COMPLIANT = "Compliant" @@ -28,18 +26,18 @@ class ComplianceStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INSTALLED = "Installed" FAILED = "Failed" -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 FluxComplianceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Compliance state of the cluster object. - """ + +class FluxComplianceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Compliance state of the cluster object.""" COMPLIANT = "Compliant" NON_COMPLIANT = "Non-Compliant" @@ -47,7 +45,8 @@ class FluxComplianceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUSPENDED = "Suspended" UNKNOWN = "Unknown" -class KustomizationValidationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class KustomizationValidationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify whether to validate the Kubernetes objects referenced in the Kustomization before applying them to the cluster. """ @@ -56,38 +55,38 @@ class KustomizationValidationType(with_metaclass(CaseInsensitiveEnumMeta, str, E CLIENT = "client" SERVER = "server" -class LevelType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Level of the status. - """ + +class LevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the status.""" ERROR = "Error" WARNING = "Warning" INFORMATION = "Information" -class MessageLevelType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Level of the message. - """ + +class MessageLevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the message.""" ERROR = "Error" WARNING = "Warning" INFORMATION = "Information" -class OperatorScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Scope at which the operator will be installed. - """ + +class OperatorScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scope at which the operator will be installed.""" CLUSTER = "cluster" NAMESPACE = "namespace" -class OperatorType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the operator - """ + +class OperatorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the operator.""" FLUX = "Flux" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of the resource. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource.""" SUCCEEDED = "Succeeded" FAILED = "Failed" @@ -96,9 +95,9 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" DELETING = "Deleting" -class ProvisioningStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state of the resource provider. - """ + +class ProvisioningStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource provider.""" ACCEPTED = "Accepted" DELETING = "Deleting" @@ -106,16 +105,16 @@ class ProvisioningStateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" FAILED = "Failed" -class ScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Scope at which the configuration will be installed. - """ + +class ScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scope at which the configuration will be installed.""" CLUSTER = "cluster" NAMESPACE = "namespace" -class SourceKindType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Source Kind to pull the configuration data from. - """ + +class SourceKindType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Source Kind to pull the configuration data from.""" GIT_REPOSITORY = "GitRepository" BUCKET = "Bucket" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/__init__.py index e18b201b5dc3..9d58b5443a05 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/__init__.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/__init__.py @@ -13,11 +13,17 @@ from ._source_control_configurations_operations import SourceControlConfigurationsOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ExtensionsOperations', - 'OperationStatusOperations', - 'FluxConfigurationsOperations', - 'FluxConfigOperationStatusOperations', - 'SourceControlConfigurationsOperations', - 'Operations', + "ExtensionsOperations", + "OperationStatusOperations", + "FluxConfigurationsOperations", + "FluxConfigOperationStatusOperations", + "SourceControlConfigurationsOperations", + "Operations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_extensions_operations.py index 5ebf5788b77b..80a1fe167acc 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_extensions_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_extensions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,275 +6,279 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -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 msrest import Serializer 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_create_request_initial( - subscription_id: str, + +def build_create_request( resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, extension_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2022-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, extension_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, extension_name: str, + subscription_id: str, *, force_delete: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2022-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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") if force_delete is not None: - query_parameters['forceDelete'] = _SERIALIZER.query("force_delete", force_delete, 'bool') + _params["forceDelete"] = _SERIALIZER.query("force_delete", force_delete, "bool") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, +def build_update_request( resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, extension_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2022-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_request( - subscription_id: str, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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 - ) - -class ExtensionsOperations(object): - """ExtensionsOperations 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.kubernetesconfiguration.v2022_03_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 ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_03_01.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _create_initial( self, @@ -282,53 +287,169 @@ def _create_initial( cluster_resource_name: str, cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> "_models.Extension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + ) -> _models.Extension: 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 {}) - 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(extension, 'Extension') + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IO, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") + + request = build_create_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension + :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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -338,25 +459,30 @@ def begin_create( cluster_resource_name: str, cluster_name: str, extension_name: str, - extension: "_models.Extension", + extension: Union[_models.Extension, IO], **kwargs: Any - ) -> LROPoller["_models.Extension"]: + ) -> LROPoller[_models.Extension]: """Create a new Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param extension: Properties necessary to Create an Extension. - :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension + :param extension: Properties necessary to Create an Extension. Is either a Extension type or a + IO type. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension 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 @@ -368,16 +494,17 @@ def begin_create( :return: An instance of LROPoller that returns either Extension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] - 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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, @@ -386,34 +513,41 @@ def begin_create( cluster_name=cluster_name, extension_name=extension_name, extension=extension, + 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('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def get( @@ -424,46 +558,60 @@ def get( cluster_name: str, extension_name: str, **kwargs: Any - ) -> "_models.Extension": + ) -> _models.Extension: """Gets Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Extension, or the result of cls(response) + :return: Extension or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] 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: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -471,17 +619,18 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_rp: str, @@ -491,38 +640,53 @@ def _delete_initial( force_delete: Optional[bool] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, + subscription_id=self._config.subscription_id, force_delete=force_delete, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(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, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def begin_delete( @@ -539,19 +703,20 @@ def begin_delete( from the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str :param force_delete: Delete the extension resource in Azure - not the normal asynchronous - delete. + delete. Default value is None. :type force_delete: bool :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. @@ -563,47 +728,56 @@ def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, force_delete=force_delete, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } def _update_initial( self, @@ -612,49 +786,169 @@ def _update_initial( cluster_resource_name: str, cluster_name: str, extension_name: str, - patch_extension: "_models.PatchExtension", + patch_extension: Union[_models.PatchExtension, IO], **kwargs: Any - ) -> "_models.Extension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + ) -> _models.Extension: 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 {}) - 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(patch_extension, 'PatchExtension') + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = 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(patch_extension, (IO, bytes)): + _content = patch_extension + else: + _json = self._serialize.body(patch_extension, "PatchExtension") + + request = build_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_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(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]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Extension', pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("Extension", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Extension", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: _models.PatchExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.PatchExtension + :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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -664,25 +958,31 @@ def begin_update( cluster_resource_name: str, cluster_name: str, extension_name: str, - patch_extension: "_models.PatchExtension", + patch_extension: Union[_models.PatchExtension, IO], **kwargs: Any - ) -> LROPoller["_models.Extension"]: + ) -> LROPoller[_models.Extension]: """Patch an existing Kubernetes Cluster Extension. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param patch_extension: Properties to Patch in an existing Extension. - :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.PatchExtension + :param patch_extension: Properties to Patch in an existing Extension. Is either a + PatchExtension type or a IO type. Required. + :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.PatchExtension 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 @@ -694,16 +994,17 @@ def begin_update( :return: An instance of LROPoller that returns either Extension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] - 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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = 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, @@ -712,90 +1013,108 @@ def begin_update( cluster_name=cluster_name, extension_name=extension_name, patch_extension=patch_extension, + 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('Extension', pipeline_response) + deserialized = self._deserialize("Extension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}'} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } @distributed_trace def list( - self, - resource_group_name: str, - cluster_rp: str, - cluster_resource_name: str, - cluster_name: str, - **kwargs: Any - ) -> Iterable["_models.ExtensionsList"]: + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.Extension"]: """List all Extensions in the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtensionsList or the result of cls(response) + :return: An iterator like instance of either Extension or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ExtensionsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.ExtensionsList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -806,13 +1125,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ExtensionsList", 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(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]: @@ -822,8 +1143,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_flux_config_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_flux_config_operation_status_operations.py index aa9a53eca61e..b5cb3b05cd63 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_flux_config_operation_status_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_flux_config_operation_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,89 +6,101 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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_get_request( - subscription_id: str, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, flux_configuration_name: str, operation_id: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_name, 'str'), - "operationId": _SERIALIZER.url("operation_id", operation_id, '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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "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 - ) - -class FluxConfigOperationStatusOperations(object): - """FluxConfigOperationStatusOperations 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.kubernetesconfiguration.v2022_03_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 FluxConfigOperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_03_01.SourceControlConfigurationClient`'s + :attr:`flux_config_operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -99,49 +112,63 @@ def get( flux_configuration_name: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationStatusResult": + ) -> _models.OperationStatusResult: """Get Async Operation status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str - :param operation_id: operation Id. + :param operation_id: operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatusResult, or the result of cls(response) + :return: OperationStatusResult or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.OperationStatusResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -149,12 +176,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_flux_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_flux_configurations_operations.py index cb2bddb55aa5..fced2f7affc1 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_flux_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_flux_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,275 +6,279 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -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 msrest import Serializer 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_get_request( - subscription_id: str, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, flux_configuration_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, flux_configuration_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2022-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, +def build_update_request( resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, flux_configuration_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2022-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, flux_configuration_name: str, + subscription_id: str, *, force_delete: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2022-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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") if force_delete is not None: - query_parameters['forceDelete'] = _SERIALIZER.query("force_delete", force_delete, 'bool') + _params["forceDelete"] = _SERIALIZER.query("force_delete", force_delete, "bool") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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 - ) - -class FluxConfigurationsOperations(object): - """FluxConfigurationsOperations 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.kubernetesconfiguration.v2022_03_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 FluxConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_03_01.SourceControlConfigurationClient`'s + :attr:`flux_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -284,46 +289,60 @@ def get( cluster_name: str, flux_configuration_name: str, **kwargs: Any - ) -> "_models.FluxConfiguration": + ) -> _models.FluxConfiguration: """Gets details of the Flux Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FluxConfiguration, or the result of cls(response) + :return: FluxConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] 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: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -331,15 +350,16 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } def _create_or_update_initial( self, @@ -348,53 +368,172 @@ def _create_or_update_initial( cluster_resource_name: str, cluster_name: str, flux_configuration_name: str, - flux_configuration: "_models.FluxConfiguration", + flux_configuration: Union[_models.FluxConfiguration, IO], **kwargs: Any - ) -> "_models.FluxConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + ) -> _models.FluxConfiguration: 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 {}) - 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(flux_configuration, 'FluxConfiguration') + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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(flux_configuration, (IO, bytes)): + _content = flux_configuration + else: + _json = self._serialize.body(flux_configuration, "FluxConfiguration") + + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_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(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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: _models.FluxConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -404,26 +543,31 @@ def begin_create_or_update( cluster_resource_name: str, cluster_name: str, flux_configuration_name: str, - flux_configuration: "_models.FluxConfiguration", + flux_configuration: Union[_models.FluxConfiguration, IO], **kwargs: Any - ) -> LROPoller["_models.FluxConfiguration"]: + ) -> LROPoller[_models.FluxConfiguration]: """Create a new Kubernetes Flux Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str - :param flux_configuration: Properties necessary to Create a FluxConfiguration. + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Is either a + FluxConfiguration type or a IO type. Required. :type flux_configuration: - ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration + ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration 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 @@ -436,16 +580,17 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] - 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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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, @@ -454,34 +599,41 @@ def begin_create_or_update( cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, flux_configuration=flux_configuration, + 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('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } def _update_initial( self, @@ -490,51 +642,77 @@ def _update_initial( cluster_resource_name: str, cluster_name: str, flux_configuration_name: str, - flux_configuration_patch: "_models.FluxConfigurationPatch", + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], **kwargs: Any - ) -> "_models.FluxConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] + ) -> _models.FluxConfiguration: 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 {}) - 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(flux_configuration_patch, 'FluxConfigurationPatch') + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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(flux_configuration_patch, (IO, bytes)): + _content = flux_configuration_patch + else: + _json = self._serialize.body(flux_configuration_patch, "FluxConfigurationPatch") + + request = build_update_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_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(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]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FluxConfiguration", pipeline_response) - deserialized = self._deserialize('FluxConfiguration', pipeline_response) + if response.status_code == 202: + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + return deserialized # type: ignore + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } - @distributed_trace + @overload def begin_update( self, resource_group_name: str, @@ -542,26 +720,33 @@ def begin_update( cluster_resource_name: str, cluster_name: str, flux_configuration_name: str, - flux_configuration_patch: "_models.FluxConfigurationPatch", + flux_configuration_patch: _models.FluxConfigurationPatch, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.FluxConfiguration"]: + ) -> LROPoller[_models.FluxConfiguration]: """Update an existing Kubernetes Flux Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. :type flux_configuration_patch: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfigurationPatch + :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 @@ -574,16 +759,114 @@ def begin_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. + :type flux_configuration_patch: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. Is + either a FluxConfigurationPatch type or a IO type. Required. + :type flux_configuration_patch: + ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfigurationPatch 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration] + :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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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, @@ -592,36 +875,43 @@ def begin_update( cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, flux_configuration_patch=flux_configuration_patch, + 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('FluxConfiguration', pipeline_response) + deserialized = self._deserialize("FluxConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_rp: str, @@ -631,38 +921,53 @@ def _delete_initial( force_delete: Optional[bool] = None, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, + subscription_id=self._config.subscription_id, force_delete=force_delete, - template_url=self._delete_initial.metadata['url'], + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(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, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } @distributed_trace def begin_delete( @@ -679,19 +984,20 @@ def begin_delete( from the source repo. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param flux_configuration_name: Name of the Flux Configuration. + :param flux_configuration_name: Name of the Flux Configuration. Required. :type flux_configuration_name: str :param force_delete: Delete the extension resource in Azure - not the normal asynchronous - delete. + delete. Default value is None. :type force_delete: bool :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. @@ -703,104 +1009,123 @@ def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, flux_configuration_name=flux_configuration_name, force_delete=force_delete, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } @distributed_trace def list( - self, - resource_group_name: str, - cluster_rp: str, - cluster_resource_name: str, - cluster_name: str, - **kwargs: Any - ) -> Iterable["_models.FluxConfigurationsList"]: + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.FluxConfiguration"]: """List all Flux Configurations. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FluxConfigurationsList or the result of - cls(response) + :return: An iterator like instance of either FluxConfiguration or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfigurationsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FluxConfigurationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.FluxConfigurationsList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -811,13 +1136,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("FluxConfigurationsList", 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(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]: @@ -827,8 +1154,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_operation_status_operations.py index 74483698fc05..6311f4d78827 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_operation_status_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_operation_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,129 +6,143 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 msrest import Serializer from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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_get_request( - subscription_id: str, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, extension_name: str, operation_id: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "extensionName": _SERIALIZER.url("extension_name", extension_name, 'str'), - "operationId": _SERIALIZER.url("operation_id", operation_id, '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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "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="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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 - ) - -class OperationStatusOperations(object): - """OperationStatusOperations 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.kubernetesconfiguration.v2022_03_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 OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_03_01.SourceControlConfigurationClient`'s + :attr:`operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -139,49 +154,63 @@ def get( extension_name: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationStatusResult": + ) -> _models.OperationStatusResult: """Get Async Operation status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param extension_name: Name of the Extension. + :param extension_name: Name of the Extension. Required. :type extension_name: str - :param operation_id: operation Id. + :param operation_id: operation Id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatusResult, or the result of cls(response) + :return: OperationStatusResult or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.OperationStatusResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, extension_name=extension_name, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -189,71 +218,84 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationStatusResult', pipeline_response) + deserialized = self._deserialize("OperationStatusResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + } @distributed_trace def list( - self, - resource_group_name: str, - cluster_rp: str, - cluster_resource_name: str, - cluster_name: str, - **kwargs: Any - ) -> Iterable["_models.OperationStatusList"]: + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.OperationStatusResult"]: """List Async Operations, currently in progress, in a cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationStatusList or the result of cls(response) + :return: An iterator like instance of either OperationStatusResult or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.OperationStatusList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.OperationStatusList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -264,13 +306,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationStatusList", 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(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]: @@ -280,8 +324,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_operations.py index 71758018e4fb..d896e75c45ab 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +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 functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 msrest import Serializer 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 = "2022-03-01" - 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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.KubernetesConfiguration/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.KubernetesConfiguration/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.kubernetesconfiguration.v2022_03_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.kubernetesconfiguration.v2022_03_01.SourceControlConfigurationClient`'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.ResourceProviderOperationList"]: + def list(self, **kwargs: Any) -> Iterable["_models.ResourceProviderOperation"]: """List all the available operations the KubernetesConfiguration resource provider supports. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of + :return: An iterator like instance of either ResourceProviderOperation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ResourceProviderOperationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.ResourceProviderOperationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - 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) @@ -114,13 +138,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ResourceProviderOperationList", 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(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]: @@ -130,8 +156,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.KubernetesConfiguration/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_source_control_configurations_operations.py index 300824b2190f..455d80553b94 100644 --- a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_source_control_configurations_operations.py +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_03_01/operations/_source_control_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,221 +6,236 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -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 msrest import Serializer 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_get_request( - subscription_id: str, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, source_control_configuration_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, source_control_configuration_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - 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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - api_version = "2022-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, source_control_configuration_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "sourceControlConfigurationName": _SERIALIZER.url("source_control_configuration_name", source_control_configuration_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations", + ) # 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), - "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, 'str'), - "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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 - ) - -class SourceControlConfigurationsOperations(object): - """SourceControlConfigurationsOperations 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.kubernetesconfiguration.v2022_03_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 SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_03_01.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -230,46 +246,60 @@ def get( cluster_name: str, source_control_configuration_name: str, **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Gets details of the Source Control Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self.get.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -277,17 +307,18 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, @@ -295,56 +326,162 @@ def create_or_update( cluster_resource_name: str, cluster_name: str, source_control_configuration_name: str, - source_control_configuration: "_models.SourceControlConfiguration", + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SourceControlConfiguration": + ) -> _models.SourceControlConfiguration: """Create a new Kubernetes Source Control Configuration. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_name: str :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. :type source_control_configuration: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceControlConfiguration + :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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceControlConfiguration 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: SourceControlConfiguration, or the result of cls(response) + :return: SourceControlConfiguration or the result of cls(response) :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceControlConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfiguration"] 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 {}) - 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(source_control_configuration, 'SourceControlConfiguration') + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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 = self._client._pipeline.run(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]: @@ -353,20 +490,21 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SourceControlConfiguration', pipeline_response) + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_rp: str, @@ -375,37 +513,52 @@ def _delete_initial( source_control_configuration_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 {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - template_url=self._delete_initial.metadata['url'], + 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 = self._client._pipeline.run(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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def begin_delete( @@ -421,16 +574,17 @@ def begin_delete( future sync from the source repo. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str - :param source_control_configuration_name: Name of the Source Control Configuration. + :param source_control_configuration_name: Name of the Source Control Configuration. Required. :type source_control_configuration_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. @@ -442,103 +596,121 @@ def begin_delete( 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-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, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, source_control_configuration_name=source_control_configuration_name, - cls=lambda x,y,z: x, + api_version=api_version, + 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, ) - else: - 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } @distributed_trace def list( - self, - resource_group_name: str, - cluster_rp: str, - cluster_resource_name: str, - cluster_name: str, - **kwargs: Any - ) -> Iterable["_models.SourceControlConfigurationList"]: + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.SourceControlConfiguration"]: """List all Source Control Configurations. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, - Microsoft.Kubernetes, Microsoft.HybridContainerService. + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, - connectedClusters, provisionedClusters. + connectedClusters, provisionedClusters. Required. :type cluster_resource_name: str - :param cluster_name: The name of the kubernetes cluster. + :param cluster_name: The name of the kubernetes cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlConfigurationList or the result of + :return: An iterator like instance of either SourceControlConfiguration or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceControlConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_03_01.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + cls: ClsType[_models.SourceControlConfigurationList] = kwargs.pop("cls", 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 {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_rp=cluster_rp, cluster_resource_name=cluster_resource_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_rp=cluster_rp, - cluster_resource_name=cluster_resource_name, - cluster_name=cluster_name, - 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) @@ -549,13 +721,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SourceControlConfigurationList", 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(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]: @@ -565,8 +739,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations'} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/__init__.py new file mode 100644 index 000000000000..3ad4bd8b604e --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/__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 ._source_control_configuration_client import SourceControlConfigurationClient +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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/_configuration.py new file mode 100644 index 000000000000..76e791c4f1a6 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/_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 SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for SourceControlConfigurationClient. + + 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-04-02-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2022-04-02-preview"] = kwargs.pop("api_version", "2022-04-02-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/_metadata.json b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/_metadata.json new file mode 100644 index 000000000000..1a2102404ed0 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/_metadata.json @@ -0,0 +1,114 @@ +{ + "chosen_version": "2022-04-02-preview", + "total_api_version_list": ["2022-04-02-preview"], + "client": { + "name": "SourceControlConfigurationClient", + "filename": "_source_control_configuration_client", + "description": "KubernetesConfiguration Client.", + "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\": [\"SourceControlConfigurationClientConfiguration\"], \".._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\": [\"SourceControlConfigurationClientConfiguration\"], \"..._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, + "method_location": "positional" + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", + "docstring_type": "str", + "required": true, + "method_location": "positional" + } + }, + "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, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + }, + "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, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + } + } + }, + "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": { + "extensions": "ExtensionsOperations", + "operation_status": "OperationStatusOperations", + "private_link_scopes": "PrivateLinkScopesOperations", + "private_link_resources": "PrivateLinkResourcesOperations", + "private_endpoint_connections": "PrivateEndpointConnectionsOperations" + } +} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/_source_control_configuration_client.py new file mode 100644 index 000000000000..a0d1c81454ec --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/_source_control_configuration_client.py @@ -0,0 +1,122 @@ +# 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 SourceControlConfigurationClientConfiguration +from .operations import ( + ExtensionsOperations, + OperationStatusOperations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + PrivateLinkScopesOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword + """KubernetesConfiguration Client. + + :ivar extensions: ExtensionsOperations operations + :vartype extensions: + azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.operations.ExtensionsOperations + :ivar operation_status: OperationStatusOperations operations + :vartype operation_status: + azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.operations.OperationStatusOperations + :ivar private_link_scopes: PrivateLinkScopesOperations operations + :vartype private_link_scopes: + azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.operations.PrivateLinkScopesOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.operations.PrivateLinkResourcesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.operations.PrivateEndpointConnectionsOperations + :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-04-02-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = SourceControlConfigurationClientConfiguration( + 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.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_scopes = PrivateLinkScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + 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) -> "SourceControlConfigurationClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/_vendor.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/_vendor.py new file mode 100644 index 000000000000..bd0df84f5319 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/_vendor.py @@ -0,0 +1,30 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import List, cast + +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: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/_version.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/_version.py new file mode 100644 index 000000000000..59deb8c7263b --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/_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.1.0" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/__init__.py new file mode 100644 index 000000000000..b95230ae03c5 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/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 ._source_control_configuration_client import SourceControlConfigurationClient + +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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/_configuration.py new file mode 100644 index 000000000000..5e3401d33a35 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/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 SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for SourceControlConfigurationClient. + + 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-04-02-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2022-04-02-preview"] = kwargs.pop("api_version", "2022-04-02-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/_source_control_configuration_client.py new file mode 100644 index 000000000000..5cb5f83dc7fb --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/_source_control_configuration_client.py @@ -0,0 +1,122 @@ +# 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 SourceControlConfigurationClientConfiguration +from .operations import ( + ExtensionsOperations, + OperationStatusOperations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + PrivateLinkScopesOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword + """KubernetesConfiguration Client. + + :ivar extensions: ExtensionsOperations operations + :vartype extensions: + azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.aio.operations.ExtensionsOperations + :ivar operation_status: OperationStatusOperations operations + :vartype operation_status: + azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.aio.operations.OperationStatusOperations + :ivar private_link_scopes: PrivateLinkScopesOperations operations + :vartype private_link_scopes: + azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.aio.operations.PrivateLinkScopesOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.aio.operations.PrivateLinkResourcesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.aio.operations.PrivateEndpointConnectionsOperations + :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-04-02-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = SourceControlConfigurationClientConfiguration( + 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.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_scopes = PrivateLinkScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + 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) -> "SourceControlConfigurationClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..15e6d84b033d --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/__init__.py @@ -0,0 +1,27 @@ +# 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 ._extensions_operations import ExtensionsOperations +from ._operation_status_operations import OperationStatusOperations +from ._private_link_scopes_operations import PrivateLinkScopesOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ExtensionsOperations", + "OperationStatusOperations", + "PrivateLinkScopesOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/_extensions_operations.py new file mode 100644 index 000000000000..7082bef03a0a --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/_extensions_operations.py @@ -0,0 +1,962 @@ +# 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._extensions_operations import ( + build_create_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 ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.aio.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: Union[_models.Extension, IO], + **kwargs: Any + ) -> _models.Extension: + 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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IO, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") + + request = build_create_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Extension", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension + :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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: Union[_models.Extension, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Is either a Extension type or a + IO type. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension] + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + extension=extension, + 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("Extension", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + **kwargs: Any + ) -> _models.Extension: + """Gets Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Extension or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + force_delete: Optional[bool] = None, + **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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + force_delete=force_delete, + 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 [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a Kubernetes Cluster Extension. This will cause the Agent to Uninstall the extension + from the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param force_delete: Delete the extension resource in Azure - not the normal asynchronous + delete. Default value is None. + :type force_delete: bool + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + force_delete=force_delete, + 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, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + async def _update_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: Union[_models.PatchExtension, IO], + **kwargs: Any + ) -> _models.Extension: + 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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(patch_extension, (IO, bytes)): + _content = patch_extension + else: + _json = self._serialize.body(patch_extension, "PatchExtension") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Extension", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: _models.PatchExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PatchExtension + :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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: Union[_models.PatchExtension, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Is either a + PatchExtension type or a IO type. Required. + :type patch_extension: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PatchExtension 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension] + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + patch_extension=patch_extension, + 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("Extension", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Extension"]: + """List all Extensions in the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Extension or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.ExtensionsList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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("ExtensionsList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/_operation_status_operations.py new file mode 100644 index 000000000000..d42550ab2731 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/_operation_status_operations.py @@ -0,0 +1,143 @@ +# 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, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operation_status_operations import build_get_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 OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.aio.SourceControlConfigurationClient`'s + :attr:`operation_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + operation_id: str, + **kwargs: Any + ) -> _models.OperationStatusResult: + """Get Async Operation status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param operation_id: operation Id. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.OperationStatusResult + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + operation_id=operation_id, + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..ceae76d64eb1 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,570 @@ +# 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, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_private_link_scope_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 PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.aio.SourceControlConfigurationClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointConnection + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + 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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointConnection + :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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: 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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a + PrivateEndpointConnection type or a IO type. Required. + :type properties: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointConnection 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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointConnection] + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = 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, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_name, + properties=properties, + 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("PrivateEndpointConnection", 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.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, scope_name: str, private_endpoint_connection_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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_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 [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + 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, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_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.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace_async + async def list_by_private_link_scope( + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnectionListResult: + """Gets all private endpoint connections on a private link scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnectionListResult or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointConnectionListResult + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + request = build_list_by_private_link_scope_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_private_link_scope.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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_private_link_scope.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/_private_link_resources_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..d53d97e76fee --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/_private_link_resources_operations.py @@ -0,0 +1,192 @@ +# 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, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_get_request, build_list_by_private_link_scope_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 PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.aio.SourceControlConfigurationClient`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list_by_private_link_scope( + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResourceListResult or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateLinkResourceListResult + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + request = build_list_by_private_link_scope_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_private_link_scope.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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_private_link_scope.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateLinkResources" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, scope_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param group_name: The name of the private link resource. Required. + :type group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateLinkResource + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + group_name=group_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/_private_link_scopes_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/_private_link_scopes_operations.py new file mode 100644 index 000000000000..08802ade7815 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/aio/operations/_private_link_scopes_operations.py @@ -0,0 +1,742 @@ +# 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._private_link_scopes_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_tags_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 PrivateLinkScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.aio.SourceControlConfigurationClient`'s + :attr:`private_link_scopes` 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.KubernetesConfigurationPrivateLinkScope"]: + """Gets a list of all Azure Arc PrivateLinkScopes within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either KubernetesConfigurationPrivateLinkScope or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.KubernetesConfigurationPrivateLinkScopeListResult] = 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("KubernetesConfigurationPrivateLinkScopeListResult", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes" + } + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.KubernetesConfigurationPrivateLinkScope"]: + """Gets a list of Azure Arc PrivateLinkScopes within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either KubernetesConfigurationPrivateLinkScope or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.KubernetesConfigurationPrivateLinkScopeListResult] = 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("KubernetesConfigurationPrivateLinkScopeListResult", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, scope_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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + scope_name=scope_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 [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}" + } + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes a Azure Arc PrivateLinkScope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + 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, + scope_name=scope_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.KubernetesConfiguration/privateLinkScopes/{scopeName}" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> _models.KubernetesConfigurationPrivateLinkScope: + """Returns a Azure Arc PrivateLinkScope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: KubernetesConfigurationPrivateLinkScope or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.KubernetesConfigurationPrivateLinkScope] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + scope_name=scope_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("KubernetesConfigurationPrivateLinkScope", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + scope_name: str, + parameters: _models.KubernetesConfigurationPrivateLinkScope, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.KubernetesConfigurationPrivateLinkScope: + """Creates (or updates) a Azure Arc PrivateLinkScope. Note: You cannot specify a different value + for InstrumentationKey nor AppId in the Put operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param parameters: Properties that need to be specified to create or update a Azure Arc for + Servers and Clusters PrivateLinkScope. Required. + :type parameters: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope + :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: KubernetesConfigurationPrivateLinkScope or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + scope_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.KubernetesConfigurationPrivateLinkScope: + """Creates (or updates) a Azure Arc PrivateLinkScope. Note: You cannot specify a different value + for InstrumentationKey nor AppId in the Put operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param parameters: Properties that need to be specified to create or update a Azure Arc for + Servers and Clusters PrivateLinkScope. 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: KubernetesConfigurationPrivateLinkScope or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + scope_name: str, + parameters: Union[_models.KubernetesConfigurationPrivateLinkScope, IO], + **kwargs: Any + ) -> _models.KubernetesConfigurationPrivateLinkScope: + """Creates (or updates) a Azure Arc PrivateLinkScope. Note: You cannot specify a different value + for InstrumentationKey nor AppId in the Put operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param parameters: Properties that need to be specified to create or update a Azure Arc for + Servers and Clusters PrivateLinkScope. Is either a KubernetesConfigurationPrivateLinkScope type + or a IO type. Required. + :type parameters: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope + 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: KubernetesConfigurationPrivateLinkScope or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.KubernetesConfigurationPrivateLinkScope] = 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, "KubernetesConfigurationPrivateLinkScope") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + scope_name=scope_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("KubernetesConfigurationPrivateLinkScope", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("KubernetesConfigurationPrivateLinkScope", 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.KubernetesConfiguration/privateLinkScopes/{scopeName}" + } + + @overload + async def update_tags( + self, + resource_group_name: str, + scope_name: str, + private_link_scope_tags: _models.TagsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.KubernetesConfigurationPrivateLinkScope: + """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope + instance. Required. + :type private_link_scope_tags: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.TagsResource + :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: KubernetesConfigurationPrivateLinkScope or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + scope_name: str, + private_link_scope_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.KubernetesConfigurationPrivateLinkScope: + """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope + instance. Required. + :type private_link_scope_tags: 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: KubernetesConfigurationPrivateLinkScope or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + scope_name: str, + private_link_scope_tags: Union[_models.TagsResource, IO], + **kwargs: Any + ) -> _models.KubernetesConfigurationPrivateLinkScope: + """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope + instance. Is either a TagsResource type or a IO type. Required. + :type private_link_scope_tags: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.TagsResource 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: KubernetesConfigurationPrivateLinkScope or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.KubernetesConfigurationPrivateLinkScope] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_link_scope_tags, (IO, bytes)): + _content = private_link_scope_tags + else: + _json = self._serialize.body(private_link_scope_tags, "TagsResource") + + request = build_update_tags_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update_tags.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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("KubernetesConfigurationPrivateLinkScope", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/models/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/models/__init__.py new file mode 100644 index 000000000000..f4352e3aa45c --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/models/__init__.py @@ -0,0 +1,89 @@ +# 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 ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import Extension +from ._models_py3 import ExtensionPropertiesAksAssignedIdentity +from ._models_py3 import ExtensionStatus +from ._models_py3 import ExtensionsList +from ._models_py3 import Identity +from ._models_py3 import KubernetesConfigurationPrivateLinkScope +from ._models_py3 import KubernetesConfigurationPrivateLinkScopeListResult +from ._models_py3 import KubernetesConfigurationPrivateLinkScopeProperties +from ._models_py3 import OperationStatusResult +from ._models_py3 import PatchExtension +from ._models_py3 import Plan +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceListResult +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import ResourceAutoGenerated +from ._models_py3 import Scope +from ._models_py3 import ScopeCluster +from ._models_py3 import ScopeNamespace +from ._models_py3 import SystemData +from ._models_py3 import TagsResource +from ._models_py3 import TrackedResource + +from ._source_control_configuration_client_enums import AKSIdentityType +from ._source_control_configuration_client_enums import CreatedByType +from ._source_control_configuration_client_enums import LevelType +from ._source_control_configuration_client_enums import PrivateEndpointConnectionProvisioningState +from ._source_control_configuration_client_enums import PrivateEndpointServiceConnectionStatus +from ._source_control_configuration_client_enums import ProvisioningState +from ._source_control_configuration_client_enums import PublicNetworkAccessType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "Extension", + "ExtensionPropertiesAksAssignedIdentity", + "ExtensionStatus", + "ExtensionsList", + "Identity", + "KubernetesConfigurationPrivateLinkScope", + "KubernetesConfigurationPrivateLinkScopeListResult", + "KubernetesConfigurationPrivateLinkScopeProperties", + "OperationStatusResult", + "PatchExtension", + "Plan", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProxyResource", + "Resource", + "ResourceAutoGenerated", + "Scope", + "ScopeCluster", + "ScopeNamespace", + "SystemData", + "TagsResource", + "TrackedResource", + "AKSIdentityType", + "CreatedByType", + "LevelType", + "PrivateEndpointConnectionProvisioningState", + "PrivateEndpointServiceConnectionStatus", + "ProvisioningState", + "PublicNetworkAccessType", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/models/_models_py3.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/models/_models_py3.py new file mode 100644 index 000000000000..2b1b2e168ced --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/models/_models_py3.py @@ -0,0 +1,1373 @@ +# 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 +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +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 .. import models as _models + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: + list[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +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 + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + + +class Extension(ProxyResource): # pylint: disable=too-many-instance-attributes + """The Extension object. + + 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 identity: Identity of the Extension resource. + :vartype identity: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Identity + :ivar system_data: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.SystemData + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Plan + :ivar extension_type: Type of the Extension, of which this resource is an instance of. It must + be one of the Extension Types registered with Microsoft.KubernetesConfiguration by the + Extension publisher. + :vartype extension_type: str + :ivar auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade + of minor version, or not. + :vartype auto_upgrade_minor_version: bool + :ivar release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. Stable, + Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :vartype release_train: str + :ivar version: User-specified version of the extension for this extension to 'pin'. To use + 'version', autoUpgradeMinorVersion must be 'false'. + :vartype version: str + :ivar scope: Scope at which the extension is installed. + :vartype scope: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Scope + :ivar configuration_settings: Configuration settings, as name-value pairs for configuring this + extension. + :vartype configuration_settings: dict[str, str] + :ivar configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :vartype configuration_protected_settings: dict[str, str] + :ivar installed_version: Installed version of the extension. + :vartype installed_version: str + :ivar provisioning_state: Status of installation of this extension. Known values are: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.ProvisioningState + :ivar statuses: Status from this extension. + :vartype statuses: + list[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.ExtensionStatus] + :ivar error_info: Error information from the Agent - e.g. errors during installation. + :vartype error_info: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.ErrorDetail + :ivar custom_location_settings: Custom Location settings properties. + :vartype custom_location_settings: dict[str, str] + :ivar package_uri: Uri of the Helm package. + :vartype package_uri: str + :ivar aks_assigned_identity: Identity of the Extension resource in an AKS cluster. + :vartype aks_assigned_identity: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.ExtensionPropertiesAksAssignedIdentity + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "installed_version": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "error_info": {"readonly": True}, + "custom_location_settings": {"readonly": True}, + "package_uri": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "plan": {"key": "plan", "type": "Plan"}, + "extension_type": {"key": "properties.extensionType", "type": "str"}, + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "scope": {"key": "properties.scope", "type": "Scope"}, + "configuration_settings": {"key": "properties.configurationSettings", "type": "{str}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "installed_version": {"key": "properties.installedVersion", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "statuses": {"key": "properties.statuses", "type": "[ExtensionStatus]"}, + "error_info": {"key": "properties.errorInfo", "type": "ErrorDetail"}, + "custom_location_settings": {"key": "properties.customLocationSettings", "type": "{str}"}, + "package_uri": {"key": "properties.packageUri", "type": "str"}, + "aks_assigned_identity": { + "key": "properties.aksAssignedIdentity", + "type": "ExtensionPropertiesAksAssignedIdentity", + }, + } + + def __init__( + self, + *, + identity: Optional["_models.Identity"] = None, + plan: Optional["_models.Plan"] = None, + extension_type: Optional[str] = None, + auto_upgrade_minor_version: bool = True, + release_train: str = "Stable", + version: Optional[str] = None, + scope: Optional["_models.Scope"] = None, + configuration_settings: Optional[Dict[str, str]] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + statuses: Optional[List["_models.ExtensionStatus"]] = None, + aks_assigned_identity: Optional["_models.ExtensionPropertiesAksAssignedIdentity"] = None, + **kwargs: Any + ) -> None: + """ + :keyword identity: Identity of the Extension resource. + :paramtype identity: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Identity + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Plan + :keyword extension_type: Type of the Extension, of which this resource is an instance of. It + must be one of the Extension Types registered with Microsoft.KubernetesConfiguration by the + Extension publisher. + :paramtype extension_type: str + :keyword auto_upgrade_minor_version: Flag to note if this extension participates in auto + upgrade of minor version, or not. + :paramtype auto_upgrade_minor_version: bool + :keyword release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. + Stable, Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :paramtype release_train: str + :keyword version: User-specified version of the extension for this extension to 'pin'. To use + 'version', autoUpgradeMinorVersion must be 'false'. + :paramtype version: str + :keyword scope: Scope at which the extension is installed. + :paramtype scope: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Scope + :keyword configuration_settings: Configuration settings, as name-value pairs for configuring + this extension. + :paramtype configuration_settings: dict[str, str] + :keyword configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :paramtype configuration_protected_settings: dict[str, str] + :keyword statuses: Status from this extension. + :paramtype statuses: + list[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.ExtensionStatus] + :keyword aks_assigned_identity: Identity of the Extension resource in an AKS cluster. + :paramtype aks_assigned_identity: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.ExtensionPropertiesAksAssignedIdentity + """ + super().__init__(**kwargs) + self.identity = identity + self.system_data = None + self.plan = plan + self.extension_type = extension_type + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.release_train = release_train + self.version = version + self.scope = scope + self.configuration_settings = configuration_settings + self.configuration_protected_settings = configuration_protected_settings + self.installed_version = None + self.provisioning_state = None + self.statuses = statuses + self.error_info = None + self.custom_location_settings = None + self.package_uri = None + self.aks_assigned_identity = aks_assigned_identity + + +class ExtensionPropertiesAksAssignedIdentity(_serialization.Model): + """Identity of the Extension resource in an AKS cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Known values are: "SystemAssigned" and "UserAssigned". + :vartype type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.AKSIdentityType + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Union[str, "_models.AKSIdentityType"]] = None, **kwargs: Any) -> None: + """ + :keyword type: The identity type. Known values are: "SystemAssigned" and "UserAssigned". + :paramtype type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.AKSIdentityType + """ + super().__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + + +class ExtensionsList(_serialization.Model): + """Result of the request to list Extensions. It contains a list of Extension objects and a URL + link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Extensions within a Kubernetes cluster. + :vartype value: list[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension] + :ivar next_link: URL to get the next set of extension objects, if any. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Extension]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class ExtensionStatus(_serialization.Model): + """Status from the extension. + + :ivar code: Status code provided by the Extension. + :vartype code: str + :ivar display_status: Short description of status of the extension. + :vartype display_status: str + :ivar level: Level of the status. Known values are: "Error", "Warning", and "Information". + :vartype level: str or ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.LevelType + :ivar message: Detailed message of the status from the Extension. + :vartype message: str + :ivar time: DateLiteral (per ISO8601) noting the time of installation status. + :vartype time: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "display_status": {"key": "displayStatus", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "time": {"key": "time", "type": "str"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + display_status: Optional[str] = None, + level: Union[str, "_models.LevelType"] = "Information", + message: Optional[str] = None, + time: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: Status code provided by the Extension. + :paramtype code: str + :keyword display_status: Short description of status of the extension. + :paramtype display_status: str + :keyword level: Level of the status. Known values are: "Error", "Warning", and "Information". + :paramtype level: str or + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.LevelType + :keyword message: Detailed message of the status from the Extension. + :paramtype message: str + :keyword time: DateLiteral (per ISO8601) noting the time of installation status. + :paramtype time: str + """ + super().__init__(**kwargs) + self.code = code + self.display_status = display_status + self.level = level + self.message = message + self.time = time + + +class Identity(_serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Default value is "SystemAssigned". + :vartype type: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: + """ + :keyword type: The identity type. Default value is "SystemAssigned". + :paramtype type: str + """ + super().__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + + +class ResourceAutoGenerated(_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.kubernetesconfiguration.v2022_04_02_preview.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +class TrackedResource(ResourceAutoGenerated): + """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.kubernetesconfiguration.v2022_04_02_preview.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(**kwargs) + self.tags = tags + self.location = location + + +class KubernetesConfigurationPrivateLinkScope(TrackedResource): + """An Azure Arc PrivateLinkScope definition. + + 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.kubernetesconfiguration.v2022_04_02_preview.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Properties that define a Azure Arc PrivateLinkScope resource. + :vartype properties: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScopeProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "KubernetesConfigurationPrivateLinkScopeProperties"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.KubernetesConfigurationPrivateLinkScopeProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: Properties that define a Azure Arc PrivateLinkScope resource. + :paramtype properties: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScopeProperties + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + + +class KubernetesConfigurationPrivateLinkScopeListResult(_serialization.Model): + """Describes the list of Azure Arc PrivateLinkScope resources. + + All required parameters must be populated in order to send to Azure. + + :ivar value: List of Azure Arc PrivateLinkScope definitions. Required. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope] + :ivar next_link: The URI to get the next set of Azure Arc PrivateLinkScope definitions if too + many PrivateLinkScopes where returned in the result set. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[KubernetesConfigurationPrivateLinkScope]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: List["_models.KubernetesConfigurationPrivateLinkScope"], + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: List of Azure Arc PrivateLinkScope definitions. Required. + :paramtype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope] + :keyword next_link: The URI to get the next set of Azure Arc PrivateLinkScope definitions if + too many PrivateLinkScopes where returned in the result set. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class KubernetesConfigurationPrivateLinkScopeProperties(_serialization.Model): + """Properties that define a Azure Arc PrivateLinkScope resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar public_network_access: Indicates whether machines associated with the private link scope + can also use public Azure Arc service endpoints. Known values are: "Enabled" and "Disabled". + :vartype public_network_access: str or + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PublicNetworkAccessType + :ivar provisioning_state: Current state of this PrivateLinkScope: whether or not is has been + provisioned within the resource group it is defined. Users cannot change this value but are + able to read from it. Values will include Provisioning ,Succeeded, Canceled and Failed. Known + values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.ProvisioningState + :ivar cluster_resource_id: Managed Cluster ARM ID for the private link scope (Required). + Required. + :vartype cluster_resource_id: str + :ivar private_link_scope_id: The Guid id of the private link scope. + :vartype private_link_scope_id: str + :ivar private_endpoint_connections: The collection of associated Private Endpoint Connections. + :vartype private_endpoint_connections: + list[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointConnection] + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "cluster_resource_id": {"required": True}, + "private_link_scope_id": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + } + + _attribute_map = { + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "cluster_resource_id": {"key": "clusterResourceId", "type": "str"}, + "private_link_scope_id": {"key": "privateLinkScopeId", "type": "str"}, + "private_endpoint_connections": {"key": "privateEndpointConnections", "type": "[PrivateEndpointConnection]"}, + } + + def __init__( + self, + *, + cluster_resource_id: str, + public_network_access: Union[str, "_models.PublicNetworkAccessType"] = "Disabled", + **kwargs: Any + ) -> None: + """ + :keyword public_network_access: Indicates whether machines associated with the private link + scope can also use public Azure Arc service endpoints. Known values are: "Enabled" and + "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PublicNetworkAccessType + :keyword cluster_resource_id: Managed Cluster ARM ID for the private link scope (Required). + Required. + :paramtype cluster_resource_id: str + """ + super().__init__(**kwargs) + self.public_network_access = public_network_access + self.provisioning_state = None + self.cluster_resource_id = cluster_resource_id + self.private_link_scope_id = None + self.private_endpoint_connections = None + + +class OperationStatusResult(_serialization.Model): + """The current status of an async operation. + + 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 ID for the async operation. + :vartype id: str + :ivar name: Name of the async operation. + :vartype name: str + :ivar status: Operation status. Required. + :vartype status: str + :ivar properties: Additional information, if available. + :vartype properties: dict[str, str] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.ErrorDetail + """ + + _validation = { + "status": {"required": True}, + "error": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__( + self, + *, + status: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Fully qualified ID for the async operation. + :paramtype id: str + :keyword name: Name of the async operation. + :paramtype name: str + :keyword status: Operation status. Required. + :paramtype status: str + :keyword properties: Additional information, if available. + :paramtype properties: dict[str, str] + """ + super().__init__(**kwargs) + self.id = id + self.name = name + self.status = status + self.properties = properties + self.error = None + + +class PatchExtension(_serialization.Model): + """The Extension Patch Request object. + + :ivar auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade + of minor version, or not. + :vartype auto_upgrade_minor_version: bool + :ivar release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. Stable, + Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :vartype release_train: str + :ivar version: Version of the extension for this extension, if it is 'pinned' to a specific + version. autoUpgradeMinorVersion must be 'false'. + :vartype version: str + :ivar configuration_settings: Configuration settings, as name-value pairs for configuring this + extension. + :vartype configuration_settings: dict[str, str] + :ivar configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :vartype configuration_protected_settings: dict[str, str] + """ + + _attribute_map = { + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "configuration_settings": {"key": "properties.configurationSettings", "type": "{str}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + } + + def __init__( + self, + *, + auto_upgrade_minor_version: bool = True, + release_train: str = "Stable", + version: Optional[str] = None, + configuration_settings: Optional[Dict[str, str]] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword auto_upgrade_minor_version: Flag to note if this extension participates in auto + upgrade of minor version, or not. + :paramtype auto_upgrade_minor_version: bool + :keyword release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. + Stable, Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :paramtype release_train: str + :keyword version: Version of the extension for this extension, if it is 'pinned' to a specific + version. autoUpgradeMinorVersion must be 'false'. + :paramtype version: str + :keyword configuration_settings: Configuration settings, as name-value pairs for configuring + this extension. + :paramtype configuration_settings: dict[str, str] + :keyword configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :paramtype configuration_protected_settings: dict[str, str] + """ + super().__init__(**kwargs) + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.release_train = release_train + self.version = version + self.configuration_settings = configuration_settings + self.configuration_protected_settings = configuration_protected_settings + + +class Plan(_serialization.Model): + """Plan for the resource. + + All required parameters must be populated in order to send to Azure. + + :ivar name: A user defined name of the 3rd Party Artifact that is being procured. Required. + :vartype name: str + :ivar publisher: The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic. + Required. + :vartype publisher: str + :ivar product: The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to + the OfferID specified for the artifact at the time of Data Market onboarding. Required. + :vartype product: str + :ivar promotion_code: A publisher provided promotion code as provisioned in Data Market for the + said product/artifact. + :vartype promotion_code: str + :ivar version: The version of the desired product/artifact. + :vartype version: str + """ + + _validation = { + "name": {"required": True}, + "publisher": {"required": True}, + "product": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + publisher: str, + product: str, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: A user defined name of the 3rd Party Artifact that is being procured. Required. + :paramtype name: str + :keyword publisher: The publisher of the 3rd Party Artifact that is being bought. E.g. + NewRelic. Required. + :paramtype publisher: str + :keyword product: The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to + the OfferID specified for the artifact at the time of Data Market onboarding. Required. + :paramtype product: str + :keyword promotion_code: A publisher provided promotion code as provisioned in Data Market for + the said product/artifact. + :paramtype promotion_code: str + :keyword version: The version of the desired product/artifact. + :paramtype version: str + """ + super().__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class PrivateEndpoint(_serialization.Model): + """The Private Endpoint resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ARM identifier for Private Endpoint. + :vartype id: str + """ + + _validation = { + "id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + + +class PrivateEndpointConnection(ResourceAutoGenerated): + """The Private Endpoint Connection resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.SystemData + :ivar private_endpoint: The resource of private end point. + :vartype private_endpoint: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. + :vartype private_link_service_connection_state: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateLinkServiceConnectionState + :ivar provisioning_state: The provisioning state of the private endpoint connection resource. + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointConnectionProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, + **kwargs: Any + ) -> None: + """ + :keyword private_endpoint: The resource of private end point. + :paramtype private_endpoint: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpoint + :keyword private_link_service_connection_state: A collection of information about the state of + the connection between service consumer and provider. + :paramtype private_link_service_connection_state: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateLinkServiceConnectionState + """ + super().__init__(**kwargs) + self.private_endpoint = private_endpoint + self.private_link_service_connection_state = private_link_service_connection_state + self.provisioning_state = None + + +class PrivateEndpointConnectionListResult(_serialization.Model): + """List of private endpoint connection associated with the specified storage account. + + :ivar value: Array of private endpoint connections. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointConnection] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + } + + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Array of private endpoint connections. + :paramtype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointConnection] + """ + super().__init__(**kwargs) + self.value = value + + +class PrivateLinkResource(ResourceAutoGenerated): + """A private link resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.SystemData + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + :ivar required_zone_names: The private link resource Private link DNS zone name. + :vartype required_zone_names: list[str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"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"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, + } + + def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs: Any) -> None: + """ + :keyword required_zone_names: The private link resource Private link DNS zone name. + :paramtype required_zone_names: list[str] + """ + super().__init__(**kwargs) + self.group_id = None + self.required_members = None + self.required_zone_names = required_zone_names + + +class PrivateLinkResourceListResult(_serialization.Model): + """A list of private link resources. + + :ivar value: Array of private link resources. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateLinkResource] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + } + + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Array of private link resources. + :paramtype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateLinkResource] + """ + super().__init__(**kwargs) + self.value = value + + +class PrivateLinkServiceConnectionState(_serialization.Model): + """A collection of information about the state of the connection between service consumer and + provider. + + :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + of the service. Known values are: "Pending", "Approved", and "Rejected". + :vartype status: str or + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointServiceConnectionStatus + :ivar description: The reason for approval/rejection of the connection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :vartype actions_required: str + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, + description: Optional[str] = None, + actions_required: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the + owner of the service. Known values are: "Pending", "Approved", and "Rejected". + :paramtype status: str or + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointServiceConnectionStatus + :keyword description: The reason for approval/rejection of the connection. + :paramtype description: str + :keyword actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :paramtype actions_required: str + """ + super().__init__(**kwargs) + self.status = status + self.description = description + self.actions_required = actions_required + + +class Scope(_serialization.Model): + """Scope of the extension. It can be either Cluster or Namespace; but not both. + + :ivar cluster: Specifies that the scope of the extension is Cluster. + :vartype cluster: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.ScopeCluster + :ivar namespace: Specifies that the scope of the extension is Namespace. + :vartype namespace: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.ScopeNamespace + """ + + _attribute_map = { + "cluster": {"key": "cluster", "type": "ScopeCluster"}, + "namespace": {"key": "namespace", "type": "ScopeNamespace"}, + } + + def __init__( + self, + *, + cluster: Optional["_models.ScopeCluster"] = None, + namespace: Optional["_models.ScopeNamespace"] = None, + **kwargs: Any + ) -> None: + """ + :keyword cluster: Specifies that the scope of the extension is Cluster. + :paramtype cluster: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.ScopeCluster + :keyword namespace: Specifies that the scope of the extension is Namespace. + :paramtype namespace: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.ScopeNamespace + """ + super().__init__(**kwargs) + self.cluster = cluster + self.namespace = namespace + + +class ScopeCluster(_serialization.Model): + """Specifies that the scope of the extension is Cluster. + + :ivar release_namespace: Namespace where the extension Release must be placed, for a Cluster + scoped extension. If this namespace does not exist, it will be created. + :vartype release_namespace: str + """ + + _attribute_map = { + "release_namespace": {"key": "releaseNamespace", "type": "str"}, + } + + def __init__(self, *, release_namespace: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword release_namespace: Namespace where the extension Release must be placed, for a Cluster + scoped extension. If this namespace does not exist, it will be created. + :paramtype release_namespace: str + """ + super().__init__(**kwargs) + self.release_namespace = release_namespace + + +class ScopeNamespace(_serialization.Model): + """Specifies that the scope of the extension is Namespace. + + :ivar target_namespace: Namespace where the extension will be created for an Namespace scoped + extension. If this namespace does not exist, it will be created. + :vartype target_namespace: str + """ + + _attribute_map = { + "target_namespace": {"key": "targetNamespace", "type": "str"}, + } + + def __init__(self, *, target_namespace: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword target_namespace: Namespace where the extension will be created for an Namespace + scoped extension. If this namespace does not exist, it will be created. + :paramtype target_namespace: str + """ + super().__init__(**kwargs) + self.target_namespace = target_namespace + + +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.kubernetesconfiguration.v2022_04_02_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. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_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. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.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 TagsResource(_serialization.Model): + """A container holding only the Tags for a resource, allowing the user to update the tags on a + PrivateLinkScope instance. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/models/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/models/_source_control_configuration_client_enums.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/models/_source_control_configuration_client_enums.py new file mode 100644 index 000000000000..6a06958deeb8 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/models/_source_control_configuration_client_enums.py @@ -0,0 +1,75 @@ +# 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 AKSIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class LevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the status.""" + + ERROR = "Error" + WARNING = "Warning" + INFORMATION = "Information" + + +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current provisioning state.""" + + SUCCEEDED = "Succeeded" + CREATING = "Creating" + DELETING = "Deleting" + FAILED = "Failed" + + +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private endpoint connection status.""" + + PENDING = "Pending" + APPROVED = "Approved" + REJECTED = "Rejected" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource.""" + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + + +class PublicNetworkAccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The network access policy to determine if Azure Arc agents can use public Azure Arc service + endpoints. Defaults to disabled (access to Azure Arc services only via private link). + """ + + ENABLED = "Enabled" + """Allows Azure Arc agents to communicate with Azure Arc services over both public (internet) and + #: private endpoints.""" + DISABLED = "Disabled" + """Does not allow Azure Arc agents to communicate with Azure Arc services over public (internet) + #: endpoints. The agents must use the private link.""" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/__init__.py new file mode 100644 index 000000000000..15e6d84b033d --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/__init__.py @@ -0,0 +1,27 @@ +# 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 ._extensions_operations import ExtensionsOperations +from ._operation_status_operations import OperationStatusOperations +from ._private_link_scopes_operations import PrivateLinkScopesOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ExtensionsOperations", + "OperationStatusOperations", + "PrivateLinkScopesOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/_extensions_operations.py new file mode 100644 index 000000000000..db624fe08dba --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/_extensions_operations.py @@ -0,0 +1,1177 @@ +# 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_create_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_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-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_get_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_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-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_delete_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + subscription_id: str, + *, + force_delete: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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") + if force_delete is not None: + _params["forceDelete"] = _SERIALIZER.query("force_delete", force_delete, "bool") + + # 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, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_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-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_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-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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) + + +class ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: Union[_models.Extension, IO], + **kwargs: Any + ) -> _models.Extension: + 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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IO, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") + + request = build_create_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Extension", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension + :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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: Union[_models.Extension, IO], + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Is either a Extension type or a + IO type. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension] + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + extension=extension, + 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("Extension", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + **kwargs: Any + ) -> _models.Extension: + """Gets Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Extension or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + force_delete: Optional[bool] = None, + **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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + force_delete=force_delete, + 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 [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Delete a Kubernetes Cluster Extension. This will cause the Agent to Uninstall the extension + from the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param force_delete: Delete the extension resource in Azure - not the normal asynchronous + delete. Default value is None. + :type force_delete: bool + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + force_delete=force_delete, + 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, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + def _update_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: Union[_models.PatchExtension, IO], + **kwargs: Any + ) -> _models.Extension: + 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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(patch_extension, (IO, bytes)): + _content = patch_extension + else: + _json = self._serialize.body(patch_extension, "PatchExtension") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Extension", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: _models.PatchExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PatchExtension + :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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: Union[_models.PatchExtension, IO], + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Is either a + PatchExtension type or a IO type. Required. + :type patch_extension: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PatchExtension 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension] + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + patch_extension=patch_extension, + 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("Extension", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.Extension"]: + """List all Extensions in the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Extension or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.ExtensionsList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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("ExtensionsList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/_operation_status_operations.py new file mode 100644 index 000000000000..d0ff438202e9 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/_operation_status_operations.py @@ -0,0 +1,192 @@ +# 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, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + operation_id: 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-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "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) + + +class OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.SourceControlConfigurationClient`'s + :attr:`operation_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + operation_id: str, + **kwargs: Any + ) -> _models.OperationStatusResult: + """Get Async Operation status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param operation_id: operation Id. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.OperationStatusResult + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + operation_id=operation_id, + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/_private_endpoint_connections_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..2ecdd83512d4 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,732 @@ +# 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, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.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_get_request( + resource_group_name: str, + scope_name: str, + private_endpoint_connection_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-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_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, + scope_name: str, + private_endpoint_connection_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-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_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, + scope_name: str, + private_endpoint_connection_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-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_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_list_by_private_link_scope_request( + resource_group_name: str, scope_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-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections", + ) # 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 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_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) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.SourceControlConfigurationClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointConnection + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + 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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointConnection + :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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: 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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a + PrivateEndpointConnection type or a IO type. Required. + :type properties: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointConnection 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 PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointConnection] + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = 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, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_name, + properties=properties, + 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("PrivateEndpointConnection", 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.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, scope_name: str, private_endpoint_connection_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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_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 [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + 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, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_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.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace + def list_by_private_link_scope( + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnectionListResult: + """Gets all private endpoint connections on a private link scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnectionListResult or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateEndpointConnectionListResult + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + request = build_list_by_private_link_scope_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_private_link_scope.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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_private_link_scope.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateEndpointConnections" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/_private_link_resources_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..f760c6a65ae4 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/_private_link_resources_operations.py @@ -0,0 +1,266 @@ +# 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, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_private_link_scope_request( + resource_group_name: str, scope_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-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateLinkResources", + ) # 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 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_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_get_request( + resource_group_name: str, scope_name: str, 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-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}", + ) # 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 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + "groupName": _SERIALIZER.url("group_name", group_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) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.SourceControlConfigurationClient`'s + :attr:`private_link_resources` 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_by_private_link_scope( + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResourceListResult or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateLinkResourceListResult + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + request = build_list_by_private_link_scope_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_private_link_scope.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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_private_link_scope.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateLinkResources" + } + + @distributed_trace + def get( + self, resource_group_name: str, scope_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param group_name: The name of the private link resource. Required. + :type group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.PrivateLinkResource + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + group_name=group_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/_private_link_scopes_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/_private_link_scopes_operations.py new file mode 100644 index 000000000000..87dd92f844bd --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/operations/_private_link_scopes_operations.py @@ -0,0 +1,939 @@ +# 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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes" + ) # 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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes", + ) # pylint: disable=line-too-long + path_format_arguments = { + "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), + } + + _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_delete_request(resource_group_name: str, scope_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-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "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), + "scopeName": _SERIALIZER.url("scope_name", scope_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_get_request(resource_group_name: str, scope_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-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "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), + "scopeName": _SERIALIZER.url("scope_name", scope_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, scope_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-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "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), + "scopeName": _SERIALIZER.url("scope_name", scope_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_update_tags_request( + resource_group_name: str, scope_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-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "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), + "scopeName": _SERIALIZER.url("scope_name", scope_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) + + +class PrivateLinkScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.SourceControlConfigurationClient`'s + :attr:`private_link_scopes` 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.KubernetesConfigurationPrivateLinkScope"]: + """Gets a list of all Azure Arc PrivateLinkScopes within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either KubernetesConfigurationPrivateLinkScope or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.KubernetesConfigurationPrivateLinkScopeListResult] = 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("KubernetesConfigurationPrivateLinkScopeListResult", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes" + } + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.KubernetesConfigurationPrivateLinkScope"]: + """Gets a list of Azure Arc PrivateLinkScopes within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either KubernetesConfigurationPrivateLinkScope or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.KubernetesConfigurationPrivateLinkScopeListResult] = 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("KubernetesConfigurationPrivateLinkScopeListResult", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, scope_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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + scope_name=scope_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 [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}" + } + + @distributed_trace + def begin_delete(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a Azure Arc PrivateLinkScope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + 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, + scope_name=scope_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.KubernetesConfiguration/privateLinkScopes/{scopeName}" + } + + @distributed_trace + def get( + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> _models.KubernetesConfigurationPrivateLinkScope: + """Returns a Azure Arc PrivateLinkScope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: KubernetesConfigurationPrivateLinkScope or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + cls: ClsType[_models.KubernetesConfigurationPrivateLinkScope] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + scope_name=scope_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("KubernetesConfigurationPrivateLinkScope", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + scope_name: str, + parameters: _models.KubernetesConfigurationPrivateLinkScope, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.KubernetesConfigurationPrivateLinkScope: + """Creates (or updates) a Azure Arc PrivateLinkScope. Note: You cannot specify a different value + for InstrumentationKey nor AppId in the Put operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param parameters: Properties that need to be specified to create or update a Azure Arc for + Servers and Clusters PrivateLinkScope. Required. + :type parameters: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope + :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: KubernetesConfigurationPrivateLinkScope or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + scope_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.KubernetesConfigurationPrivateLinkScope: + """Creates (or updates) a Azure Arc PrivateLinkScope. Note: You cannot specify a different value + for InstrumentationKey nor AppId in the Put operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param parameters: Properties that need to be specified to create or update a Azure Arc for + Servers and Clusters PrivateLinkScope. 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: KubernetesConfigurationPrivateLinkScope or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + scope_name: str, + parameters: Union[_models.KubernetesConfigurationPrivateLinkScope, IO], + **kwargs: Any + ) -> _models.KubernetesConfigurationPrivateLinkScope: + """Creates (or updates) a Azure Arc PrivateLinkScope. Note: You cannot specify a different value + for InstrumentationKey nor AppId in the Put operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param parameters: Properties that need to be specified to create or update a Azure Arc for + Servers and Clusters PrivateLinkScope. Is either a KubernetesConfigurationPrivateLinkScope type + or a IO type. Required. + :type parameters: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope + 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: KubernetesConfigurationPrivateLinkScope or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.KubernetesConfigurationPrivateLinkScope] = 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, "KubernetesConfigurationPrivateLinkScope") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + scope_name=scope_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("KubernetesConfigurationPrivateLinkScope", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("KubernetesConfigurationPrivateLinkScope", 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.KubernetesConfiguration/privateLinkScopes/{scopeName}" + } + + @overload + def update_tags( + self, + resource_group_name: str, + scope_name: str, + private_link_scope_tags: _models.TagsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.KubernetesConfigurationPrivateLinkScope: + """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope + instance. Required. + :type private_link_scope_tags: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.TagsResource + :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: KubernetesConfigurationPrivateLinkScope or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + scope_name: str, + private_link_scope_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.KubernetesConfigurationPrivateLinkScope: + """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope + instance. Required. + :type private_link_scope_tags: 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: KubernetesConfigurationPrivateLinkScope or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + scope_name: str, + private_link_scope_tags: Union[_models.TagsResource, IO], + **kwargs: Any + ) -> _models.KubernetesConfigurationPrivateLinkScope: + """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Arc PrivateLinkScope resource. Required. + :type scope_name: str + :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope + instance. Is either a TagsResource type or a IO type. Required. + :type private_link_scope_tags: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.TagsResource 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: KubernetesConfigurationPrivateLinkScope or the result of cls(response) + :rtype: + ~azure.mgmt.kubernetesconfiguration.v2022_04_02_preview.models.KubernetesConfigurationPrivateLinkScope + :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-04-02-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-02-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.KubernetesConfigurationPrivateLinkScope] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_link_scope_tags, (IO, bytes)): + _content = private_link_scope_tags + else: + _json = self._serialize.body(private_link_scope_tags, "TagsResource") + + request = build_update_tags_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update_tags.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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("KubernetesConfigurationPrivateLinkScope", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KubernetesConfiguration/privateLinkScopes/{scopeName}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/py.typed b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_04_02_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/__init__.py new file mode 100644 index 000000000000..3ad4bd8b604e --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/__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 ._source_control_configuration_client import SourceControlConfigurationClient +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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/_configuration.py new file mode 100644 index 000000000000..d180d4953336 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/_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 SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for SourceControlConfigurationClient. + + 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-07-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: + super(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2022-07-01"] = kwargs.pop("api_version", "2022-07-01") + + 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-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/_metadata.json b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/_metadata.json new file mode 100644 index 000000000000..fa22caeda3c0 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/_metadata.json @@ -0,0 +1,115 @@ +{ + "chosen_version": "2022-07-01", + "total_api_version_list": ["2022-07-01"], + "client": { + "name": "SourceControlConfigurationClient", + "filename": "_source_control_configuration_client", + "description": "KubernetesConfiguration Client.", + "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\": [\"SourceControlConfigurationClientConfiguration\"], \".._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\": [\"SourceControlConfigurationClientConfiguration\"], \"..._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, + "method_location": "positional" + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", + "docstring_type": "str", + "required": true, + "method_location": "positional" + } + }, + "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, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + }, + "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, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + } + } + }, + "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": { + "extensions": "ExtensionsOperations", + "operation_status": "OperationStatusOperations", + "flux_configurations": "FluxConfigurationsOperations", + "flux_config_operation_status": "FluxConfigOperationStatusOperations", + "source_control_configurations": "SourceControlConfigurationsOperations", + "operations": "Operations" + } +} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/_source_control_configuration_client.py new file mode 100644 index 000000000000..e3d5d1323b8c --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/_source_control_configuration_client.py @@ -0,0 +1,126 @@ +# 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 SourceControlConfigurationClientConfiguration +from .operations import ( + ExtensionsOperations, + FluxConfigOperationStatusOperations, + FluxConfigurationsOperations, + OperationStatusOperations, + Operations, + SourceControlConfigurationsOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword + """KubernetesConfiguration Client. + + :ivar extensions: ExtensionsOperations operations + :vartype extensions: + azure.mgmt.kubernetesconfiguration.v2022_07_01.operations.ExtensionsOperations + :ivar operation_status: OperationStatusOperations operations + :vartype operation_status: + azure.mgmt.kubernetesconfiguration.v2022_07_01.operations.OperationStatusOperations + :ivar flux_configurations: FluxConfigurationsOperations operations + :vartype flux_configurations: + azure.mgmt.kubernetesconfiguration.v2022_07_01.operations.FluxConfigurationsOperations + :ivar flux_config_operation_status: FluxConfigOperationStatusOperations operations + :vartype flux_config_operation_status: + azure.mgmt.kubernetesconfiguration.v2022_07_01.operations.FluxConfigOperationStatusOperations + :ivar source_control_configurations: SourceControlConfigurationsOperations operations + :vartype source_control_configurations: + azure.mgmt.kubernetesconfiguration.v2022_07_01.operations.SourceControlConfigurationsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.kubernetesconfiguration.v2022_07_01.operations.Operations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-07-01". 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 = SourceControlConfigurationClientConfiguration( + 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.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_configurations = FluxConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_config_operation_status = FluxConfigOperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **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) -> "SourceControlConfigurationClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/_vendor.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/_vendor.py new file mode 100644 index 000000000000..bd0df84f5319 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/_vendor.py @@ -0,0 +1,30 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import List, cast + +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: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/_version.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/_version.py new file mode 100644 index 000000000000..59deb8c7263b --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/_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.1.0" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/__init__.py new file mode 100644 index 000000000000..b95230ae03c5 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/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 ._source_control_configuration_client import SourceControlConfigurationClient + +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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/_configuration.py new file mode 100644 index 000000000000..f2d295e9ad80 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/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 SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for SourceControlConfigurationClient. + + 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-07-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: + super(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2022-07-01"] = kwargs.pop("api_version", "2022-07-01") + + 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-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/_source_control_configuration_client.py new file mode 100644 index 000000000000..8aa09d569f0b --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/_source_control_configuration_client.py @@ -0,0 +1,126 @@ +# 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 SourceControlConfigurationClientConfiguration +from .operations import ( + ExtensionsOperations, + FluxConfigOperationStatusOperations, + FluxConfigurationsOperations, + OperationStatusOperations, + Operations, + SourceControlConfigurationsOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword + """KubernetesConfiguration Client. + + :ivar extensions: ExtensionsOperations operations + :vartype extensions: + azure.mgmt.kubernetesconfiguration.v2022_07_01.aio.operations.ExtensionsOperations + :ivar operation_status: OperationStatusOperations operations + :vartype operation_status: + azure.mgmt.kubernetesconfiguration.v2022_07_01.aio.operations.OperationStatusOperations + :ivar flux_configurations: FluxConfigurationsOperations operations + :vartype flux_configurations: + azure.mgmt.kubernetesconfiguration.v2022_07_01.aio.operations.FluxConfigurationsOperations + :ivar flux_config_operation_status: FluxConfigOperationStatusOperations operations + :vartype flux_config_operation_status: + azure.mgmt.kubernetesconfiguration.v2022_07_01.aio.operations.FluxConfigOperationStatusOperations + :ivar source_control_configurations: SourceControlConfigurationsOperations operations + :vartype source_control_configurations: + azure.mgmt.kubernetesconfiguration.v2022_07_01.aio.operations.SourceControlConfigurationsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.kubernetesconfiguration.v2022_07_01.aio.operations.Operations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-07-01". 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 = SourceControlConfigurationClientConfiguration( + 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.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_configurations = FluxConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_config_operation_status = FluxConfigOperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **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) -> "SourceControlConfigurationClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/__init__.py new file mode 100644 index 000000000000..9d58b5443a05 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/__init__.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._extensions_operations import ExtensionsOperations +from ._operation_status_operations import OperationStatusOperations +from ._flux_configurations_operations import FluxConfigurationsOperations +from ._flux_config_operation_status_operations import FluxConfigOperationStatusOperations +from ._source_control_configurations_operations import SourceControlConfigurationsOperations +from ._operations import Operations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ExtensionsOperations", + "OperationStatusOperations", + "FluxConfigurationsOperations", + "FluxConfigOperationStatusOperations", + "SourceControlConfigurationsOperations", + "Operations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_extensions_operations.py new file mode 100644 index 000000000000..769091459e14 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_extensions_operations.py @@ -0,0 +1,945 @@ +# 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._extensions_operations import ( + build_create_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 ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_07_01.aio.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: Union[_models.Extension, IO], + **kwargs: Any + ) -> _models.Extension: + 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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IO, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") + + request = build_create_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Extension", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension + :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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: Union[_models.Extension, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Is either a Extension type or a + IO type. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension] + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + extension=extension, + 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("Extension", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + **kwargs: Any + ) -> _models.Extension: + """Gets Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Extension or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + force_delete: Optional[bool] = None, + **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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + force_delete=force_delete, + 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 [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a Kubernetes Cluster Extension. This will cause the Agent to Uninstall the extension + from the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param force_delete: Delete the extension resource in Azure - not the normal asynchronous + delete. Default value is None. + :type force_delete: bool + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-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( # type: ignore + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + force_delete=force_delete, + 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, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + async def _update_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: Union[_models.PatchExtension, IO], + **kwargs: Any + ) -> _models.Extension: + 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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(patch_extension, (IO, bytes)): + _content = patch_extension + else: + _json = self._serialize.body(patch_extension, "PatchExtension") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Extension", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: _models.PatchExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.PatchExtension + :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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: Union[_models.PatchExtension, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Is either a + PatchExtension type or a IO type. Required. + :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.PatchExtension 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension] + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + patch_extension=patch_extension, + 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("Extension", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Extension"]: + """List all Extensions in the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Extension or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.ExtensionsList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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("ExtensionsList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_flux_config_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_flux_config_operation_status_operations.py new file mode 100644 index 000000000000..5586fb5783d8 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_flux_config_operation_status_operations.py @@ -0,0 +1,141 @@ +# 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, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._flux_config_operation_status_operations import build_get_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 FluxConfigOperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_07_01.aio.SourceControlConfigurationClient`'s + :attr:`flux_config_operation_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + operation_id: str, + **kwargs: Any + ) -> _models.OperationStatusResult: + """Get Async Operation status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param operation_id: operation Id. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.OperationStatusResult + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + operation_id=operation_id, + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_flux_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_flux_configurations_operations.py new file mode 100644 index 000000000000..65a3d3541c01 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_flux_configurations_operations.py @@ -0,0 +1,950 @@ +# 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._flux_configurations_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 FluxConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_07_01.aio.SourceControlConfigurationClient`'s + :attr:`flux_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + **kwargs: Any + ) -> _models.FluxConfiguration: + """Gets details of the Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FluxConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: Union[_models.FluxConfiguration, IO], + **kwargs: Any + ) -> _models.FluxConfiguration: + 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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration, (IO, bytes)): + _content = flux_configuration + else: + _json = self._serialize.body(flux_configuration, "FluxConfiguration") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("FluxConfiguration", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: _models.FluxConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: Union[_models.FluxConfiguration, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Is either a + FluxConfiguration type or a IO type. Required. + :type flux_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration] + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + flux_configuration=flux_configuration, + 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("FluxConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + async def _update_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], + **kwargs: Any + ) -> _models.FluxConfiguration: + 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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration_patch, (IO, bytes)): + _content = flux_configuration_patch + else: + _json = self._serialize.body(flux_configuration_patch, "FluxConfigurationPatch") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: _models.FluxConfigurationPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. + :type flux_configuration_patch: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfigurationPatch + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. + :type flux_configuration_patch: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. Is + either a FluxConfigurationPatch type or a IO type. Required. + :type flux_configuration_patch: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfigurationPatch 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration] + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + flux_configuration_patch=flux_configuration_patch, + 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("FluxConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + force_delete: Optional[bool] = None, + **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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + subscription_id=self._config.subscription_id, + force_delete=force_delete, + 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 [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """This will delete the YAML file used to set up the Flux Configuration, thus stopping future sync + from the source repo. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param force_delete: Delete the extension resource in Azure - not the normal asynchronous + delete. Default value is None. + :type force_delete: bool + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-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( # type: ignore + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + force_delete=force_delete, + 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, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.FluxConfiguration"]: + """List all Flux Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FluxConfiguration or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.FluxConfigurationsList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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("FluxConfigurationsList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_operation_status_operations.py new file mode 100644 index 000000000000..8d6cac20a17f --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_operation_status_operations.py @@ -0,0 +1,245 @@ +# 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.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._operation_status_operations import build_get_request, 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 OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_07_01.aio.SourceControlConfigurationClient`'s + :attr:`operation_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + operation_id: str, + **kwargs: Any + ) -> _models.OperationStatusResult: + """Get Async Operation status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param operation_id: operation Id. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.OperationStatusResult + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + operation_id=operation_id, + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.OperationStatusResult"]: + """List Async Operations, currently in progress, in a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.OperationStatusList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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("OperationStatusList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_operations.py new file mode 100644 index 000000000000..b491e9d37652 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/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.kubernetesconfiguration.v2022_07_01.aio.SourceControlConfigurationClient`'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.ResourceProviderOperation"]: + """List all the available operations the KubernetesConfiguration resource provider supports. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceProviderOperation or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.ResourceProviderOperationList] = 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("ResourceProviderOperationList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_source_control_configurations_operations.py new file mode 100644 index 000000000000..e01caa39e5ec --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/aio/operations/_source_control_configurations_operations.py @@ -0,0 +1,574 @@ +# 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._source_control_configurations_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + 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 SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_07_01.aio.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Gets details of the Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceControlConfiguration + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceControlConfiguration + :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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceControlConfiguration 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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceControlConfiguration + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SourceControlConfiguration", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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 [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """This will delete the YAML file used to set up the Source control configuration, thus stopping + future sync from the source repo. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-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( # type: ignore + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SourceControlConfiguration"]: + """List all Source Control Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SourceControlConfiguration or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.SourceControlConfigurationList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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("SourceControlConfigurationList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/models/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/models/__init__.py new file mode 100644 index 000000000000..ec64905f8638 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/models/__init__.py @@ -0,0 +1,131 @@ +# 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 AzureBlobDefinition +from ._models_py3 import AzureBlobPatchDefinition +from ._models_py3 import BucketDefinition +from ._models_py3 import BucketPatchDefinition +from ._models_py3 import ComplianceStatus +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import Extension +from ._models_py3 import ExtensionPropertiesAksAssignedIdentity +from ._models_py3 import ExtensionStatus +from ._models_py3 import ExtensionsList +from ._models_py3 import FluxConfiguration +from ._models_py3 import FluxConfigurationPatch +from ._models_py3 import FluxConfigurationsList +from ._models_py3 import GitRepositoryDefinition +from ._models_py3 import GitRepositoryPatchDefinition +from ._models_py3 import HelmOperatorProperties +from ._models_py3 import HelmReleasePropertiesDefinition +from ._models_py3 import Identity +from ._models_py3 import KustomizationDefinition +from ._models_py3 import KustomizationPatchDefinition +from ._models_py3 import ManagedIdentityDefinition +from ._models_py3 import ManagedIdentityPatchDefinition +from ._models_py3 import ObjectReferenceDefinition +from ._models_py3 import ObjectStatusConditionDefinition +from ._models_py3 import ObjectStatusDefinition +from ._models_py3 import OperationStatusList +from ._models_py3 import OperationStatusResult +from ._models_py3 import PatchExtension +from ._models_py3 import ProxyResource +from ._models_py3 import RepositoryRefDefinition +from ._models_py3 import Resource +from ._models_py3 import ResourceProviderOperation +from ._models_py3 import ResourceProviderOperationDisplay +from ._models_py3 import ResourceProviderOperationList +from ._models_py3 import Scope +from ._models_py3 import ScopeCluster +from ._models_py3 import ScopeNamespace +from ._models_py3 import ServicePrincipalDefinition +from ._models_py3 import ServicePrincipalPatchDefinition +from ._models_py3 import SourceControlConfiguration +from ._models_py3 import SourceControlConfigurationList +from ._models_py3 import SystemData + +from ._source_control_configuration_client_enums import AKSIdentityType +from ._source_control_configuration_client_enums import ComplianceStateType +from ._source_control_configuration_client_enums import CreatedByType +from ._source_control_configuration_client_enums import FluxComplianceState +from ._source_control_configuration_client_enums import KustomizationValidationType +from ._source_control_configuration_client_enums import LevelType +from ._source_control_configuration_client_enums import MessageLevelType +from ._source_control_configuration_client_enums import OperatorScopeType +from ._source_control_configuration_client_enums import OperatorType +from ._source_control_configuration_client_enums import ProvisioningState +from ._source_control_configuration_client_enums import ProvisioningStateType +from ._source_control_configuration_client_enums import ScopeType +from ._source_control_configuration_client_enums import SourceKindType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AzureBlobDefinition", + "AzureBlobPatchDefinition", + "BucketDefinition", + "BucketPatchDefinition", + "ComplianceStatus", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "Extension", + "ExtensionPropertiesAksAssignedIdentity", + "ExtensionStatus", + "ExtensionsList", + "FluxConfiguration", + "FluxConfigurationPatch", + "FluxConfigurationsList", + "GitRepositoryDefinition", + "GitRepositoryPatchDefinition", + "HelmOperatorProperties", + "HelmReleasePropertiesDefinition", + "Identity", + "KustomizationDefinition", + "KustomizationPatchDefinition", + "ManagedIdentityDefinition", + "ManagedIdentityPatchDefinition", + "ObjectReferenceDefinition", + "ObjectStatusConditionDefinition", + "ObjectStatusDefinition", + "OperationStatusList", + "OperationStatusResult", + "PatchExtension", + "ProxyResource", + "RepositoryRefDefinition", + "Resource", + "ResourceProviderOperation", + "ResourceProviderOperationDisplay", + "ResourceProviderOperationList", + "Scope", + "ScopeCluster", + "ScopeNamespace", + "ServicePrincipalDefinition", + "ServicePrincipalPatchDefinition", + "SourceControlConfiguration", + "SourceControlConfigurationList", + "SystemData", + "AKSIdentityType", + "ComplianceStateType", + "CreatedByType", + "FluxComplianceState", + "KustomizationValidationType", + "LevelType", + "MessageLevelType", + "OperatorScopeType", + "OperatorType", + "ProvisioningState", + "ProvisioningStateType", + "ScopeType", + "SourceKindType", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/models/_models_py3.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/models/_models_py3.py new file mode 100644 index 000000000000..0eaba5a2d23f --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/models/_models_py3.py @@ -0,0 +1,2587 @@ +# 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 +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +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 .. import models as _models + + +class AzureBlobDefinition(_serialization.Model): + """Parameters to reconcile to the AzureBlob source kind type. + + :ivar url: The URL to sync for the flux configuration Azure Blob storage account. + :vartype url: str + :ivar container_name: The Azure Blob container name to sync from the url endpoint for the flux + configuration. + :vartype container_name: str + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster Azure Blob + source with the remote. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster Azure Blob + source with the remote. + :vartype sync_interval_in_seconds: int + :ivar service_principal: Parameters to authenticate using Service Principal. + :vartype service_principal: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ServicePrincipalDefinition + :ivar account_key: The account key (shared key) to access the storage account. + :vartype account_key: str + :ivar sas_token: The Shared Access token to access the storage container. + :vartype sas_token: str + :ivar managed_identity: Parameters to authenticate using a Managed Identity. + :vartype managed_identity: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ManagedIdentityDefinition + :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :vartype local_auth_ref: str + """ + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "service_principal": {"key": "servicePrincipal", "type": "ServicePrincipalDefinition"}, + "account_key": {"key": "accountKey", "type": "str"}, + "sas_token": {"key": "sasToken", "type": "str"}, + "managed_identity": {"key": "managedIdentity", "type": "ManagedIdentityDefinition"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + container_name: Optional[str] = None, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, + service_principal: Optional["_models.ServicePrincipalDefinition"] = None, + account_key: Optional[str] = None, + sas_token: Optional[str] = None, + managed_identity: Optional["_models.ManagedIdentityDefinition"] = None, + local_auth_ref: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword url: The URL to sync for the flux configuration Azure Blob storage account. + :paramtype url: str + :keyword container_name: The Azure Blob container name to sync from the url endpoint for the + flux configuration. + :paramtype container_name: str + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster Azure Blob + source with the remote. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster Azure Blob + source with the remote. + :paramtype sync_interval_in_seconds: int + :keyword service_principal: Parameters to authenticate using Service Principal. + :paramtype service_principal: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ServicePrincipalDefinition + :keyword account_key: The account key (shared key) to access the storage account. + :paramtype account_key: str + :keyword sas_token: The Shared Access token to access the storage container. + :paramtype sas_token: str + :keyword managed_identity: Parameters to authenticate using a Managed Identity. + :paramtype managed_identity: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ManagedIdentityDefinition + :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :paramtype local_auth_ref: str + """ + super().__init__(**kwargs) + self.url = url + self.container_name = container_name + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.service_principal = service_principal + self.account_key = account_key + self.sas_token = sas_token + self.managed_identity = managed_identity + self.local_auth_ref = local_auth_ref + + +class AzureBlobPatchDefinition(_serialization.Model): + """Parameters to reconcile to the AzureBlob source kind type. + + :ivar url: The URL to sync for the flux configuration Azure Blob storage account. + :vartype url: str + :ivar container_name: The Azure Blob container name to sync from the url endpoint for the flux + configuration. + :vartype container_name: str + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster Azure Blob + source with the remote. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster Azure Blob + source with the remote. + :vartype sync_interval_in_seconds: int + :ivar service_principal: Parameters to authenticate using Service Principal. + :vartype service_principal: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ServicePrincipalPatchDefinition + :ivar account_key: The account key (shared key) to access the storage account. + :vartype account_key: str + :ivar sas_token: The Shared Access token to access the storage container. + :vartype sas_token: str + :ivar managed_identity: Parameters to authenticate using a Managed Identity. + :vartype managed_identity: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ManagedIdentityPatchDefinition + :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :vartype local_auth_ref: str + """ + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "service_principal": {"key": "servicePrincipal", "type": "ServicePrincipalPatchDefinition"}, + "account_key": {"key": "accountKey", "type": "str"}, + "sas_token": {"key": "sasToken", "type": "str"}, + "managed_identity": {"key": "managedIdentity", "type": "ManagedIdentityPatchDefinition"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + container_name: Optional[str] = None, + timeout_in_seconds: Optional[int] = None, + sync_interval_in_seconds: Optional[int] = None, + service_principal: Optional["_models.ServicePrincipalPatchDefinition"] = None, + account_key: Optional[str] = None, + sas_token: Optional[str] = None, + managed_identity: Optional["_models.ManagedIdentityPatchDefinition"] = None, + local_auth_ref: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword url: The URL to sync for the flux configuration Azure Blob storage account. + :paramtype url: str + :keyword container_name: The Azure Blob container name to sync from the url endpoint for the + flux configuration. + :paramtype container_name: str + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster Azure Blob + source with the remote. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster Azure Blob + source with the remote. + :paramtype sync_interval_in_seconds: int + :keyword service_principal: Parameters to authenticate using Service Principal. + :paramtype service_principal: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ServicePrincipalPatchDefinition + :keyword account_key: The account key (shared key) to access the storage account. + :paramtype account_key: str + :keyword sas_token: The Shared Access token to access the storage container. + :paramtype sas_token: str + :keyword managed_identity: Parameters to authenticate using a Managed Identity. + :paramtype managed_identity: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ManagedIdentityPatchDefinition + :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :paramtype local_auth_ref: str + """ + super().__init__(**kwargs) + self.url = url + self.container_name = container_name + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.service_principal = service_principal + self.account_key = account_key + self.sas_token = sas_token + self.managed_identity = managed_identity + self.local_auth_ref = local_auth_ref + + +class BucketDefinition(_serialization.Model): + """Parameters to reconcile to the Bucket source kind type. + + :ivar url: The URL to sync for the flux configuration S3 bucket. + :vartype url: str + :ivar bucket_name: The bucket name to sync from the url endpoint for the flux configuration. + :vartype bucket_name: str + :ivar insecure: Specify whether to use insecure communication when puling data from the S3 + bucket. + :vartype insecure: bool + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster bucket source + with the remote. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster bucket source + with the remote. + :vartype sync_interval_in_seconds: int + :ivar access_key: Plaintext access key used to securely access the S3 bucket. + :vartype access_key: str + :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :vartype local_auth_ref: str + """ + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + "bucket_name": {"key": "bucketName", "type": "str"}, + "insecure": {"key": "insecure", "type": "bool"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "access_key": {"key": "accessKey", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + bucket_name: Optional[str] = None, + insecure: bool = True, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, + access_key: Optional[str] = None, + local_auth_ref: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword url: The URL to sync for the flux configuration S3 bucket. + :paramtype url: str + :keyword bucket_name: The bucket name to sync from the url endpoint for the flux configuration. + :paramtype bucket_name: str + :keyword insecure: Specify whether to use insecure communication when puling data from the S3 + bucket. + :paramtype insecure: bool + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster bucket source + with the remote. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster bucket + source with the remote. + :paramtype sync_interval_in_seconds: int + :keyword access_key: Plaintext access key used to securely access the S3 bucket. + :paramtype access_key: str + :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :paramtype local_auth_ref: str + """ + super().__init__(**kwargs) + self.url = url + self.bucket_name = bucket_name + self.insecure = insecure + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.access_key = access_key + self.local_auth_ref = local_auth_ref + + +class BucketPatchDefinition(_serialization.Model): + """Parameters to reconcile to the Bucket source kind type. + + :ivar url: The URL to sync for the flux configuration S3 bucket. + :vartype url: str + :ivar bucket_name: The bucket name to sync from the url endpoint for the flux configuration. + :vartype bucket_name: str + :ivar insecure: Specify whether to use insecure communication when puling data from the S3 + bucket. + :vartype insecure: bool + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster bucket source + with the remote. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster bucket source + with the remote. + :vartype sync_interval_in_seconds: int + :ivar access_key: Plaintext access key used to securely access the S3 bucket. + :vartype access_key: str + :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :vartype local_auth_ref: str + """ + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + "bucket_name": {"key": "bucketName", "type": "str"}, + "insecure": {"key": "insecure", "type": "bool"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "access_key": {"key": "accessKey", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + bucket_name: Optional[str] = None, + insecure: Optional[bool] = None, + timeout_in_seconds: Optional[int] = None, + sync_interval_in_seconds: Optional[int] = None, + access_key: Optional[str] = None, + local_auth_ref: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword url: The URL to sync for the flux configuration S3 bucket. + :paramtype url: str + :keyword bucket_name: The bucket name to sync from the url endpoint for the flux configuration. + :paramtype bucket_name: str + :keyword insecure: Specify whether to use insecure communication when puling data from the S3 + bucket. + :paramtype insecure: bool + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster bucket source + with the remote. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster bucket + source with the remote. + :paramtype sync_interval_in_seconds: int + :keyword access_key: Plaintext access key used to securely access the S3 bucket. + :paramtype access_key: str + :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :paramtype local_auth_ref: str + """ + super().__init__(**kwargs) + self.url = url + self.bucket_name = bucket_name + self.insecure = insecure + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.access_key = access_key + self.local_auth_ref = local_auth_ref + + +class ComplianceStatus(_serialization.Model): + """Compliance Status details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar compliance_state: The compliance state of the configuration. Known values are: "Pending", + "Compliant", "Noncompliant", "Installed", and "Failed". + :vartype compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ComplianceStateType + :ivar last_config_applied: Datetime the configuration was last applied. + :vartype last_config_applied: ~datetime.datetime + :ivar message: Message from when the configuration was applied. + :vartype message: str + :ivar message_level: Level of the message. Known values are: "Error", "Warning", and + "Information". + :vartype message_level: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.MessageLevelType + """ + + _validation = { + "compliance_state": {"readonly": True}, + } + + _attribute_map = { + "compliance_state": {"key": "complianceState", "type": "str"}, + "last_config_applied": {"key": "lastConfigApplied", "type": "iso-8601"}, + "message": {"key": "message", "type": "str"}, + "message_level": {"key": "messageLevel", "type": "str"}, + } + + def __init__( + self, + *, + last_config_applied: Optional[datetime.datetime] = None, + message: Optional[str] = None, + message_level: Optional[Union[str, "_models.MessageLevelType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword last_config_applied: Datetime the configuration was last applied. + :paramtype last_config_applied: ~datetime.datetime + :keyword message: Message from when the configuration was applied. + :paramtype message: str + :keyword message_level: Level of the message. Known values are: "Error", "Warning", and + "Information". + :paramtype message_level: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.MessageLevelType + """ + super().__init__(**kwargs) + self.compliance_state = None + self.last_config_applied = last_config_applied + self.message = message + self.message_level = message_level + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +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 + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + + +class Extension(ProxyResource): # pylint: disable=too-many-instance-attributes + """The Extension object. + + 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 identity: Identity of the Extension resource. + :vartype identity: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Identity + :ivar system_data: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SystemData + :ivar extension_type: Type of the Extension, of which this resource is an instance of. It must + be one of the Extension Types registered with Microsoft.KubernetesConfiguration by the + Extension publisher. + :vartype extension_type: str + :ivar auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade + of minor version, or not. + :vartype auto_upgrade_minor_version: bool + :ivar release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. Stable, + Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :vartype release_train: str + :ivar version: User-specified version of the extension for this extension to 'pin'. To use + 'version', autoUpgradeMinorVersion must be 'false'. + :vartype version: str + :ivar scope: Scope at which the extension is installed. + :vartype scope: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Scope + :ivar configuration_settings: Configuration settings, as name-value pairs for configuring this + extension. + :vartype configuration_settings: dict[str, str] + :ivar configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :vartype configuration_protected_settings: dict[str, str] + :ivar installed_version: Installed version of the extension. + :vartype installed_version: str + :ivar provisioning_state: Status of installation of this extension. Known values are: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ProvisioningState + :ivar statuses: Status from this extension. + :vartype statuses: list[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ExtensionStatus] + :ivar error_info: Error information from the Agent - e.g. errors during installation. + :vartype error_info: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ErrorDetail + :ivar custom_location_settings: Custom Location settings properties. + :vartype custom_location_settings: dict[str, str] + :ivar package_uri: Uri of the Helm package. + :vartype package_uri: str + :ivar aks_assigned_identity: Identity of the Extension resource in an AKS cluster. + :vartype aks_assigned_identity: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ExtensionPropertiesAksAssignedIdentity + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "installed_version": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "error_info": {"readonly": True}, + "custom_location_settings": {"readonly": True}, + "package_uri": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "extension_type": {"key": "properties.extensionType", "type": "str"}, + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "scope": {"key": "properties.scope", "type": "Scope"}, + "configuration_settings": {"key": "properties.configurationSettings", "type": "{str}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "installed_version": {"key": "properties.installedVersion", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "statuses": {"key": "properties.statuses", "type": "[ExtensionStatus]"}, + "error_info": {"key": "properties.errorInfo", "type": "ErrorDetail"}, + "custom_location_settings": {"key": "properties.customLocationSettings", "type": "{str}"}, + "package_uri": {"key": "properties.packageUri", "type": "str"}, + "aks_assigned_identity": { + "key": "properties.aksAssignedIdentity", + "type": "ExtensionPropertiesAksAssignedIdentity", + }, + } + + def __init__( + self, + *, + identity: Optional["_models.Identity"] = None, + extension_type: Optional[str] = None, + auto_upgrade_minor_version: bool = True, + release_train: str = "Stable", + version: Optional[str] = None, + scope: Optional["_models.Scope"] = None, + configuration_settings: Optional[Dict[str, str]] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + statuses: Optional[List["_models.ExtensionStatus"]] = None, + aks_assigned_identity: Optional["_models.ExtensionPropertiesAksAssignedIdentity"] = None, + **kwargs: Any + ) -> None: + """ + :keyword identity: Identity of the Extension resource. + :paramtype identity: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Identity + :keyword extension_type: Type of the Extension, of which this resource is an instance of. It + must be one of the Extension Types registered with Microsoft.KubernetesConfiguration by the + Extension publisher. + :paramtype extension_type: str + :keyword auto_upgrade_minor_version: Flag to note if this extension participates in auto + upgrade of minor version, or not. + :paramtype auto_upgrade_minor_version: bool + :keyword release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. + Stable, Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :paramtype release_train: str + :keyword version: User-specified version of the extension for this extension to 'pin'. To use + 'version', autoUpgradeMinorVersion must be 'false'. + :paramtype version: str + :keyword scope: Scope at which the extension is installed. + :paramtype scope: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Scope + :keyword configuration_settings: Configuration settings, as name-value pairs for configuring + this extension. + :paramtype configuration_settings: dict[str, str] + :keyword configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :paramtype configuration_protected_settings: dict[str, str] + :keyword statuses: Status from this extension. + :paramtype statuses: + list[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ExtensionStatus] + :keyword aks_assigned_identity: Identity of the Extension resource in an AKS cluster. + :paramtype aks_assigned_identity: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ExtensionPropertiesAksAssignedIdentity + """ + super().__init__(**kwargs) + self.identity = identity + self.system_data = None + self.extension_type = extension_type + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.release_train = release_train + self.version = version + self.scope = scope + self.configuration_settings = configuration_settings + self.configuration_protected_settings = configuration_protected_settings + self.installed_version = None + self.provisioning_state = None + self.statuses = statuses + self.error_info = None + self.custom_location_settings = None + self.package_uri = None + self.aks_assigned_identity = aks_assigned_identity + + +class ExtensionPropertiesAksAssignedIdentity(_serialization.Model): + """Identity of the Extension resource in an AKS cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Known values are: "SystemAssigned" and "UserAssigned". + :vartype type: str or ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.AKSIdentityType + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Union[str, "_models.AKSIdentityType"]] = None, **kwargs: Any) -> None: + """ + :keyword type: The identity type. Known values are: "SystemAssigned" and "UserAssigned". + :paramtype type: str or ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.AKSIdentityType + """ + super().__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + + +class ExtensionsList(_serialization.Model): + """Result of the request to list Extensions. It contains a list of Extension objects and a URL + link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Extensions within a Kubernetes cluster. + :vartype value: list[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension] + :ivar next_link: URL to get the next set of extension objects, if any. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Extension]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class ExtensionStatus(_serialization.Model): + """Status from the extension. + + :ivar code: Status code provided by the Extension. + :vartype code: str + :ivar display_status: Short description of status of the extension. + :vartype display_status: str + :ivar level: Level of the status. Known values are: "Error", "Warning", and "Information". + :vartype level: str or ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.LevelType + :ivar message: Detailed message of the status from the Extension. + :vartype message: str + :ivar time: DateLiteral (per ISO8601) noting the time of installation status. + :vartype time: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "display_status": {"key": "displayStatus", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "time": {"key": "time", "type": "str"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + display_status: Optional[str] = None, + level: Union[str, "_models.LevelType"] = "Information", + message: Optional[str] = None, + time: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: Status code provided by the Extension. + :paramtype code: str + :keyword display_status: Short description of status of the extension. + :paramtype display_status: str + :keyword level: Level of the status. Known values are: "Error", "Warning", and "Information". + :paramtype level: str or ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.LevelType + :keyword message: Detailed message of the status from the Extension. + :paramtype message: str + :keyword time: DateLiteral (per ISO8601) noting the time of installation status. + :paramtype time: str + """ + super().__init__(**kwargs) + self.code = code + self.display_status = display_status + self.level = level + self.message = message + self.time = time + + +class FluxConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes + """The Flux Configuration object returned in Get & Put response. + + 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: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SystemData + :ivar scope: Scope at which the operator will be installed. Known values are: "cluster" and + "namespace". + :vartype scope: str or ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ScopeType + :ivar namespace: The namespace to which this configuration is installed to. Maximum of 253 + lower case alphanumeric characters, hyphen and period only. + :vartype namespace: str + :ivar source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository", "Bucket", and "AzureBlob". + :vartype source_kind: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceKindType + :ivar suspend: Whether this configuration should suspend its reconciliation of its + kustomizations and sources. + :vartype suspend: bool + :ivar git_repository: Parameters to reconcile to the GitRepository source kind type. + :vartype git_repository: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.GitRepositoryDefinition + :ivar bucket: Parameters to reconcile to the Bucket source kind type. + :vartype bucket: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.BucketDefinition + :ivar azure_blob: Parameters to reconcile to the AzureBlob source kind type. + :vartype azure_blob: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.AzureBlobDefinition + :ivar kustomizations: Array of kustomizations used to reconcile the artifact pulled by the + source type on the cluster. + :vartype kustomizations: dict[str, + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.KustomizationDefinition] + :ivar configuration_protected_settings: Key-value pairs of protected configuration settings for + the configuration. + :vartype configuration_protected_settings: dict[str, str] + :ivar statuses: Statuses of the Flux Kubernetes resources created by the fluxConfiguration or + created by the managed objects provisioned by the fluxConfiguration. + :vartype statuses: + list[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ObjectStatusDefinition] + :ivar repository_public_key: Public Key associated with this fluxConfiguration (either + generated within the cluster or provided by the user). + :vartype repository_public_key: str + :ivar source_synced_commit_id: Branch and/or SHA of the source commit synced with the cluster. + :vartype source_synced_commit_id: str + :ivar source_updated_at: Datetime the fluxConfiguration synced its source on the cluster. + :vartype source_updated_at: ~datetime.datetime + :ivar status_updated_at: Datetime the fluxConfiguration synced its status on the cluster with + Azure. + :vartype status_updated_at: ~datetime.datetime + :ivar compliance_state: Combined status of the Flux Kubernetes resources created by the + fluxConfiguration or created by the managed objects. Known values are: "Compliant", + "Non-Compliant", "Pending", "Suspended", and "Unknown". + :vartype compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxComplianceState + :ivar provisioning_state: Status of the creation of the fluxConfiguration. Known values are: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ProvisioningState + :ivar error_message: Error message returned to the user in the case of provisioning failure. + :vartype error_message: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "statuses": {"readonly": True}, + "repository_public_key": {"readonly": True}, + "source_synced_commit_id": {"readonly": True}, + "source_updated_at": {"readonly": True}, + "status_updated_at": {"readonly": True}, + "compliance_state": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "error_message": {"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"}, + "scope": {"key": "properties.scope", "type": "str"}, + "namespace": {"key": "properties.namespace", "type": "str"}, + "source_kind": {"key": "properties.sourceKind", "type": "str"}, + "suspend": {"key": "properties.suspend", "type": "bool"}, + "git_repository": {"key": "properties.gitRepository", "type": "GitRepositoryDefinition"}, + "bucket": {"key": "properties.bucket", "type": "BucketDefinition"}, + "azure_blob": {"key": "properties.azureBlob", "type": "AzureBlobDefinition"}, + "kustomizations": {"key": "properties.kustomizations", "type": "{KustomizationDefinition}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "statuses": {"key": "properties.statuses", "type": "[ObjectStatusDefinition]"}, + "repository_public_key": {"key": "properties.repositoryPublicKey", "type": "str"}, + "source_synced_commit_id": {"key": "properties.sourceSyncedCommitId", "type": "str"}, + "source_updated_at": {"key": "properties.sourceUpdatedAt", "type": "iso-8601"}, + "status_updated_at": {"key": "properties.statusUpdatedAt", "type": "iso-8601"}, + "compliance_state": {"key": "properties.complianceState", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "error_message": {"key": "properties.errorMessage", "type": "str"}, + } + + def __init__( + self, + *, + scope: Union[str, "_models.ScopeType"] = "cluster", + namespace: str = "default", + source_kind: Optional[Union[str, "_models.SourceKindType"]] = None, + suspend: bool = False, + git_repository: Optional["_models.GitRepositoryDefinition"] = None, + bucket: Optional["_models.BucketDefinition"] = None, + azure_blob: Optional["_models.AzureBlobDefinition"] = None, + kustomizations: Optional[Dict[str, "_models.KustomizationDefinition"]] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword scope: Scope at which the operator will be installed. Known values are: "cluster" and + "namespace". + :paramtype scope: str or ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ScopeType + :keyword namespace: The namespace to which this configuration is installed to. Maximum of 253 + lower case alphanumeric characters, hyphen and period only. + :paramtype namespace: str + :keyword source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository", "Bucket", and "AzureBlob". + :paramtype source_kind: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceKindType + :keyword suspend: Whether this configuration should suspend its reconciliation of its + kustomizations and sources. + :paramtype suspend: bool + :keyword git_repository: Parameters to reconcile to the GitRepository source kind type. + :paramtype git_repository: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.GitRepositoryDefinition + :keyword bucket: Parameters to reconcile to the Bucket source kind type. + :paramtype bucket: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.BucketDefinition + :keyword azure_blob: Parameters to reconcile to the AzureBlob source kind type. + :paramtype azure_blob: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.AzureBlobDefinition + :keyword kustomizations: Array of kustomizations used to reconcile the artifact pulled by the + source type on the cluster. + :paramtype kustomizations: dict[str, + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.KustomizationDefinition] + :keyword configuration_protected_settings: Key-value pairs of protected configuration settings + for the configuration. + :paramtype configuration_protected_settings: dict[str, str] + """ + super().__init__(**kwargs) + self.system_data = None + self.scope = scope + self.namespace = namespace + self.source_kind = source_kind + self.suspend = suspend + self.git_repository = git_repository + self.bucket = bucket + self.azure_blob = azure_blob + self.kustomizations = kustomizations + self.configuration_protected_settings = configuration_protected_settings + self.statuses = None + self.repository_public_key = None + self.source_synced_commit_id = None + self.source_updated_at = None + self.status_updated_at = None + self.compliance_state = None + self.provisioning_state = None + self.error_message = None + + +class FluxConfigurationPatch(_serialization.Model): + """The Flux Configuration Patch Request object. + + :ivar source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository", "Bucket", and "AzureBlob". + :vartype source_kind: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceKindType + :ivar suspend: Whether this configuration should suspend its reconciliation of its + kustomizations and sources. + :vartype suspend: bool + :ivar git_repository: Parameters to reconcile to the GitRepository source kind type. + :vartype git_repository: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.GitRepositoryPatchDefinition + :ivar bucket: Parameters to reconcile to the Bucket source kind type. + :vartype bucket: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.BucketPatchDefinition + :ivar azure_blob: Parameters to reconcile to the AzureBlob source kind type. + :vartype azure_blob: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.AzureBlobPatchDefinition + :ivar kustomizations: Array of kustomizations used to reconcile the artifact pulled by the + source type on the cluster. + :vartype kustomizations: dict[str, + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.KustomizationPatchDefinition] + :ivar configuration_protected_settings: Key-value pairs of protected configuration settings for + the configuration. + :vartype configuration_protected_settings: dict[str, str] + """ + + _attribute_map = { + "source_kind": {"key": "properties.sourceKind", "type": "str"}, + "suspend": {"key": "properties.suspend", "type": "bool"}, + "git_repository": {"key": "properties.gitRepository", "type": "GitRepositoryPatchDefinition"}, + "bucket": {"key": "properties.bucket", "type": "BucketPatchDefinition"}, + "azure_blob": {"key": "properties.azureBlob", "type": "AzureBlobPatchDefinition"}, + "kustomizations": {"key": "properties.kustomizations", "type": "{KustomizationPatchDefinition}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + } + + def __init__( + self, + *, + source_kind: Optional[Union[str, "_models.SourceKindType"]] = None, + suspend: Optional[bool] = None, + git_repository: Optional["_models.GitRepositoryPatchDefinition"] = None, + bucket: Optional["_models.BucketPatchDefinition"] = None, + azure_blob: Optional["_models.AzureBlobPatchDefinition"] = None, + kustomizations: Optional[Dict[str, "_models.KustomizationPatchDefinition"]] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository", "Bucket", and "AzureBlob". + :paramtype source_kind: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceKindType + :keyword suspend: Whether this configuration should suspend its reconciliation of its + kustomizations and sources. + :paramtype suspend: bool + :keyword git_repository: Parameters to reconcile to the GitRepository source kind type. + :paramtype git_repository: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.GitRepositoryPatchDefinition + :keyword bucket: Parameters to reconcile to the Bucket source kind type. + :paramtype bucket: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.BucketPatchDefinition + :keyword azure_blob: Parameters to reconcile to the AzureBlob source kind type. + :paramtype azure_blob: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.AzureBlobPatchDefinition + :keyword kustomizations: Array of kustomizations used to reconcile the artifact pulled by the + source type on the cluster. + :paramtype kustomizations: dict[str, + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.KustomizationPatchDefinition] + :keyword configuration_protected_settings: Key-value pairs of protected configuration settings + for the configuration. + :paramtype configuration_protected_settings: dict[str, str] + """ + super().__init__(**kwargs) + self.source_kind = source_kind + self.suspend = suspend + self.git_repository = git_repository + self.bucket = bucket + self.azure_blob = azure_blob + self.kustomizations = kustomizations + self.configuration_protected_settings = configuration_protected_settings + + +class FluxConfigurationsList(_serialization.Model): + """Result of the request to list Flux Configurations. It contains a list of FluxConfiguration + objects and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Flux Configurations within a Kubernetes cluster. + :vartype value: list[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration] + :ivar next_link: URL to get the next set of configuration objects, if any. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[FluxConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class GitRepositoryDefinition(_serialization.Model): + """Parameters to reconcile to the GitRepository source kind type. + + :ivar url: The URL to sync for the flux configuration git repository. + :vartype url: str + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository + source with the remote. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :vartype sync_interval_in_seconds: int + :ivar repository_ref: The source reference for the GitRepository object. + :vartype repository_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.RepositoryRefDefinition + :ivar ssh_known_hosts: Base64-encoded known_hosts value containing public SSH keys required to + access private git repositories over SSH. + :vartype ssh_known_hosts: str + :ivar https_user: Plaintext HTTPS username used to access private git repositories over HTTPS. + :vartype https_user: str + :ivar https_ca_cert: Base64-encoded HTTPS certificate authority contents used to access git + private git repositories over HTTPS. + :vartype https_ca_cert: str + :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :vartype local_auth_ref: str + """ + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "repository_ref": {"key": "repositoryRef", "type": "RepositoryRefDefinition"}, + "ssh_known_hosts": {"key": "sshKnownHosts", "type": "str"}, + "https_user": {"key": "httpsUser", "type": "str"}, + "https_ca_cert": {"key": "httpsCACert", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, + repository_ref: Optional["_models.RepositoryRefDefinition"] = None, + ssh_known_hosts: Optional[str] = None, + https_user: Optional[str] = None, + https_ca_cert: Optional[str] = None, + local_auth_ref: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword url: The URL to sync for the flux configuration git repository. + :paramtype url: str + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster git + repository source with the remote. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :paramtype sync_interval_in_seconds: int + :keyword repository_ref: The source reference for the GitRepository object. + :paramtype repository_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.RepositoryRefDefinition + :keyword ssh_known_hosts: Base64-encoded known_hosts value containing public SSH keys required + to access private git repositories over SSH. + :paramtype ssh_known_hosts: str + :keyword https_user: Plaintext HTTPS username used to access private git repositories over + HTTPS. + :paramtype https_user: str + :keyword https_ca_cert: Base64-encoded HTTPS certificate authority contents used to access git + private git repositories over HTTPS. + :paramtype https_ca_cert: str + :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :paramtype local_auth_ref: str + """ + super().__init__(**kwargs) + self.url = url + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.repository_ref = repository_ref + self.ssh_known_hosts = ssh_known_hosts + self.https_user = https_user + self.https_ca_cert = https_ca_cert + self.local_auth_ref = local_auth_ref + + +class GitRepositoryPatchDefinition(_serialization.Model): + """Parameters to reconcile to the GitRepository source kind type. + + :ivar url: The URL to sync for the flux configuration git repository. + :vartype url: str + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository + source with the remote. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :vartype sync_interval_in_seconds: int + :ivar repository_ref: The source reference for the GitRepository object. + :vartype repository_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.RepositoryRefDefinition + :ivar ssh_known_hosts: Base64-encoded known_hosts value containing public SSH keys required to + access private git repositories over SSH. + :vartype ssh_known_hosts: str + :ivar https_user: Plaintext HTTPS username used to access private git repositories over HTTPS. + :vartype https_user: str + :ivar https_ca_cert: Base64-encoded HTTPS certificate authority contents used to access git + private git repositories over HTTPS. + :vartype https_ca_cert: str + :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :vartype local_auth_ref: str + """ + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "repository_ref": {"key": "repositoryRef", "type": "RepositoryRefDefinition"}, + "ssh_known_hosts": {"key": "sshKnownHosts", "type": "str"}, + "https_user": {"key": "httpsUser", "type": "str"}, + "https_ca_cert": {"key": "httpsCACert", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + timeout_in_seconds: Optional[int] = None, + sync_interval_in_seconds: Optional[int] = None, + repository_ref: Optional["_models.RepositoryRefDefinition"] = None, + ssh_known_hosts: Optional[str] = None, + https_user: Optional[str] = None, + https_ca_cert: Optional[str] = None, + local_auth_ref: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword url: The URL to sync for the flux configuration git repository. + :paramtype url: str + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster git + repository source with the remote. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :paramtype sync_interval_in_seconds: int + :keyword repository_ref: The source reference for the GitRepository object. + :paramtype repository_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.RepositoryRefDefinition + :keyword ssh_known_hosts: Base64-encoded known_hosts value containing public SSH keys required + to access private git repositories over SSH. + :paramtype ssh_known_hosts: str + :keyword https_user: Plaintext HTTPS username used to access private git repositories over + HTTPS. + :paramtype https_user: str + :keyword https_ca_cert: Base64-encoded HTTPS certificate authority contents used to access git + private git repositories over HTTPS. + :paramtype https_ca_cert: str + :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :paramtype local_auth_ref: str + """ + super().__init__(**kwargs) + self.url = url + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.repository_ref = repository_ref + self.ssh_known_hosts = ssh_known_hosts + self.https_user = https_user + self.https_ca_cert = https_ca_cert + self.local_auth_ref = local_auth_ref + + +class HelmOperatorProperties(_serialization.Model): + """Properties for Helm operator. + + :ivar chart_version: Version of the operator Helm chart. + :vartype chart_version: str + :ivar chart_values: Values override for the operator Helm chart. + :vartype chart_values: str + """ + + _attribute_map = { + "chart_version": {"key": "chartVersion", "type": "str"}, + "chart_values": {"key": "chartValues", "type": "str"}, + } + + def __init__( + self, *, chart_version: Optional[str] = None, chart_values: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword chart_version: Version of the operator Helm chart. + :paramtype chart_version: str + :keyword chart_values: Values override for the operator Helm chart. + :paramtype chart_values: str + """ + super().__init__(**kwargs) + self.chart_version = chart_version + self.chart_values = chart_values + + +class HelmReleasePropertiesDefinition(_serialization.Model): + """Properties for HelmRelease objects. + + :ivar last_revision_applied: The revision number of the last released object change. + :vartype last_revision_applied: int + :ivar helm_chart_ref: The reference to the HelmChart object used as the source to this + HelmRelease. + :vartype helm_chart_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ObjectReferenceDefinition + :ivar failure_count: Total number of times that the HelmRelease failed to install or upgrade. + :vartype failure_count: int + :ivar install_failure_count: Number of times that the HelmRelease failed to install. + :vartype install_failure_count: int + :ivar upgrade_failure_count: Number of times that the HelmRelease failed to upgrade. + :vartype upgrade_failure_count: int + """ + + _attribute_map = { + "last_revision_applied": {"key": "lastRevisionApplied", "type": "int"}, + "helm_chart_ref": {"key": "helmChartRef", "type": "ObjectReferenceDefinition"}, + "failure_count": {"key": "failureCount", "type": "int"}, + "install_failure_count": {"key": "installFailureCount", "type": "int"}, + "upgrade_failure_count": {"key": "upgradeFailureCount", "type": "int"}, + } + + def __init__( + self, + *, + last_revision_applied: Optional[int] = None, + helm_chart_ref: Optional["_models.ObjectReferenceDefinition"] = None, + failure_count: Optional[int] = None, + install_failure_count: Optional[int] = None, + upgrade_failure_count: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword last_revision_applied: The revision number of the last released object change. + :paramtype last_revision_applied: int + :keyword helm_chart_ref: The reference to the HelmChart object used as the source to this + HelmRelease. + :paramtype helm_chart_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ObjectReferenceDefinition + :keyword failure_count: Total number of times that the HelmRelease failed to install or + upgrade. + :paramtype failure_count: int + :keyword install_failure_count: Number of times that the HelmRelease failed to install. + :paramtype install_failure_count: int + :keyword upgrade_failure_count: Number of times that the HelmRelease failed to upgrade. + :paramtype upgrade_failure_count: int + """ + super().__init__(**kwargs) + self.last_revision_applied = last_revision_applied + self.helm_chart_ref = helm_chart_ref + self.failure_count = failure_count + self.install_failure_count = install_failure_count + self.upgrade_failure_count = upgrade_failure_count + + +class Identity(_serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Default value is "SystemAssigned". + :vartype type: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: + """ + :keyword type: The identity type. Default value is "SystemAssigned". + :paramtype type: str + """ + super().__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + + +class KustomizationDefinition(_serialization.Model): + """The Kustomization defining how to reconcile the artifact pulled by the source type on the + cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Kustomization, matching the key in the Kustomizations object map. + :vartype name: str + :ivar path: The path in the source reference to reconcile on the cluster. + :vartype path: str + :ivar depends_on: Specifies other Kustomizations that this Kustomization depends on. This + Kustomization will not reconcile until all dependencies have completed their reconciliation. + :vartype depends_on: list[str] + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the + cluster. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the + cluster. + :vartype sync_interval_in_seconds: int + :ivar retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the + cluster in the event of failure on reconciliation. + :vartype retry_interval_in_seconds: int + :ivar prune: Enable/disable garbage collections of Kubernetes objects created by this + Kustomization. + :vartype prune: bool + :ivar force: Enable/disable re-creating Kubernetes resources on the cluster when patching fails + due to an immutable field change. + :vartype force: bool + """ + + _validation = { + "name": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "path": {"key": "path", "type": "str"}, + "depends_on": {"key": "dependsOn", "type": "[str]"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "retry_interval_in_seconds": {"key": "retryIntervalInSeconds", "type": "int"}, + "prune": {"key": "prune", "type": "bool"}, + "force": {"key": "force", "type": "bool"}, + } + + def __init__( + self, + *, + path: str = "", + depends_on: Optional[List[str]] = None, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, + retry_interval_in_seconds: Optional[int] = None, + prune: bool = False, + force: bool = False, + **kwargs: Any + ) -> None: + """ + :keyword path: The path in the source reference to reconcile on the cluster. + :paramtype path: str + :keyword depends_on: Specifies other Kustomizations that this Kustomization depends on. This + Kustomization will not reconcile until all dependencies have completed their reconciliation. + :paramtype depends_on: list[str] + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the + cluster. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on + the cluster. + :paramtype sync_interval_in_seconds: int + :keyword retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on + the cluster in the event of failure on reconciliation. + :paramtype retry_interval_in_seconds: int + :keyword prune: Enable/disable garbage collections of Kubernetes objects created by this + Kustomization. + :paramtype prune: bool + :keyword force: Enable/disable re-creating Kubernetes resources on the cluster when patching + fails due to an immutable field change. + :paramtype force: bool + """ + super().__init__(**kwargs) + self.name = None + self.path = path + self.depends_on = depends_on + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.retry_interval_in_seconds = retry_interval_in_seconds + self.prune = prune + self.force = force + + +class KustomizationPatchDefinition(_serialization.Model): + """The Kustomization defining how to reconcile the artifact pulled by the source type on the + cluster. + + :ivar path: The path in the source reference to reconcile on the cluster. + :vartype path: str + :ivar depends_on: Specifies other Kustomizations that this Kustomization depends on. This + Kustomization will not reconcile until all dependencies have completed their reconciliation. + :vartype depends_on: list[str] + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the + cluster. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the + cluster. + :vartype sync_interval_in_seconds: int + :ivar retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the + cluster in the event of failure on reconciliation. + :vartype retry_interval_in_seconds: int + :ivar prune: Enable/disable garbage collections of Kubernetes objects created by this + Kustomization. + :vartype prune: bool + :ivar force: Enable/disable re-creating Kubernetes resources on the cluster when patching fails + due to an immutable field change. + :vartype force: bool + """ + + _attribute_map = { + "path": {"key": "path", "type": "str"}, + "depends_on": {"key": "dependsOn", "type": "[str]"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "retry_interval_in_seconds": {"key": "retryIntervalInSeconds", "type": "int"}, + "prune": {"key": "prune", "type": "bool"}, + "force": {"key": "force", "type": "bool"}, + } + + def __init__( + self, + *, + path: Optional[str] = None, + depends_on: Optional[List[str]] = None, + timeout_in_seconds: Optional[int] = None, + sync_interval_in_seconds: Optional[int] = None, + retry_interval_in_seconds: Optional[int] = None, + prune: Optional[bool] = None, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword path: The path in the source reference to reconcile on the cluster. + :paramtype path: str + :keyword depends_on: Specifies other Kustomizations that this Kustomization depends on. This + Kustomization will not reconcile until all dependencies have completed their reconciliation. + :paramtype depends_on: list[str] + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the + cluster. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on + the cluster. + :paramtype sync_interval_in_seconds: int + :keyword retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on + the cluster in the event of failure on reconciliation. + :paramtype retry_interval_in_seconds: int + :keyword prune: Enable/disable garbage collections of Kubernetes objects created by this + Kustomization. + :paramtype prune: bool + :keyword force: Enable/disable re-creating Kubernetes resources on the cluster when patching + fails due to an immutable field change. + :paramtype force: bool + """ + super().__init__(**kwargs) + self.path = path + self.depends_on = depends_on + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.retry_interval_in_seconds = retry_interval_in_seconds + self.prune = prune + self.force = force + + +class ManagedIdentityDefinition(_serialization.Model): + """Parameters to authenticate using a Managed Identity. + + :ivar client_id: The client Id for authenticating a Managed Identity. + :vartype client_id: str + """ + + _attribute_map = { + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, *, client_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword client_id: The client Id for authenticating a Managed Identity. + :paramtype client_id: str + """ + super().__init__(**kwargs) + self.client_id = client_id + + +class ManagedIdentityPatchDefinition(_serialization.Model): + """Parameters to authenticate using a Managed Identity. + + :ivar client_id: The client Id for authenticating a Managed Identity. + :vartype client_id: str + """ + + _attribute_map = { + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, *, client_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword client_id: The client Id for authenticating a Managed Identity. + :paramtype client_id: str + """ + super().__init__(**kwargs) + self.client_id = client_id + + +class ObjectReferenceDefinition(_serialization.Model): + """Object reference to a Kubernetes object on a cluster. + + :ivar name: Name of the object. + :vartype name: str + :ivar namespace: Namespace of the object. + :vartype namespace: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, namespace: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: Name of the object. + :paramtype name: str + :keyword namespace: Namespace of the object. + :paramtype namespace: str + """ + super().__init__(**kwargs) + self.name = name + self.namespace = namespace + + +class ObjectStatusConditionDefinition(_serialization.Model): + """Status condition of Kubernetes object. + + :ivar last_transition_time: Last time this status condition has changed. + :vartype last_transition_time: ~datetime.datetime + :ivar message: A more verbose description of the object status condition. + :vartype message: str + :ivar reason: Reason for the specified status condition type status. + :vartype reason: str + :ivar status: Status of the Kubernetes object condition type. + :vartype status: str + :ivar type: Object status condition type for this object. + :vartype type: str + """ + + _attribute_map = { + "last_transition_time": {"key": "lastTransitionTime", "type": "iso-8601"}, + "message": {"key": "message", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + last_transition_time: Optional[datetime.datetime] = None, + message: Optional[str] = None, + reason: Optional[str] = None, + status: Optional[str] = None, + type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword last_transition_time: Last time this status condition has changed. + :paramtype last_transition_time: ~datetime.datetime + :keyword message: A more verbose description of the object status condition. + :paramtype message: str + :keyword reason: Reason for the specified status condition type status. + :paramtype reason: str + :keyword status: Status of the Kubernetes object condition type. + :paramtype status: str + :keyword type: Object status condition type for this object. + :paramtype type: str + """ + super().__init__(**kwargs) + self.last_transition_time = last_transition_time + self.message = message + self.reason = reason + self.status = status + self.type = type + + +class ObjectStatusDefinition(_serialization.Model): + """Statuses of objects deployed by the user-specified kustomizations from the git repository. + + :ivar name: Name of the applied object. + :vartype name: str + :ivar namespace: Namespace of the applied object. + :vartype namespace: str + :ivar kind: Kind of the applied object. + :vartype kind: str + :ivar compliance_state: Compliance state of the applied object showing whether the applied + object has come into a ready state on the cluster. Known values are: "Compliant", + "Non-Compliant", "Pending", "Suspended", and "Unknown". + :vartype compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxComplianceState + :ivar applied_by: Object reference to the Kustomization that applied this object. + :vartype applied_by: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ObjectReferenceDefinition + :ivar status_conditions: List of Kubernetes object status conditions present on the cluster. + :vartype status_conditions: + list[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ObjectStatusConditionDefinition] + :ivar helm_release_properties: Additional properties that are provided from objects of the + HelmRelease kind. + :vartype helm_release_properties: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.HelmReleasePropertiesDefinition + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "compliance_state": {"key": "complianceState", "type": "str"}, + "applied_by": {"key": "appliedBy", "type": "ObjectReferenceDefinition"}, + "status_conditions": {"key": "statusConditions", "type": "[ObjectStatusConditionDefinition]"}, + "helm_release_properties": {"key": "helmReleaseProperties", "type": "HelmReleasePropertiesDefinition"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + namespace: Optional[str] = None, + kind: Optional[str] = None, + compliance_state: Union[str, "_models.FluxComplianceState"] = "Unknown", + applied_by: Optional["_models.ObjectReferenceDefinition"] = None, + status_conditions: Optional[List["_models.ObjectStatusConditionDefinition"]] = None, + helm_release_properties: Optional["_models.HelmReleasePropertiesDefinition"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the applied object. + :paramtype name: str + :keyword namespace: Namespace of the applied object. + :paramtype namespace: str + :keyword kind: Kind of the applied object. + :paramtype kind: str + :keyword compliance_state: Compliance state of the applied object showing whether the applied + object has come into a ready state on the cluster. Known values are: "Compliant", + "Non-Compliant", "Pending", "Suspended", and "Unknown". + :paramtype compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxComplianceState + :keyword applied_by: Object reference to the Kustomization that applied this object. + :paramtype applied_by: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ObjectReferenceDefinition + :keyword status_conditions: List of Kubernetes object status conditions present on the cluster. + :paramtype status_conditions: + list[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ObjectStatusConditionDefinition] + :keyword helm_release_properties: Additional properties that are provided from objects of the + HelmRelease kind. + :paramtype helm_release_properties: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.HelmReleasePropertiesDefinition + """ + super().__init__(**kwargs) + self.name = name + self.namespace = namespace + self.kind = kind + self.compliance_state = compliance_state + self.applied_by = applied_by + self.status_conditions = status_conditions + self.helm_release_properties = helm_release_properties + + +class OperationStatusList(_serialization.Model): + """The async operations in progress, in the cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of async operations in progress, in the cluster. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.OperationStatusResult] + :ivar next_link: URL to get the next set of Operation Result objects, if any. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[OperationStatusResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class OperationStatusResult(_serialization.Model): + """The current status of an async operation. + + 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 ID for the async operation. + :vartype id: str + :ivar name: Name of the async operation. + :vartype name: str + :ivar status: Operation status. Required. + :vartype status: str + :ivar properties: Additional information, if available. + :vartype properties: dict[str, str] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ErrorDetail + """ + + _validation = { + "status": {"required": True}, + "error": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__( + self, + *, + status: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Fully qualified ID for the async operation. + :paramtype id: str + :keyword name: Name of the async operation. + :paramtype name: str + :keyword status: Operation status. Required. + :paramtype status: str + :keyword properties: Additional information, if available. + :paramtype properties: dict[str, str] + """ + super().__init__(**kwargs) + self.id = id + self.name = name + self.status = status + self.properties = properties + self.error = None + + +class PatchExtension(_serialization.Model): + """The Extension Patch Request object. + + :ivar auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade + of minor version, or not. + :vartype auto_upgrade_minor_version: bool + :ivar release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. Stable, + Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :vartype release_train: str + :ivar version: Version of the extension for this extension, if it is 'pinned' to a specific + version. autoUpgradeMinorVersion must be 'false'. + :vartype version: str + :ivar configuration_settings: Configuration settings, as name-value pairs for configuring this + extension. + :vartype configuration_settings: dict[str, str] + :ivar configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :vartype configuration_protected_settings: dict[str, str] + """ + + _attribute_map = { + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "configuration_settings": {"key": "properties.configurationSettings", "type": "{str}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + } + + def __init__( + self, + *, + auto_upgrade_minor_version: bool = True, + release_train: str = "Stable", + version: Optional[str] = None, + configuration_settings: Optional[Dict[str, str]] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword auto_upgrade_minor_version: Flag to note if this extension participates in auto + upgrade of minor version, or not. + :paramtype auto_upgrade_minor_version: bool + :keyword release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. + Stable, Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :paramtype release_train: str + :keyword version: Version of the extension for this extension, if it is 'pinned' to a specific + version. autoUpgradeMinorVersion must be 'false'. + :paramtype version: str + :keyword configuration_settings: Configuration settings, as name-value pairs for configuring + this extension. + :paramtype configuration_settings: dict[str, str] + :keyword configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :paramtype configuration_protected_settings: dict[str, str] + """ + super().__init__(**kwargs) + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.release_train = release_train + self.version = version + self.configuration_settings = configuration_settings + self.configuration_protected_settings = configuration_protected_settings + + +class RepositoryRefDefinition(_serialization.Model): + """The source reference for the GitRepository object. + + :ivar branch: The git repository branch name to checkout. + :vartype branch: str + :ivar tag: The git repository tag name to checkout. This takes precedence over branch. + :vartype tag: str + :ivar semver: The semver range used to match against git repository tags. This takes precedence + over tag. + :vartype semver: str + :ivar commit: The commit SHA to checkout. This value must be combined with the branch name to + be valid. This takes precedence over semver. + :vartype commit: str + """ + + _attribute_map = { + "branch": {"key": "branch", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "semver": {"key": "semver", "type": "str"}, + "commit": {"key": "commit", "type": "str"}, + } + + def __init__( + self, + *, + branch: Optional[str] = None, + tag: Optional[str] = None, + semver: Optional[str] = None, + commit: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword branch: The git repository branch name to checkout. + :paramtype branch: str + :keyword tag: The git repository tag name to checkout. This takes precedence over branch. + :paramtype tag: str + :keyword semver: The semver range used to match against git repository tags. This takes + precedence over tag. + :paramtype semver: str + :keyword commit: The commit SHA to checkout. This value must be combined with the branch name + to be valid. This takes precedence over semver. + :paramtype commit: str + """ + super().__init__(**kwargs) + self.branch = branch + self.tag = tag + self.semver = semver + self.commit = commit + + +class ResourceProviderOperation(_serialization.Model): + """Supported operation of this resource provider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Operation name, in format of {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: Display metadata associated with the operation. + :vartype display: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ResourceProviderOperationDisplay + :ivar is_data_action: The flag that indicates whether the operation applies to data plane. + :vartype is_data_action: bool + :ivar origin: Origin of the operation. + :vartype origin: str + """ + + _validation = { + "is_data_action": {"readonly": True}, + "origin": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "ResourceProviderOperationDisplay"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "origin": {"key": "origin", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["_models.ResourceProviderOperationDisplay"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Operation name, in format of {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: Display metadata associated with the operation. + :paramtype display: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ResourceProviderOperationDisplay + """ + super().__init__(**kwargs) + self.name = name + self.display = display + self.is_data_action = None + self.origin = None + + +class ResourceProviderOperationDisplay(_serialization.Model): + """Display metadata associated with the operation. + + :ivar provider: Resource provider: Microsoft KubernetesConfiguration. + :vartype provider: str + :ivar resource: Resource on which the operation is performed. + :vartype resource: str + :ivar operation: Type of operation: get, read, delete, etc. + :vartype operation: str + :ivar description: Description of this 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: Any + ) -> None: + """ + :keyword provider: Resource provider: Microsoft KubernetesConfiguration. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed. + :paramtype resource: str + :keyword operation: Type of operation: get, read, delete, etc. + :paramtype operation: str + :keyword description: Description of this operation. + :paramtype description: str + """ + super().__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class ResourceProviderOperationList(_serialization.Model): + """Result of the request to list operations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by this resource provider. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ResourceProviderOperation] + :ivar next_link: URL to the next set of results, if any. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ResourceProviderOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ResourceProviderOperation"]] = None, **kwargs: Any) -> None: + """ + :keyword value: List of operations supported by this resource provider. + :paramtype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ResourceProviderOperation] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class Scope(_serialization.Model): + """Scope of the extension. It can be either Cluster or Namespace; but not both. + + :ivar cluster: Specifies that the scope of the extension is Cluster. + :vartype cluster: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ScopeCluster + :ivar namespace: Specifies that the scope of the extension is Namespace. + :vartype namespace: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ScopeNamespace + """ + + _attribute_map = { + "cluster": {"key": "cluster", "type": "ScopeCluster"}, + "namespace": {"key": "namespace", "type": "ScopeNamespace"}, + } + + def __init__( + self, + *, + cluster: Optional["_models.ScopeCluster"] = None, + namespace: Optional["_models.ScopeNamespace"] = None, + **kwargs: Any + ) -> None: + """ + :keyword cluster: Specifies that the scope of the extension is Cluster. + :paramtype cluster: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ScopeCluster + :keyword namespace: Specifies that the scope of the extension is Namespace. + :paramtype namespace: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ScopeNamespace + """ + super().__init__(**kwargs) + self.cluster = cluster + self.namespace = namespace + + +class ScopeCluster(_serialization.Model): + """Specifies that the scope of the extension is Cluster. + + :ivar release_namespace: Namespace where the extension Release must be placed, for a Cluster + scoped extension. If this namespace does not exist, it will be created. + :vartype release_namespace: str + """ + + _attribute_map = { + "release_namespace": {"key": "releaseNamespace", "type": "str"}, + } + + def __init__(self, *, release_namespace: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword release_namespace: Namespace where the extension Release must be placed, for a Cluster + scoped extension. If this namespace does not exist, it will be created. + :paramtype release_namespace: str + """ + super().__init__(**kwargs) + self.release_namespace = release_namespace + + +class ScopeNamespace(_serialization.Model): + """Specifies that the scope of the extension is Namespace. + + :ivar target_namespace: Namespace where the extension will be created for an Namespace scoped + extension. If this namespace does not exist, it will be created. + :vartype target_namespace: str + """ + + _attribute_map = { + "target_namespace": {"key": "targetNamespace", "type": "str"}, + } + + def __init__(self, *, target_namespace: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword target_namespace: Namespace where the extension will be created for an Namespace + scoped extension. If this namespace does not exist, it will be created. + :paramtype target_namespace: str + """ + super().__init__(**kwargs) + self.target_namespace = target_namespace + + +class ServicePrincipalDefinition(_serialization.Model): + """Parameters to authenticate using Service Principal. + + :ivar client_id: The client Id for authenticating a Service Principal. + :vartype client_id: str + :ivar tenant_id: The tenant Id for authenticating a Service Principal. + :vartype tenant_id: str + :ivar client_secret: The client secret for authenticating a Service Principal. + :vartype client_secret: str + :ivar client_certificate: Base64-encoded certificate used to authenticate a Service Principal. + :vartype client_certificate: str + :ivar client_certificate_password: The password for the certificate used to authenticate a + Service Principal. + :vartype client_certificate_password: str + :ivar client_certificate_send_chain: Specifies whether to include x5c header in client claims + when acquiring a token to enable subject name / issuer based authentication for the Client + Certificate. + :vartype client_certificate_send_chain: bool + """ + + _attribute_map = { + "client_id": {"key": "clientId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, + "client_certificate": {"key": "clientCertificate", "type": "str"}, + "client_certificate_password": {"key": "clientCertificatePassword", "type": "str"}, + "client_certificate_send_chain": {"key": "clientCertificateSendChain", "type": "bool"}, + } + + def __init__( + self, + *, + client_id: Optional[str] = None, + tenant_id: Optional[str] = None, + client_secret: Optional[str] = None, + client_certificate: Optional[str] = None, + client_certificate_password: Optional[str] = None, + client_certificate_send_chain: bool = False, + **kwargs: Any + ) -> None: + """ + :keyword client_id: The client Id for authenticating a Service Principal. + :paramtype client_id: str + :keyword tenant_id: The tenant Id for authenticating a Service Principal. + :paramtype tenant_id: str + :keyword client_secret: The client secret for authenticating a Service Principal. + :paramtype client_secret: str + :keyword client_certificate: Base64-encoded certificate used to authenticate a Service + Principal. + :paramtype client_certificate: str + :keyword client_certificate_password: The password for the certificate used to authenticate a + Service Principal. + :paramtype client_certificate_password: str + :keyword client_certificate_send_chain: Specifies whether to include x5c header in client + claims when acquiring a token to enable subject name / issuer based authentication for the + Client Certificate. + :paramtype client_certificate_send_chain: bool + """ + super().__init__(**kwargs) + self.client_id = client_id + self.tenant_id = tenant_id + self.client_secret = client_secret + self.client_certificate = client_certificate + self.client_certificate_password = client_certificate_password + self.client_certificate_send_chain = client_certificate_send_chain + + +class ServicePrincipalPatchDefinition(_serialization.Model): + """Parameters to authenticate using Service Principal. + + :ivar client_id: The client Id for authenticating a Service Principal. + :vartype client_id: str + :ivar tenant_id: The tenant Id for authenticating a Service Principal. + :vartype tenant_id: str + :ivar client_secret: The client secret for authenticating a Service Principal. + :vartype client_secret: str + :ivar client_certificate: Base64-encoded certificate used to authenticate a Service Principal. + :vartype client_certificate: str + :ivar client_certificate_password: The password for the certificate used to authenticate a + Service Principal. + :vartype client_certificate_password: str + :ivar client_certificate_send_chain: Specifies whether to include x5c header in client claims + when acquiring a token to enable subject name / issuer based authentication for the Client + Certificate. + :vartype client_certificate_send_chain: bool + """ + + _attribute_map = { + "client_id": {"key": "clientId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, + "client_certificate": {"key": "clientCertificate", "type": "str"}, + "client_certificate_password": {"key": "clientCertificatePassword", "type": "str"}, + "client_certificate_send_chain": {"key": "clientCertificateSendChain", "type": "bool"}, + } + + def __init__( + self, + *, + client_id: Optional[str] = None, + tenant_id: Optional[str] = None, + client_secret: Optional[str] = None, + client_certificate: Optional[str] = None, + client_certificate_password: Optional[str] = None, + client_certificate_send_chain: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword client_id: The client Id for authenticating a Service Principal. + :paramtype client_id: str + :keyword tenant_id: The tenant Id for authenticating a Service Principal. + :paramtype tenant_id: str + :keyword client_secret: The client secret for authenticating a Service Principal. + :paramtype client_secret: str + :keyword client_certificate: Base64-encoded certificate used to authenticate a Service + Principal. + :paramtype client_certificate: str + :keyword client_certificate_password: The password for the certificate used to authenticate a + Service Principal. + :paramtype client_certificate_password: str + :keyword client_certificate_send_chain: Specifies whether to include x5c header in client + claims when acquiring a token to enable subject name / issuer based authentication for the + Client Certificate. + :paramtype client_certificate_send_chain: bool + """ + super().__init__(**kwargs) + self.client_id = client_id + self.tenant_id = tenant_id + self.client_secret = client_secret + self.client_certificate = client_certificate + self.client_certificate_password = client_certificate_password + self.client_certificate_send_chain = client_certificate_send_chain + + +class SourceControlConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes + """The SourceControl Configuration object returned in Get & Put response. + + 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: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SystemData + :ivar repository_url: Url of the SourceControl Repository. + :vartype repository_url: str + :ivar operator_namespace: The namespace to which this operator is installed to. Maximum of 253 + lower case alphanumeric characters, hyphen and period only. + :vartype operator_namespace: str + :ivar operator_instance_name: Instance name of the operator - identifying the specific + configuration. + :vartype operator_instance_name: str + :ivar operator_type: Type of the operator. "Flux" + :vartype operator_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.OperatorType + :ivar operator_params: Any Parameters for the Operator instance in string format. + :vartype operator_params: str + :ivar configuration_protected_settings: Name-value pairs of protected configuration settings + for the configuration. + :vartype configuration_protected_settings: dict[str, str] + :ivar operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". + :vartype operator_scope: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.OperatorScopeType + :ivar repository_public_key: Public Key associated with this SourceControl configuration + (either generated within the cluster or provided by the user). + :vartype repository_public_key: str + :ivar ssh_known_hosts_contents: Base64-encoded known_hosts contents containing public SSH keys + required to access private Git instances. + :vartype ssh_known_hosts_contents: str + :ivar enable_helm_operator: Option to enable Helm Operator for this git configuration. + :vartype enable_helm_operator: bool + :ivar helm_operator_properties: Properties for Helm operator. + :vartype helm_operator_properties: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.HelmOperatorProperties + :ivar provisioning_state: The provisioning state of the resource provider. Known values are: + "Accepted", "Deleting", "Running", "Succeeded", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ProvisioningStateType + :ivar compliance_status: Compliance Status of the Configuration. + :vartype compliance_status: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ComplianceStatus + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "repository_public_key": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "compliance_status": {"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"}, + "repository_url": {"key": "properties.repositoryUrl", "type": "str"}, + "operator_namespace": {"key": "properties.operatorNamespace", "type": "str"}, + "operator_instance_name": {"key": "properties.operatorInstanceName", "type": "str"}, + "operator_type": {"key": "properties.operatorType", "type": "str"}, + "operator_params": {"key": "properties.operatorParams", "type": "str"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "operator_scope": {"key": "properties.operatorScope", "type": "str"}, + "repository_public_key": {"key": "properties.repositoryPublicKey", "type": "str"}, + "ssh_known_hosts_contents": {"key": "properties.sshKnownHostsContents", "type": "str"}, + "enable_helm_operator": {"key": "properties.enableHelmOperator", "type": "bool"}, + "helm_operator_properties": {"key": "properties.helmOperatorProperties", "type": "HelmOperatorProperties"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "compliance_status": {"key": "properties.complianceStatus", "type": "ComplianceStatus"}, + } + + def __init__( + self, + *, + repository_url: Optional[str] = None, + operator_namespace: str = "default", + operator_instance_name: Optional[str] = None, + operator_type: Optional[Union[str, "_models.OperatorType"]] = None, + operator_params: Optional[str] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + operator_scope: Union[str, "_models.OperatorScopeType"] = "cluster", + ssh_known_hosts_contents: Optional[str] = None, + enable_helm_operator: Optional[bool] = None, + helm_operator_properties: Optional["_models.HelmOperatorProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword repository_url: Url of the SourceControl Repository. + :paramtype repository_url: str + :keyword operator_namespace: The namespace to which this operator is installed to. Maximum of + 253 lower case alphanumeric characters, hyphen and period only. + :paramtype operator_namespace: str + :keyword operator_instance_name: Instance name of the operator - identifying the specific + configuration. + :paramtype operator_instance_name: str + :keyword operator_type: Type of the operator. "Flux" + :paramtype operator_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.OperatorType + :keyword operator_params: Any Parameters for the Operator instance in string format. + :paramtype operator_params: str + :keyword configuration_protected_settings: Name-value pairs of protected configuration settings + for the configuration. + :paramtype configuration_protected_settings: dict[str, str] + :keyword operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". + :paramtype operator_scope: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.OperatorScopeType + :keyword ssh_known_hosts_contents: Base64-encoded known_hosts contents containing public SSH + keys required to access private Git instances. + :paramtype ssh_known_hosts_contents: str + :keyword enable_helm_operator: Option to enable Helm Operator for this git configuration. + :paramtype enable_helm_operator: bool + :keyword helm_operator_properties: Properties for Helm operator. + :paramtype helm_operator_properties: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.HelmOperatorProperties + """ + super().__init__(**kwargs) + self.system_data = None + self.repository_url = repository_url + self.operator_namespace = operator_namespace + self.operator_instance_name = operator_instance_name + self.operator_type = operator_type + self.operator_params = operator_params + self.configuration_protected_settings = configuration_protected_settings + self.operator_scope = operator_scope + self.repository_public_key = None + self.ssh_known_hosts_contents = ssh_known_hosts_contents + self.enable_helm_operator = enable_helm_operator + self.helm_operator_properties = helm_operator_properties + self.provisioning_state = None + self.compliance_status = None + + +class SourceControlConfigurationList(_serialization.Model): + """Result of the request to list Source Control Configurations. It contains a list of + SourceControlConfiguration objects and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Source Control Configurations within a Kubernetes cluster. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceControlConfiguration] + :ivar next_link: URL to get the next set of configuration objects, if any. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SourceControlConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_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. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_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. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.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 diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/models/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/models/_source_control_configuration_client_enums.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/models/_source_control_configuration_client_enums.py new file mode 100644 index 000000000000..cf0979847940 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/models/_source_control_configuration_client_enums.py @@ -0,0 +1,121 @@ +# 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 AKSIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + + +class ComplianceStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The compliance state of the configuration.""" + + PENDING = "Pending" + COMPLIANT = "Compliant" + NONCOMPLIANT = "Noncompliant" + INSTALLED = "Installed" + FAILED = "Failed" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class FluxComplianceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Compliance state of the cluster object.""" + + COMPLIANT = "Compliant" + NON_COMPLIANT = "Non-Compliant" + PENDING = "Pending" + SUSPENDED = "Suspended" + UNKNOWN = "Unknown" + + +class KustomizationValidationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specify whether to validate the Kubernetes objects referenced in the Kustomization before + applying them to the cluster. + """ + + NONE = "none" + CLIENT = "client" + SERVER = "server" + + +class LevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the status.""" + + ERROR = "Error" + WARNING = "Warning" + INFORMATION = "Information" + + +class MessageLevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the message.""" + + ERROR = "Error" + WARNING = "Warning" + INFORMATION = "Information" + + +class OperatorScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scope at which the operator will be installed.""" + + CLUSTER = "cluster" + NAMESPACE = "namespace" + + +class OperatorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the operator.""" + + FLUX = "Flux" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource.""" + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + + +class ProvisioningStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource provider.""" + + ACCEPTED = "Accepted" + DELETING = "Deleting" + RUNNING = "Running" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + + +class ScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scope at which the configuration will be installed.""" + + CLUSTER = "cluster" + NAMESPACE = "namespace" + + +class SourceKindType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Source Kind to pull the configuration data from.""" + + GIT_REPOSITORY = "GitRepository" + BUCKET = "Bucket" + AZURE_BLOB = "AzureBlob" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/__init__.py new file mode 100644 index 000000000000..9d58b5443a05 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/__init__.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._extensions_operations import ExtensionsOperations +from ._operation_status_operations import OperationStatusOperations +from ._flux_configurations_operations import FluxConfigurationsOperations +from ._flux_config_operation_status_operations import FluxConfigOperationStatusOperations +from ._source_control_configurations_operations import SourceControlConfigurationsOperations +from ._operations import Operations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ExtensionsOperations", + "OperationStatusOperations", + "FluxConfigurationsOperations", + "FluxConfigOperationStatusOperations", + "SourceControlConfigurationsOperations", + "Operations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_extensions_operations.py new file mode 100644 index 000000000000..f44daff07c06 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_extensions_operations.py @@ -0,0 +1,1150 @@ +# 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_create_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_get_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_delete_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + subscription_id: str, + *, + force_delete: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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") + if force_delete is not None: + _params["forceDelete"] = _SERIALIZER.query("force_delete", force_delete, "bool") + + # 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, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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) + + +class ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_07_01.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: Union[_models.Extension, IO], + **kwargs: Any + ) -> _models.Extension: + 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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IO, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") + + request = build_create_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Extension", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension + :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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: Union[_models.Extension, IO], + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Is either a Extension type or a + IO type. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension] + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + extension=extension, + 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("Extension", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + **kwargs: Any + ) -> _models.Extension: + """Gets Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Extension or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + force_delete: Optional[bool] = None, + **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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + force_delete=force_delete, + 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 [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Delete a Kubernetes Cluster Extension. This will cause the Agent to Uninstall the extension + from the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param force_delete: Delete the extension resource in Azure - not the normal asynchronous + delete. Default value is None. + :type force_delete: bool + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-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( # type: ignore + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + force_delete=force_delete, + 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, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + def _update_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: Union[_models.PatchExtension, IO], + **kwargs: Any + ) -> _models.Extension: + 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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(patch_extension, (IO, bytes)): + _content = patch_extension + else: + _json = self._serialize.body(patch_extension, "PatchExtension") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Extension", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: _models.PatchExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.PatchExtension + :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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: Union[_models.PatchExtension, IO], + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Is either a + PatchExtension type or a IO type. Required. + :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.PatchExtension 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension] + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + patch_extension=patch_extension, + 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("Extension", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.Extension"]: + """List all Extensions in the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Extension or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.ExtensionsList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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("ExtensionsList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_flux_config_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_flux_config_operation_status_operations.py new file mode 100644 index 000000000000..e97597a78044 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_flux_config_operation_status_operations.py @@ -0,0 +1,188 @@ +# 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, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + operation_id: 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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "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) + + +class FluxConfigOperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_07_01.SourceControlConfigurationClient`'s + :attr:`flux_config_operation_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + operation_id: str, + **kwargs: Any + ) -> _models.OperationStatusResult: + """Get Async Operation status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param operation_id: operation Id. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.OperationStatusResult + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + operation_id=operation_id, + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_flux_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_flux_configurations_operations.py new file mode 100644 index 000000000000..8c569a411034 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_flux_configurations_operations.py @@ -0,0 +1,1161 @@ +# 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_get_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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_update_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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_delete_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + subscription_id: str, + *, + force_delete: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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") + if force_delete is not None: + _params["forceDelete"] = _SERIALIZER.query("force_delete", force_delete, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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) + + +class FluxConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_07_01.SourceControlConfigurationClient`'s + :attr:`flux_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + **kwargs: Any + ) -> _models.FluxConfiguration: + """Gets details of the Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FluxConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: Union[_models.FluxConfiguration, IO], + **kwargs: Any + ) -> _models.FluxConfiguration: + 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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration, (IO, bytes)): + _content = flux_configuration + else: + _json = self._serialize.body(flux_configuration, "FluxConfiguration") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("FluxConfiguration", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: _models.FluxConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: Union[_models.FluxConfiguration, IO], + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Is either a + FluxConfiguration type or a IO type. Required. + :type flux_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration] + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + flux_configuration=flux_configuration, + 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("FluxConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + def _update_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], + **kwargs: Any + ) -> _models.FluxConfiguration: + 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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration_patch, (IO, bytes)): + _content = flux_configuration_patch + else: + _json = self._serialize.body(flux_configuration_patch, "FluxConfigurationPatch") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: _models.FluxConfigurationPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. + :type flux_configuration_patch: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfigurationPatch + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. + :type flux_configuration_patch: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. Is + either a FluxConfigurationPatch type or a IO type. Required. + :type flux_configuration_patch: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfigurationPatch 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration] + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + flux_configuration_patch=flux_configuration_patch, + 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("FluxConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + force_delete: Optional[bool] = None, + **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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + subscription_id=self._config.subscription_id, + force_delete=force_delete, + 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 [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """This will delete the YAML file used to set up the Flux Configuration, thus stopping future sync + from the source repo. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param force_delete: Delete the extension resource in Azure - not the normal asynchronous + delete. Default value is None. + :type force_delete: bool + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-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( # type: ignore + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + force_delete=force_delete, + 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, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.FluxConfiguration"]: + """List all Flux Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FluxConfiguration or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.FluxConfigurationsList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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("FluxConfigurationsList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_operation_status_operations.py new file mode 100644 index 000000000000..144629045b29 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_operation_status_operations.py @@ -0,0 +1,331 @@ +# 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_get_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + operation_id: 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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "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_list_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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) + + +class OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_07_01.SourceControlConfigurationClient`'s + :attr:`operation_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + operation_id: str, + **kwargs: Any + ) -> _models.OperationStatusResult: + """Get Async Operation status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param operation_id: operation Id. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.OperationStatusResult + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + operation_id=operation_id, + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.OperationStatusResult"]: + """List Async Operations, currently in progress, in a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.OperationStatusList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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("OperationStatusList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_operations.py new file mode 100644 index 000000000000..1690382a2618 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_operations.py @@ -0,0 +1,161 @@ +# 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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.KubernetesConfiguration/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.kubernetesconfiguration.v2022_07_01.SourceControlConfigurationClient`'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.ResourceProviderOperation"]: + """List all the available operations the KubernetesConfiguration resource provider supports. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceProviderOperation or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.ResourceProviderOperationList] = 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("ResourceProviderOperationList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_source_control_configurations_operations.py new file mode 100644 index 000000000000..498cbcf5cdee --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/operations/_source_control_configurations_operations.py @@ -0,0 +1,746 @@ +# 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_get_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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_list_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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) + + +class SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_07_01.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Gets details of the Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceControlConfiguration + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceControlConfiguration + :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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceControlConfiguration 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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceControlConfiguration + :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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SourceControlConfiguration", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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 [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """This will delete the YAML file used to set up the Source control configuration, thus stopping + future sync from the source repo. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_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-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-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( # type: ignore + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.SourceControlConfiguration"]: + """List all Source Control Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SourceControlConfiguration or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_07_01.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01")) + cls: ClsType[_models.SourceControlConfigurationList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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("SourceControlConfigurationList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/py.typed b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_07_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/__init__.py new file mode 100644 index 000000000000..3ad4bd8b604e --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/__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 ._source_control_configuration_client import SourceControlConfigurationClient +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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/_configuration.py new file mode 100644 index 000000000000..892e20c2a4dd --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/_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 SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for SourceControlConfigurationClient. + + 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-11-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: + super(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", "2022-11-01") + + 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-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/_metadata.json b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/_metadata.json new file mode 100644 index 000000000000..59fdaab4a1cd --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/_metadata.json @@ -0,0 +1,115 @@ +{ + "chosen_version": "2022-11-01", + "total_api_version_list": ["2022-11-01"], + "client": { + "name": "SourceControlConfigurationClient", + "filename": "_source_control_configuration_client", + "description": "KubernetesConfiguration Client.", + "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\": [\"SourceControlConfigurationClientConfiguration\"], \".._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\": [\"SourceControlConfigurationClientConfiguration\"], \"..._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, + "method_location": "positional" + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", + "docstring_type": "str", + "required": true, + "method_location": "positional" + } + }, + "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, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + }, + "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, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + } + } + }, + "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": { + "extensions": "ExtensionsOperations", + "operation_status": "OperationStatusOperations", + "flux_configurations": "FluxConfigurationsOperations", + "flux_config_operation_status": "FluxConfigOperationStatusOperations", + "source_control_configurations": "SourceControlConfigurationsOperations", + "operations": "Operations" + } +} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/_source_control_configuration_client.py new file mode 100644 index 000000000000..7885c08da54e --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/_source_control_configuration_client.py @@ -0,0 +1,126 @@ +# 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 SourceControlConfigurationClientConfiguration +from .operations import ( + ExtensionsOperations, + FluxConfigOperationStatusOperations, + FluxConfigurationsOperations, + OperationStatusOperations, + Operations, + SourceControlConfigurationsOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword + """KubernetesConfiguration Client. + + :ivar extensions: ExtensionsOperations operations + :vartype extensions: + azure.mgmt.kubernetesconfiguration.v2022_11_01.operations.ExtensionsOperations + :ivar operation_status: OperationStatusOperations operations + :vartype operation_status: + azure.mgmt.kubernetesconfiguration.v2022_11_01.operations.OperationStatusOperations + :ivar flux_configurations: FluxConfigurationsOperations operations + :vartype flux_configurations: + azure.mgmt.kubernetesconfiguration.v2022_11_01.operations.FluxConfigurationsOperations + :ivar flux_config_operation_status: FluxConfigOperationStatusOperations operations + :vartype flux_config_operation_status: + azure.mgmt.kubernetesconfiguration.v2022_11_01.operations.FluxConfigOperationStatusOperations + :ivar source_control_configurations: SourceControlConfigurationsOperations operations + :vartype source_control_configurations: + azure.mgmt.kubernetesconfiguration.v2022_11_01.operations.SourceControlConfigurationsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.kubernetesconfiguration.v2022_11_01.operations.Operations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-11-01". 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 = SourceControlConfigurationClientConfiguration( + 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.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_configurations = FluxConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_config_operation_status = FluxConfigOperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **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) -> "SourceControlConfigurationClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/_vendor.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/_vendor.py new file mode 100644 index 000000000000..bd0df84f5319 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/_vendor.py @@ -0,0 +1,30 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import List, cast + +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: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/_version.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/_version.py new file mode 100644 index 000000000000..59deb8c7263b --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/_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.1.0" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/__init__.py new file mode 100644 index 000000000000..b95230ae03c5 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/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 ._source_control_configuration_client import SourceControlConfigurationClient + +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__ = [ + "SourceControlConfigurationClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/_configuration.py new file mode 100644 index 000000000000..bcb640ee8d9c --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/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 SourceControlConfigurationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for SourceControlConfigurationClient. + + 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-11-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: + super(SourceControlConfigurationClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", "2022-11-01") + + 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-kubernetesconfiguration/{}".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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/_source_control_configuration_client.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/_source_control_configuration_client.py new file mode 100644 index 000000000000..9e6f58750e94 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/_source_control_configuration_client.py @@ -0,0 +1,126 @@ +# 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 SourceControlConfigurationClientConfiguration +from .operations import ( + ExtensionsOperations, + FluxConfigOperationStatusOperations, + FluxConfigurationsOperations, + OperationStatusOperations, + Operations, + SourceControlConfigurationsOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SourceControlConfigurationClient: # pylint: disable=client-accepts-api-version-keyword + """KubernetesConfiguration Client. + + :ivar extensions: ExtensionsOperations operations + :vartype extensions: + azure.mgmt.kubernetesconfiguration.v2022_11_01.aio.operations.ExtensionsOperations + :ivar operation_status: OperationStatusOperations operations + :vartype operation_status: + azure.mgmt.kubernetesconfiguration.v2022_11_01.aio.operations.OperationStatusOperations + :ivar flux_configurations: FluxConfigurationsOperations operations + :vartype flux_configurations: + azure.mgmt.kubernetesconfiguration.v2022_11_01.aio.operations.FluxConfigurationsOperations + :ivar flux_config_operation_status: FluxConfigOperationStatusOperations operations + :vartype flux_config_operation_status: + azure.mgmt.kubernetesconfiguration.v2022_11_01.aio.operations.FluxConfigOperationStatusOperations + :ivar source_control_configurations: SourceControlConfigurationsOperations operations + :vartype source_control_configurations: + azure.mgmt.kubernetesconfiguration.v2022_11_01.aio.operations.SourceControlConfigurationsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.kubernetesconfiguration.v2022_11_01.aio.operations.Operations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-11-01". 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 = SourceControlConfigurationClientConfiguration( + 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.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_configurations = FluxConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.flux_config_operation_status = FluxConfigOperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **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) -> "SourceControlConfigurationClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/__init__.py new file mode 100644 index 000000000000..9d58b5443a05 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/__init__.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._extensions_operations import ExtensionsOperations +from ._operation_status_operations import OperationStatusOperations +from ._flux_configurations_operations import FluxConfigurationsOperations +from ._flux_config_operation_status_operations import FluxConfigOperationStatusOperations +from ._source_control_configurations_operations import SourceControlConfigurationsOperations +from ._operations import Operations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ExtensionsOperations", + "OperationStatusOperations", + "FluxConfigurationsOperations", + "FluxConfigOperationStatusOperations", + "SourceControlConfigurationsOperations", + "Operations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_extensions_operations.py new file mode 100644 index 000000000000..19da31b1da2b --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_extensions_operations.py @@ -0,0 +1,945 @@ +# 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._extensions_operations import ( + build_create_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 ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_11_01.aio.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: Union[_models.Extension, IO], + **kwargs: Any + ) -> _models.Extension: + 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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IO, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") + + request = build_create_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Extension", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension + :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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: Union[_models.Extension, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Is either a Extension type or a + IO type. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension] + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + extension=extension, + 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("Extension", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + **kwargs: Any + ) -> _models.Extension: + """Gets Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Extension or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + force_delete: Optional[bool] = None, + **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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + force_delete=force_delete, + 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 [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a Kubernetes Cluster Extension. This will cause the Agent to Uninstall the extension + from the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param force_delete: Delete the extension resource in Azure - not the normal asynchronous + delete. Default value is None. + :type force_delete: bool + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-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( # type: ignore + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + force_delete=force_delete, + 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, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + async def _update_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: Union[_models.PatchExtension, IO], + **kwargs: Any + ) -> _models.Extension: + 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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(patch_extension, (IO, bytes)): + _content = patch_extension + else: + _json = self._serialize.body(patch_extension, "PatchExtension") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Extension", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: _models.PatchExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.PatchExtension + :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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: Union[_models.PatchExtension, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Is either a + PatchExtension type or a IO type. Required. + :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.PatchExtension 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 Extension or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension] + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + patch_extension=patch_extension, + 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("Extension", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Extension"]: + """List all Extensions in the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Extension or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.ExtensionsList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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("ExtensionsList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_flux_config_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_flux_config_operation_status_operations.py new file mode 100644 index 000000000000..74255fcf6d39 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_flux_config_operation_status_operations.py @@ -0,0 +1,141 @@ +# 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, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._flux_config_operation_status_operations import build_get_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 FluxConfigOperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_11_01.aio.SourceControlConfigurationClient`'s + :attr:`flux_config_operation_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + operation_id: str, + **kwargs: Any + ) -> _models.OperationStatusResult: + """Get Async Operation status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param operation_id: operation Id. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.OperationStatusResult + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + operation_id=operation_id, + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_flux_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_flux_configurations_operations.py new file mode 100644 index 000000000000..b19baa1a1e14 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_flux_configurations_operations.py @@ -0,0 +1,950 @@ +# 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._flux_configurations_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 FluxConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_11_01.aio.SourceControlConfigurationClient`'s + :attr:`flux_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + **kwargs: Any + ) -> _models.FluxConfiguration: + """Gets details of the Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FluxConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: Union[_models.FluxConfiguration, IO], + **kwargs: Any + ) -> _models.FluxConfiguration: + 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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration, (IO, bytes)): + _content = flux_configuration + else: + _json = self._serialize.body(flux_configuration, "FluxConfiguration") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("FluxConfiguration", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: _models.FluxConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: Union[_models.FluxConfiguration, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Is either a + FluxConfiguration type or a IO type. Required. + :type flux_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration] + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + flux_configuration=flux_configuration, + 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("FluxConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + async def _update_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], + **kwargs: Any + ) -> _models.FluxConfiguration: + 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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration_patch, (IO, bytes)): + _content = flux_configuration_patch + else: + _json = self._serialize.body(flux_configuration_patch, "FluxConfigurationPatch") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: _models.FluxConfigurationPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. + :type flux_configuration_patch: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfigurationPatch + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. + :type flux_configuration_patch: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. Is + either a FluxConfigurationPatch type or a IO type. Required. + :type flux_configuration_patch: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfigurationPatch 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration] + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + flux_configuration_patch=flux_configuration_patch, + 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("FluxConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + force_delete: Optional[bool] = None, + **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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + subscription_id=self._config.subscription_id, + force_delete=force_delete, + 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 [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """This will delete the YAML file used to set up the Flux Configuration, thus stopping future sync + from the source repo. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param force_delete: Delete the extension resource in Azure - not the normal asynchronous + delete. Default value is None. + :type force_delete: bool + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-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( # type: ignore + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + force_delete=force_delete, + 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, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.FluxConfiguration"]: + """List all Flux Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FluxConfiguration or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.FluxConfigurationsList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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("FluxConfigurationsList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_operation_status_operations.py new file mode 100644 index 000000000000..5ba6e4998e79 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_operation_status_operations.py @@ -0,0 +1,245 @@ +# 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.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._operation_status_operations import build_get_request, 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 OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_11_01.aio.SourceControlConfigurationClient`'s + :attr:`operation_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + operation_id: str, + **kwargs: Any + ) -> _models.OperationStatusResult: + """Get Async Operation status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param operation_id: operation Id. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.OperationStatusResult + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + operation_id=operation_id, + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.OperationStatusResult"]: + """List Async Operations, currently in progress, in a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.OperationStatusList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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("OperationStatusList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_operations.py new file mode 100644 index 000000000000..0c33d9bb11a0 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/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.kubernetesconfiguration.v2022_11_01.aio.SourceControlConfigurationClient`'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.ResourceProviderOperation"]: + """List all the available operations the KubernetesConfiguration resource provider supports. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceProviderOperation or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.ResourceProviderOperationList] = 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("ResourceProviderOperationList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_source_control_configurations_operations.py new file mode 100644 index 000000000000..1701ed6e8572 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/aio/operations/_source_control_configurations_operations.py @@ -0,0 +1,574 @@ +# 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._source_control_configurations_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + 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 SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_11_01.aio.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Gets details of the Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceControlConfiguration + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceControlConfiguration + :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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceControlConfiguration 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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceControlConfiguration + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SourceControlConfiguration", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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 [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """This will delete the YAML file used to set up the Source control configuration, thus stopping + future sync from the source repo. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-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( # type: ignore + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SourceControlConfiguration"]: + """List all Source Control Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SourceControlConfiguration or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.SourceControlConfigurationList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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("SourceControlConfigurationList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/models/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/models/__init__.py new file mode 100644 index 000000000000..0ae6f6df11e0 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/models/__init__.py @@ -0,0 +1,133 @@ +# 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 AzureBlobDefinition +from ._models_py3 import AzureBlobPatchDefinition +from ._models_py3 import BucketDefinition +from ._models_py3 import BucketPatchDefinition +from ._models_py3 import ComplianceStatus +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import Extension +from ._models_py3 import ExtensionPropertiesAksAssignedIdentity +from ._models_py3 import ExtensionStatus +from ._models_py3 import ExtensionsList +from ._models_py3 import FluxConfiguration +from ._models_py3 import FluxConfigurationPatch +from ._models_py3 import FluxConfigurationsList +from ._models_py3 import GitRepositoryDefinition +from ._models_py3 import GitRepositoryPatchDefinition +from ._models_py3 import HelmOperatorProperties +from ._models_py3 import HelmReleasePropertiesDefinition +from ._models_py3 import Identity +from ._models_py3 import KustomizationDefinition +from ._models_py3 import KustomizationPatchDefinition +from ._models_py3 import ManagedIdentityDefinition +from ._models_py3 import ManagedIdentityPatchDefinition +from ._models_py3 import ObjectReferenceDefinition +from ._models_py3 import ObjectStatusConditionDefinition +from ._models_py3 import ObjectStatusDefinition +from ._models_py3 import OperationStatusList +from ._models_py3 import OperationStatusResult +from ._models_py3 import PatchExtension +from ._models_py3 import Plan +from ._models_py3 import ProxyResource +from ._models_py3 import RepositoryRefDefinition +from ._models_py3 import Resource +from ._models_py3 import ResourceProviderOperation +from ._models_py3 import ResourceProviderOperationDisplay +from ._models_py3 import ResourceProviderOperationList +from ._models_py3 import Scope +from ._models_py3 import ScopeCluster +from ._models_py3 import ScopeNamespace +from ._models_py3 import ServicePrincipalDefinition +from ._models_py3 import ServicePrincipalPatchDefinition +from ._models_py3 import SourceControlConfiguration +from ._models_py3 import SourceControlConfigurationList +from ._models_py3 import SystemData + +from ._source_control_configuration_client_enums import AKSIdentityType +from ._source_control_configuration_client_enums import ComplianceStateType +from ._source_control_configuration_client_enums import CreatedByType +from ._source_control_configuration_client_enums import FluxComplianceState +from ._source_control_configuration_client_enums import KustomizationValidationType +from ._source_control_configuration_client_enums import LevelType +from ._source_control_configuration_client_enums import MessageLevelType +from ._source_control_configuration_client_enums import OperatorScopeType +from ._source_control_configuration_client_enums import OperatorType +from ._source_control_configuration_client_enums import ProvisioningState +from ._source_control_configuration_client_enums import ProvisioningStateType +from ._source_control_configuration_client_enums import ScopeType +from ._source_control_configuration_client_enums import SourceKindType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AzureBlobDefinition", + "AzureBlobPatchDefinition", + "BucketDefinition", + "BucketPatchDefinition", + "ComplianceStatus", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "Extension", + "ExtensionPropertiesAksAssignedIdentity", + "ExtensionStatus", + "ExtensionsList", + "FluxConfiguration", + "FluxConfigurationPatch", + "FluxConfigurationsList", + "GitRepositoryDefinition", + "GitRepositoryPatchDefinition", + "HelmOperatorProperties", + "HelmReleasePropertiesDefinition", + "Identity", + "KustomizationDefinition", + "KustomizationPatchDefinition", + "ManagedIdentityDefinition", + "ManagedIdentityPatchDefinition", + "ObjectReferenceDefinition", + "ObjectStatusConditionDefinition", + "ObjectStatusDefinition", + "OperationStatusList", + "OperationStatusResult", + "PatchExtension", + "Plan", + "ProxyResource", + "RepositoryRefDefinition", + "Resource", + "ResourceProviderOperation", + "ResourceProviderOperationDisplay", + "ResourceProviderOperationList", + "Scope", + "ScopeCluster", + "ScopeNamespace", + "ServicePrincipalDefinition", + "ServicePrincipalPatchDefinition", + "SourceControlConfiguration", + "SourceControlConfigurationList", + "SystemData", + "AKSIdentityType", + "ComplianceStateType", + "CreatedByType", + "FluxComplianceState", + "KustomizationValidationType", + "LevelType", + "MessageLevelType", + "OperatorScopeType", + "OperatorType", + "ProvisioningState", + "ProvisioningStateType", + "ScopeType", + "SourceKindType", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/models/_models_py3.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/models/_models_py3.py new file mode 100644 index 000000000000..105d1bd73572 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/models/_models_py3.py @@ -0,0 +1,2666 @@ +# 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 +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +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 .. import models as _models + + +class AzureBlobDefinition(_serialization.Model): + """Parameters to reconcile to the AzureBlob source kind type. + + :ivar url: The URL to sync for the flux configuration Azure Blob storage account. + :vartype url: str + :ivar container_name: The Azure Blob container name to sync from the url endpoint for the flux + configuration. + :vartype container_name: str + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster Azure Blob + source with the remote. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster Azure Blob + source with the remote. + :vartype sync_interval_in_seconds: int + :ivar service_principal: Parameters to authenticate using Service Principal. + :vartype service_principal: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ServicePrincipalDefinition + :ivar account_key: The account key (shared key) to access the storage account. + :vartype account_key: str + :ivar sas_token: The Shared Access token to access the storage container. + :vartype sas_token: str + :ivar managed_identity: Parameters to authenticate using a Managed Identity. + :vartype managed_identity: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ManagedIdentityDefinition + :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :vartype local_auth_ref: str + """ + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "service_principal": {"key": "servicePrincipal", "type": "ServicePrincipalDefinition"}, + "account_key": {"key": "accountKey", "type": "str"}, + "sas_token": {"key": "sasToken", "type": "str"}, + "managed_identity": {"key": "managedIdentity", "type": "ManagedIdentityDefinition"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + container_name: Optional[str] = None, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, + service_principal: Optional["_models.ServicePrincipalDefinition"] = None, + account_key: Optional[str] = None, + sas_token: Optional[str] = None, + managed_identity: Optional["_models.ManagedIdentityDefinition"] = None, + local_auth_ref: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword url: The URL to sync for the flux configuration Azure Blob storage account. + :paramtype url: str + :keyword container_name: The Azure Blob container name to sync from the url endpoint for the + flux configuration. + :paramtype container_name: str + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster Azure Blob + source with the remote. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster Azure Blob + source with the remote. + :paramtype sync_interval_in_seconds: int + :keyword service_principal: Parameters to authenticate using Service Principal. + :paramtype service_principal: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ServicePrincipalDefinition + :keyword account_key: The account key (shared key) to access the storage account. + :paramtype account_key: str + :keyword sas_token: The Shared Access token to access the storage container. + :paramtype sas_token: str + :keyword managed_identity: Parameters to authenticate using a Managed Identity. + :paramtype managed_identity: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ManagedIdentityDefinition + :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :paramtype local_auth_ref: str + """ + super().__init__(**kwargs) + self.url = url + self.container_name = container_name + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.service_principal = service_principal + self.account_key = account_key + self.sas_token = sas_token + self.managed_identity = managed_identity + self.local_auth_ref = local_auth_ref + + +class AzureBlobPatchDefinition(_serialization.Model): + """Parameters to reconcile to the AzureBlob source kind type. + + :ivar url: The URL to sync for the flux configuration Azure Blob storage account. + :vartype url: str + :ivar container_name: The Azure Blob container name to sync from the url endpoint for the flux + configuration. + :vartype container_name: str + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster Azure Blob + source with the remote. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster Azure Blob + source with the remote. + :vartype sync_interval_in_seconds: int + :ivar service_principal: Parameters to authenticate using Service Principal. + :vartype service_principal: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ServicePrincipalPatchDefinition + :ivar account_key: The account key (shared key) to access the storage account. + :vartype account_key: str + :ivar sas_token: The Shared Access token to access the storage container. + :vartype sas_token: str + :ivar managed_identity: Parameters to authenticate using a Managed Identity. + :vartype managed_identity: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ManagedIdentityPatchDefinition + :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :vartype local_auth_ref: str + """ + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "service_principal": {"key": "servicePrincipal", "type": "ServicePrincipalPatchDefinition"}, + "account_key": {"key": "accountKey", "type": "str"}, + "sas_token": {"key": "sasToken", "type": "str"}, + "managed_identity": {"key": "managedIdentity", "type": "ManagedIdentityPatchDefinition"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + container_name: Optional[str] = None, + timeout_in_seconds: Optional[int] = None, + sync_interval_in_seconds: Optional[int] = None, + service_principal: Optional["_models.ServicePrincipalPatchDefinition"] = None, + account_key: Optional[str] = None, + sas_token: Optional[str] = None, + managed_identity: Optional["_models.ManagedIdentityPatchDefinition"] = None, + local_auth_ref: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword url: The URL to sync for the flux configuration Azure Blob storage account. + :paramtype url: str + :keyword container_name: The Azure Blob container name to sync from the url endpoint for the + flux configuration. + :paramtype container_name: str + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster Azure Blob + source with the remote. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster Azure Blob + source with the remote. + :paramtype sync_interval_in_seconds: int + :keyword service_principal: Parameters to authenticate using Service Principal. + :paramtype service_principal: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ServicePrincipalPatchDefinition + :keyword account_key: The account key (shared key) to access the storage account. + :paramtype account_key: str + :keyword sas_token: The Shared Access token to access the storage container. + :paramtype sas_token: str + :keyword managed_identity: Parameters to authenticate using a Managed Identity. + :paramtype managed_identity: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ManagedIdentityPatchDefinition + :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :paramtype local_auth_ref: str + """ + super().__init__(**kwargs) + self.url = url + self.container_name = container_name + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.service_principal = service_principal + self.account_key = account_key + self.sas_token = sas_token + self.managed_identity = managed_identity + self.local_auth_ref = local_auth_ref + + +class BucketDefinition(_serialization.Model): + """Parameters to reconcile to the Bucket source kind type. + + :ivar url: The URL to sync for the flux configuration S3 bucket. + :vartype url: str + :ivar bucket_name: The bucket name to sync from the url endpoint for the flux configuration. + :vartype bucket_name: str + :ivar insecure: Specify whether to use insecure communication when puling data from the S3 + bucket. + :vartype insecure: bool + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster bucket source + with the remote. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster bucket source + with the remote. + :vartype sync_interval_in_seconds: int + :ivar access_key: Plaintext access key used to securely access the S3 bucket. + :vartype access_key: str + :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :vartype local_auth_ref: str + """ + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + "bucket_name": {"key": "bucketName", "type": "str"}, + "insecure": {"key": "insecure", "type": "bool"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "access_key": {"key": "accessKey", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + bucket_name: Optional[str] = None, + insecure: bool = True, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, + access_key: Optional[str] = None, + local_auth_ref: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword url: The URL to sync for the flux configuration S3 bucket. + :paramtype url: str + :keyword bucket_name: The bucket name to sync from the url endpoint for the flux configuration. + :paramtype bucket_name: str + :keyword insecure: Specify whether to use insecure communication when puling data from the S3 + bucket. + :paramtype insecure: bool + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster bucket source + with the remote. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster bucket + source with the remote. + :paramtype sync_interval_in_seconds: int + :keyword access_key: Plaintext access key used to securely access the S3 bucket. + :paramtype access_key: str + :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :paramtype local_auth_ref: str + """ + super().__init__(**kwargs) + self.url = url + self.bucket_name = bucket_name + self.insecure = insecure + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.access_key = access_key + self.local_auth_ref = local_auth_ref + + +class BucketPatchDefinition(_serialization.Model): + """Parameters to reconcile to the Bucket source kind type. + + :ivar url: The URL to sync for the flux configuration S3 bucket. + :vartype url: str + :ivar bucket_name: The bucket name to sync from the url endpoint for the flux configuration. + :vartype bucket_name: str + :ivar insecure: Specify whether to use insecure communication when puling data from the S3 + bucket. + :vartype insecure: bool + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster bucket source + with the remote. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster bucket source + with the remote. + :vartype sync_interval_in_seconds: int + :ivar access_key: Plaintext access key used to securely access the S3 bucket. + :vartype access_key: str + :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :vartype local_auth_ref: str + """ + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + "bucket_name": {"key": "bucketName", "type": "str"}, + "insecure": {"key": "insecure", "type": "bool"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "access_key": {"key": "accessKey", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + bucket_name: Optional[str] = None, + insecure: Optional[bool] = None, + timeout_in_seconds: Optional[int] = None, + sync_interval_in_seconds: Optional[int] = None, + access_key: Optional[str] = None, + local_auth_ref: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword url: The URL to sync for the flux configuration S3 bucket. + :paramtype url: str + :keyword bucket_name: The bucket name to sync from the url endpoint for the flux configuration. + :paramtype bucket_name: str + :keyword insecure: Specify whether to use insecure communication when puling data from the S3 + bucket. + :paramtype insecure: bool + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster bucket source + with the remote. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster bucket + source with the remote. + :paramtype sync_interval_in_seconds: int + :keyword access_key: Plaintext access key used to securely access the S3 bucket. + :paramtype access_key: str + :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :paramtype local_auth_ref: str + """ + super().__init__(**kwargs) + self.url = url + self.bucket_name = bucket_name + self.insecure = insecure + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.access_key = access_key + self.local_auth_ref = local_auth_ref + + +class ComplianceStatus(_serialization.Model): + """Compliance Status details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar compliance_state: The compliance state of the configuration. Known values are: "Pending", + "Compliant", "Noncompliant", "Installed", and "Failed". + :vartype compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ComplianceStateType + :ivar last_config_applied: Datetime the configuration was last applied. + :vartype last_config_applied: ~datetime.datetime + :ivar message: Message from when the configuration was applied. + :vartype message: str + :ivar message_level: Level of the message. Known values are: "Error", "Warning", and + "Information". + :vartype message_level: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.MessageLevelType + """ + + _validation = { + "compliance_state": {"readonly": True}, + } + + _attribute_map = { + "compliance_state": {"key": "complianceState", "type": "str"}, + "last_config_applied": {"key": "lastConfigApplied", "type": "iso-8601"}, + "message": {"key": "message", "type": "str"}, + "message_level": {"key": "messageLevel", "type": "str"}, + } + + def __init__( + self, + *, + last_config_applied: Optional[datetime.datetime] = None, + message: Optional[str] = None, + message_level: Optional[Union[str, "_models.MessageLevelType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword last_config_applied: Datetime the configuration was last applied. + :paramtype last_config_applied: ~datetime.datetime + :keyword message: Message from when the configuration was applied. + :paramtype message: str + :keyword message_level: Level of the message. Known values are: "Error", "Warning", and + "Information". + :paramtype message_level: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.MessageLevelType + """ + super().__init__(**kwargs) + self.compliance_state = None + self.last_config_applied = last_config_applied + self.message = message + self.message_level = message_level + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +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 + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + + +class Extension(ProxyResource): # pylint: disable=too-many-instance-attributes + """The Extension object. + + 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 identity: Identity of the Extension resource. + :vartype identity: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Identity + :ivar system_data: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SystemData + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Plan + :ivar extension_type: Type of the Extension, of which this resource is an instance of. It must + be one of the Extension Types registered with Microsoft.KubernetesConfiguration by the + Extension publisher. + :vartype extension_type: str + :ivar auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade + of minor version, or not. + :vartype auto_upgrade_minor_version: bool + :ivar release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. Stable, + Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :vartype release_train: str + :ivar version: User-specified version of the extension for this extension to 'pin'. To use + 'version', autoUpgradeMinorVersion must be 'false'. + :vartype version: str + :ivar scope: Scope at which the extension is installed. + :vartype scope: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Scope + :ivar configuration_settings: Configuration settings, as name-value pairs for configuring this + extension. + :vartype configuration_settings: dict[str, str] + :ivar configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :vartype configuration_protected_settings: dict[str, str] + :ivar current_version: Currently installed version of the extension. + :vartype current_version: str + :ivar provisioning_state: Status of installation of this extension. Known values are: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ProvisioningState + :ivar statuses: Status from this extension. + :vartype statuses: list[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ExtensionStatus] + :ivar error_info: Error information from the Agent - e.g. errors during installation. + :vartype error_info: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ErrorDetail + :ivar custom_location_settings: Custom Location settings properties. + :vartype custom_location_settings: dict[str, str] + :ivar package_uri: Uri of the Helm package. + :vartype package_uri: str + :ivar aks_assigned_identity: Identity of the Extension resource in an AKS cluster. + :vartype aks_assigned_identity: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ExtensionPropertiesAksAssignedIdentity + :ivar is_system_extension: Flag to note if this extension is a system extension. + :vartype is_system_extension: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "current_version": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "error_info": {"readonly": True}, + "custom_location_settings": {"readonly": True}, + "package_uri": {"readonly": True}, + "is_system_extension": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "plan": {"key": "plan", "type": "Plan"}, + "extension_type": {"key": "properties.extensionType", "type": "str"}, + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "scope": {"key": "properties.scope", "type": "Scope"}, + "configuration_settings": {"key": "properties.configurationSettings", "type": "{str}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "current_version": {"key": "properties.currentVersion", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "statuses": {"key": "properties.statuses", "type": "[ExtensionStatus]"}, + "error_info": {"key": "properties.errorInfo", "type": "ErrorDetail"}, + "custom_location_settings": {"key": "properties.customLocationSettings", "type": "{str}"}, + "package_uri": {"key": "properties.packageUri", "type": "str"}, + "aks_assigned_identity": { + "key": "properties.aksAssignedIdentity", + "type": "ExtensionPropertiesAksAssignedIdentity", + }, + "is_system_extension": {"key": "properties.isSystemExtension", "type": "bool"}, + } + + def __init__( + self, + *, + identity: Optional["_models.Identity"] = None, + plan: Optional["_models.Plan"] = None, + extension_type: Optional[str] = None, + auto_upgrade_minor_version: bool = True, + release_train: str = "Stable", + version: Optional[str] = None, + scope: Optional["_models.Scope"] = None, + configuration_settings: Optional[Dict[str, str]] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + statuses: Optional[List["_models.ExtensionStatus"]] = None, + aks_assigned_identity: Optional["_models.ExtensionPropertiesAksAssignedIdentity"] = None, + **kwargs: Any + ) -> None: + """ + :keyword identity: Identity of the Extension resource. + :paramtype identity: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Identity + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Plan + :keyword extension_type: Type of the Extension, of which this resource is an instance of. It + must be one of the Extension Types registered with Microsoft.KubernetesConfiguration by the + Extension publisher. + :paramtype extension_type: str + :keyword auto_upgrade_minor_version: Flag to note if this extension participates in auto + upgrade of minor version, or not. + :paramtype auto_upgrade_minor_version: bool + :keyword release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. + Stable, Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :paramtype release_train: str + :keyword version: User-specified version of the extension for this extension to 'pin'. To use + 'version', autoUpgradeMinorVersion must be 'false'. + :paramtype version: str + :keyword scope: Scope at which the extension is installed. + :paramtype scope: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Scope + :keyword configuration_settings: Configuration settings, as name-value pairs for configuring + this extension. + :paramtype configuration_settings: dict[str, str] + :keyword configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :paramtype configuration_protected_settings: dict[str, str] + :keyword statuses: Status from this extension. + :paramtype statuses: + list[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ExtensionStatus] + :keyword aks_assigned_identity: Identity of the Extension resource in an AKS cluster. + :paramtype aks_assigned_identity: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ExtensionPropertiesAksAssignedIdentity + """ + super().__init__(**kwargs) + self.identity = identity + self.system_data = None + self.plan = plan + self.extension_type = extension_type + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.release_train = release_train + self.version = version + self.scope = scope + self.configuration_settings = configuration_settings + self.configuration_protected_settings = configuration_protected_settings + self.current_version = None + self.provisioning_state = None + self.statuses = statuses + self.error_info = None + self.custom_location_settings = None + self.package_uri = None + self.aks_assigned_identity = aks_assigned_identity + self.is_system_extension = None + + +class ExtensionPropertiesAksAssignedIdentity(_serialization.Model): + """Identity of the Extension resource in an AKS cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Known values are: "SystemAssigned" and "UserAssigned". + :vartype type: str or ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.AKSIdentityType + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Union[str, "_models.AKSIdentityType"]] = None, **kwargs: Any) -> None: + """ + :keyword type: The identity type. Known values are: "SystemAssigned" and "UserAssigned". + :paramtype type: str or ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.AKSIdentityType + """ + super().__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + + +class ExtensionsList(_serialization.Model): + """Result of the request to list Extensions. It contains a list of Extension objects and a URL + link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Extensions within a Kubernetes cluster. + :vartype value: list[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension] + :ivar next_link: URL to get the next set of extension objects, if any. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Extension]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class ExtensionStatus(_serialization.Model): + """Status from the extension. + + :ivar code: Status code provided by the Extension. + :vartype code: str + :ivar display_status: Short description of status of the extension. + :vartype display_status: str + :ivar level: Level of the status. Known values are: "Error", "Warning", and "Information". + :vartype level: str or ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.LevelType + :ivar message: Detailed message of the status from the Extension. + :vartype message: str + :ivar time: DateLiteral (per ISO8601) noting the time of installation status. + :vartype time: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "display_status": {"key": "displayStatus", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "time": {"key": "time", "type": "str"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + display_status: Optional[str] = None, + level: Union[str, "_models.LevelType"] = "Information", + message: Optional[str] = None, + time: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: Status code provided by the Extension. + :paramtype code: str + :keyword display_status: Short description of status of the extension. + :paramtype display_status: str + :keyword level: Level of the status. Known values are: "Error", "Warning", and "Information". + :paramtype level: str or ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.LevelType + :keyword message: Detailed message of the status from the Extension. + :paramtype message: str + :keyword time: DateLiteral (per ISO8601) noting the time of installation status. + :paramtype time: str + """ + super().__init__(**kwargs) + self.code = code + self.display_status = display_status + self.level = level + self.message = message + self.time = time + + +class FluxConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes + """The Flux Configuration object returned in Get & Put response. + + 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: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SystemData + :ivar scope: Scope at which the operator will be installed. Known values are: "cluster" and + "namespace". + :vartype scope: str or ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ScopeType + :ivar namespace: The namespace to which this configuration is installed to. Maximum of 253 + lower case alphanumeric characters, hyphen and period only. + :vartype namespace: str + :ivar source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository", "Bucket", and "AzureBlob". + :vartype source_kind: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceKindType + :ivar suspend: Whether this configuration should suspend its reconciliation of its + kustomizations and sources. + :vartype suspend: bool + :ivar git_repository: Parameters to reconcile to the GitRepository source kind type. + :vartype git_repository: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.GitRepositoryDefinition + :ivar bucket: Parameters to reconcile to the Bucket source kind type. + :vartype bucket: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.BucketDefinition + :ivar azure_blob: Parameters to reconcile to the AzureBlob source kind type. + :vartype azure_blob: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.AzureBlobDefinition + :ivar kustomizations: Array of kustomizations used to reconcile the artifact pulled by the + source type on the cluster. + :vartype kustomizations: dict[str, + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.KustomizationDefinition] + :ivar configuration_protected_settings: Key-value pairs of protected configuration settings for + the configuration. + :vartype configuration_protected_settings: dict[str, str] + :ivar statuses: Statuses of the Flux Kubernetes resources created by the fluxConfiguration or + created by the managed objects provisioned by the fluxConfiguration. + :vartype statuses: + list[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ObjectStatusDefinition] + :ivar repository_public_key: Public Key associated with this fluxConfiguration (either + generated within the cluster or provided by the user). + :vartype repository_public_key: str + :ivar source_synced_commit_id: Branch and/or SHA of the source commit synced with the cluster. + :vartype source_synced_commit_id: str + :ivar source_updated_at: Datetime the fluxConfiguration synced its source on the cluster. + :vartype source_updated_at: ~datetime.datetime + :ivar status_updated_at: Datetime the fluxConfiguration synced its status on the cluster with + Azure. + :vartype status_updated_at: ~datetime.datetime + :ivar compliance_state: Combined status of the Flux Kubernetes resources created by the + fluxConfiguration or created by the managed objects. Known values are: "Compliant", + "Non-Compliant", "Pending", "Suspended", and "Unknown". + :vartype compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxComplianceState + :ivar provisioning_state: Status of the creation of the fluxConfiguration. Known values are: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ProvisioningState + :ivar error_message: Error message returned to the user in the case of provisioning failure. + :vartype error_message: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "statuses": {"readonly": True}, + "repository_public_key": {"readonly": True}, + "source_synced_commit_id": {"readonly": True}, + "source_updated_at": {"readonly": True}, + "status_updated_at": {"readonly": True}, + "compliance_state": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "error_message": {"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"}, + "scope": {"key": "properties.scope", "type": "str"}, + "namespace": {"key": "properties.namespace", "type": "str"}, + "source_kind": {"key": "properties.sourceKind", "type": "str"}, + "suspend": {"key": "properties.suspend", "type": "bool"}, + "git_repository": {"key": "properties.gitRepository", "type": "GitRepositoryDefinition"}, + "bucket": {"key": "properties.bucket", "type": "BucketDefinition"}, + "azure_blob": {"key": "properties.azureBlob", "type": "AzureBlobDefinition"}, + "kustomizations": {"key": "properties.kustomizations", "type": "{KustomizationDefinition}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "statuses": {"key": "properties.statuses", "type": "[ObjectStatusDefinition]"}, + "repository_public_key": {"key": "properties.repositoryPublicKey", "type": "str"}, + "source_synced_commit_id": {"key": "properties.sourceSyncedCommitId", "type": "str"}, + "source_updated_at": {"key": "properties.sourceUpdatedAt", "type": "iso-8601"}, + "status_updated_at": {"key": "properties.statusUpdatedAt", "type": "iso-8601"}, + "compliance_state": {"key": "properties.complianceState", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "error_message": {"key": "properties.errorMessage", "type": "str"}, + } + + def __init__( + self, + *, + scope: Union[str, "_models.ScopeType"] = "cluster", + namespace: str = "default", + source_kind: Optional[Union[str, "_models.SourceKindType"]] = None, + suspend: bool = False, + git_repository: Optional["_models.GitRepositoryDefinition"] = None, + bucket: Optional["_models.BucketDefinition"] = None, + azure_blob: Optional["_models.AzureBlobDefinition"] = None, + kustomizations: Optional[Dict[str, "_models.KustomizationDefinition"]] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword scope: Scope at which the operator will be installed. Known values are: "cluster" and + "namespace". + :paramtype scope: str or ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ScopeType + :keyword namespace: The namespace to which this configuration is installed to. Maximum of 253 + lower case alphanumeric characters, hyphen and period only. + :paramtype namespace: str + :keyword source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository", "Bucket", and "AzureBlob". + :paramtype source_kind: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceKindType + :keyword suspend: Whether this configuration should suspend its reconciliation of its + kustomizations and sources. + :paramtype suspend: bool + :keyword git_repository: Parameters to reconcile to the GitRepository source kind type. + :paramtype git_repository: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.GitRepositoryDefinition + :keyword bucket: Parameters to reconcile to the Bucket source kind type. + :paramtype bucket: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.BucketDefinition + :keyword azure_blob: Parameters to reconcile to the AzureBlob source kind type. + :paramtype azure_blob: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.AzureBlobDefinition + :keyword kustomizations: Array of kustomizations used to reconcile the artifact pulled by the + source type on the cluster. + :paramtype kustomizations: dict[str, + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.KustomizationDefinition] + :keyword configuration_protected_settings: Key-value pairs of protected configuration settings + for the configuration. + :paramtype configuration_protected_settings: dict[str, str] + """ + super().__init__(**kwargs) + self.system_data = None + self.scope = scope + self.namespace = namespace + self.source_kind = source_kind + self.suspend = suspend + self.git_repository = git_repository + self.bucket = bucket + self.azure_blob = azure_blob + self.kustomizations = kustomizations + self.configuration_protected_settings = configuration_protected_settings + self.statuses = None + self.repository_public_key = None + self.source_synced_commit_id = None + self.source_updated_at = None + self.status_updated_at = None + self.compliance_state = None + self.provisioning_state = None + self.error_message = None + + +class FluxConfigurationPatch(_serialization.Model): + """The Flux Configuration Patch Request object. + + :ivar source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository", "Bucket", and "AzureBlob". + :vartype source_kind: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceKindType + :ivar suspend: Whether this configuration should suspend its reconciliation of its + kustomizations and sources. + :vartype suspend: bool + :ivar git_repository: Parameters to reconcile to the GitRepository source kind type. + :vartype git_repository: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.GitRepositoryPatchDefinition + :ivar bucket: Parameters to reconcile to the Bucket source kind type. + :vartype bucket: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.BucketPatchDefinition + :ivar azure_blob: Parameters to reconcile to the AzureBlob source kind type. + :vartype azure_blob: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.AzureBlobPatchDefinition + :ivar kustomizations: Array of kustomizations used to reconcile the artifact pulled by the + source type on the cluster. + :vartype kustomizations: dict[str, + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.KustomizationPatchDefinition] + :ivar configuration_protected_settings: Key-value pairs of protected configuration settings for + the configuration. + :vartype configuration_protected_settings: dict[str, str] + """ + + _attribute_map = { + "source_kind": {"key": "properties.sourceKind", "type": "str"}, + "suspend": {"key": "properties.suspend", "type": "bool"}, + "git_repository": {"key": "properties.gitRepository", "type": "GitRepositoryPatchDefinition"}, + "bucket": {"key": "properties.bucket", "type": "BucketPatchDefinition"}, + "azure_blob": {"key": "properties.azureBlob", "type": "AzureBlobPatchDefinition"}, + "kustomizations": {"key": "properties.kustomizations", "type": "{KustomizationPatchDefinition}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + } + + def __init__( + self, + *, + source_kind: Optional[Union[str, "_models.SourceKindType"]] = None, + suspend: Optional[bool] = None, + git_repository: Optional["_models.GitRepositoryPatchDefinition"] = None, + bucket: Optional["_models.BucketPatchDefinition"] = None, + azure_blob: Optional["_models.AzureBlobPatchDefinition"] = None, + kustomizations: Optional[Dict[str, "_models.KustomizationPatchDefinition"]] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword source_kind: Source Kind to pull the configuration data from. Known values are: + "GitRepository", "Bucket", and "AzureBlob". + :paramtype source_kind: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceKindType + :keyword suspend: Whether this configuration should suspend its reconciliation of its + kustomizations and sources. + :paramtype suspend: bool + :keyword git_repository: Parameters to reconcile to the GitRepository source kind type. + :paramtype git_repository: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.GitRepositoryPatchDefinition + :keyword bucket: Parameters to reconcile to the Bucket source kind type. + :paramtype bucket: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.BucketPatchDefinition + :keyword azure_blob: Parameters to reconcile to the AzureBlob source kind type. + :paramtype azure_blob: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.AzureBlobPatchDefinition + :keyword kustomizations: Array of kustomizations used to reconcile the artifact pulled by the + source type on the cluster. + :paramtype kustomizations: dict[str, + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.KustomizationPatchDefinition] + :keyword configuration_protected_settings: Key-value pairs of protected configuration settings + for the configuration. + :paramtype configuration_protected_settings: dict[str, str] + """ + super().__init__(**kwargs) + self.source_kind = source_kind + self.suspend = suspend + self.git_repository = git_repository + self.bucket = bucket + self.azure_blob = azure_blob + self.kustomizations = kustomizations + self.configuration_protected_settings = configuration_protected_settings + + +class FluxConfigurationsList(_serialization.Model): + """Result of the request to list Flux Configurations. It contains a list of FluxConfiguration + objects and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Flux Configurations within a Kubernetes cluster. + :vartype value: list[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration] + :ivar next_link: URL to get the next set of configuration objects, if any. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[FluxConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class GitRepositoryDefinition(_serialization.Model): + """Parameters to reconcile to the GitRepository source kind type. + + :ivar url: The URL to sync for the flux configuration git repository. + :vartype url: str + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository + source with the remote. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :vartype sync_interval_in_seconds: int + :ivar repository_ref: The source reference for the GitRepository object. + :vartype repository_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.RepositoryRefDefinition + :ivar ssh_known_hosts: Base64-encoded known_hosts value containing public SSH keys required to + access private git repositories over SSH. + :vartype ssh_known_hosts: str + :ivar https_user: Plaintext HTTPS username used to access private git repositories over HTTPS. + :vartype https_user: str + :ivar https_ca_cert: Base64-encoded HTTPS certificate authority contents used to access git + private git repositories over HTTPS. + :vartype https_ca_cert: str + :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :vartype local_auth_ref: str + """ + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "repository_ref": {"key": "repositoryRef", "type": "RepositoryRefDefinition"}, + "ssh_known_hosts": {"key": "sshKnownHosts", "type": "str"}, + "https_user": {"key": "httpsUser", "type": "str"}, + "https_ca_cert": {"key": "httpsCACert", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, + repository_ref: Optional["_models.RepositoryRefDefinition"] = None, + ssh_known_hosts: Optional[str] = None, + https_user: Optional[str] = None, + https_ca_cert: Optional[str] = None, + local_auth_ref: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword url: The URL to sync for the flux configuration git repository. + :paramtype url: str + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster git + repository source with the remote. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :paramtype sync_interval_in_seconds: int + :keyword repository_ref: The source reference for the GitRepository object. + :paramtype repository_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.RepositoryRefDefinition + :keyword ssh_known_hosts: Base64-encoded known_hosts value containing public SSH keys required + to access private git repositories over SSH. + :paramtype ssh_known_hosts: str + :keyword https_user: Plaintext HTTPS username used to access private git repositories over + HTTPS. + :paramtype https_user: str + :keyword https_ca_cert: Base64-encoded HTTPS certificate authority contents used to access git + private git repositories over HTTPS. + :paramtype https_ca_cert: str + :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :paramtype local_auth_ref: str + """ + super().__init__(**kwargs) + self.url = url + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.repository_ref = repository_ref + self.ssh_known_hosts = ssh_known_hosts + self.https_user = https_user + self.https_ca_cert = https_ca_cert + self.local_auth_ref = local_auth_ref + + +class GitRepositoryPatchDefinition(_serialization.Model): + """Parameters to reconcile to the GitRepository source kind type. + + :ivar url: The URL to sync for the flux configuration git repository. + :vartype url: str + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the cluster git repository + source with the remote. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :vartype sync_interval_in_seconds: int + :ivar repository_ref: The source reference for the GitRepository object. + :vartype repository_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.RepositoryRefDefinition + :ivar ssh_known_hosts: Base64-encoded known_hosts value containing public SSH keys required to + access private git repositories over SSH. + :vartype ssh_known_hosts: str + :ivar https_user: Plaintext HTTPS username used to access private git repositories over HTTPS. + :vartype https_user: str + :ivar https_ca_cert: Base64-encoded HTTPS certificate authority contents used to access git + private git repositories over HTTPS. + :vartype https_ca_cert: str + :ivar local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :vartype local_auth_ref: str + """ + + _attribute_map = { + "url": {"key": "url", "type": "str"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "repository_ref": {"key": "repositoryRef", "type": "RepositoryRefDefinition"}, + "ssh_known_hosts": {"key": "sshKnownHosts", "type": "str"}, + "https_user": {"key": "httpsUser", "type": "str"}, + "https_ca_cert": {"key": "httpsCACert", "type": "str"}, + "local_auth_ref": {"key": "localAuthRef", "type": "str"}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + timeout_in_seconds: Optional[int] = None, + sync_interval_in_seconds: Optional[int] = None, + repository_ref: Optional["_models.RepositoryRefDefinition"] = None, + ssh_known_hosts: Optional[str] = None, + https_user: Optional[str] = None, + https_ca_cert: Optional[str] = None, + local_auth_ref: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword url: The URL to sync for the flux configuration git repository. + :paramtype url: str + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the cluster git + repository source with the remote. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the cluster git + repository source with the remote. + :paramtype sync_interval_in_seconds: int + :keyword repository_ref: The source reference for the GitRepository object. + :paramtype repository_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.RepositoryRefDefinition + :keyword ssh_known_hosts: Base64-encoded known_hosts value containing public SSH keys required + to access private git repositories over SSH. + :paramtype ssh_known_hosts: str + :keyword https_user: Plaintext HTTPS username used to access private git repositories over + HTTPS. + :paramtype https_user: str + :keyword https_ca_cert: Base64-encoded HTTPS certificate authority contents used to access git + private git repositories over HTTPS. + :paramtype https_ca_cert: str + :keyword local_auth_ref: Name of a local secret on the Kubernetes cluster to use as the + authentication secret rather than the managed or user-provided configuration secrets. + :paramtype local_auth_ref: str + """ + super().__init__(**kwargs) + self.url = url + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.repository_ref = repository_ref + self.ssh_known_hosts = ssh_known_hosts + self.https_user = https_user + self.https_ca_cert = https_ca_cert + self.local_auth_ref = local_auth_ref + + +class HelmOperatorProperties(_serialization.Model): + """Properties for Helm operator. + + :ivar chart_version: Version of the operator Helm chart. + :vartype chart_version: str + :ivar chart_values: Values override for the operator Helm chart. + :vartype chart_values: str + """ + + _attribute_map = { + "chart_version": {"key": "chartVersion", "type": "str"}, + "chart_values": {"key": "chartValues", "type": "str"}, + } + + def __init__( + self, *, chart_version: Optional[str] = None, chart_values: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword chart_version: Version of the operator Helm chart. + :paramtype chart_version: str + :keyword chart_values: Values override for the operator Helm chart. + :paramtype chart_values: str + """ + super().__init__(**kwargs) + self.chart_version = chart_version + self.chart_values = chart_values + + +class HelmReleasePropertiesDefinition(_serialization.Model): + """Properties for HelmRelease objects. + + :ivar last_revision_applied: The revision number of the last released object change. + :vartype last_revision_applied: int + :ivar helm_chart_ref: The reference to the HelmChart object used as the source to this + HelmRelease. + :vartype helm_chart_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ObjectReferenceDefinition + :ivar failure_count: Total number of times that the HelmRelease failed to install or upgrade. + :vartype failure_count: int + :ivar install_failure_count: Number of times that the HelmRelease failed to install. + :vartype install_failure_count: int + :ivar upgrade_failure_count: Number of times that the HelmRelease failed to upgrade. + :vartype upgrade_failure_count: int + """ + + _attribute_map = { + "last_revision_applied": {"key": "lastRevisionApplied", "type": "int"}, + "helm_chart_ref": {"key": "helmChartRef", "type": "ObjectReferenceDefinition"}, + "failure_count": {"key": "failureCount", "type": "int"}, + "install_failure_count": {"key": "installFailureCount", "type": "int"}, + "upgrade_failure_count": {"key": "upgradeFailureCount", "type": "int"}, + } + + def __init__( + self, + *, + last_revision_applied: Optional[int] = None, + helm_chart_ref: Optional["_models.ObjectReferenceDefinition"] = None, + failure_count: Optional[int] = None, + install_failure_count: Optional[int] = None, + upgrade_failure_count: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword last_revision_applied: The revision number of the last released object change. + :paramtype last_revision_applied: int + :keyword helm_chart_ref: The reference to the HelmChart object used as the source to this + HelmRelease. + :paramtype helm_chart_ref: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ObjectReferenceDefinition + :keyword failure_count: Total number of times that the HelmRelease failed to install or + upgrade. + :paramtype failure_count: int + :keyword install_failure_count: Number of times that the HelmRelease failed to install. + :paramtype install_failure_count: int + :keyword upgrade_failure_count: Number of times that the HelmRelease failed to upgrade. + :paramtype upgrade_failure_count: int + """ + super().__init__(**kwargs) + self.last_revision_applied = last_revision_applied + self.helm_chart_ref = helm_chart_ref + self.failure_count = failure_count + self.install_failure_count = install_failure_count + self.upgrade_failure_count = upgrade_failure_count + + +class Identity(_serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Default value is "SystemAssigned". + :vartype type: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: + """ + :keyword type: The identity type. Default value is "SystemAssigned". + :paramtype type: str + """ + super().__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + + +class KustomizationDefinition(_serialization.Model): + """The Kustomization defining how to reconcile the artifact pulled by the source type on the + cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Kustomization, matching the key in the Kustomizations object map. + :vartype name: str + :ivar path: The path in the source reference to reconcile on the cluster. + :vartype path: str + :ivar depends_on: Specifies other Kustomizations that this Kustomization depends on. This + Kustomization will not reconcile until all dependencies have completed their reconciliation. + :vartype depends_on: list[str] + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the + cluster. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the + cluster. + :vartype sync_interval_in_seconds: int + :ivar retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the + cluster in the event of failure on reconciliation. + :vartype retry_interval_in_seconds: int + :ivar prune: Enable/disable garbage collections of Kubernetes objects created by this + Kustomization. + :vartype prune: bool + :ivar force: Enable/disable re-creating Kubernetes resources on the cluster when patching fails + due to an immutable field change. + :vartype force: bool + """ + + _validation = { + "name": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "path": {"key": "path", "type": "str"}, + "depends_on": {"key": "dependsOn", "type": "[str]"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "retry_interval_in_seconds": {"key": "retryIntervalInSeconds", "type": "int"}, + "prune": {"key": "prune", "type": "bool"}, + "force": {"key": "force", "type": "bool"}, + } + + def __init__( + self, + *, + path: str = "", + depends_on: Optional[List[str]] = None, + timeout_in_seconds: int = 600, + sync_interval_in_seconds: int = 600, + retry_interval_in_seconds: Optional[int] = None, + prune: bool = False, + force: bool = False, + **kwargs: Any + ) -> None: + """ + :keyword path: The path in the source reference to reconcile on the cluster. + :paramtype path: str + :keyword depends_on: Specifies other Kustomizations that this Kustomization depends on. This + Kustomization will not reconcile until all dependencies have completed their reconciliation. + :paramtype depends_on: list[str] + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the + cluster. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on + the cluster. + :paramtype sync_interval_in_seconds: int + :keyword retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on + the cluster in the event of failure on reconciliation. + :paramtype retry_interval_in_seconds: int + :keyword prune: Enable/disable garbage collections of Kubernetes objects created by this + Kustomization. + :paramtype prune: bool + :keyword force: Enable/disable re-creating Kubernetes resources on the cluster when patching + fails due to an immutable field change. + :paramtype force: bool + """ + super().__init__(**kwargs) + self.name = None + self.path = path + self.depends_on = depends_on + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.retry_interval_in_seconds = retry_interval_in_seconds + self.prune = prune + self.force = force + + +class KustomizationPatchDefinition(_serialization.Model): + """The Kustomization defining how to reconcile the artifact pulled by the source type on the + cluster. + + :ivar path: The path in the source reference to reconcile on the cluster. + :vartype path: str + :ivar depends_on: Specifies other Kustomizations that this Kustomization depends on. This + Kustomization will not reconcile until all dependencies have completed their reconciliation. + :vartype depends_on: list[str] + :ivar timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the + cluster. + :vartype timeout_in_seconds: int + :ivar sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the + cluster. + :vartype sync_interval_in_seconds: int + :ivar retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on the + cluster in the event of failure on reconciliation. + :vartype retry_interval_in_seconds: int + :ivar prune: Enable/disable garbage collections of Kubernetes objects created by this + Kustomization. + :vartype prune: bool + :ivar force: Enable/disable re-creating Kubernetes resources on the cluster when patching fails + due to an immutable field change. + :vartype force: bool + """ + + _attribute_map = { + "path": {"key": "path", "type": "str"}, + "depends_on": {"key": "dependsOn", "type": "[str]"}, + "timeout_in_seconds": {"key": "timeoutInSeconds", "type": "int"}, + "sync_interval_in_seconds": {"key": "syncIntervalInSeconds", "type": "int"}, + "retry_interval_in_seconds": {"key": "retryIntervalInSeconds", "type": "int"}, + "prune": {"key": "prune", "type": "bool"}, + "force": {"key": "force", "type": "bool"}, + } + + def __init__( + self, + *, + path: Optional[str] = None, + depends_on: Optional[List[str]] = None, + timeout_in_seconds: Optional[int] = None, + sync_interval_in_seconds: Optional[int] = None, + retry_interval_in_seconds: Optional[int] = None, + prune: Optional[bool] = None, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword path: The path in the source reference to reconcile on the cluster. + :paramtype path: str + :keyword depends_on: Specifies other Kustomizations that this Kustomization depends on. This + Kustomization will not reconcile until all dependencies have completed their reconciliation. + :paramtype depends_on: list[str] + :keyword timeout_in_seconds: The maximum time to attempt to reconcile the Kustomization on the + cluster. + :paramtype timeout_in_seconds: int + :keyword sync_interval_in_seconds: The interval at which to re-reconcile the Kustomization on + the cluster. + :paramtype sync_interval_in_seconds: int + :keyword retry_interval_in_seconds: The interval at which to re-reconcile the Kustomization on + the cluster in the event of failure on reconciliation. + :paramtype retry_interval_in_seconds: int + :keyword prune: Enable/disable garbage collections of Kubernetes objects created by this + Kustomization. + :paramtype prune: bool + :keyword force: Enable/disable re-creating Kubernetes resources on the cluster when patching + fails due to an immutable field change. + :paramtype force: bool + """ + super().__init__(**kwargs) + self.path = path + self.depends_on = depends_on + self.timeout_in_seconds = timeout_in_seconds + self.sync_interval_in_seconds = sync_interval_in_seconds + self.retry_interval_in_seconds = retry_interval_in_seconds + self.prune = prune + self.force = force + + +class ManagedIdentityDefinition(_serialization.Model): + """Parameters to authenticate using a Managed Identity. + + :ivar client_id: The client Id for authenticating a Managed Identity. + :vartype client_id: str + """ + + _attribute_map = { + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, *, client_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword client_id: The client Id for authenticating a Managed Identity. + :paramtype client_id: str + """ + super().__init__(**kwargs) + self.client_id = client_id + + +class ManagedIdentityPatchDefinition(_serialization.Model): + """Parameters to authenticate using a Managed Identity. + + :ivar client_id: The client Id for authenticating a Managed Identity. + :vartype client_id: str + """ + + _attribute_map = { + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, *, client_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword client_id: The client Id for authenticating a Managed Identity. + :paramtype client_id: str + """ + super().__init__(**kwargs) + self.client_id = client_id + + +class ObjectReferenceDefinition(_serialization.Model): + """Object reference to a Kubernetes object on a cluster. + + :ivar name: Name of the object. + :vartype name: str + :ivar namespace: Namespace of the object. + :vartype namespace: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, namespace: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: Name of the object. + :paramtype name: str + :keyword namespace: Namespace of the object. + :paramtype namespace: str + """ + super().__init__(**kwargs) + self.name = name + self.namespace = namespace + + +class ObjectStatusConditionDefinition(_serialization.Model): + """Status condition of Kubernetes object. + + :ivar last_transition_time: Last time this status condition has changed. + :vartype last_transition_time: ~datetime.datetime + :ivar message: A more verbose description of the object status condition. + :vartype message: str + :ivar reason: Reason for the specified status condition type status. + :vartype reason: str + :ivar status: Status of the Kubernetes object condition type. + :vartype status: str + :ivar type: Object status condition type for this object. + :vartype type: str + """ + + _attribute_map = { + "last_transition_time": {"key": "lastTransitionTime", "type": "iso-8601"}, + "message": {"key": "message", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + last_transition_time: Optional[datetime.datetime] = None, + message: Optional[str] = None, + reason: Optional[str] = None, + status: Optional[str] = None, + type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword last_transition_time: Last time this status condition has changed. + :paramtype last_transition_time: ~datetime.datetime + :keyword message: A more verbose description of the object status condition. + :paramtype message: str + :keyword reason: Reason for the specified status condition type status. + :paramtype reason: str + :keyword status: Status of the Kubernetes object condition type. + :paramtype status: str + :keyword type: Object status condition type for this object. + :paramtype type: str + """ + super().__init__(**kwargs) + self.last_transition_time = last_transition_time + self.message = message + self.reason = reason + self.status = status + self.type = type + + +class ObjectStatusDefinition(_serialization.Model): + """Statuses of objects deployed by the user-specified kustomizations from the git repository. + + :ivar name: Name of the applied object. + :vartype name: str + :ivar namespace: Namespace of the applied object. + :vartype namespace: str + :ivar kind: Kind of the applied object. + :vartype kind: str + :ivar compliance_state: Compliance state of the applied object showing whether the applied + object has come into a ready state on the cluster. Known values are: "Compliant", + "Non-Compliant", "Pending", "Suspended", and "Unknown". + :vartype compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxComplianceState + :ivar applied_by: Object reference to the Kustomization that applied this object. + :vartype applied_by: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ObjectReferenceDefinition + :ivar status_conditions: List of Kubernetes object status conditions present on the cluster. + :vartype status_conditions: + list[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ObjectStatusConditionDefinition] + :ivar helm_release_properties: Additional properties that are provided from objects of the + HelmRelease kind. + :vartype helm_release_properties: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.HelmReleasePropertiesDefinition + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "compliance_state": {"key": "complianceState", "type": "str"}, + "applied_by": {"key": "appliedBy", "type": "ObjectReferenceDefinition"}, + "status_conditions": {"key": "statusConditions", "type": "[ObjectStatusConditionDefinition]"}, + "helm_release_properties": {"key": "helmReleaseProperties", "type": "HelmReleasePropertiesDefinition"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + namespace: Optional[str] = None, + kind: Optional[str] = None, + compliance_state: Union[str, "_models.FluxComplianceState"] = "Unknown", + applied_by: Optional["_models.ObjectReferenceDefinition"] = None, + status_conditions: Optional[List["_models.ObjectStatusConditionDefinition"]] = None, + helm_release_properties: Optional["_models.HelmReleasePropertiesDefinition"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the applied object. + :paramtype name: str + :keyword namespace: Namespace of the applied object. + :paramtype namespace: str + :keyword kind: Kind of the applied object. + :paramtype kind: str + :keyword compliance_state: Compliance state of the applied object showing whether the applied + object has come into a ready state on the cluster. Known values are: "Compliant", + "Non-Compliant", "Pending", "Suspended", and "Unknown". + :paramtype compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxComplianceState + :keyword applied_by: Object reference to the Kustomization that applied this object. + :paramtype applied_by: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ObjectReferenceDefinition + :keyword status_conditions: List of Kubernetes object status conditions present on the cluster. + :paramtype status_conditions: + list[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ObjectStatusConditionDefinition] + :keyword helm_release_properties: Additional properties that are provided from objects of the + HelmRelease kind. + :paramtype helm_release_properties: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.HelmReleasePropertiesDefinition + """ + super().__init__(**kwargs) + self.name = name + self.namespace = namespace + self.kind = kind + self.compliance_state = compliance_state + self.applied_by = applied_by + self.status_conditions = status_conditions + self.helm_release_properties = helm_release_properties + + +class OperationStatusList(_serialization.Model): + """The async operations in progress, in the cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of async operations in progress, in the cluster. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.OperationStatusResult] + :ivar next_link: URL to get the next set of Operation Result objects, if any. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[OperationStatusResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class OperationStatusResult(_serialization.Model): + """The current status of an async operation. + + 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 ID for the async operation. + :vartype id: str + :ivar name: Name of the async operation. + :vartype name: str + :ivar status: Operation status. Required. + :vartype status: str + :ivar properties: Additional information, if available. + :vartype properties: dict[str, str] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ErrorDetail + """ + + _validation = { + "status": {"required": True}, + "error": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__( + self, + *, + status: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Fully qualified ID for the async operation. + :paramtype id: str + :keyword name: Name of the async operation. + :paramtype name: str + :keyword status: Operation status. Required. + :paramtype status: str + :keyword properties: Additional information, if available. + :paramtype properties: dict[str, str] + """ + super().__init__(**kwargs) + self.id = id + self.name = name + self.status = status + self.properties = properties + self.error = None + + +class PatchExtension(_serialization.Model): + """The Extension Patch Request object. + + :ivar auto_upgrade_minor_version: Flag to note if this extension participates in auto upgrade + of minor version, or not. + :vartype auto_upgrade_minor_version: bool + :ivar release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. Stable, + Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :vartype release_train: str + :ivar version: Version of the extension for this extension, if it is 'pinned' to a specific + version. autoUpgradeMinorVersion must be 'false'. + :vartype version: str + :ivar configuration_settings: Configuration settings, as name-value pairs for configuring this + extension. + :vartype configuration_settings: dict[str, str] + :ivar configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :vartype configuration_protected_settings: dict[str, str] + """ + + _attribute_map = { + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "release_train": {"key": "properties.releaseTrain", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "configuration_settings": {"key": "properties.configurationSettings", "type": "{str}"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + } + + def __init__( + self, + *, + auto_upgrade_minor_version: bool = True, + release_train: str = "Stable", + version: Optional[str] = None, + configuration_settings: Optional[Dict[str, str]] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword auto_upgrade_minor_version: Flag to note if this extension participates in auto + upgrade of minor version, or not. + :paramtype auto_upgrade_minor_version: bool + :keyword release_train: ReleaseTrain this extension participates in for auto-upgrade (e.g. + Stable, Preview, etc.) - only if autoUpgradeMinorVersion is 'true'. + :paramtype release_train: str + :keyword version: Version of the extension for this extension, if it is 'pinned' to a specific + version. autoUpgradeMinorVersion must be 'false'. + :paramtype version: str + :keyword configuration_settings: Configuration settings, as name-value pairs for configuring + this extension. + :paramtype configuration_settings: dict[str, str] + :keyword configuration_protected_settings: Configuration settings that are sensitive, as + name-value pairs for configuring this extension. + :paramtype configuration_protected_settings: dict[str, str] + """ + super().__init__(**kwargs) + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.release_train = release_train + self.version = version + self.configuration_settings = configuration_settings + self.configuration_protected_settings = configuration_protected_settings + + +class Plan(_serialization.Model): + """Plan for the resource. + + All required parameters must be populated in order to send to Azure. + + :ivar name: A user defined name of the 3rd Party Artifact that is being procured. Required. + :vartype name: str + :ivar publisher: The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic. + Required. + :vartype publisher: str + :ivar product: The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to + the OfferID specified for the artifact at the time of Data Market onboarding. Required. + :vartype product: str + :ivar promotion_code: A publisher provided promotion code as provisioned in Data Market for the + said product/artifact. + :vartype promotion_code: str + :ivar version: The version of the desired product/artifact. + :vartype version: str + """ + + _validation = { + "name": {"required": True}, + "publisher": {"required": True}, + "product": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "publisher": {"key": "publisher", "type": "str"}, + "product": {"key": "product", "type": "str"}, + "promotion_code": {"key": "promotionCode", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + publisher: str, + product: str, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: A user defined name of the 3rd Party Artifact that is being procured. Required. + :paramtype name: str + :keyword publisher: The publisher of the 3rd Party Artifact that is being bought. E.g. + NewRelic. Required. + :paramtype publisher: str + :keyword product: The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to + the OfferID specified for the artifact at the time of Data Market onboarding. Required. + :paramtype product: str + :keyword promotion_code: A publisher provided promotion code as provisioned in Data Market for + the said product/artifact. + :paramtype promotion_code: str + :keyword version: The version of the desired product/artifact. + :paramtype version: str + """ + super().__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product + self.promotion_code = promotion_code + self.version = version + + +class RepositoryRefDefinition(_serialization.Model): + """The source reference for the GitRepository object. + + :ivar branch: The git repository branch name to checkout. + :vartype branch: str + :ivar tag: The git repository tag name to checkout. This takes precedence over branch. + :vartype tag: str + :ivar semver: The semver range used to match against git repository tags. This takes precedence + over tag. + :vartype semver: str + :ivar commit: The commit SHA to checkout. This value must be combined with the branch name to + be valid. This takes precedence over semver. + :vartype commit: str + """ + + _attribute_map = { + "branch": {"key": "branch", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "semver": {"key": "semver", "type": "str"}, + "commit": {"key": "commit", "type": "str"}, + } + + def __init__( + self, + *, + branch: Optional[str] = None, + tag: Optional[str] = None, + semver: Optional[str] = None, + commit: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword branch: The git repository branch name to checkout. + :paramtype branch: str + :keyword tag: The git repository tag name to checkout. This takes precedence over branch. + :paramtype tag: str + :keyword semver: The semver range used to match against git repository tags. This takes + precedence over tag. + :paramtype semver: str + :keyword commit: The commit SHA to checkout. This value must be combined with the branch name + to be valid. This takes precedence over semver. + :paramtype commit: str + """ + super().__init__(**kwargs) + self.branch = branch + self.tag = tag + self.semver = semver + self.commit = commit + + +class ResourceProviderOperation(_serialization.Model): + """Supported operation of this resource provider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Operation name, in format of {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: Display metadata associated with the operation. + :vartype display: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ResourceProviderOperationDisplay + :ivar is_data_action: The flag that indicates whether the operation applies to data plane. + :vartype is_data_action: bool + :ivar origin: Origin of the operation. + :vartype origin: str + """ + + _validation = { + "is_data_action": {"readonly": True}, + "origin": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "ResourceProviderOperationDisplay"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "origin": {"key": "origin", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["_models.ResourceProviderOperationDisplay"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Operation name, in format of {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: Display metadata associated with the operation. + :paramtype display: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ResourceProviderOperationDisplay + """ + super().__init__(**kwargs) + self.name = name + self.display = display + self.is_data_action = None + self.origin = None + + +class ResourceProviderOperationDisplay(_serialization.Model): + """Display metadata associated with the operation. + + :ivar provider: Resource provider: Microsoft KubernetesConfiguration. + :vartype provider: str + :ivar resource: Resource on which the operation is performed. + :vartype resource: str + :ivar operation: Type of operation: get, read, delete, etc. + :vartype operation: str + :ivar description: Description of this 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: Any + ) -> None: + """ + :keyword provider: Resource provider: Microsoft KubernetesConfiguration. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed. + :paramtype resource: str + :keyword operation: Type of operation: get, read, delete, etc. + :paramtype operation: str + :keyword description: Description of this operation. + :paramtype description: str + """ + super().__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class ResourceProviderOperationList(_serialization.Model): + """Result of the request to list operations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by this resource provider. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ResourceProviderOperation] + :ivar next_link: URL to the next set of results, if any. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ResourceProviderOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ResourceProviderOperation"]] = None, **kwargs: Any) -> None: + """ + :keyword value: List of operations supported by this resource provider. + :paramtype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ResourceProviderOperation] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class Scope(_serialization.Model): + """Scope of the extension. It can be either Cluster or Namespace; but not both. + + :ivar cluster: Specifies that the scope of the extension is Cluster. + :vartype cluster: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ScopeCluster + :ivar namespace: Specifies that the scope of the extension is Namespace. + :vartype namespace: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ScopeNamespace + """ + + _attribute_map = { + "cluster": {"key": "cluster", "type": "ScopeCluster"}, + "namespace": {"key": "namespace", "type": "ScopeNamespace"}, + } + + def __init__( + self, + *, + cluster: Optional["_models.ScopeCluster"] = None, + namespace: Optional["_models.ScopeNamespace"] = None, + **kwargs: Any + ) -> None: + """ + :keyword cluster: Specifies that the scope of the extension is Cluster. + :paramtype cluster: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ScopeCluster + :keyword namespace: Specifies that the scope of the extension is Namespace. + :paramtype namespace: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ScopeNamespace + """ + super().__init__(**kwargs) + self.cluster = cluster + self.namespace = namespace + + +class ScopeCluster(_serialization.Model): + """Specifies that the scope of the extension is Cluster. + + :ivar release_namespace: Namespace where the extension Release must be placed, for a Cluster + scoped extension. If this namespace does not exist, it will be created. + :vartype release_namespace: str + """ + + _attribute_map = { + "release_namespace": {"key": "releaseNamespace", "type": "str"}, + } + + def __init__(self, *, release_namespace: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword release_namespace: Namespace where the extension Release must be placed, for a Cluster + scoped extension. If this namespace does not exist, it will be created. + :paramtype release_namespace: str + """ + super().__init__(**kwargs) + self.release_namespace = release_namespace + + +class ScopeNamespace(_serialization.Model): + """Specifies that the scope of the extension is Namespace. + + :ivar target_namespace: Namespace where the extension will be created for an Namespace scoped + extension. If this namespace does not exist, it will be created. + :vartype target_namespace: str + """ + + _attribute_map = { + "target_namespace": {"key": "targetNamespace", "type": "str"}, + } + + def __init__(self, *, target_namespace: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword target_namespace: Namespace where the extension will be created for an Namespace + scoped extension. If this namespace does not exist, it will be created. + :paramtype target_namespace: str + """ + super().__init__(**kwargs) + self.target_namespace = target_namespace + + +class ServicePrincipalDefinition(_serialization.Model): + """Parameters to authenticate using Service Principal. + + :ivar client_id: The client Id for authenticating a Service Principal. + :vartype client_id: str + :ivar tenant_id: The tenant Id for authenticating a Service Principal. + :vartype tenant_id: str + :ivar client_secret: The client secret for authenticating a Service Principal. + :vartype client_secret: str + :ivar client_certificate: Base64-encoded certificate used to authenticate a Service Principal. + :vartype client_certificate: str + :ivar client_certificate_password: The password for the certificate used to authenticate a + Service Principal. + :vartype client_certificate_password: str + :ivar client_certificate_send_chain: Specifies whether to include x5c header in client claims + when acquiring a token to enable subject name / issuer based authentication for the Client + Certificate. + :vartype client_certificate_send_chain: bool + """ + + _attribute_map = { + "client_id": {"key": "clientId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, + "client_certificate": {"key": "clientCertificate", "type": "str"}, + "client_certificate_password": {"key": "clientCertificatePassword", "type": "str"}, + "client_certificate_send_chain": {"key": "clientCertificateSendChain", "type": "bool"}, + } + + def __init__( + self, + *, + client_id: Optional[str] = None, + tenant_id: Optional[str] = None, + client_secret: Optional[str] = None, + client_certificate: Optional[str] = None, + client_certificate_password: Optional[str] = None, + client_certificate_send_chain: bool = False, + **kwargs: Any + ) -> None: + """ + :keyword client_id: The client Id for authenticating a Service Principal. + :paramtype client_id: str + :keyword tenant_id: The tenant Id for authenticating a Service Principal. + :paramtype tenant_id: str + :keyword client_secret: The client secret for authenticating a Service Principal. + :paramtype client_secret: str + :keyword client_certificate: Base64-encoded certificate used to authenticate a Service + Principal. + :paramtype client_certificate: str + :keyword client_certificate_password: The password for the certificate used to authenticate a + Service Principal. + :paramtype client_certificate_password: str + :keyword client_certificate_send_chain: Specifies whether to include x5c header in client + claims when acquiring a token to enable subject name / issuer based authentication for the + Client Certificate. + :paramtype client_certificate_send_chain: bool + """ + super().__init__(**kwargs) + self.client_id = client_id + self.tenant_id = tenant_id + self.client_secret = client_secret + self.client_certificate = client_certificate + self.client_certificate_password = client_certificate_password + self.client_certificate_send_chain = client_certificate_send_chain + + +class ServicePrincipalPatchDefinition(_serialization.Model): + """Parameters to authenticate using Service Principal. + + :ivar client_id: The client Id for authenticating a Service Principal. + :vartype client_id: str + :ivar tenant_id: The tenant Id for authenticating a Service Principal. + :vartype tenant_id: str + :ivar client_secret: The client secret for authenticating a Service Principal. + :vartype client_secret: str + :ivar client_certificate: Base64-encoded certificate used to authenticate a Service Principal. + :vartype client_certificate: str + :ivar client_certificate_password: The password for the certificate used to authenticate a + Service Principal. + :vartype client_certificate_password: str + :ivar client_certificate_send_chain: Specifies whether to include x5c header in client claims + when acquiring a token to enable subject name / issuer based authentication for the Client + Certificate. + :vartype client_certificate_send_chain: bool + """ + + _attribute_map = { + "client_id": {"key": "clientId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, + "client_certificate": {"key": "clientCertificate", "type": "str"}, + "client_certificate_password": {"key": "clientCertificatePassword", "type": "str"}, + "client_certificate_send_chain": {"key": "clientCertificateSendChain", "type": "bool"}, + } + + def __init__( + self, + *, + client_id: Optional[str] = None, + tenant_id: Optional[str] = None, + client_secret: Optional[str] = None, + client_certificate: Optional[str] = None, + client_certificate_password: Optional[str] = None, + client_certificate_send_chain: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword client_id: The client Id for authenticating a Service Principal. + :paramtype client_id: str + :keyword tenant_id: The tenant Id for authenticating a Service Principal. + :paramtype tenant_id: str + :keyword client_secret: The client secret for authenticating a Service Principal. + :paramtype client_secret: str + :keyword client_certificate: Base64-encoded certificate used to authenticate a Service + Principal. + :paramtype client_certificate: str + :keyword client_certificate_password: The password for the certificate used to authenticate a + Service Principal. + :paramtype client_certificate_password: str + :keyword client_certificate_send_chain: Specifies whether to include x5c header in client + claims when acquiring a token to enable subject name / issuer based authentication for the + Client Certificate. + :paramtype client_certificate_send_chain: bool + """ + super().__init__(**kwargs) + self.client_id = client_id + self.tenant_id = tenant_id + self.client_secret = client_secret + self.client_certificate = client_certificate + self.client_certificate_password = client_certificate_password + self.client_certificate_send_chain = client_certificate_send_chain + + +class SourceControlConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes + """The SourceControl Configuration object returned in Get & Put response. + + 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: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. + :vartype system_data: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SystemData + :ivar repository_url: Url of the SourceControl Repository. + :vartype repository_url: str + :ivar operator_namespace: The namespace to which this operator is installed to. Maximum of 253 + lower case alphanumeric characters, hyphen and period only. + :vartype operator_namespace: str + :ivar operator_instance_name: Instance name of the operator - identifying the specific + configuration. + :vartype operator_instance_name: str + :ivar operator_type: Type of the operator. "Flux" + :vartype operator_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.OperatorType + :ivar operator_params: Any Parameters for the Operator instance in string format. + :vartype operator_params: str + :ivar configuration_protected_settings: Name-value pairs of protected configuration settings + for the configuration. + :vartype configuration_protected_settings: dict[str, str] + :ivar operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". + :vartype operator_scope: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.OperatorScopeType + :ivar repository_public_key: Public Key associated with this SourceControl configuration + (either generated within the cluster or provided by the user). + :vartype repository_public_key: str + :ivar ssh_known_hosts_contents: Base64-encoded known_hosts contents containing public SSH keys + required to access private Git instances. + :vartype ssh_known_hosts_contents: str + :ivar enable_helm_operator: Option to enable Helm Operator for this git configuration. + :vartype enable_helm_operator: bool + :ivar helm_operator_properties: Properties for Helm operator. + :vartype helm_operator_properties: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.HelmOperatorProperties + :ivar provisioning_state: The provisioning state of the resource provider. Known values are: + "Accepted", "Deleting", "Running", "Succeeded", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ProvisioningStateType + :ivar compliance_status: Compliance Status of the Configuration. + :vartype compliance_status: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ComplianceStatus + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "repository_public_key": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "compliance_status": {"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"}, + "repository_url": {"key": "properties.repositoryUrl", "type": "str"}, + "operator_namespace": {"key": "properties.operatorNamespace", "type": "str"}, + "operator_instance_name": {"key": "properties.operatorInstanceName", "type": "str"}, + "operator_type": {"key": "properties.operatorType", "type": "str"}, + "operator_params": {"key": "properties.operatorParams", "type": "str"}, + "configuration_protected_settings": {"key": "properties.configurationProtectedSettings", "type": "{str}"}, + "operator_scope": {"key": "properties.operatorScope", "type": "str"}, + "repository_public_key": {"key": "properties.repositoryPublicKey", "type": "str"}, + "ssh_known_hosts_contents": {"key": "properties.sshKnownHostsContents", "type": "str"}, + "enable_helm_operator": {"key": "properties.enableHelmOperator", "type": "bool"}, + "helm_operator_properties": {"key": "properties.helmOperatorProperties", "type": "HelmOperatorProperties"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "compliance_status": {"key": "properties.complianceStatus", "type": "ComplianceStatus"}, + } + + def __init__( + self, + *, + repository_url: Optional[str] = None, + operator_namespace: str = "default", + operator_instance_name: Optional[str] = None, + operator_type: Optional[Union[str, "_models.OperatorType"]] = None, + operator_params: Optional[str] = None, + configuration_protected_settings: Optional[Dict[str, str]] = None, + operator_scope: Union[str, "_models.OperatorScopeType"] = "cluster", + ssh_known_hosts_contents: Optional[str] = None, + enable_helm_operator: Optional[bool] = None, + helm_operator_properties: Optional["_models.HelmOperatorProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword repository_url: Url of the SourceControl Repository. + :paramtype repository_url: str + :keyword operator_namespace: The namespace to which this operator is installed to. Maximum of + 253 lower case alphanumeric characters, hyphen and period only. + :paramtype operator_namespace: str + :keyword operator_instance_name: Instance name of the operator - identifying the specific + configuration. + :paramtype operator_instance_name: str + :keyword operator_type: Type of the operator. "Flux" + :paramtype operator_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.OperatorType + :keyword operator_params: Any Parameters for the Operator instance in string format. + :paramtype operator_params: str + :keyword configuration_protected_settings: Name-value pairs of protected configuration settings + for the configuration. + :paramtype configuration_protected_settings: dict[str, str] + :keyword operator_scope: Scope at which the operator will be installed. Known values are: + "cluster" and "namespace". + :paramtype operator_scope: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.OperatorScopeType + :keyword ssh_known_hosts_contents: Base64-encoded known_hosts contents containing public SSH + keys required to access private Git instances. + :paramtype ssh_known_hosts_contents: str + :keyword enable_helm_operator: Option to enable Helm Operator for this git configuration. + :paramtype enable_helm_operator: bool + :keyword helm_operator_properties: Properties for Helm operator. + :paramtype helm_operator_properties: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.HelmOperatorProperties + """ + super().__init__(**kwargs) + self.system_data = None + self.repository_url = repository_url + self.operator_namespace = operator_namespace + self.operator_instance_name = operator_instance_name + self.operator_type = operator_type + self.operator_params = operator_params + self.configuration_protected_settings = configuration_protected_settings + self.operator_scope = operator_scope + self.repository_public_key = None + self.ssh_known_hosts_contents = ssh_known_hosts_contents + self.enable_helm_operator = enable_helm_operator + self.helm_operator_properties = helm_operator_properties + self.provisioning_state = None + self.compliance_status = None + + +class SourceControlConfigurationList(_serialization.Model): + """Result of the request to list Source Control Configurations. It contains a list of + SourceControlConfiguration objects and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Source Control Configurations within a Kubernetes cluster. + :vartype value: + list[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceControlConfiguration] + :ivar next_link: URL to get the next set of configuration objects, if any. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SourceControlConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_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. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_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. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.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 diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/models/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/models/_source_control_configuration_client_enums.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/models/_source_control_configuration_client_enums.py new file mode 100644 index 000000000000..cf0979847940 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/models/_source_control_configuration_client_enums.py @@ -0,0 +1,121 @@ +# 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 AKSIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + + +class ComplianceStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The compliance state of the configuration.""" + + PENDING = "Pending" + COMPLIANT = "Compliant" + NONCOMPLIANT = "Noncompliant" + INSTALLED = "Installed" + FAILED = "Failed" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class FluxComplianceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Compliance state of the cluster object.""" + + COMPLIANT = "Compliant" + NON_COMPLIANT = "Non-Compliant" + PENDING = "Pending" + SUSPENDED = "Suspended" + UNKNOWN = "Unknown" + + +class KustomizationValidationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specify whether to validate the Kubernetes objects referenced in the Kustomization before + applying them to the cluster. + """ + + NONE = "none" + CLIENT = "client" + SERVER = "server" + + +class LevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the status.""" + + ERROR = "Error" + WARNING = "Warning" + INFORMATION = "Information" + + +class MessageLevelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level of the message.""" + + ERROR = "Error" + WARNING = "Warning" + INFORMATION = "Information" + + +class OperatorScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scope at which the operator will be installed.""" + + CLUSTER = "cluster" + NAMESPACE = "namespace" + + +class OperatorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the operator.""" + + FLUX = "Flux" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource.""" + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + + +class ProvisioningStateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource provider.""" + + ACCEPTED = "Accepted" + DELETING = "Deleting" + RUNNING = "Running" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + + +class ScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scope at which the configuration will be installed.""" + + CLUSTER = "cluster" + NAMESPACE = "namespace" + + +class SourceKindType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Source Kind to pull the configuration data from.""" + + GIT_REPOSITORY = "GitRepository" + BUCKET = "Bucket" + AZURE_BLOB = "AzureBlob" diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/__init__.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/__init__.py new file mode 100644 index 000000000000..9d58b5443a05 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/__init__.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._extensions_operations import ExtensionsOperations +from ._operation_status_operations import OperationStatusOperations +from ._flux_configurations_operations import FluxConfigurationsOperations +from ._flux_config_operation_status_operations import FluxConfigOperationStatusOperations +from ._source_control_configurations_operations import SourceControlConfigurationsOperations +from ._operations import Operations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ExtensionsOperations", + "OperationStatusOperations", + "FluxConfigurationsOperations", + "FluxConfigOperationStatusOperations", + "SourceControlConfigurationsOperations", + "Operations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_extensions_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_extensions_operations.py new file mode 100644 index 000000000000..cca9a1cbe296 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_extensions_operations.py @@ -0,0 +1,1150 @@ +# 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_create_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_get_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_delete_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + subscription_id: str, + *, + force_delete: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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") + if force_delete is not None: + _params["forceDelete"] = _SERIALIZER.query("force_delete", force_delete, "bool") + + # 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, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_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_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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) + + +class ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_11_01.SourceControlConfigurationClient`'s + :attr:`extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: Union[_models.Extension, IO], + **kwargs: Any + ) -> _models.Extension: + 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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IO, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") + + request = build_create_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Extension", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension + :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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Required. + :type extension: 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + extension: Union[_models.Extension, IO], + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create a new Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param extension: Properties necessary to Create an Extension. Is either a Extension type or a + IO type. Required. + :type extension: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension] + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + extension=extension, + 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("Extension", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + **kwargs: Any + ) -> _models.Extension: + """Gets Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Extension or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + force_delete: Optional[bool] = None, + **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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + force_delete=force_delete, + 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 [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Delete a Kubernetes Cluster Extension. This will cause the Agent to Uninstall the extension + from the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param force_delete: Delete the extension resource in Azure - not the normal asynchronous + delete. Default value is None. + :type force_delete: bool + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-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( # type: ignore + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + force_delete=force_delete, + 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, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + def _update_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: Union[_models.PatchExtension, IO], + **kwargs: Any + ) -> _models.Extension: + 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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(patch_extension, (IO, bytes)): + _content = patch_extension + else: + _json = self._serialize.body(patch_extension, "PatchExtension") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Extension", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("Extension", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: _models.PatchExtension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.PatchExtension + :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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Required. + :type patch_extension: 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + patch_extension: Union[_models.PatchExtension, IO], + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Patch an existing Kubernetes Cluster Extension. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param patch_extension: Properties to Patch in an existing Extension. Is either a + PatchExtension type or a IO type. Required. + :type patch_extension: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.PatchExtension 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 Extension or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension] + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + patch_extension=patch_extension, + 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("Extension", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.Extension"]: + """List all Extensions in the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Extension or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.ExtensionsList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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("ExtensionsList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_flux_config_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_flux_config_operation_status_operations.py new file mode 100644 index 000000000000..4e29d0fa5d17 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_flux_config_operation_status_operations.py @@ -0,0 +1,188 @@ +# 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, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + operation_id: 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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "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) + + +class FluxConfigOperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_11_01.SourceControlConfigurationClient`'s + :attr:`flux_config_operation_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + operation_id: str, + **kwargs: Any + ) -> _models.OperationStatusResult: + """Get Async Operation status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param operation_id: operation Id. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.OperationStatusResult + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + operation_id=operation_id, + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}/operations/{operationId}" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_flux_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_flux_configurations_operations.py new file mode 100644 index 000000000000..667ddb59b1ae --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_flux_configurations_operations.py @@ -0,0 +1,1161 @@ +# 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_get_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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_update_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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_delete_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + subscription_id: str, + *, + force_delete: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "fluxConfigurationName": _SERIALIZER.url("flux_configuration_name", flux_configuration_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") + if force_delete is not None: + _params["forceDelete"] = _SERIALIZER.query("force_delete", force_delete, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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) + + +class FluxConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_11_01.SourceControlConfigurationClient`'s + :attr:`flux_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + **kwargs: Any + ) -> _models.FluxConfiguration: + """Gets details of the Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FluxConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: Union[_models.FluxConfiguration, IO], + **kwargs: Any + ) -> _models.FluxConfiguration: + 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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration, (IO, bytes)): + _content = flux_configuration + else: + _json = self._serialize.body(flux_configuration, "FluxConfiguration") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("FluxConfiguration", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: _models.FluxConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Required. + :type flux_configuration: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration: Union[_models.FluxConfiguration, IO], + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Create a new Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration: Properties necessary to Create a FluxConfiguration. Is either a + FluxConfiguration type or a IO type. Required. + :type flux_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration] + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + flux_configuration=flux_configuration, + 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("FluxConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + def _update_initial( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], + **kwargs: Any + ) -> _models.FluxConfiguration: + 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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(flux_configuration_patch, (IO, bytes)): + _content = flux_configuration_patch + else: + _json = self._serialize.body(flux_configuration_patch, "FluxConfigurationPatch") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("FluxConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: _models.FluxConfigurationPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. + :type flux_configuration_patch: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfigurationPatch + :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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. + Required. + :type flux_configuration_patch: 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + flux_configuration_patch: Union[_models.FluxConfigurationPatch, IO], + **kwargs: Any + ) -> LROPoller[_models.FluxConfiguration]: + """Update an existing Kubernetes Flux Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param flux_configuration_patch: Properties to Patch in an existing Flux Configuration. Is + either a FluxConfigurationPatch type or a IO type. Required. + :type flux_configuration_patch: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfigurationPatch 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 FluxConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration] + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FluxConfiguration] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + flux_configuration_patch=flux_configuration_patch, + 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("FluxConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + force_delete: Optional[bool] = None, + **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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + subscription_id=self._config.subscription_id, + force_delete=force_delete, + 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 [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + flux_configuration_name: str, + force_delete: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """This will delete the YAML file used to set up the Flux Configuration, thus stopping future sync + from the source repo. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param flux_configuration_name: Name of the Flux Configuration. Required. + :type flux_configuration_name: str + :param force_delete: Delete the extension resource in Azure - not the normal asynchronous + delete. Default value is None. + :type force_delete: bool + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-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( # type: ignore + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + flux_configuration_name=flux_configuration_name, + force_delete=force_delete, + 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, lro_options={"final-state-via": "azure-async-operation"}, **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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/{fluxConfigurationName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.FluxConfiguration"]: + """List all Flux Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FluxConfiguration or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.FluxConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.FluxConfigurationsList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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("FluxConfigurationsList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/fluxConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_operation_status_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_operation_status_operations.py new file mode 100644 index 000000000000..c8807b11f5c5 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_operation_status_operations.py @@ -0,0 +1,331 @@ +# 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_get_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + operation_id: 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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "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_list_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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) + + +class OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_11_01.SourceControlConfigurationClient`'s + :attr:`operation_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + extension_name: str, + operation_id: str, + **kwargs: Any + ) -> _models.OperationStatusResult: + """Get Async Operation status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param extension_name: Name of the Extension. Required. + :type extension_name: str + :param operation_id: operation Id. Required. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.OperationStatusResult + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + extension_name=extension_name, + operation_id=operation_id, + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionName}/operations/{operationId}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.OperationStatusResult"]: + """List Async Operations, currently in progress, in a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationStatusResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.OperationStatusList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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("OperationStatusList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/operations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_operations.py new file mode 100644 index 000000000000..c08f3f3ea5f8 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_operations.py @@ -0,0 +1,161 @@ +# 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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.KubernetesConfiguration/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.kubernetesconfiguration.v2022_11_01.SourceControlConfigurationClient`'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.ResourceProviderOperation"]: + """List all the available operations the KubernetesConfiguration resource provider supports. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceProviderOperation or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.ResourceProviderOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.ResourceProviderOperationList] = 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("ResourceProviderOperationList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.KubernetesConfiguration/operations"} diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_patch.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_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/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_source_control_configurations_operations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_source_control_configurations_operations.py new file mode 100644 index 000000000000..f3ef7d4c3926 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/operations/_source_control_configurations_operations.py @@ -0,0 +1,746 @@ +# 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_get_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "sourceControlConfigurationName": _SERIALIZER.url( + "source_control_configuration_name", source_control_configuration_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_list_request( + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations", + ) # 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 + ), + "clusterRp": _SERIALIZER.url("cluster_rp", cluster_rp, "str"), + "clusterResourceName": _SERIALIZER.url("cluster_resource_name", cluster_resource_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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) + + +class SourceControlConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kubernetesconfiguration.v2022_11_01.SourceControlConfigurationClient`'s + :attr:`source_control_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Gets details of the Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceControlConfiguration + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: _models.SourceControlConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceControlConfiguration + :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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. + Required. + :type source_control_configuration: 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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceControlConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + source_control_configuration: Union[_models.SourceControlConfiguration, IO], + **kwargs: Any + ) -> _models.SourceControlConfiguration: + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create KubernetesConfiguration. Is + either a SourceControlConfiguration type or a IO type. Required. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceControlConfiguration 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: SourceControlConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceControlConfiguration + :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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SourceControlConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_configuration, (IO, bytes)): + _content = source_control_configuration + else: + _json = self._serialize.body(source_control_configuration, "SourceControlConfiguration") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SourceControlConfiguration", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SourceControlConfiguration", 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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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 [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + cluster_rp: str, + cluster_resource_name: str, + cluster_name: str, + source_control_configuration_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """This will delete the YAML file used to set up the Source control configuration, thus stopping + future sync from the source repo. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control Configuration. Required. + :type source_control_configuration_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-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-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( # type: ignore + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_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/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, cluster_rp: str, cluster_resource_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.SourceControlConfiguration"]: + """List all Source Control Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - i.e. Microsoft.ContainerService, + Microsoft.Kubernetes, Microsoft.HybridContainerService. Required. + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - i.e. managedClusters, + connectedClusters, provisionedClusters. Required. + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SourceControlConfiguration or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.kubernetesconfiguration.v2022_11_01.models.SourceControlConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01")) + cls: ClsType[_models.SourceControlConfigurationList] = 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, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_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("SourceControlConfigurationList", 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations" + } diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/py.typed b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/azure/mgmt/kubernetesconfiguration/v2022_11_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/create_extension.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/create_extension.py new file mode 100644 index 000000000000..3379e78e7e21 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/create_extension.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python create_extension.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.extensions.begin_create( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + extension_name="ClusterMonitor", + extension={ + "properties": { + "autoUpgradeMinorVersion": True, + "configurationProtectedSettings": {"omsagent.secret.key": "secretKeyValue01"}, + "configurationSettings": { + "omsagent.env.clusterName": "clusterName1", + "omsagent.secret.wsid": "a38cef99-5a89-52ed-b6db-22095c23664b", + }, + "extensionType": "azuremonitor-containers", + "releaseTrain": "Preview", + "scope": {"cluster": {"releaseNamespace": "kube-system"}}, + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/CreateExtension.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/create_extension_with_plan.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/create_extension_with_plan.py new file mode 100644 index 000000000000..fda362b60b02 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/create_extension_with_plan.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python create_extension_with_plan.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.extensions.begin_create( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + extension_name="azureVote", + extension={ + "plan": { + "name": "azure-vote-standard", + "product": "azure-vote-standard-offer-id", + "publisher": "Microsoft", + }, + "properties": {"autoUpgradeMinorVersion": True, "extensionType": "azure-vote", "releaseTrain": "Preview"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/CreateExtensionWithPlan.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/create_flux_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/create_flux_configuration.py new file mode 100644 index 000000000000..04a09d1508bd --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/create_flux_configuration.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python create_flux_configuration.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.flux_configurations.begin_create_or_update( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + flux_configuration_name="srs-fluxconfig", + flux_configuration={ + "properties": { + "gitRepository": { + "httpsCACert": "ZXhhbXBsZWNlcnRpZmljYXRl", + "repositoryRef": {"branch": "master"}, + "syncIntervalInSeconds": 600, + "timeoutInSeconds": 600, + "url": "https://github.com/Azure/arc-k8s-demo", + }, + "kustomizations": { + "srs-kustomization1": { + "dependsOn": [], + "path": "./test/path", + "syncIntervalInSeconds": 600, + "timeoutInSeconds": 600, + }, + "srs-kustomization2": { + "dependsOn": ["srs-kustomization1"], + "path": "./other/test/path", + "prune": False, + "retryIntervalInSeconds": 600, + "syncIntervalInSeconds": 600, + "timeoutInSeconds": 600, + }, + }, + "namespace": "srs-namespace", + "scope": "cluster", + "sourceKind": "GitRepository", + "suspend": False, + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/CreateFluxConfiguration.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/create_flux_configuration_with_bucket.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/create_flux_configuration_with_bucket.py new file mode 100644 index 000000000000..0f8b037ff569 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/create_flux_configuration_with_bucket.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python create_flux_configuration_with_bucket.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.flux_configurations.begin_create_or_update( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + flux_configuration_name="srs-fluxconfig", + flux_configuration={ + "properties": { + "bucket": { + "accessKey": "fluxminiotest", + "bucketName": "flux", + "syncIntervalInSeconds": 1000, + "timeoutInSeconds": 1000, + "url": "https://fluxminiotest.az.minio.io", + }, + "kustomizations": { + "srs-kustomization1": { + "dependsOn": [], + "path": "./test/path", + "syncIntervalInSeconds": 600, + "timeoutInSeconds": 600, + }, + "srs-kustomization2": { + "dependsOn": ["srs-kustomization1"], + "path": "./other/test/path", + "prune": False, + "retryIntervalInSeconds": 600, + "syncIntervalInSeconds": 600, + "timeoutInSeconds": 600, + }, + }, + "namespace": "srs-namespace", + "scope": "cluster", + "sourceKind": "Bucket", + "suspend": False, + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/CreateFluxConfigurationWithBucket.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/create_source_control_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/create_source_control_configuration.py new file mode 100644 index 000000000000..4b39aef3c0d7 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/create_source_control_configuration.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python create_source_control_configuration.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.source_control_configurations.create_or_update( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + source_control_configuration_name="SRS_GitHubConfig", + source_control_configuration={ + "properties": { + "configurationProtectedSettings": {"protectedSetting1Key": "protectedSetting1Value"}, + "enableHelmOperator": True, + "helmOperatorProperties": { + "chartValues": "--set git.ssh.secretName=flux-git-deploy --set tillerNamespace=kube-system", + "chartVersion": "0.3.0", + }, + "operatorInstanceName": "SRSGitHubFluxOp-01", + "operatorNamespace": "SRS_Namespace", + "operatorParams": "--git-email=xyzgituser@users.srs.github.com", + "operatorScope": "namespace", + "operatorType": "Flux", + "repositoryUrl": "git@github.com:k8sdeveloper425/flux-get-started", + "sshKnownHostsContents": "c3NoLmRldi5henVyZS5jb20gc3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBREFRQUJBQUFCQVFDN0hyMW9UV3FOcU9sekdKT2ZHSjROYWtWeUl6ZjFyWFlkNGQ3d282akJsa0x2Q0E0b2RCbEwwbURVeVowL1FVZlRUcWV1K3RtMjJnT3N2K1ZyVlRNazZ2d1JVNzVnWS95OXV0NU1iM2JSNUJWNThkS1h5cTlBOVVlQjVDYWtlaG41WmdtNngxbUtvVnlmK0ZGbjI2aVlxWEpSZ3pJWlpjWjVWNmhyRTBRZzM5a1ptNGF6NDhvMEFVYmY2U3A0U0xkdm51TWEyc1ZOd0hCYm9TN0VKa201N1hRUFZVMy9RcHlOTEhiV0Rkend0cmxTK2V6MzBTM0FkWWhMS0VPeEFHOHdlT255cnRMSkFVZW45bVRrb2w4b0lJMWVkZjdtV1diV1ZmMG5CbWx5MjErblpjbUNUSVNRQnRkY3lQYUVubzdmRlFNREQyNi9zMGxmS29iNEt3OEg=", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/CreateSourceControlConfiguration.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/delete_extension.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/delete_extension.py new file mode 100644 index 000000000000..895dcbad7ed5 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/delete_extension.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python delete_extension.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.extensions.begin_delete( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + extension_name="ClusterMonitor", + ).result() + print(response) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/DeleteExtension.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/delete_flux_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/delete_flux_configuration.py new file mode 100644 index 000000000000..0d793da016d2 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/delete_flux_configuration.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python delete_flux_configuration.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.flux_configurations.begin_delete( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + flux_configuration_name="srs-fluxconfig", + ).result() + print(response) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/DeleteFluxConfiguration.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/delete_source_control_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/delete_source_control_configuration.py new file mode 100644 index 000000000000..8e924237c577 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/delete_source_control_configuration.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python delete_source_control_configuration.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.source_control_configurations.begin_delete( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + source_control_configuration_name="SRS_GitHubConfig", + ).result() + print(response) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/DeleteSourceControlConfiguration.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/get_extension.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/get_extension.py new file mode 100644 index 000000000000..fafc484ff339 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/get_extension.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python get_extension.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.extensions.get( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + extension_name="ClusterMonitor", + ) + print(response) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetExtension.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/get_extension_async_operation_status.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/get_extension_async_operation_status.py new file mode 100644 index 000000000000..dc8bc5372d18 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/get_extension_async_operation_status.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python get_extension_async_operation_status.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.operation_status.get( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + extension_name="ClusterMonitor", + operation_id="99999999-9999-9999-9999-999999999999", + ) + print(response) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetExtensionAsyncOperationStatus.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/get_extension_with_plan.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/get_extension_with_plan.py new file mode 100644 index 000000000000..c61246bb4e7b --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/get_extension_with_plan.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python get_extension_with_plan.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.extensions.get( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + extension_name="azureVote", + ) + print(response) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetExtensionWithPlan.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/get_flux_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/get_flux_configuration.py new file mode 100644 index 000000000000..9559f67ebe08 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/get_flux_configuration.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python get_flux_configuration.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.flux_configurations.get( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + flux_configuration_name="srs-fluxconfig", + ) + print(response) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetFluxConfiguration.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/get_flux_configuration_async_operation_status.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/get_flux_configuration_async_operation_status.py new file mode 100644 index 000000000000..aa40f39f4e39 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/get_flux_configuration_async_operation_status.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python get_flux_configuration_async_operation_status.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.flux_config_operation_status.get( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + flux_configuration_name="srs-fluxconfig", + operation_id="99999999-9999-9999-9999-999999999999", + ) + print(response) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetFluxConfigurationAsyncOperationStatus.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/get_source_control_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/get_source_control_configuration.py new file mode 100644 index 000000000000..eca7d7f0713a --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/get_source_control_configuration.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python get_source_control_configuration.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.source_control_configurations.get( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + source_control_configuration_name="SRS_GitHubConfig", + ) + print(response) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetSourceControlConfiguration.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/list_async_operation_status.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/list_async_operation_status.py new file mode 100644 index 000000000000..2e426504c8df --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/list_async_operation_status.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python list_async_operation_status.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.operation_status.list( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/ListAsyncOperationStatus.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/list_extensions.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/list_extensions.py new file mode 100644 index 000000000000..488d181162af --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/list_extensions.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python list_extensions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.extensions.list( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/ListExtensions.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/list_flux_configurations.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/list_flux_configurations.py new file mode 100644 index 000000000000..ffd109cb4842 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/list_flux_configurations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python list_flux_configurations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.flux_configurations.list( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/ListFluxConfigurations.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/list_source_control_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/list_source_control_configuration.py new file mode 100644 index 000000000000..7b0fb273bf5a --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/list_source_control_configuration.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python list_source_control_configuration.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.source_control_configurations.list( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/ListSourceControlConfiguration.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/operations_list.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/operations_list.py new file mode 100644 index 000000000000..854fd46f7172 --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/operations_list.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python operations_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.operations.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/OperationsList.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/patch_extension.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/patch_extension.py new file mode 100644 index 000000000000..f2f0ae195aab --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/patch_extension.py @@ -0,0 +1,55 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python patch_extension.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.extensions.begin_update( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + extension_name="ClusterMonitor", + patch_extension={ + "properties": { + "autoUpgradeMinorVersion": True, + "configurationProtectedSettings": {"omsagent.secret.key": "secretKeyValue01"}, + "configurationSettings": { + "omsagent.env.clusterName": "clusterName1", + "omsagent.secret.wsid": "a38cef99-5a89-52ed-b6db-22095c23664b", + }, + "releaseTrain": "Preview", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/PatchExtension.json +if __name__ == "__main__": + main() diff --git a/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/patch_flux_configuration.py b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/patch_flux_configuration.py new file mode 100644 index 000000000000..6bf37323a99a --- /dev/null +++ b/sdk/kubernetesconfiguration/azure-mgmt-kubernetesconfiguration/generated_samples/patch_flux_configuration.py @@ -0,0 +1,55 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kubernetesconfiguration +# USAGE + python patch_flux_configuration.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SourceControlConfigurationClient( + credential=DefaultAzureCredential(), + subscription_id="subId1", + ) + + response = client.flux_configurations.begin_update( + resource_group_name="rg1", + cluster_rp="Microsoft.Kubernetes", + cluster_resource_name="connectedClusters", + cluster_name="clusterName1", + flux_configuration_name="srs-fluxconfig", + flux_configuration_patch={ + "properties": { + "gitRepository": {"url": "https://github.com/jonathan-innis/flux2-kustomize-helm-example.git"}, + "kustomizations": { + "srs-kustomization1": None, + "srs-kustomization2": {"dependsOn": None, "path": "./test/alt-path", "syncIntervalInSeconds": 300}, + "srs-kustomization3": {"path": "./test/another-path", "syncIntervalInSeconds": 300}, + }, + "suspend": True, + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/PatchFluxConfiguration.json +if __name__ == "__main__": + main()