Skip to content

Commit

Permalink
CodeGen from PR 25765 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge 8680493b1963ee785b129db54ff88781187826b6 into 5fb829494ad9388ad5baba80e9e74d79d377a163
  • Loading branch information
SDKAuto committed Sep 12, 2023
1 parent 3220dc2 commit 691f5d7
Show file tree
Hide file tree
Showing 237 changed files with 1,029 additions and 736 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"commit": "c7daa3d35baaaabece0dbc6f731eadbe426973b9",
"commit": "f965b27797dd3d9659f3ea6d09e5e12693e3a595",
"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/machinelearningservices/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/machinelearningservices/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/machinelearningservices/resource-manager/readme.md"
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class MachineLearningServicesMgmtClientConfiguration(Configuration): # pylint:
: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-04-01". Note that overriding this
:keyword api_version: Api Version. Default value is "2023-10-01". 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(MachineLearningServicesMgmtClientConfiguration, self).__init__(**kwargs)
api_version: str = kwargs.pop("api_version", "2023-04-01")
api_version: str = kwargs.pop("api_version", "2023-10-01")

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 @@ -172,7 +172,7 @@ class MachineLearningServicesMgmtClient: # pylint: disable=client-accepts-api-v
: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-04-01". Note that overriding this
:keyword api_version: Api Version. Default value is "2023-10-01". 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
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 = "2.0.0b2"
VERSION = "1.0.0b1"
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class MachineLearningServicesMgmtClientConfiguration(Configuration): # pylint:
: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-04-01". Note that overriding this
:keyword api_version: Api Version. Default value is "2023-10-01". 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(MachineLearningServicesMgmtClientConfiguration, self).__init__(**kwargs)
api_version: str = kwargs.pop("api_version", "2023-04-01")
api_version: str = kwargs.pop("api_version", "2023-10-01")

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 @@ -175,7 +175,7 @@ class MachineLearningServicesMgmtClient: # pylint: disable=client-accepts-api-v
: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-04-01". Note that overriding this
:keyword api_version: Api Version. Default value is "2023-10-01". 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 @@ -71,6 +71,7 @@ def list(
job_type: Optional[str] = None,
tag: Optional[str] = None,
list_view_type: Optional[Union[str, _models.ListViewType]] = None,
properties: Optional[str] = None,
**kwargs: Any
) -> AsyncIterable["_models.JobBase"]:
"""Lists Jobs in the workspace.
Expand All @@ -91,6 +92,9 @@ def list(
:param list_view_type: View type for including/excluding (for example) archived entities. Known
values are: "ActiveOnly", "ArchivedOnly", and "All". Default value is None.
:type list_view_type: str or ~azure.mgmt.machinelearningservices.models.ListViewType
:param properties: Comma-separated list of user property names (and optionally values).
Example: prop1,prop2=value2. Default value is None.
:type properties: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either JobBase or the result of cls(response)
:rtype:
Expand Down Expand Up @@ -122,6 +126,7 @@ def prepare_request(next_link=None):
job_type=job_type,
tag=tag,
list_view_type=list_view_type,
properties=properties,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ def __init__(self, *args, **kwargs) -> None:
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")

@distributed_trace
def list(self, **kwargs: Any) -> AsyncIterable["_models.AmlOperation"]:
def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]:
"""Lists all of the available Azure Machine Learning Workspaces REST API operations.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either AmlOperation or the result of cls(response)
:return: An iterator like instance of either Operation or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.machinelearningservices.models.AmlOperation]
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.machinelearningservices.models.Operation]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
cls: ClsType[_models.AmlOperationListResult] = kwargs.pop("cls", None)
cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None)

error_map = {
401: ClientAuthenticationError,
Expand Down Expand Up @@ -107,7 +107,7 @@ def prepare_request(next_link=None):
return request

async def extract_data(pipeline_response):
deserialized = self._deserialize("AmlOperationListResult", pipeline_response)
deserialized = self._deserialize("OperationListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,16 @@ async def _create_or_update_initial(
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

deserialized = None
response_headers = {}
if response.status_code == 200:
deserialized = self._deserialize("Workspace", pipeline_response)

if response.status_code == 202:
response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))

if cls:
return cls(pipeline_response, deserialized, {})
return cls(pipeline_response, deserialized, response_headers)

return deserialized

Expand Down Expand Up @@ -525,11 +530,16 @@ async def _update_initial(
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

deserialized = None
response_headers = {}
if response.status_code == 200:
deserialized = self._deserialize("Workspace", pipeline_response)

if response.status_code == 202:
response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))

if cls:
return cls(pipeline_response, deserialized, {})
return cls(pipeline_response, deserialized, response_headers)

return deserialized

Expand Down Expand Up @@ -1137,8 +1147,13 @@ async def _resync_keys_initial( # pylint: disable=inconsistent-return-statement
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

response_headers = {}
if response.status_code == 202:
response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))

if cls:
return cls(pipeline_response, None, {})
return cls(pipeline_response, None, response_headers)

_resync_keys_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/resyncKeys"
Expand Down Expand Up @@ -1405,11 +1420,16 @@ async def _prepare_notebook_initial(
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

deserialized = None
response_headers = {}
if response.status_code == 200:
deserialized = self._deserialize("NotebookResourceInfo", pipeline_response)

if response.status_code == 202:
response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))

if cls:
return cls(pipeline_response, deserialized, {})
return cls(pipeline_response, deserialized, response_headers)

return deserialized

Expand Down
Loading

0 comments on commit 691f5d7

Please sign in to comment.