Skip to content

Commit

Permalink
CodeGen from PR 25326 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
[Hub Generated] Review request for Microsoft.DocumentDB to add version preview/2023-09-15-preview (Azure#25326)

* Adds base for updating Microsoft.DocumentDB from version preview/2023-03-15-preview to version 2023-09-15-preview

* Updates readme

* Updates API version in new specs and examples

* Add remoteAccountName in DTS create job

* Update cosmos-db.json

* Update custom-words.txt

* Added EnablePriorityBasedExecution and DefaultPriorityLevel properties (Azure#25470)

* Added Changes for Priority Based Execution

* Whitespace change

---------

Co-authored-by: Achint Agrawal <acagrawal@microsoft.com>

* Added SecuredByPerimeter enum value

* Added liana's 04-15 changes - MaximumThroughput

* Fix comment

* Update model name

* Revert changes to model

* Added clarification for throughput/autoscaleSettings option

* Update MI Cassandra preview swagger (Azure#25704)

* Updated preview swagger

* Removed repair additions and updated example files

* fix examples

* Fix prettier check for examples (Azure#25833)

---------

Co-authored-by: Nitesh Vijay <niteshvijay@microsoft.com>
Co-authored-by: AdrianSibajaRetana <54075415+AdrianSibajaRetana@users.noreply.github.com>
Co-authored-by: Achint-Agrawal <45819170+Achint-Agrawal@users.noreply.github.com>
Co-authored-by: Achint Agrawal <acagrawal@microsoft.com>
Co-authored-by: Praful Johari <pjohari@microsoft.com>
Co-authored-by: carjackson-msft <124716637+carjackson-msft@users.noreply.github.com>
Co-authored-by: DrewKaufmann <131404826+DrewKaufmann@users.noreply.github.com>
Co-authored-by: Arthur Ma <arthurma@microsoft.com>
  • Loading branch information
9 people committed Sep 20, 2023
1 parent 767facc commit 130e930
Show file tree
Hide file tree
Showing 292 changed files with 1,377 additions and 840 deletions.
10 changes: 5 additions & 5 deletions sdk/cosmos/azure-mgmt-cosmosdb/_meta.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"commit": "e5d8bf380ef60a6a283ba81fd0ce4bc0e49e6680",
"commit": "fa285f544fa37cd839c4befe1109db3547b016ab",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"autorest": "3.9.2",
"autorest": "3.9.7",
"use": [
"@autorest/python@6.6.0",
"@autorest/modelerfour@4.24.3"
"@autorest/python@6.7.1",
"@autorest/modelerfour@4.26.2"
],
"autorest_command": "autorest specification/cosmos-db/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.6.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False",
"autorest_command": "autorest specification/cosmos-db/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False",
"readme": "specification/cosmos-db/resource-manager/readme.md"
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class CosmosDBManagementClientConfiguration(Configuration): # pylint: disable=t
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2023-03-15-preview". Note that overriding
:keyword api_version: Api Version. Default value is "2023-09-15-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(CosmosDBManagementClientConfiguration, self).__init__(**kwargs)
api_version: str = kwargs.pop("api_version", "2023-03-15-preview")
api_version: str = kwargs.pop("api_version", "2023-09-15-preview")

if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class CosmosDBManagementClient: # pylint: disable=client-accepts-api-version-ke
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2023-03-15-preview". Note that overriding
:keyword api_version: Api Version. Default value is "2023-09-15-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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,9 @@ def _serialize(self, target_obj, data_type=None, **kwargs):
_serialized.update(_new_attr) # type: ignore
_new_attr = _new_attr[k] # type: ignore
_serialized = _serialized[k]
except ValueError:
continue
except ValueError as err:
if isinstance(err, SerializationError):
raise

except (AttributeError, KeyError, TypeError) as err:
msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj))
Expand Down Expand Up @@ -741,6 +742,8 @@ def query(self, name, data, data_type, **kwargs):
:param data: The data to be serialized.
:param str data_type: The type to be serialized from.
:keyword bool skip_quote: Whether to skip quote the serialized result.
Defaults to False.
:rtype: str
:raises: TypeError if serialization fails.
:raises: ValueError if data is None
Expand All @@ -749,10 +752,8 @@ def query(self, name, data, data_type, **kwargs):
# Treat the list aside, since we don't want to encode the div separator
if data_type.startswith("["):
internal_data_type = data_type[1:-1]
data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data]
if not kwargs.get("skip_quote", False):
data = [quote(str(d), safe="") for d in data]
return str(self.serialize_iter(data, internal_data_type, **kwargs))
do_quote = not kwargs.get("skip_quote", False)
return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs))

# Not a list, regular serialization
output = self.serialize_data(data, data_type, **kwargs)
Expand Down Expand Up @@ -891,6 +892,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs):
not be None or empty.
:param str div: If set, this str will be used to combine the elements
in the iterable into a combined string. Default is 'None'.
:keyword bool do_quote: Whether to quote the serialized result of each iterable element.
Defaults to False.
:rtype: list, str
"""
if isinstance(data, str):
Expand All @@ -903,9 +906,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs):
for d in data:
try:
serialized.append(self.serialize_data(d, iter_type, **kwargs))
except ValueError:
except ValueError as err:
if isinstance(err, SerializationError):
raise
serialized.append(None)

if kwargs.get("do_quote", False):
serialized = ["" if s is None else quote(str(s), safe="") for s in serialized]

if div:
serialized = ["" if s is None else str(s) for s in serialized]
serialized = div.join(serialized)
Expand Down Expand Up @@ -950,7 +958,9 @@ def serialize_dict(self, attr, dict_type, **kwargs):
for key, value in attr.items():
try:
serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs)
except ValueError:
except ValueError as err:
if isinstance(err, SerializationError):
raise
serialized[self.serialize_unicode(key)] = None

if "xml" in serialization_ctxt:
Expand Down
14 changes: 0 additions & 14 deletions sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_vendor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import List, cast

from azure.core.pipeline.transport import HttpRequest


Expand All @@ -16,15 +14,3 @@ def _convert_request(request, files=None):
if files:
request.set_formdata_body(files)
return request


def _format_url_section(template, **kwargs):
components = template.split("/")
while components:
try:
return template.format(**kwargs)
except KeyError as key:
# Need the cast, as for some reasons "split" is typed as list[str | Any]
formatted_components = cast(List[str], template.split("/"))
components = [c for c in formatted_components if "{}".format(key.args[0]) not in c]
template = "/".join(components)
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

VERSION = "10.0.0b1"
VERSION = "0.7.0"
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class CosmosDBManagementClientConfiguration(Configuration): # pylint: disable=t
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2023-03-15-preview". Note that overriding
:keyword api_version: Api Version. Default value is "2023-09-15-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(CosmosDBManagementClientConfiguration, self).__init__(**kwargs)
api_version: str = kwargs.pop("api_version", "2023-03-15-preview")
api_version: str = kwargs.pop("api_version", "2023-09-15-preview")

if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class CosmosDBManagementClient: # pylint: disable=client-accepts-api-version-ke
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2023-03-15-preview". Note that overriding
:keyword api_version: Api Version. Default value is "2023-09-15-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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ async def get_backup(
}

async def _deallocate_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, cluster_name: str, **kwargs: Any
self, resource_group_name: str, cluster_name: str, x_ms_force_deallocate: Optional[bool] = None, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
Expand All @@ -1243,6 +1243,7 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
x_ms_force_deallocate=x_ms_force_deallocate,
api_version=api_version,
template_url=self._deallocate_initial.metadata["url"],
headers=_headers,
Expand Down Expand Up @@ -1271,7 +1272,7 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements

@distributed_trace_async
async def begin_deallocate(
self, resource_group_name: str, cluster_name: str, **kwargs: Any
self, resource_group_name: str, cluster_name: str, x_ms_force_deallocate: Optional[bool] = None, **kwargs: Any
) -> AsyncLROPoller[None]:
"""Deallocate the Managed Cassandra Cluster and Associated Data Centers. Deallocation will
deallocate the host virtual machine of this cluster, and reserved the data disk. This won't do
Expand All @@ -1282,6 +1283,10 @@ async def begin_deallocate(
:type resource_group_name: str
:param cluster_name: Managed Cassandra cluster name. Required.
:type cluster_name: str
:param x_ms_force_deallocate: Force to deallocate a cluster of Cluster Type Production. Force
to deallocate a cluster of Cluster Type Production might cause data loss. Default value is
None.
:type x_ms_force_deallocate: bool
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
Expand All @@ -1306,6 +1311,7 @@ async def begin_deallocate(
raw_result = await self._deallocate_initial( # type: ignore
resource_group_name=resource_group_name,
cluster_name=cluster_name,
x_ms_force_deallocate=x_ms_force_deallocate,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
from ._models_py3 import BackupPolicy
from ._models_py3 import BackupPolicyMigrationState
from ._models_py3 import BackupResource
from ._models_py3 import BackupResourceProperties
from ._models_py3 import BackupSchedule
from ._models_py3 import BaseCosmosDataTransferDataSourceSink
from ._models_py3 import Capability
from ._models_py3 import Capacity
from ._models_py3 import CassandraClusterDataCenterNodeItem
Expand Down Expand Up @@ -336,19 +337,23 @@
from ._cosmos_db_management_client_enums import AuthenticationMethod
from ._cosmos_db_management_client_enums import BackupPolicyMigrationStatus
from ._cosmos_db_management_client_enums import BackupPolicyType
from ._cosmos_db_management_client_enums import BackupState
from ._cosmos_db_management_client_enums import BackupStorageRedundancy
from ._cosmos_db_management_client_enums import CheckNameAvailabilityReason
from ._cosmos_db_management_client_enums import ClusterType
from ._cosmos_db_management_client_enums import CompositePathSortOrder
from ._cosmos_db_management_client_enums import ConflictResolutionMode
from ._cosmos_db_management_client_enums import ConnectionState
from ._cosmos_db_management_client_enums import ConnectorOffer
from ._cosmos_db_management_client_enums import ContinuousTier
from ._cosmos_db_management_client_enums import CreateMode
from ._cosmos_db_management_client_enums import CreatedByType
from ._cosmos_db_management_client_enums import CustomerManagedKeyStatus
from ._cosmos_db_management_client_enums import DataTransferComponent
from ._cosmos_db_management_client_enums import DataType
from ._cosmos_db_management_client_enums import DatabaseAccountKind
from ._cosmos_db_management_client_enums import DefaultConsistencyLevel
from ._cosmos_db_management_client_enums import DefaultPriorityLevel
from ._cosmos_db_management_client_enums import EnableFullTextQuery
from ._cosmos_db_management_client_enums import IndexKind
from ._cosmos_db_management_client_enums import IndexingMode
Expand Down Expand Up @@ -402,7 +407,8 @@
"BackupPolicy",
"BackupPolicyMigrationState",
"BackupResource",
"BackupResourceProperties",
"BackupSchedule",
"BaseCosmosDataTransferDataSourceSink",
"Capability",
"Capacity",
"CassandraClusterDataCenterNodeItem",
Expand Down Expand Up @@ -717,19 +723,23 @@
"AuthenticationMethod",
"BackupPolicyMigrationStatus",
"BackupPolicyType",
"BackupState",
"BackupStorageRedundancy",
"CheckNameAvailabilityReason",
"ClusterType",
"CompositePathSortOrder",
"ConflictResolutionMode",
"ConnectionState",
"ConnectorOffer",
"ContinuousTier",
"CreateMode",
"CreatedByType",
"CustomerManagedKeyStatus",
"DataTransferComponent",
"DataType",
"DatabaseAccountKind",
"DefaultConsistencyLevel",
"DefaultPriorityLevel",
"EnableFullTextQuery",
"IndexKind",
"IndexingMode",
Expand Down
Loading

0 comments on commit 130e930

Please sign in to comment.