Skip to content

Commit 6f65902

Browse files
author
SDKAuto
committed
CodeGen from PR 25079 in Azure/azure-rest-api-specs
Merge cdfbf61fd7459da4bfb8d9e20ad457177e01e0aa into 037091593046a87dd8fac14c3a15fd744f5df151
1 parent 67384df commit 6f65902

11 files changed

+62
-66
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"commit": "c183bb012de8e9e1d0d2e67a0994748df4747d2c",
2+
"commit": "28f4ecfee68b90b3f884524b42adc3a64b341f6e",
33
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4-
"autorest": "3.9.2",
4+
"autorest": "3.9.7",
55
"use": [
6-
"@autorest/python@6.4.12",
7-
"@autorest/modelerfour@4.24.3"
6+
"@autorest/python@6.7.1",
7+
"@autorest/modelerfour@4.26.2"
88
],
9-
"autorest_command": "autorest specification/redis/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",
9+
"autorest_command": "autorest specification/redis/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",
1010
"readme": "specification/redis/resource-manager/readme.md"
1111
}

sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_serialization.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,9 @@ def _serialize(self, target_obj, data_type=None, **kwargs):
662662
_serialized.update(_new_attr) # type: ignore
663663
_new_attr = _new_attr[k] # type: ignore
664664
_serialized = _serialized[k]
665-
except ValueError:
666-
continue
665+
except ValueError as err:
666+
if isinstance(err, SerializationError):
667+
raise
667668

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

757758
# Not a list, regular serialization
758759
output = self.serialize_data(data, data_type, **kwargs)
@@ -891,6 +892,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs):
891892
not be None or empty.
892893
:param str div: If set, this str will be used to combine the elements
893894
in the iterable into a combined string. Default is 'None'.
895+
:keyword bool do_quote: Whether to quote the serialized result of each iterable element.
896+
Defaults to False.
894897
:rtype: list, str
895898
"""
896899
if isinstance(data, str):
@@ -903,9 +906,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs):
903906
for d in data:
904907
try:
905908
serialized.append(self.serialize_data(d, iter_type, **kwargs))
906-
except ValueError:
909+
except ValueError as err:
910+
if isinstance(err, SerializationError):
911+
raise
907912
serialized.append(None)
908913

914+
if kwargs.get("do_quote", False):
915+
serialized = ["" if s is None else quote(str(s), safe="") for s in serialized]
916+
909917
if div:
910918
serialized = ["" if s is None else str(s) for s in serialized]
911919
serialized = div.join(serialized)
@@ -950,7 +958,9 @@ def serialize_dict(self, attr, dict_type, **kwargs):
950958
for key, value in attr.items():
951959
try:
952960
serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs)
953-
except ValueError:
961+
except ValueError as err:
962+
if isinstance(err, SerializationError):
963+
raise
954964
serialized[self.serialize_unicode(key)] = None
955965

956966
if "xml" in serialization_ctxt:

sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_vendor.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
66
# --------------------------------------------------------------------------
77

8-
from typing import List, cast
9-
108
from azure.core.pipeline.transport import HttpRequest
119

1210

@@ -16,15 +14,3 @@ def _convert_request(request, files=None):
1614
if files:
1715
request.set_formdata_body(files)
1816
return request
19-
20-
21-
def _format_url_section(template, **kwargs):
22-
components = template.split("/")
23-
while components:
24-
try:
25-
return template.format(**kwargs)
26-
except KeyError as key:
27-
# Need the cast, as for some reasons "split" is typed as list[str | Any]
28-
formatted_components = cast(List[str], template.split("/"))
29-
components = [c for c in formatted_components if "{}".format(key.args[0]) not in c]
30-
template = "/".join(components)

sdk/redis/azure-mgmt-redis/azure/mgmt/redis/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
VERSION = "14.2.0"
9+
VERSION = "12.0.0b1"

sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_async_operation_status_operations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
from .. import models as _models
2727
from .._serialization import Serializer
28-
from .._vendor import _convert_request, _format_url_section
28+
from .._vendor import _convert_request
2929

3030
T = TypeVar("T")
3131
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
@@ -52,7 +52,7 @@ def build_get_request(location: str, operation_id: str, subscription_id: str, **
5252
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
5353
}
5454

55-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
55+
_url: str = _url.format(**path_format_arguments) # type: ignore
5656

5757
# Construct parameters
5858
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_firewall_rules_operations.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
from .. import models as _models
3030
from .._serialization import Serializer
31-
from .._vendor import _convert_request, _format_url_section
31+
from .._vendor import _convert_request
3232

3333
T = TypeVar("T")
3434
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
@@ -55,7 +55,7 @@ def build_list_request(resource_group_name: str, cache_name: str, subscription_i
5555
"cacheName": _SERIALIZER.url("cache_name", cache_name, "str"),
5656
}
5757

58-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
58+
_url: str = _url.format(**path_format_arguments) # type: ignore
5959

6060
# Construct parameters
6161
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -88,7 +88,7 @@ def build_create_or_update_request(
8888
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
8989
}
9090

91-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
91+
_url: str = _url.format(**path_format_arguments) # type: ignore
9292

9393
# Construct parameters
9494
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -122,7 +122,7 @@ def build_get_request(
122122
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
123123
}
124124

125-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
125+
_url: str = _url.format(**path_format_arguments) # type: ignore
126126

127127
# Construct parameters
128128
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -154,7 +154,7 @@ def build_delete_request(
154154
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
155155
}
156156

157-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
157+
_url: str = _url.format(**path_format_arguments) # type: ignore
158158

159159
# Construct parameters
160160
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_linked_server_operations.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
from .. import models as _models
3232
from .._serialization import Serializer
33-
from .._vendor import _convert_request, _format_url_section
33+
from .._vendor import _convert_request
3434

3535
T = TypeVar("T")
3636
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
@@ -61,7 +61,7 @@ def build_create_request(
6161
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
6262
}
6363

64-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
64+
_url: str = _url.format(**path_format_arguments) # type: ignore
6565

6666
# Construct parameters
6767
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -95,7 +95,7 @@ def build_delete_request(
9595
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
9696
}
9797

98-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
98+
_url: str = _url.format(**path_format_arguments) # type: ignore
9999

100100
# Construct parameters
101101
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -127,7 +127,7 @@ def build_get_request(
127127
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
128128
}
129129

130-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
130+
_url: str = _url.format(**path_format_arguments) # type: ignore
131131

132132
# Construct parameters
133133
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -156,7 +156,7 @@ def build_list_request(resource_group_name: str, name: str, subscription_id: str
156156
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
157157
}
158158

159-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
159+
_url: str = _url.format(**path_format_arguments) # type: ignore
160160

161161
# Construct parameters
162162
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_patch_schedules_operations.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
from .. import models as _models
3030
from .._serialization import Serializer
31-
from .._vendor import _convert_request, _format_url_section
31+
from .._vendor import _convert_request
3232

3333
T = TypeVar("T")
3434
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
@@ -57,7 +57,7 @@ def build_list_by_redis_resource_request(
5757
"cacheName": _SERIALIZER.url("cache_name", cache_name, "str"),
5858
}
5959

60-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
60+
_url: str = _url.format(**path_format_arguments) # type: ignore
6161

6262
# Construct parameters
6363
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -90,7 +90,7 @@ def build_create_or_update_request(
9090
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
9191
}
9292

93-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
93+
_url: str = _url.format(**path_format_arguments) # type: ignore
9494

9595
# Construct parameters
9696
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -124,7 +124,7 @@ def build_delete_request(
124124
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
125125
}
126126

127-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
127+
_url: str = _url.format(**path_format_arguments) # type: ignore
128128

129129
# Construct parameters
130130
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -156,7 +156,7 @@ def build_get_request(
156156
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
157157
}
158158

159-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
159+
_url: str = _url.format(**path_format_arguments) # type: ignore
160160

161161
# Construct parameters
162162
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_private_endpoint_connections_operations.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
from .. import models as _models
3232
from .._serialization import Serializer
33-
from .._vendor import _convert_request, _format_url_section
33+
from .._vendor import _convert_request
3434

3535
T = TypeVar("T")
3636
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
@@ -57,7 +57,7 @@ def build_list_request(resource_group_name: str, cache_name: str, subscription_i
5757
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
5858
}
5959

60-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
60+
_url: str = _url.format(**path_format_arguments) # type: ignore
6161

6262
# Construct parameters
6363
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -95,7 +95,7 @@ def build_get_request(
9595
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
9696
}
9797

98-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
98+
_url: str = _url.format(**path_format_arguments) # type: ignore
9999

100100
# Construct parameters
101101
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -134,7 +134,7 @@ def build_put_request(
134134
),
135135
}
136136

137-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
137+
_url: str = _url.format(**path_format_arguments) # type: ignore
138138

139139
# Construct parameters
140140
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -174,7 +174,7 @@ def build_delete_request(
174174
),
175175
}
176176

177-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
177+
_url: str = _url.format(**path_format_arguments) # type: ignore
178178

179179
# Construct parameters
180180
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

sdk/redis/azure-mgmt-redis/azure/mgmt/redis/operations/_private_link_resources_operations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
from .. import models as _models
2929
from .._serialization import Serializer
30-
from .._vendor import _convert_request, _format_url_section
30+
from .._vendor import _convert_request
3131

3232
T = TypeVar("T")
3333
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
@@ -56,7 +56,7 @@ def build_list_by_redis_cache_request(
5656
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
5757
}
5858

59-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
59+
_url: str = _url.format(**path_format_arguments) # type: ignore
6060

6161
# Construct parameters
6262
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

0 commit comments

Comments
 (0)