Skip to content

Commit

Permalink
[AutoRelease] t2-cosmosdbforpostgresql-2023-08-24-28748(can only be m…
Browse files Browse the repository at this point in the history
…erged by SDK owner) (Azure#31781)

* code and test

* version-update

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md

---------

Co-authored-by: azure-sdk <PythonSdkPipelines>
Co-authored-by: ChenxiJiang333 <v-chenjiang@microsoft.com>
Co-authored-by: ChenxiJiang333 <119990644+ChenxiJiang333@users.noreply.github.com>
Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com>
  • Loading branch information
4 people authored Sep 20, 2023
1 parent 6276378 commit c1b0a0e
Show file tree
Hide file tree
Showing 19 changed files with 262 additions and 80 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release History

## 1.0.0 (2023-09-20)

### Other Changes

- First GA

## 1.0.0b1 (2023-06-16)

* Initial Release
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"commit": "aea36c92c00247b195efb08a0161ab74859e606e",
"commit": "b646a42aa3b7a0ce488d05f1724827ea41d12cf1",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"autorest": "3.9.2",
"autorest": "3.9.7",
"use": [
"@autorest/python@6.4.12",
"@autorest/modelerfour@4.24.3"
"@autorest/python@6.7.1",
"@autorest/modelerfour@4.26.2"
],
"autorest_command": "autorest specification/postgresqlhsc/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.4.12 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False",
"autorest_command": "autorest specification/postgresqlhsc/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.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False",
"readme": "specification/postgresqlhsc/resource-manager/readme.md"
}
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
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 = "1.0.0b1"
VERSION = "1.0.0"
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ class Cluster(TrackedResource): # pylint: disable=too-many-instance-attributes
:vartype maintenance_window: ~azure.mgmt.cosmosdbforpostgresql.models.MaintenanceWindow
:ivar preferred_primary_zone: Preferred primary availability zone (AZ) for all cluster servers.
:vartype preferred_primary_zone: str
:ivar enable_shards_on_coordinator: If shards on coordinator is enabled or not for the cluster.
:ivar enable_shards_on_coordinator: If distributed tables are placed on coordinator or not.
Should be set to 'true' on single node clusters. Requires shard rebalancing after value is
changed.
:vartype enable_shards_on_coordinator: bool
:ivar enable_ha: If high availability (HA) is enabled or not for the cluster.
:vartype enable_ha: bool
Expand Down Expand Up @@ -295,8 +297,9 @@ def __init__( # pylint: disable=too-many-locals
:keyword preferred_primary_zone: Preferred primary availability zone (AZ) for all cluster
servers.
:paramtype preferred_primary_zone: str
:keyword enable_shards_on_coordinator: If shards on coordinator is enabled or not for the
cluster.
:keyword enable_shards_on_coordinator: If distributed tables are placed on coordinator or not.
Should be set to 'true' on single node clusters. Requires shard rebalancing after value is
changed.
:paramtype enable_shards_on_coordinator: bool
:keyword enable_ha: If high availability (HA) is enabled or not for the cluster.
:paramtype enable_ha: bool
Expand Down Expand Up @@ -408,7 +411,9 @@ class ClusterForUpdate(_serialization.Model): # pylint: disable=too-many-instan
:vartype postgresql_version: str
:ivar citus_version: The Citus extension version on all cluster servers.
:vartype citus_version: str
:ivar enable_shards_on_coordinator: If shards on coordinator is enabled or not for the cluster.
:ivar enable_shards_on_coordinator: If distributed tables are placed on coordinator or not.
Should be set to 'true' on single node clusters. Requires shard rebalancing after value is
changed.
:vartype enable_shards_on_coordinator: bool
:ivar enable_ha: If high availability (HA) is enabled or not for the cluster.
:vartype enable_ha: bool
Expand Down Expand Up @@ -493,8 +498,9 @@ def __init__(
:paramtype postgresql_version: str
:keyword citus_version: The Citus extension version on all cluster servers.
:paramtype citus_version: str
:keyword enable_shards_on_coordinator: If shards on coordinator is enabled or not for the
cluster.
:keyword enable_shards_on_coordinator: If distributed tables are placed on coordinator or not.
Should be set to 'true' on single node clusters. Requires shard rebalancing after value is
changed.
:paramtype enable_shards_on_coordinator: bool
:keyword enable_ha: If high availability (HA) is enabled or not for the cluster.
:paramtype enable_ha: bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
from .._vendor import _convert_request

T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
Expand All @@ -54,7 +54,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -84,7 +84,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_
),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -125,7 +125,7 @@ def build_create_request(
),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -165,7 +165,7 @@ def build_get_request(resource_group_name: str, cluster_name: str, subscription_
),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -205,7 +205,7 @@ def build_delete_request(
),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -246,7 +246,7 @@ def build_update_request(
),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -288,7 +288,7 @@ def build_restart_request(
),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -328,7 +328,7 @@ def build_start_request(
),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -366,7 +366,7 @@ def build_stop_request(resource_group_name: str, cluster_name: str, subscription
),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -406,7 +406,7 @@ def build_promote_read_replica_request(
),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand All @@ -433,7 +433,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
from .._vendor import _convert_request

T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
Expand Down Expand Up @@ -71,7 +71,7 @@ def build_list_by_server_request(
),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -111,7 +111,7 @@ def build_list_by_cluster_request(
),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -154,7 +154,7 @@ def build_get_request(
),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -197,7 +197,7 @@ def build_get_coordinator_request(
),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -241,7 +241,7 @@ def build_update_on_coordinator_request(
),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -286,7 +286,7 @@ def build_get_node_request(
),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down Expand Up @@ -330,7 +330,7 @@ def build_update_on_node_request(
),
}

_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
Expand Down
Loading

0 comments on commit c1b0a0e

Please sign in to comment.