Skip to content

Commit

Permalink
CodeGen from PR 32843 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge 3c0903a819e952244992050c06f33425013c2ab1 into 80a1036678da5411d44a18bc24c66cc6e14e3605
  • Loading branch information
SDKAuto committed Feb 26, 2025
1 parent f65d0fe commit 7af4541
Show file tree
Hide file tree
Showing 36 changed files with 702 additions and 504 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"commit": "399cbac2de1bc0acbed4c9a0a864a9c84da3692e",
"commit": "c043ad98975c9d07afb8e86091325d7646e9fafe",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"typespec_src": "specification/kubernetesruntime/KubernetesRuntime.Management",
"@azure-tools/typespec-python": "0.33.0"
"@azure-tools/typespec-python": "0.38.4"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"CrossLanguagePackageId": "Microsoft.KubernetesRuntime",
"CrossLanguageDefinitionId": {
"azure.mgmt.containerorchestratorruntime.models.Resource": "Azure.ResourceManager.CommonTypes.Resource",
"azure.mgmt.containerorchestratorruntime.models.ExtensionResource": "Azure.ResourceManager.CommonTypes.ExtensionResource",
"azure.mgmt.containerorchestratorruntime.models.BgpPeer": "Microsoft.KubernetesRuntime.BgpPeer",
"azure.mgmt.containerorchestratorruntime.models.BgpPeerProperties": "Microsoft.KubernetesRuntime.BgpPeerProperties",
"azure.mgmt.containerorchestratorruntime.models.StorageClassTypeProperties": "Microsoft.KubernetesRuntime.StorageClassTypeProperties",
"azure.mgmt.containerorchestratorruntime.models.BlobStorageClassTypeProperties": "Microsoft.KubernetesRuntime.BlobStorageClassTypeProperties",
"azure.mgmt.containerorchestratorruntime.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo",
"azure.mgmt.containerorchestratorruntime.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail",
"azure.mgmt.containerorchestratorruntime.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse",
"azure.mgmt.containerorchestratorruntime.models.LoadBalancer": "Microsoft.KubernetesRuntime.LoadBalancer",
"azure.mgmt.containerorchestratorruntime.models.LoadBalancerProperties": "Microsoft.KubernetesRuntime.LoadBalancerProperties",
"azure.mgmt.containerorchestratorruntime.models.NativeStorageClassTypeProperties": "Microsoft.KubernetesRuntime.NativeStorageClassTypeProperties",
"azure.mgmt.containerorchestratorruntime.models.NfsStorageClassTypeProperties": "Microsoft.KubernetesRuntime.NfsStorageClassTypeProperties",
"azure.mgmt.containerorchestratorruntime.models.Operation": "Azure.ResourceManager.CommonTypes.Operation",
"azure.mgmt.containerorchestratorruntime.models.OperationDisplay": "Azure.ResourceManager.CommonTypes.OperationDisplay",
"azure.mgmt.containerorchestratorruntime.models.RwxStorageClassTypeProperties": "Microsoft.KubernetesRuntime.RwxStorageClassTypeProperties",
"azure.mgmt.containerorchestratorruntime.models.ServiceProperties": "Microsoft.KubernetesRuntime.ServiceProperties",
"azure.mgmt.containerorchestratorruntime.models.ServiceResource": "Microsoft.KubernetesRuntime.ServiceResource",
"azure.mgmt.containerorchestratorruntime.models.SmbStorageClassTypeProperties": "Microsoft.KubernetesRuntime.SmbStorageClassTypeProperties",
"azure.mgmt.containerorchestratorruntime.models.StorageClassProperties": "Microsoft.KubernetesRuntime.StorageClassProperties",
"azure.mgmt.containerorchestratorruntime.models.StorageClassPropertiesUpdate": "Microsoft.KubernetesRuntime.StorageClassPropertiesUpdate",
"azure.mgmt.containerorchestratorruntime.models.StorageClassResource": "Microsoft.KubernetesRuntime.StorageClassResource",
"azure.mgmt.containerorchestratorruntime.models.StorageClassResourceUpdate": "Microsoft.KubernetesRuntime.StorageClassResourceUpdate",
"azure.mgmt.containerorchestratorruntime.models.StorageClassTypePropertiesUpdate": "Microsoft.KubernetesRuntime.StorageClassTypePropertiesUpdate",
"azure.mgmt.containerorchestratorruntime.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData",
"azure.mgmt.containerorchestratorruntime.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType",
"azure.mgmt.containerorchestratorruntime.models.VolumeExpansion": "Microsoft.KubernetesRuntime.VolumeExpansion",
"azure.mgmt.containerorchestratorruntime.models.VolumeBindingMode": "Microsoft.KubernetesRuntime.VolumeBindingMode",
"azure.mgmt.containerorchestratorruntime.models.AccessMode": "Microsoft.KubernetesRuntime.AccessMode",
"azure.mgmt.containerorchestratorruntime.models.DataResilienceTier": "Microsoft.KubernetesRuntime.DataResilienceTier",
"azure.mgmt.containerorchestratorruntime.models.FailoverTier": "Microsoft.KubernetesRuntime.FailoverTier",
"azure.mgmt.containerorchestratorruntime.models.PerformanceTier": "Microsoft.KubernetesRuntime.PerformanceTier",
"azure.mgmt.containerorchestratorruntime.models.SCType": "Microsoft.KubernetesRuntime.SCType",
"azure.mgmt.containerorchestratorruntime.models.NfsDirectoryActionOnVolumeDeletion": "Microsoft.KubernetesRuntime.NfsDirectoryActionOnVolumeDeletion",
"azure.mgmt.containerorchestratorruntime.models.ProvisioningState": "Microsoft.KubernetesRuntime.ProvisioningState",
"azure.mgmt.containerorchestratorruntime.models.Origin": "Azure.ResourceManager.CommonTypes.Origin",
"azure.mgmt.containerorchestratorruntime.models.ActionType": "Azure.ResourceManager.CommonTypes.ActionType",
"azure.mgmt.containerorchestratorruntime.models.AdvertiseMode": "Microsoft.KubernetesRuntime.AdvertiseMode",
"azure.mgmt.containerorchestratorruntime.ContainerOrchestratorRuntimeMgmtClient.storage_class.get": "Microsoft.KubernetesRuntime.StorageClass.get",
"azure.mgmt.containerorchestratorruntime.ContainerOrchestratorRuntimeMgmtClient.storage_class.begin_create_or_update": "Microsoft.KubernetesRuntime.StorageClass.createOrUpdate",
"azure.mgmt.containerorchestratorruntime.ContainerOrchestratorRuntimeMgmtClient.storage_class.begin_update": "Microsoft.KubernetesRuntime.StorageClass.update",
"azure.mgmt.containerorchestratorruntime.ContainerOrchestratorRuntimeMgmtClient.storage_class.begin_delete": "Microsoft.KubernetesRuntime.StorageClass.delete",
"azure.mgmt.containerorchestratorruntime.ContainerOrchestratorRuntimeMgmtClient.storage_class.list": "Microsoft.KubernetesRuntime.StorageClass.list",
"azure.mgmt.containerorchestratorruntime.ContainerOrchestratorRuntimeMgmtClient.operations.list": "Azure.ResourceManager.Operations.list",
"azure.mgmt.containerorchestratorruntime.ContainerOrchestratorRuntimeMgmtClient.load_balancers.get": "Microsoft.KubernetesRuntime.LoadBalancers.get",
"azure.mgmt.containerorchestratorruntime.ContainerOrchestratorRuntimeMgmtClient.load_balancers.begin_create_or_update": "Microsoft.KubernetesRuntime.LoadBalancers.createOrUpdate",
"azure.mgmt.containerorchestratorruntime.ContainerOrchestratorRuntimeMgmtClient.load_balancers.delete": "Microsoft.KubernetesRuntime.LoadBalancers.delete",
"azure.mgmt.containerorchestratorruntime.ContainerOrchestratorRuntimeMgmtClient.load_balancers.list": "Microsoft.KubernetesRuntime.LoadBalancers.list",
"azure.mgmt.containerorchestratorruntime.ContainerOrchestratorRuntimeMgmtClient.bgp_peers.get": "Microsoft.KubernetesRuntime.BgpPeers.get",
"azure.mgmt.containerorchestratorruntime.ContainerOrchestratorRuntimeMgmtClient.bgp_peers.begin_create_or_update": "Microsoft.KubernetesRuntime.BgpPeers.createOrUpdate",
"azure.mgmt.containerorchestratorruntime.ContainerOrchestratorRuntimeMgmtClient.bgp_peers.delete": "Microsoft.KubernetesRuntime.BgpPeers.delete",
"azure.mgmt.containerorchestratorruntime.ContainerOrchestratorRuntimeMgmtClient.bgp_peers.list": "Microsoft.KubernetesRuntime.BgpPeers.list",
"azure.mgmt.containerorchestratorruntime.ContainerOrchestratorRuntimeMgmtClient.services.get": "Microsoft.KubernetesRuntime.Services.get",
"azure.mgmt.containerorchestratorruntime.ContainerOrchestratorRuntimeMgmtClient.services.create_or_update": "Microsoft.KubernetesRuntime.Services.createOrUpdate",
"azure.mgmt.containerorchestratorruntime.ContainerOrchestratorRuntimeMgmtClient.services.delete": "Microsoft.KubernetesRuntime.Services.delete",
"azure.mgmt.containerorchestratorruntime.ContainerOrchestratorRuntimeMgmtClient.services.list": "Microsoft.KubernetesRuntime.Services.list"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,28 @@
# Code generated by Microsoft (R) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wrong-import-position

from ._client import ContainerOrchestratorRuntimeMgmtClient
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from ._patch import * # pylint: disable=unused-wildcard-import

from ._client import ContainerOrchestratorRuntimeMgmtClient # type: ignore
from ._version import VERSION

__version__ = VERSION

try:
from ._patch import __all__ as _patch_all
from ._patch import * # pylint: disable=unused-wildcard-import
from ._patch import *
except ImportError:
_patch_all = []
from ._patch import patch_sdk as _patch_sdk

__all__ = [
"ContainerOrchestratorRuntimeMgmtClient",
]
__all__.extend([p for p in _patch_all if p not in __all__])
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore

_patch_sdk()
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@
)

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential


class ContainerOrchestratorRuntimeMgmtClient: # pylint: disable=client-accepts-api-version-keyword
class ContainerOrchestratorRuntimeMgmtClient:
"""ContainerOrchestratorRuntimeMgmtClient.
:ivar storage_class: StorageClassOperations operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from ._version import VERSION

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential


Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# 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.
# --------------------------------------------------------------------------
# pylint: disable=protected-access, arguments-differ, signature-differs, broad-except, too-many-lines
# pylint: disable=protected-access, broad-except

import copy
import calendar
Expand Down Expand Up @@ -372,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:
Expand All @@ -396,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
Expand All @@ -416,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)
Expand Down Expand Up @@ -573,7 +621,7 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
def copy(self) -> "Model":
return Model(self.__dict__)

def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: disable=unused-argument
def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self:
if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated:
# we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping',
# 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object'
Expand All @@ -584,8 +632,8 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di
annotations = {
k: v
for mro_class in mros
if hasattr(mro_class, "__annotations__") # pylint: disable=no-member
for k, v in mro_class.__annotations__.items() # pylint: disable=no-member
if hasattr(mro_class, "__annotations__")
for k, v in mro_class.__annotations__.items()
}
for attr, rf in attr_to_rest_field.items():
rf._module = cls.__module__
Expand All @@ -600,8 +648,8 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di

def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None:
for base in cls.__bases__:
if hasattr(base, "__mapping__"): # pylint: disable=no-member
base.__mapping__[discriminator or cls.__name__] = cls # type: ignore # pylint: disable=no-member
if hasattr(base, "__mapping__"):
base.__mapping__[discriminator or cls.__name__] = cls # type: ignore

@classmethod
def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]:
Expand All @@ -612,7 +660,7 @@ def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField

@classmethod
def _deserialize(cls, data, exist_discriminators):
if not hasattr(cls, "__mapping__"): # pylint: disable=no-member
if not hasattr(cls, "__mapping__"):
return cls(data)
discriminator = cls._get_discriminator(exist_discriminators)
if discriminator is None:
Expand All @@ -632,11 +680,11 @@ def _deserialize(cls, data, exist_discriminators):
discriminator_value = data.find(xml_name).text # pyright: ignore
else:
discriminator_value = data.get(discriminator._rest_name)
mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member
mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore
return mapped_cls._deserialize(data, exist_discriminators)

def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]:
"""Return a dict that can be JSONify using json.dump.
"""Return a dict that can be turned into json using json.dump.
:keyword bool exclude_readonly: Whether to remove the readonly properties.
:returns: A dict JSON compatible object
Expand Down Expand Up @@ -733,7 +781,7 @@ def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.An
)


def _get_deserialize_callable_from_annotation( # pylint: disable=R0911, R0915, R0912
def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches
annotation: typing.Any,
module: typing.Optional[str],
rf: typing.Optional["_RestField"] = None,
Expand All @@ -753,7 +801,7 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=R0911, R0915,
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):
Expand Down Expand Up @@ -893,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,
Expand Down
Loading

0 comments on commit 7af4541

Please sign in to comment.