diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/_meta.json b/sdk/neonpostgres/azure-mgmt-neonpostgres/_meta.json index 2bd52a44f3d4..ea0d8f19b44f 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/_meta.json +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/_meta.json @@ -1,6 +1,6 @@ { - "commit": "4e3820497caa29ed0efada28a38cb4292cea9d55", + "commit": "8f6744026f8f69f599f4713dadf1109f04e23a31", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "typespec_src": "specification/liftrneon/Neon.Postgres.Management", - "@azure-tools/typespec-python": "0.36.1" + "@azure-tools/typespec-python": "0.39.1" } \ No newline at end of file diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/apiview-properties.json b/sdk/neonpostgres/azure-mgmt-neonpostgres/apiview-properties.json new file mode 100644 index 000000000000..c27ccb1eb6d6 --- /dev/null +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/apiview-properties.json @@ -0,0 +1,34 @@ +{ + "CrossLanguagePackageId": "Neon.Postgres", + "CrossLanguageDefinitionId": { + "azure.mgmt.neonpostgres.models.CompanyDetails": "LiftrBase.CompanyDetails", + "azure.mgmt.neonpostgres.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "azure.mgmt.neonpostgres.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "azure.mgmt.neonpostgres.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "azure.mgmt.neonpostgres.models.MarketplaceDetails": "LiftrBase.MarketplaceDetails", + "azure.mgmt.neonpostgres.models.OfferDetails": "LiftrBase.OfferDetails", + "azure.mgmt.neonpostgres.models.Operation": "Azure.ResourceManager.CommonTypes.Operation", + "azure.mgmt.neonpostgres.models.OperationDisplay": "Azure.ResourceManager.CommonTypes.OperationDisplay", + "azure.mgmt.neonpostgres.models.OrganizationProperties": "LiftrBase.Data.OrganizationProperties", + "azure.mgmt.neonpostgres.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", + "azure.mgmt.neonpostgres.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", + "azure.mgmt.neonpostgres.models.OrganizationResource": "Neon.Postgres.OrganizationResource", + "azure.mgmt.neonpostgres.models.PartnerOrganizationProperties": "LiftrBase.Data.PartnerOrganizationProperties", + "azure.mgmt.neonpostgres.models.SingleSignOnProperties": "LiftrBase.SingleSignOnProperties", + "azure.mgmt.neonpostgres.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", + "azure.mgmt.neonpostgres.models.UserDetails": "LiftrBase.UserDetails", + "azure.mgmt.neonpostgres.models.Origin": "Azure.ResourceManager.CommonTypes.Origin", + "azure.mgmt.neonpostgres.models.ActionType": "Azure.ResourceManager.CommonTypes.ActionType", + "azure.mgmt.neonpostgres.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", + "azure.mgmt.neonpostgres.models.MarketplaceSubscriptionStatus": "LiftrBase.MarketplaceSubscriptionStatus", + "azure.mgmt.neonpostgres.models.ResourceProvisioningState": "Azure.ResourceManager.ResourceProvisioningState", + "azure.mgmt.neonpostgres.models.SingleSignOnStates": "LiftrBase.SingleSignOnStates", + "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.operations.list": "Azure.ResourceManager.Operations.list", + "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.organizations.get": "Neon.Postgres.Organizations.get", + "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.organizations.begin_create_or_update": "Neon.Postgres.Organizations.createOrUpdate", + "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.organizations.begin_update": "Neon.Postgres.Organizations.update", + "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.organizations.begin_delete": "Neon.Postgres.Organizations.delete", + "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.organizations.list_by_resource_group": "Neon.Postgres.Organizations.listByResourceGroup", + "azure.mgmt.neonpostgres.NeonPostgresMgmtClient.organizations.list_by_subscription": "Neon.Postgres.Organizations.listBySubscription" + } +} \ No newline at end of file diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_model_base.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_model_base.py index e6a2730f9276..3072ee252ed9 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_model_base.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_model_base.py @@ -373,15 +373,34 @@ def __ne__(self, other: typing.Any) -> bool: return not self.__eq__(other) def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ return self._data.keys() def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ return self._data.values() def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ return self._data.items() def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ try: return self[key] except KeyError: @@ -397,17 +416,38 @@ def pop(self, key: str, default: _T) -> _T: ... def pop(self, key: str, default: typing.Any) -> typing.Any: ... def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ if default is _UNSET: return self._data.pop(key) return self._data.pop(key, default) def popitem(self) -> typing.Tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ return self._data.popitem() def clear(self) -> None: + """ + Remove all items from D. + """ self._data.clear() def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ self._data.update(*args, **kwargs) @typing.overload @@ -417,6 +457,13 @@ def setdefault(self, key: str, default: None = None) -> None: ... def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ if default is _UNSET: return self._data.setdefault(key) return self._data.setdefault(key, default) @@ -754,7 +801,7 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur except AttributeError: model_name = annotation if module is not None: - annotation = _get_model(module, model_name) + annotation = _get_model(module, model_name) # type: ignore try: if module and _is_model(annotation): @@ -894,6 +941,35 @@ def _deserialize( return _deserialize_with_callable(deserializer, value) +def _failsafe_deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, value, module, rf, format) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + value: typing.Any, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, value) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + class _RestField: def __init__( self, diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_serialization.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_serialization.py index ce17d1798ce7..7a0232de5ddc 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_serialization.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -48,9 +48,7 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, List, ) @@ -61,13 +59,13 @@ import xml.etree.ElementTree as ET import isodate # type: ignore +from typing_extensions import Self from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -185,73 +183,7 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], 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. - - :param datetime.datetime dt: The datetime - :returns: The offset - :rtype: datetime.timedelta - """ - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation. - - :param datetime.datetime dt: The datetime - :returns: The timestamp representation - :rtype: str - """ - return "Z" - - def dst(self, dt): - """No daylight saving for UTC. - - :param datetime.datetime dt: The datetime - :returns: The daylight saving time - :rtype: datetime.timedelta - """ - 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) -> None: - 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 +TZ_UTC = datetime.timezone.utc _FLATTEN = re.compile(r"(? ModelType: + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: """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 - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( - cls: Type[ModelType], + cls, data: Any, key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, content_type: Optional[str] = None, - ) -> ModelType: + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -479,8 +411,8 @@ def from_dict( :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -563,7 +495,7 @@ def _decode_attribute_map_key(key): return key.replace("\\.", ".") -class Serializer(object): # pylint: disable=too-many-public-methods +class Serializer: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -626,7 +558,7 @@ def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, to :param object 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. + :raises SerializationError: if serialization fails. :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) @@ -736,8 +668,8 @@ def body(self, data, data_type, **kwargs): :param object 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 + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized request body """ @@ -781,8 +713,8 @@ def url(self, name, data, data_type, **kwargs): :param str data_type: The type to be serialized from. :rtype: str :returns: The serialized URL path - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None """ try: output = self.serialize_data(data, data_type, **kwargs) @@ -805,8 +737,8 @@ def query(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, list - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized query parameter """ try: @@ -835,8 +767,8 @@ def header(self, name, data, data_type, **kwargs): :param object 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 + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized header """ try: @@ -855,9 +787,9 @@ def serialize_data(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :raises: AttributeError if required data is None. - :raises: ValueError if data is None - :raises: SerializationError if serialization fails. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. :returns: The serialized data. :rtype: str, int, float, bool, dict, list """ @@ -1192,7 +1124,7 @@ def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: TypeError if format invalid. + :raises TypeError: if format invalid. :return: serialized rfc """ try: @@ -1218,7 +1150,7 @@ def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: SerializationError if format invalid. + :raises SerializationError: if format invalid. :return: serialized iso """ if isinstance(attr, str): @@ -1251,7 +1183,7 @@ def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: int - :raises: SerializationError if format invalid + :raises SerializationError: if format invalid :return: serialied unix """ if isinstance(attr, int): @@ -1429,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # 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( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) @@ -1441,7 +1373,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1488,7 +1420,7 @@ def __call__(self, target_obj, response_data, content_type=None): :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. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1502,7 +1434,7 @@ def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return :param str target_obj: Target data type to deserialize to. :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1683,17 +1615,21 @@ def _instantiate_model(self, response, attrs, additional_properties=None): subtype = getattr(response, "_subtype_map", {}) try: readonly = [ - k for k, v in response._validation.items() if v.get("readonly") # pylint: disable=protected-access + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") ] const = [ - k for k, v in response._validation.items() if v.get("constant") # pylint: disable=protected-access + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + 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 + response_obj.additional_properties = additional_properties # type: ignore return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore @@ -1713,7 +1649,7 @@ def deserialize_data(self, data, data_type): # pylint: disable=too-many-return- :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1795,7 +1731,7 @@ def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return :param dict attr: Dictionary to be deserialized. :return: Deserialized object. :rtype: dict - :raises: TypeError if non-builtin datatype encountered. + :raises TypeError: if non-builtin datatype encountered. """ if attr is None: return None @@ -1841,7 +1777,7 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return :param str data_type: deserialization data type. :return: Deserialized basic type. :rtype: str, int, float or bool - :raises: TypeError if string format is not valid. + :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 @@ -1932,7 +1868,7 @@ def deserialize_bytearray(attr): :param str attr: response string to be deserialized. :return: Deserialized bytearray :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1945,7 +1881,7 @@ def deserialize_base64(attr): :param str attr: response string to be deserialized. :return: Deserialized base64 string :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1960,7 +1896,7 @@ def deserialize_decimal(attr): :param str attr: response string to be deserialized. :return: Deserialized decimal - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. :rtype: decimal """ if isinstance(attr, ET.Element): @@ -1978,7 +1914,7 @@ def deserialize_long(attr): :param str attr: response string to be deserialized. :return: Deserialized int :rtype: long or int - :raises: ValueError if string format invalid. + :raises ValueError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1991,7 +1927,7 @@ def deserialize_duration(attr): :param str attr: response string to be deserialized. :return: Deserialized duration :rtype: TimeDelta - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2009,7 +1945,7 @@ def deserialize_date(attr): :param str attr: response string to be deserialized. :return: Deserialized date :rtype: Date - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2025,7 +1961,7 @@ def deserialize_time(attr): :param str attr: response string to be deserialized. :return: Deserialized time :rtype: datetime.time - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2040,14 +1976,14 @@ def deserialize_rfc(attr): :param str attr: response string to be deserialized. :return: Deserialized RFC datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :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)) + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) if not date_obj.tzinfo: date_obj = date_obj.astimezone(tz=TZ_UTC) @@ -2063,7 +1999,7 @@ def deserialize_iso(attr): :param str attr: response string to be deserialized. :return: Deserialized ISO datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2101,7 +2037,7 @@ def deserialize_unix(attr): :param int attr: Object to be serialized. :return: Deserialized datetime :rtype: Datetime - :raises: DeserializationError if format invalid + :raises DeserializationError: if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/operations/_operations.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/operations/_operations.py index 72ce5d8b11e9..84dbd10b7762 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/operations/_operations.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/aio/operations/_operations.py @@ -12,6 +12,7 @@ from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -33,7 +34,8 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._model_base import SdkJSONEncoder, _deserialize +from ..._model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from ..._serialization import Deserializer, Serializer from ...operations._operations import ( build_operations_list_request, build_organizations_create_or_update_request, @@ -43,6 +45,7 @@ build_organizations_list_by_subscription_request, build_organizations_update_request, ) +from .._configuration import NeonPostgresMgmtClientConfiguration if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -65,10 +68,10 @@ class Operations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NeonPostgresMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: @@ -146,7 +149,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -166,10 +169,10 @@ class OrganizationsOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NeonPostgresMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -226,7 +229,7 @@ async def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: @@ -295,7 +298,7 @@ async def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -531,7 +534,7 @@ async def _update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -751,7 +754,7 @@ async def _delete_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -909,7 +912,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -994,7 +997,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/_models.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/_models.py index cb50196e6ee8..b2cee96390c7 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/_models.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/models/_models.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -34,17 +35,25 @@ class CompanyDetails(_model_base.Model): :vartype number_of_employees: int """ - company_name: Optional[str] = rest_field(name="companyName") + company_name: Optional[str] = rest_field( + name="companyName", visibility=["read", "create", "update", "delete", "query"] + ) """Company name.""" - country: Optional[str] = rest_field() + country: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Country name of the company.""" - office_address: Optional[str] = rest_field(name="officeAddress") + office_address: Optional[str] = rest_field( + name="officeAddress", visibility=["read", "create", "update", "delete", "query"] + ) """Office address of the company.""" - business_phone: Optional[str] = rest_field(name="businessPhone") + business_phone: Optional[str] = rest_field( + name="businessPhone", visibility=["read", "create", "update", "delete", "query"] + ) """Business phone number of the company.""" - domain: Optional[str] = rest_field() + domain: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Domain of the user.""" - number_of_employees: Optional[int] = rest_field(name="numberOfEmployees") + number_of_employees: Optional[int] = rest_field( + name="numberOfEmployees", visibility=["read", "create", "update", "delete", "query"] + ) """Number of employees in the company.""" @overload @@ -73,8 +82,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class ErrorAdditionalInfo(_model_base.Model): """The resource management error additional info. - Readonly 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. @@ -90,8 +97,6 @@ class ErrorAdditionalInfo(_model_base.Model): class ErrorDetail(_model_base.Model): """The error detail. - Readonly 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. @@ -126,7 +131,7 @@ class ErrorResponse(_model_base.Model): :vartype error: ~azure.mgmt.neonpostgres.models.ErrorDetail """ - error: Optional["_models.ErrorDetail"] = rest_field() + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The error object.""" @overload @@ -150,7 +155,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class MarketplaceDetails(_model_base.Model): """Marketplace details for an organization. - :ivar subscription_id: SaaS subscription id for the the marketplace offer. :vartype subscription_id: str :ivar subscription_status: Marketplace subscription status. Known values are: @@ -161,14 +165,18 @@ class MarketplaceDetails(_model_base.Model): :vartype offer_details: ~azure.mgmt.neonpostgres.models.OfferDetails """ - subscription_id: Optional[str] = rest_field(name="subscriptionId") + subscription_id: Optional[str] = rest_field( + name="subscriptionId", visibility=["read", "create", "update", "delete", "query"] + ) """SaaS subscription id for the the marketplace offer.""" subscription_status: Optional[Union[str, "_models.MarketplaceSubscriptionStatus"]] = rest_field( - name="subscriptionStatus" + name="subscriptionStatus", visibility=["read", "create", "update", "delete", "query"] ) """Marketplace subscription status. Known values are: \"PendingFulfillmentStart\", \"Subscribed\", \"Suspended\", and \"Unsubscribed\".""" - offer_details: "_models.OfferDetails" = rest_field(name="offerDetails") + offer_details: "_models.OfferDetails" = rest_field( + name="offerDetails", visibility=["read", "create", "update", "delete", "query"] + ) """Offer details for the marketplace that is selected by the user. Required.""" @overload @@ -194,7 +202,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class OfferDetails(_model_base.Model): """Offer details for the marketplace that is selected by the user. - :ivar publisher_id: Publisher Id for the marketplace offer. Required. :vartype publisher_id: str :ivar offer_id: Offer Id for the marketplace offer. Required. @@ -209,17 +216,17 @@ class OfferDetails(_model_base.Model): :vartype term_id: str """ - publisher_id: str = rest_field(name="publisherId") + publisher_id: str = rest_field(name="publisherId", visibility=["read", "create", "update", "delete", "query"]) """Publisher Id for the marketplace offer. Required.""" - offer_id: str = rest_field(name="offerId") + offer_id: str = rest_field(name="offerId", visibility=["read", "create", "update", "delete", "query"]) """Offer Id for the marketplace offer. Required.""" - plan_id: str = rest_field(name="planId") + plan_id: str = rest_field(name="planId", visibility=["read", "create", "update", "delete", "query"]) """Plan Id for the marketplace offer. Required.""" - plan_name: Optional[str] = rest_field(name="planName") + plan_name: Optional[str] = rest_field(name="planName", visibility=["read", "create", "update", "delete", "query"]) """Plan Name for the marketplace offer.""" - term_unit: Optional[str] = rest_field(name="termUnit") + term_unit: Optional[str] = rest_field(name="termUnit", visibility=["read", "create", "update", "delete", "query"]) """Term Name for the marketplace offer.""" - term_id: Optional[str] = rest_field(name="termId") + term_id: Optional[str] = rest_field(name="termId", visibility=["read", "create", "update", "delete", "query"]) """Term Id for the marketplace offer.""" @overload @@ -248,8 +255,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class Operation(_model_base.Model): """Details of a REST API operation, returned from the Resource Provider Operations API. - Readonly variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". :vartype name: str @@ -274,13 +279,15 @@ class Operation(_model_base.Model): is_data_action: Optional[bool] = rest_field(name="isDataAction", visibility=["read"]) """Whether the operation applies to data-plane. This is \"true\" for data-plane operations and \"false\" for Azure Resource Manager/control-plane operations.""" - display: Optional["_models.OperationDisplay"] = rest_field(visibility=["read"]) + display: Optional["_models.OperationDisplay"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Localized display information for this particular operation.""" origin: Optional[Union[str, "_models.Origin"]] = rest_field(visibility=["read"]) """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is \"user,system\". Known values are: \"user\", \"system\", and \"user,system\".""" - action_type: Optional[Union[str, "_models.ActionType"]] = rest_field(name="actionType") + action_type: Optional[Union[str, "_models.ActionType"]] = rest_field(name="actionType", visibility=["read"]) """Extensible enum. Indicates the action type. \"Internal\" refers to actions that are for internal only APIs. \"Internal\"""" @@ -288,7 +295,7 @@ class Operation(_model_base.Model): def __init__( self, *, - action_type: Optional[Union[str, "_models.ActionType"]] = None, + display: Optional["_models.OperationDisplay"] = None, ) -> None: ... @overload @@ -305,8 +312,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class OperationDisplay(_model_base.Model): """Localized display information for and operation. - Readonly variables are only populated by the server, and will be ignored when sending a request. - :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". :vartype provider: str @@ -338,9 +343,6 @@ class OperationDisplay(_model_base.Model): class OrganizationProperties(_model_base.Model): """Properties specific to Data Organization resource. - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar marketplace_details: Marketplace details of the resource. Required. :vartype marketplace_details: ~azure.mgmt.neonpostgres.models.MarketplaceDetails :ivar user_details: Details of the user. Required. @@ -359,9 +361,13 @@ class OrganizationProperties(_model_base.Model): name="marketplaceDetails", visibility=["read", "create"] ) """Marketplace details of the resource. Required.""" - user_details: "_models.UserDetails" = rest_field(name="userDetails") + user_details: "_models.UserDetails" = rest_field( + name="userDetails", visibility=["read", "create", "update", "delete", "query"] + ) """Details of the user. Required.""" - company_details: "_models.CompanyDetails" = rest_field(name="companyDetails") + company_details: "_models.CompanyDetails" = rest_field( + name="companyDetails", visibility=["read", "create", "update", "delete", "query"] + ) """Details of the company. Required.""" provisioning_state: Optional[Union[str, "_models.ResourceProvisioningState"]] = rest_field( name="provisioningState", visibility=["read"] @@ -369,7 +375,7 @@ class OrganizationProperties(_model_base.Model): """Provisioning state of the resource. Known values are: \"Succeeded\", \"Failed\", and \"Canceled\".""" partner_organization_properties: Optional["_models.PartnerOrganizationProperties"] = rest_field( - name="partnerOrganizationProperties" + name="partnerOrganizationProperties", visibility=["read", "create", "update", "delete", "query"] ) """Organization properties.""" @@ -397,10 +403,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class Resource(_model_base.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. - Readonly variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -414,7 +418,7 @@ class Resource(_model_base.Model): id: Optional[str] = rest_field(visibility=["read"]) """Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long""" + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" name: Optional[str] = rest_field(visibility=["read"]) """The name of the resource.""" type: Optional[str] = rest_field(visibility=["read"]) @@ -428,11 +432,8 @@ class TrackedResource(Resource): """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -448,7 +449,7 @@ class TrackedResource(Resource): :vartype location: str """ - tags: Optional[Dict[str, str]] = rest_field() + tags: Optional[Dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Resource tags.""" location: str = rest_field(visibility=["read", "create"]) """The geo-location where the resource lives. Required.""" @@ -475,11 +476,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class OrganizationResource(TrackedResource): """Organization Resource by Neon. - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -497,7 +495,9 @@ class OrganizationResource(TrackedResource): :vartype properties: ~azure.mgmt.neonpostgres.models.OrganizationProperties """ - properties: Optional["_models.OrganizationProperties"] = rest_field() + properties: Optional["_models.OrganizationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The resource-specific properties for this resource.""" @overload @@ -523,7 +523,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class PartnerOrganizationProperties(_model_base.Model): """Properties specific to Partner's organization. - :ivar organization_id: Organization Id in partner's system. :vartype organization_id: str :ivar organization_name: Organization name in partner's system. Required. @@ -532,11 +531,17 @@ class PartnerOrganizationProperties(_model_base.Model): :vartype single_sign_on_properties: ~azure.mgmt.neonpostgres.models.SingleSignOnProperties """ - organization_id: Optional[str] = rest_field(name="organizationId") + organization_id: Optional[str] = rest_field( + name="organizationId", visibility=["read", "create", "update", "delete", "query"] + ) """Organization Id in partner's system.""" - organization_name: str = rest_field(name="organizationName") + organization_name: str = rest_field( + name="organizationName", visibility=["read", "create", "update", "delete", "query"] + ) """Organization name in partner's system. Required.""" - single_sign_on_properties: Optional["_models.SingleSignOnProperties"] = rest_field(name="singleSignOnProperties") + single_sign_on_properties: Optional["_models.SingleSignOnProperties"] = rest_field( + name="singleSignOnProperties", visibility=["read", "create", "update", "delete", "query"] + ) """Single Sign On properties for the organization.""" @overload @@ -574,14 +579,22 @@ class SingleSignOnProperties(_model_base.Model): :vartype aad_domains: list[str] """ - single_sign_on_state: Optional[Union[str, "_models.SingleSignOnStates"]] = rest_field(name="singleSignOnState") + single_sign_on_state: Optional[Union[str, "_models.SingleSignOnStates"]] = rest_field( + name="singleSignOnState", visibility=["read", "create", "update", "delete", "query"] + ) """State of the Single Sign On for the organization. Known values are: \"Initial\", \"Enable\", and \"Disable\".""" - enterprise_app_id: Optional[str] = rest_field(name="enterpriseAppId") + enterprise_app_id: Optional[str] = rest_field( + name="enterpriseAppId", visibility=["read", "create", "update", "delete", "query"] + ) """AAD enterprise application Id used to setup SSO.""" - single_sign_on_url: Optional[str] = rest_field(name="singleSignOnUrl") + single_sign_on_url: Optional[str] = rest_field( + name="singleSignOnUrl", visibility=["read", "create", "update", "delete", "query"] + ) """URL for SSO to be used by the partner to redirect the user to their system.""" - aad_domains: Optional[List[str]] = rest_field(name="aadDomains") + aad_domains: Optional[List[str]] = rest_field( + name="aadDomains", visibility=["read", "create", "update", "delete", "query"] + ) """List of AAD domains fetched from Microsoft Graph for user.""" @overload @@ -624,19 +637,29 @@ class SystemData(_model_base.Model): :vartype last_modified_at: ~datetime.datetime """ - created_by: Optional[str] = rest_field(name="createdBy") + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"]) """The identity that created the resource.""" - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field(name="createdByType") + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="createdByType", visibility=["read", "create", "update", "delete", "query"] + ) """The type of identity that created the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" - created_at: Optional[datetime.datetime] = rest_field(name="createdAt", format="rfc3339") + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """The timestamp of resource creation (UTC).""" - last_modified_by: Optional[str] = rest_field(name="lastModifiedBy") + last_modified_by: Optional[str] = rest_field( + name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] + ) """The identity that last modified the resource.""" - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field(name="lastModifiedByType") + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] + ) """The type of identity that last modified the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" - last_modified_at: Optional[datetime.datetime] = rest_field(name="lastModifiedAt", format="rfc3339") + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """The timestamp of resource last modification (UTC).""" @overload @@ -677,15 +700,19 @@ class UserDetails(_model_base.Model): :vartype phone_number: str """ - first_name: Optional[str] = rest_field(name="firstName") + first_name: Optional[str] = rest_field(name="firstName", visibility=["read", "create", "update", "delete", "query"]) """First name of the user.""" - last_name: Optional[str] = rest_field(name="lastName") + last_name: Optional[str] = rest_field(name="lastName", visibility=["read", "create", "update", "delete", "query"]) """Last name of the user.""" - email_address: Optional[str] = rest_field(name="emailAddress") + email_address: Optional[str] = rest_field( + name="emailAddress", visibility=["read", "create", "update", "delete", "query"] + ) """Email address of the user.""" - upn: Optional[str] = rest_field() + upn: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """User's principal name.""" - phone_number: Optional[str] = rest_field(name="phoneNumber") + phone_number: Optional[str] = rest_field( + name="phoneNumber", visibility=["read", "create", "update", "delete", "query"] + ) """User's phone number.""" @overload diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/operations/_operations.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/operations/_operations.py index a63af8bdb887..73a444c7750f 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/operations/_operations.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/azure/mgmt/neonpostgres/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -12,6 +12,7 @@ from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -32,8 +33,9 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._model_base import SdkJSONEncoder, _deserialize -from .._serialization import Serializer +from .._configuration import NeonPostgresMgmtClientConfiguration +from .._model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from .._serialization import Deserializer, Serializer if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -76,7 +78,7 @@ def build_organizations_get_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -105,7 +107,7 @@ def build_organizations_create_or_update_request( # pylint: disable=name-too-lo accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -136,7 +138,7 @@ def build_organizations_update_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -166,7 +168,7 @@ def build_organizations_delete_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Neon.Postgres/organizations/{organizationName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -249,10 +251,10 @@ class Operations: 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") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NeonPostgresMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: @@ -330,7 +332,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -350,10 +352,10 @@ class OrganizationsOperations: 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") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: NeonPostgresMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get(self, resource_group_name: str, organization_name: str, **kwargs: Any) -> _models.OrganizationResource: @@ -408,7 +410,7 @@ def get(self, resource_group_name: str, organization_name: str, **kwargs: Any) - except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: @@ -477,7 +479,7 @@ def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -709,7 +711,7 @@ def _update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -923,7 +925,7 @@ def _delete_initial(self, resource_group_name: str, organization_name: str, **kw except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -1078,7 +1080,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -1162,7 +1164,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/setup.py b/sdk/neonpostgres/azure-mgmt-neonpostgres/setup.py index 64312c9ca568..6942c3854b4b 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/setup.py +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/setup.py @@ -22,11 +22,9 @@ # Version extraction inspired from 'requests' with open( - ( - os.path.join(package_folder_path, "version.py") - if os.path.exists(os.path.join(package_folder_path, "version.py")) - else os.path.join(package_folder_path, "_version.py") - ), + os.path.join(package_folder_path, "version.py") + if os.path.exists(os.path.join(package_folder_path, "version.py")) + else os.path.join(package_folder_path, "_version.py"), "r", ) as fd: version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) diff --git a/sdk/neonpostgres/azure-mgmt-neonpostgres/tsp-location.yaml b/sdk/neonpostgres/azure-mgmt-neonpostgres/tsp-location.yaml index 83678b856da0..828c275fc6ee 100644 --- a/sdk/neonpostgres/azure-mgmt-neonpostgres/tsp-location.yaml +++ b/sdk/neonpostgres/azure-mgmt-neonpostgres/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/liftrneon/Neon.Postgres.Management -commit: 4e3820497caa29ed0efada28a38cb4292cea9d55 +commit: 8f6744026f8f69f599f4713dadf1109f04e23a31 repo: Azure/azure-rest-api-specs additionalDirectories: