Skip to content

Commit d1080cd

Browse files
author
SDKAuto
committed
CodeGen from PR 25564 in Azure/azure-rest-api-specs
Merge 73f8081a33109306fde7eb576df6030896bc9557 into 5dd1107d5f2be8d600325d795450e1d854fbe7e8
1 parent d5ed657 commit d1080cd

13 files changed

+89
-93
lines changed

sdk/batch/azure-mgmt-batch/_meta.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"commit": "e2b5f9323c4214408969a6e953b4075cfdc693b6",
2+
"commit": "c10717e7d69bb8114fb1b248fad4cc16e517189d",
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/batch/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/batch/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/batch/resource-manager/readme.md"
1111
}

sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_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/batch/azure-mgmt-batch/azure/mgmt/batch/_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/batch/azure-mgmt-batch/azure/mgmt/batch/_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 = "17.1.0"
9+
VERSION = "14.0.0b1"

sdk/batch/azure-mgmt-batch/azure/mgmt/batch/models/_models_py3.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2619,7 +2619,7 @@ class FixedScaleSettings(_serialization.Model):
26192619
def __init__(
26202620
self,
26212621
*,
2622-
resize_timeout: Optional[datetime.timedelta] = None,
2622+
resize_timeout: datetime.timedelta = "PT15M",
26232623
target_dedicated_nodes: Optional[int] = None,
26242624
target_low_priority_nodes: Optional[int] = None,
26252625
node_deallocation_option: Optional[Union[str, "_models.ComputeNodeDeallocationOption"]] = None,
@@ -2684,7 +2684,7 @@ def __init__(
26842684
publisher: Optional[str] = None,
26852685
offer: Optional[str] = None,
26862686
sku: Optional[str] = None,
2687-
version: Optional[str] = None,
2687+
version: str = "latest",
26882688
id: Optional[str] = None, # pylint: disable=redefined-builtin
26892689
**kwargs: Any
26902690
) -> None:
@@ -3293,7 +3293,7 @@ def __init__(
32933293
self,
32943294
*,
32953295
subnet_id: Optional[str] = None,
3296-
dynamic_vnet_assignment_scope: Optional[Union[str, "_models.DynamicVNetAssignmentScope"]] = None,
3296+
dynamic_vnet_assignment_scope: Union[str, "_models.DynamicVNetAssignmentScope"] = "none",
32973297
endpoint_configuration: Optional["_models.PoolEndpointConfiguration"] = None,
32983298
public_ip_address_configuration: Optional["_models.PublicIPAddressConfiguration"] = None,
32993299
enable_accelerated_networking: Optional[bool] = None,
@@ -3914,7 +3914,7 @@ def __init__( # pylint: disable=too-many-locals
39143914
scale_settings: Optional["_models.ScaleSettings"] = None,
39153915
inter_node_communication: Optional[Union[str, "_models.InterNodeCommunicationState"]] = None,
39163916
network_configuration: Optional["_models.NetworkConfiguration"] = None,
3917-
task_slots_per_node: Optional[int] = None,
3917+
task_slots_per_node: int = 1,
39183918
task_scheduling_policy: Optional["_models.TaskSchedulingPolicy"] = None,
39193919
user_accounts: Optional[List["_models.UserAccount"]] = None,
39203920
metadata: Optional[List["_models.MetadataItem"]] = None,
@@ -4618,7 +4618,7 @@ class StartTask(_serialization.Model):
46184618
task once, and may then retry up to this limit. For example, if the maximum retry count is 3,
46194619
Batch tries the task up to 4 times (one initial try and 3 retries). If the maximum retry count
46204620
is 0, the Batch service does not retry the task. If the maximum retry count is -1, the Batch
4621-
service retries the task without limit.
4621+
service retries the task without limit. Default is 0.
46224622
:vartype max_task_retry_count: int
46234623
:ivar wait_for_success: If true and the start task fails on a compute node, the Batch service
46244624
retries the start task up to its maximum retry count (maxTaskRetryCount). If the task has still
@@ -4653,7 +4653,7 @@ def __init__(
46534653
resource_files: Optional[List["_models.ResourceFile"]] = None,
46544654
environment_settings: Optional[List["_models.EnvironmentSetting"]] = None,
46554655
user_identity: Optional["_models.UserIdentity"] = None,
4656-
max_task_retry_count: Optional[int] = None,
4656+
max_task_retry_count: int = 0,
46574657
wait_for_success: Optional[bool] = None,
46584658
container_settings: Optional["_models.TaskContainerSettings"] = None,
46594659
**kwargs: Any
@@ -4678,7 +4678,7 @@ def __init__(
46784678
the task once, and may then retry up to this limit. For example, if the maximum retry count is
46794679
3, Batch tries the task up to 4 times (one initial try and 3 retries). If the maximum retry
46804680
count is 0, the Batch service does not retry the task. If the maximum retry count is -1, the
4681-
Batch service retries the task without limit.
4681+
Batch service retries the task without limit. Default is 0.
46824682
:paramtype max_task_retry_count: int
46834683
:keyword wait_for_success: If true and the start task fails on a compute node, the Batch
46844684
service retries the start task up to its maximum retry count (maxTaskRetryCount). If the task
@@ -4837,8 +4837,8 @@ class TaskSchedulingPolicy(_serialization.Model):
48374837
48384838
All required parameters must be populated in order to send to Azure.
48394839
4840-
:ivar node_fill_type: How tasks should be distributed across compute nodes. Required. Known
4841-
values are: "Spread" and "Pack".
4840+
:ivar node_fill_type: How tasks should be distributed across compute nodes. Known values are:
4841+
"Spread" and "Pack".
48424842
:vartype node_fill_type: str or ~azure.mgmt.batch.models.ComputeNodeFillType
48434843
"""
48444844

@@ -4850,10 +4850,10 @@ class TaskSchedulingPolicy(_serialization.Model):
48504850
"node_fill_type": {"key": "nodeFillType", "type": "str"},
48514851
}
48524852

4853-
def __init__(self, *, node_fill_type: Union[str, "_models.ComputeNodeFillType"], **kwargs: Any) -> None:
4853+
def __init__(self, *, node_fill_type: Union[str, "_models.ComputeNodeFillType"] = "Spread", **kwargs: Any) -> None:
48544854
"""
4855-
:keyword node_fill_type: How tasks should be distributed across compute nodes. Required. Known
4856-
values are: "Spread" and "Pack".
4855+
:keyword node_fill_type: How tasks should be distributed across compute nodes. Known values
4856+
are: "Spread" and "Pack".
48574857
:paramtype node_fill_type: str or ~azure.mgmt.batch.models.ComputeNodeFillType
48584858
"""
48594859
super().__init__(**kwargs)

sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_application_operations.py

Lines changed: 6 additions & 6 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]]
@@ -63,7 +63,7 @@ def build_create_request(
6363
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
6464
}
6565

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

6868
# Construct parameters
6969
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -101,7 +101,7 @@ def build_delete_request(
101101
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
102102
}
103103

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

106106
# Construct parameters
107107
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -137,7 +137,7 @@ def build_get_request(
137137
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
138138
}
139139

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

142142
# Construct parameters
143143
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -174,7 +174,7 @@ def build_update_request(
174174
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
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")
@@ -214,7 +214,7 @@ def build_list_request(
214214
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
215215
}
216216

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

219219
# Construct parameters
220220
if maxresults is not None:

sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_application_package_operations.py

Lines changed: 6 additions & 6 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]]
@@ -71,7 +71,7 @@ def build_activate_request(
7171
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
7272
}
7373

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

7676
# Construct parameters
7777
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -118,7 +118,7 @@ def build_create_request(
118118
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
119119
}
120120

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

123123
# Construct parameters
124124
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -164,7 +164,7 @@ def build_delete_request(
164164
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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")
@@ -208,7 +208,7 @@ def build_get_request(
208208
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
209209
}
210210

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

213213
# Construct parameters
214214
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -250,7 +250,7 @@ def build_list_request(
250250
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
251251
}
252252

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

255255
# Construct parameters
256256
if maxresults is not None:

0 commit comments

Comments
 (0)