Skip to content

Commit 9eed79b

Browse files
author
SDKAuto
committed
CodeGen from PR 24715 in Azure/azure-rest-api-specs
Merge ae39505977ed1f7dcfd8dc6201f3f1efa994f02f into 8a56aa33078dad6012aa59653cbfa643fa985f15
1 parent d0e378e commit 9eed79b

22 files changed

+130
-118
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"commit": "a8fb6bcb9872431012ed1c7edbb7f369295422a5",
2+
"commit": "06f8fee01019be4e2849bdde240527c461736a26",
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.6.0",
7-
"@autorest/modelerfour@4.24.3"
6+
"@autorest/python@6.7.1",
7+
"@autorest/modelerfour@4.26.2"
88
],
9-
"autorest_command": "autorest specification/dataprotection/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",
9+
"autorest_command": "autorest specification/dataprotection/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/dataprotection/resource-manager/readme.md"
1111
}

sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_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/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_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/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_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 = "1.2.0"
9+
VERSION = "1.0.0b1"

sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_instances_operations.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,9 @@ def get_long_running_output(pipeline_response):
833833
return deserialized
834834

835835
if polling is True:
836-
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
836+
polling_method: AsyncPollingMethod = cast(
837+
AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs)
838+
)
837839
elif polling is False:
838840
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
839841
else:
@@ -1067,7 +1069,9 @@ def get_long_running_output(pipeline_response):
10671069
return deserialized
10681070

10691071
if polling is True:
1070-
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
1072+
polling_method: AsyncPollingMethod = cast(
1073+
AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs)
1074+
)
10711075
elif polling is False:
10721076
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
10731077
else:
@@ -1617,7 +1621,9 @@ def get_long_running_output(pipeline_response):
16171621
return deserialized
16181622

16191623
if polling is True:
1620-
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
1624+
polling_method: AsyncPollingMethod = cast(
1625+
AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs)
1626+
)
16211627
elif polling is False:
16221628
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
16231629
else:
@@ -2599,7 +2605,9 @@ def get_long_running_output(pipeline_response):
25992605
return deserialized
26002606

26012607
if polling is True:
2602-
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
2608+
polling_method: AsyncPollingMethod = cast(
2609+
AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs)
2610+
)
26032611
elif polling is False:
26042612
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
26052613
else:

sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_instances_operations.py

Lines changed: 28 additions & 20 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]]
@@ -59,7 +59,7 @@ def build_list_request(resource_group_name: str, vault_name: str, subscription_i
5959
"vaultName": _SERIALIZER.url("vault_name", vault_name, "str"),
6060
}
6161

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

6464
# Construct parameters
6565
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -93,7 +93,7 @@ def build_get_request(
9393
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
9494
}
9595

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

9898
# Construct parameters
9999
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -128,7 +128,7 @@ def build_create_or_update_request(
128128
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
129129
}
130130

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

133133
# Construct parameters
134134
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -164,7 +164,7 @@ def build_delete_request(
164164
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
165165
}
166166

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

169169
# Construct parameters
170170
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -199,7 +199,7 @@ def build_adhoc_backup_request(
199199
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
200200
}
201201

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

204204
# Construct parameters
205205
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -235,7 +235,7 @@ def build_validate_for_backup_request(
235235
"vaultName": _SERIALIZER.url("vault_name", vault_name, "str"),
236236
}
237237

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

240240
# Construct parameters
241241
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -277,7 +277,7 @@ def build_get_backup_instance_operation_result_request(
277277
"operationId": _SERIALIZER.url("operation_id", operation_id, "str"),
278278
}
279279

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

282282
# Construct parameters
283283
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -312,7 +312,7 @@ def build_trigger_rehydrate_request(
312312
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
313313
}
314314

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

317317
# Construct parameters
318318
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -349,7 +349,7 @@ def build_trigger_restore_request(
349349
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
350350
}
351351

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

354354
# Construct parameters
355355
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -385,7 +385,7 @@ def build_resume_backups_request(
385385
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
386386
}
387387

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

390390
# Construct parameters
391391
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -419,7 +419,7 @@ def build_resume_protection_request(
419419
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
420420
}
421421

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

424424
# Construct parameters
425425
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -453,7 +453,7 @@ def build_stop_protection_request(
453453
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
454454
}
455455

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

458458
# Construct parameters
459459
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -487,7 +487,7 @@ def build_suspend_backups_request(
487487
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
488488
}
489489

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

492492
# Construct parameters
493493
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -522,7 +522,7 @@ def build_sync_backup_instance_request(
522522
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
523523
}
524524

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

527527
# Construct parameters
528528
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -559,7 +559,7 @@ def build_validate_for_restore_request(
559559
"backupInstanceName": _SERIALIZER.url("backup_instance_name", backup_instance_name, "str"),
560560
}
561561

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

564564
# Construct parameters
565565
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -1348,7 +1348,9 @@ def get_long_running_output(pipeline_response):
13481348
return deserialized
13491349

13501350
if polling is True:
1351-
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
1351+
polling_method: PollingMethod = cast(
1352+
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs)
1353+
)
13521354
elif polling is False:
13531355
polling_method = cast(PollingMethod, NoPolling())
13541356
else:
@@ -1582,7 +1584,9 @@ def get_long_running_output(pipeline_response):
15821584
return deserialized
15831585

15841586
if polling is True:
1585-
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
1587+
polling_method: PollingMethod = cast(
1588+
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs)
1589+
)
15861590
elif polling is False:
15871591
polling_method = cast(PollingMethod, NoPolling())
15881592
else:
@@ -2132,7 +2136,9 @@ def get_long_running_output(pipeline_response):
21322136
return deserialized
21332137

21342138
if polling is True:
2135-
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
2139+
polling_method: PollingMethod = cast(
2140+
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs)
2141+
)
21362142
elif polling is False:
21372143
polling_method = cast(PollingMethod, NoPolling())
21382144
else:
@@ -3114,7 +3120,9 @@ def get_long_running_output(pipeline_response):
31143120
return deserialized
31153121

31163122
if polling is True:
3117-
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
3123+
polling_method: PollingMethod = cast(
3124+
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs)
3125+
)
31183126
elif polling is False:
31193127
polling_method = cast(PollingMethod, NoPolling())
31203128
else:

sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_policies_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_request(resource_group_name: str, vault_name: str, subscription_i
5757
"vaultName": _SERIALIZER.url("vault_name", vault_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")
@@ -91,7 +91,7 @@ def build_get_request(
9191
"backupPolicyName": _SERIALIZER.url("backup_policy_name", backup_policy_name, "str"),
9292
}
9393

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

9696
# Construct parameters
9797
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -126,7 +126,7 @@ def build_create_or_update_request(
126126
"backupPolicyName": _SERIALIZER.url("backup_policy_name", backup_policy_name, "str"),
127127
}
128128

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

131131
# Construct parameters
132132
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -162,7 +162,7 @@ def build_delete_request(
162162
"backupPolicyName": _SERIALIZER.url("backup_policy_name", backup_policy_name, "str"),
163163
}
164164

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

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

0 commit comments

Comments
 (0)