Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any, TYPE_CHECKING
from typing import Any, Optional, TYPE_CHECKING

from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy

from ._version import VERSION

if TYPE_CHECKING:
from azure.core import AzureClouds
from azure.core.credentials import TokenCredential


Expand All @@ -27,13 +28,22 @@ class CosmosDBManagementClientConfiguration: # pylint: disable=too-many-instanc
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription. The value must be an UUID. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2025-05-01-preview". Note that overriding
:param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is
None.
:type cloud_setting: ~azure.core.AzureClouds
:keyword api_version: Api Version. Default value is "2025-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:
api_version: str = kwargs.pop("api_version", "2025-05-01-preview")
def __init__(
self,
credential: "TokenCredential",
subscription_id: str,
cloud_setting: Optional["AzureClouds"] = None,
**kwargs: Any
) -> None:
api_version: str = kwargs.pop("api_version", "2025-11-01-preview")

if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
Expand All @@ -42,6 +52,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs

self.credential = credential
self.subscription_id = subscription_id
self.cloud_setting = cloud_setting
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-cosmosdb/{}".format(VERSION))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
FleetOperations,
FleetspaceAccountOperations,
FleetspaceOperations,
GarnetClustersOperations,
GraphResourcesOperations,
GremlinResourcesOperations,
LocationsOperations,
Expand Down Expand Up @@ -75,12 +76,15 @@
)

if TYPE_CHECKING:
from azure.core import AzureClouds
from azure.core.credentials import TokenCredential


class CosmosDBManagementClient: # pylint: disable=too-many-instance-attributes
"""Azure Cosmos DB Chaos Fault REST API.
"""Azure Cosmos DB Role Based Access Control Resource Provider REST API.

:ivar cassandra_resources: CassandraResourcesOperations operations
:vartype cassandra_resources: azure.mgmt.cosmosdb.operations.CassandraResourcesOperations
:ivar chaos_fault: ChaosFaultOperations operations
:vartype chaos_fault: azure.mgmt.cosmosdb.operations.ChaosFaultOperations
:ivar copy_jobs: CopyJobsOperations operations
Expand Down Expand Up @@ -123,18 +127,28 @@ class CosmosDBManagementClient: # pylint: disable=too-many-instance-attributes
:vartype mongo_db_resources: azure.mgmt.cosmosdb.operations.MongoDBResourcesOperations
:ivar table_resources: TableResourcesOperations operations
:vartype table_resources: azure.mgmt.cosmosdb.operations.TableResourcesOperations
:ivar cassandra_resources: CassandraResourcesOperations operations
:vartype cassandra_resources: azure.mgmt.cosmosdb.operations.CassandraResourcesOperations
:ivar gremlin_resources: GremlinResourcesOperations operations
:vartype gremlin_resources: azure.mgmt.cosmosdb.operations.GremlinResourcesOperations
:ivar locations: LocationsOperations operations
:vartype locations: azure.mgmt.cosmosdb.operations.LocationsOperations
:ivar data_transfer_jobs: DataTransferJobsOperations operations
:vartype data_transfer_jobs: azure.mgmt.cosmosdb.operations.DataTransferJobsOperations
:ivar fleet: FleetOperations operations
:vartype fleet: azure.mgmt.cosmosdb.operations.FleetOperations
:ivar fleet_analytics: FleetAnalyticsOperations operations
:vartype fleet_analytics: azure.mgmt.cosmosdb.operations.FleetAnalyticsOperations
:ivar fleetspace: FleetspaceOperations operations
:vartype fleetspace: azure.mgmt.cosmosdb.operations.FleetspaceOperations
:ivar fleetspace_account: FleetspaceAccountOperations operations
:vartype fleetspace_account: azure.mgmt.cosmosdb.operations.FleetspaceAccountOperations
:ivar garnet_clusters: GarnetClustersOperations operations
:vartype garnet_clusters: azure.mgmt.cosmosdb.operations.GarnetClustersOperations
:ivar cassandra_clusters: CassandraClustersOperations operations
:vartype cassandra_clusters: azure.mgmt.cosmosdb.operations.CassandraClustersOperations
:ivar cassandra_data_centers: CassandraDataCentersOperations operations
:vartype cassandra_data_centers: azure.mgmt.cosmosdb.operations.CassandraDataCentersOperations
:ivar mongo_mi_resources: MongoMIResourcesOperations operations
:vartype mongo_mi_resources: azure.mgmt.cosmosdb.operations.MongoMIResourcesOperations
:ivar network_security_perimeter_configurations:
NetworkSecurityPerimeterConfigurationsOperations operations
:vartype network_security_perimeter_configurations:
Expand Down Expand Up @@ -193,39 +207,42 @@ class CosmosDBManagementClient: # pylint: disable=too-many-instance-attributes
:ivar throughput_pool_account: ThroughputPoolAccountOperations operations
:vartype throughput_pool_account:
azure.mgmt.cosmosdb.operations.ThroughputPoolAccountOperations
:ivar mongo_mi_resources: MongoMIResourcesOperations operations
:vartype mongo_mi_resources: azure.mgmt.cosmosdb.operations.MongoMIResourcesOperations
:ivar fleet: FleetOperations operations
:vartype fleet: azure.mgmt.cosmosdb.operations.FleetOperations
:ivar fleet_analytics: FleetAnalyticsOperations operations
:vartype fleet_analytics: azure.mgmt.cosmosdb.operations.FleetAnalyticsOperations
:ivar fleetspace: FleetspaceOperations operations
:vartype fleetspace: azure.mgmt.cosmosdb.operations.FleetspaceOperations
:ivar fleetspace_account: FleetspaceAccountOperations operations
:vartype fleetspace_account: azure.mgmt.cosmosdb.operations.FleetspaceAccountOperations
: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. The value must be an UUID. Required.
:type subscription_id: str
:param base_url: Service URL. Default value is None.
:type base_url: str
:keyword api_version: Api Version. Default value is "2025-05-01-preview". Note that overriding
:keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is
None.
:paramtype cloud_setting: ~azure.core.AzureClouds
:keyword api_version: Api Version. Default value is "2025-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.
"""

def __init__(
self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any
self,
credential: "TokenCredential",
subscription_id: str,
base_url: Optional[str] = None,
*,
cloud_setting: Optional["AzureClouds"] = None,
**kwargs: Any
) -> None:
_cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore
_cloud = cloud_setting or settings.current.azure_cloud # type: ignore
_endpoints = get_arm_endpoints(_cloud)
if not base_url:
base_url = _endpoints["resource_manager"]
credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"])
self._config = CosmosDBManagementClientConfiguration(
credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs
credential=credential,
subscription_id=subscription_id,
cloud_setting=cloud_setting,
credential_scopes=credential_scopes,
**kwargs
)

_policies = kwargs.pop("policies", None)
Expand All @@ -252,6 +269,9 @@ def __init__(
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.cassandra_resources = CassandraResourcesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.chaos_fault = ChaosFaultOperations(self._client, self._config, self._serialize, self._deserialize)
self.copy_jobs = CopyJobsOperations(self._client, self._config, self._serialize, self._deserialize)
self.database_accounts = DatabaseAccountsOperations(
Expand Down Expand Up @@ -291,22 +311,29 @@ def __init__(
self._client, self._config, self._serialize, self._deserialize
)
self.table_resources = TableResourcesOperations(self._client, self._config, self._serialize, self._deserialize)
self.cassandra_resources = CassandraResourcesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.gremlin_resources = GremlinResourcesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize)
self.data_transfer_jobs = DataTransferJobsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.fleet = FleetOperations(self._client, self._config, self._serialize, self._deserialize)
self.fleet_analytics = FleetAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize)
self.fleetspace = FleetspaceOperations(self._client, self._config, self._serialize, self._deserialize)
self.fleetspace_account = FleetspaceAccountOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.garnet_clusters = GarnetClustersOperations(self._client, self._config, self._serialize, self._deserialize)
self.cassandra_clusters = CassandraClustersOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.cassandra_data_centers = CassandraDataCentersOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.mongo_mi_resources = MongoMIResourcesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.network_security_perimeter_configurations = NetworkSecurityPerimeterConfigurationsOperations(
self._client, self._config, self._serialize, self._deserialize
)
Expand Down Expand Up @@ -366,15 +393,6 @@ def __init__(
self.throughput_pool_account = ThroughputPoolAccountOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.mongo_mi_resources = MongoMIResourcesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.fleet = FleetOperations(self._client, self._config, self._serialize, self._deserialize)
self.fleet_analytics = FleetAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize)
self.fleetspace = FleetspaceOperations(self._client, self._config, self._serialize, self._deserialize)
self.fleetspace_account = FleetspaceAccountOperations(
self._client, self._config, self._serialize, self._deserialize
)

def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import sys
import codecs
from typing import (
Dict,
Any,
cast,
Optional,
Expand All @@ -31,7 +30,6 @@
Mapping,
Callable,
MutableMapping,
List,
)

try:
Expand Down Expand Up @@ -229,12 +227,12 @@ class Model:
serialization and deserialization.
"""

_subtype_map: Dict[str, Dict[str, Any]] = {}
_attribute_map: Dict[str, Dict[str, Any]] = {}
_validation: Dict[str, Dict[str, Any]] = {}
_subtype_map: dict[str, dict[str, Any]] = {}
_attribute_map: dict[str, dict[str, Any]] = {}
_validation: dict[str, dict[str, Any]] = {}

def __init__(self, **kwargs: Any) -> None:
self.additional_properties: Optional[Dict[str, Any]] = {}
self.additional_properties: Optional[dict[str, Any]] = {}
for k in kwargs: # pylint: disable=consider-using-dict-items
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__)
Expand Down Expand Up @@ -311,7 +309,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON:
def as_dict(
self,
keep_readonly: bool = True,
key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer,
key_transformer: Callable[[str, dict[str, Any], Any], Any] = attribute_transformer,
**kwargs: Any
) -> JSON:
"""Return a dict that can be serialized using json.dump.
Expand Down Expand Up @@ -380,7 +378,7 @@ def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self:
def from_dict(
cls,
data: Any,
key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None,
key_extractors: Optional[Callable[[str, dict[str, Any], Any], Any]] = None,
content_type: Optional[str] = None,
) -> Self:
"""Parse a dict using given key extractor return a model.
Expand Down Expand Up @@ -414,7 +412,7 @@ def _flatten_subtype(cls, key, objects):
return {}
result = dict(cls._subtype_map[key])
for valuetype in cls._subtype_map[key].values():
result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access
result |= objects[valuetype]._flatten_subtype(key, objects) # pylint: disable=protected-access
return result

@classmethod
Expand Down Expand Up @@ -528,7 +526,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None:
"[]": self.serialize_iter,
"{}": self.serialize_dict,
}
self.dependencies: Dict[str, type] = dict(classes) if classes else {}
self.dependencies: dict[str, type] = dict(classes) if classes else {}
self.key_transformer = full_restapi_key_transformer
self.client_side_validation = True

Expand Down Expand Up @@ -579,7 +577,7 @@ def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, to

if attr_name == "additional_properties" and attr_desc["key"] == "":
if target_obj.additional_properties is not None:
serialized.update(target_obj.additional_properties)
serialized |= target_obj.additional_properties
continue
try:

Expand Down Expand Up @@ -789,7 +787,7 @@ def serialize_data(self, data, data_type, **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__)
enum_type = self.dependencies.get(data_type, cast(type, data.__class__))
if issubclass(enum_type, Enum):
return Serializer.serialize_enum(data, enum_obj=enum_type)

Expand Down Expand Up @@ -1184,7 +1182,7 @@ def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argumen

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))
dict_keys = cast(list[str], _FLATTEN.split(key))
if len(dict_keys) == 1:
key = _decode_attribute_map_key(dict_keys[0])
break
Expand Down Expand Up @@ -1386,7 +1384,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None:
"duration": (isodate.Duration, datetime.timedelta),
"iso-8601": (datetime.datetime),
}
self.dependencies: Dict[str, type] = dict(classes) if classes else {}
self.dependencies: dict[str, type] = 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any, TYPE_CHECKING
from typing import Any, Optional, TYPE_CHECKING

from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy

from .._version import VERSION

if TYPE_CHECKING:
from azure.core import AzureClouds
from azure.core.credentials_async import AsyncTokenCredential


Expand All @@ -27,13 +28,22 @@ class CosmosDBManagementClientConfiguration: # pylint: disable=too-many-instanc
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the target subscription. The value must be an UUID. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2025-05-01-preview". Note that overriding
:param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is
None.
:type cloud_setting: ~azure.core.AzureClouds
:keyword api_version: Api Version. Default value is "2025-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:
api_version: str = kwargs.pop("api_version", "2025-05-01-preview")
def __init__(
self,
credential: "AsyncTokenCredential",
subscription_id: str,
cloud_setting: Optional["AzureClouds"] = None,
**kwargs: Any
) -> None:
api_version: str = kwargs.pop("api_version", "2025-11-01-preview")

if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
Expand All @@ -42,6 +52,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k

self.credential = credential
self.subscription_id = subscription_id
self.cloud_setting = cloud_setting
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-cosmosdb/{}".format(VERSION))
Expand Down
Loading
Loading