Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: internal
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

Add test case
4 changes: 2 additions & 2 deletions packages/autorest.python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
"dependencies": {
"@typespec/http-client-python": "~0.24.1",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTc1NTgzOC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.24.1.tgz",
"@autorest/system-requirements": "~1.0.2",
"fs-extra": "~11.2.0",
"tsx": "~4.19.1"
Expand All @@ -47,4 +47,4 @@
"requirements.txt",
"generator/"
]
}
}
6 changes: 3 additions & 3 deletions packages/typespec-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"js-yaml": "~4.1.0",
"semver": "~7.6.2",
"tsx": "~4.19.1",
"@typespec/http-client-python": "~0.24.1",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTc1NTgzOC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.24.1.tgz",
"fs-extra": "~11.2.0"
},
"devDependencies": {
Expand All @@ -87,7 +87,7 @@
"@azure-tools/typespec-autorest": "~0.64.0",
"@azure-tools/typespec-client-generator-core": "~0.64.1",
"@azure-tools/azure-http-specs": "0.1.0-alpha.35",
"@typespec/http-specs": "0.1.0-alpha.30",
"@typespec/http-specs": "0.1.0-alpha.31",
"@typespec/spector": "0.1.0-alpha.22",
"@typespec/spec-api": "0.1.0-alpha.12",
"@types/js-yaml": "~4.0.5",
Expand All @@ -103,4 +103,4 @@
"chalk": "5.3.0",
"@types/fs-extra": "11.0.4"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"specialwords.models.InModel": "SpecialWords.Models.in",
"specialwords.models.IsModel": "SpecialWords.Models.is",
"specialwords.models.LambdaModel": "SpecialWords.Models.lambda",
"specialwords.models.ModelWithList": "SpecialWords.ModelProperties.ModelWithList",
"specialwords.models.NotModel": "SpecialWords.Models.not",
"specialwords.models.OrModel": "SpecialWords.Models.or",
"specialwords.models.PassModel": "SpecialWords.Models.pass",
Expand Down Expand Up @@ -106,6 +107,8 @@
"specialwords.aio.operations.ModelPropertiesOperations.same_as_model": "SpecialWords.ModelProperties.sameAsModel",
"specialwords.operations.ModelPropertiesOperations.dict_methods": "SpecialWords.ModelProperties.dictMethods",
"specialwords.aio.operations.ModelPropertiesOperations.dict_methods": "SpecialWords.ModelProperties.dictMethods",
"specialwords.operations.ModelPropertiesOperations.with_list": "SpecialWords.ModelProperties.withList",
"specialwords.aio.operations.ModelPropertiesOperations.with_list": "SpecialWords.ModelProperties.withList",
"specialwords.operations.Operations.and_method": "SpecialWords.Operations.and",
"specialwords.aio.operations.Operations.and_method": "SpecialWords.Operations.and",
"specialwords.operations.Operations.as_method": "SpecialWords.Operations.as",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,14 @@ def test_model_properties_dict_methods(self, specialwords_endpoint):

# please add some check logic here by yourself
# ...

@SpecialWordsPreparer()
@recorded_by_proxy
def test_model_properties_with_list(self, specialwords_endpoint):
client = self.create_client(endpoint=specialwords_endpoint)
response = client.model_properties.with_list(
body={"list": "str"},
)

# please add some check logic here by yourself
# ...
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,14 @@ async def test_model_properties_dict_methods(self, specialwords_endpoint):

# please add some check logic here by yourself
# ...

@SpecialWordsPreparer()
@recorded_by_proxy_async
async def test_model_properties_with_list(self, specialwords_endpoint):
client = self.create_async_client(endpoint=specialwords_endpoint)
response = await client.model_properties.with_list(
body={"list": "str"},
)

# please add some check logic here by yourself
# ...
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class SpecialWordsClient: # pylint: disable=client-accepts-api-version-keyword
in
is
lambda
list
not
or
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class SpecialWordsClient: # pylint: disable=client-accepts-api-version-keyword
in
is
lambda
list
not
or
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from ...operations._operations import (
build_model_properties_dict_methods_request,
build_model_properties_same_as_model_request,
build_model_properties_with_list_request,
build_models_with_and_request,
build_models_with_as_request,
build_models_with_assert_request,
Expand Down Expand Up @@ -3652,6 +3653,106 @@ async def dict_methods(self, body: Union[_models.DictMethods, JSON, IO[bytes]],
if cls:
return cls(pipeline_response, None, {}) # type: ignore

@overload
async def with_list(
self, body: _models.ModelWithList, *, content_type: str = "application/json", **kwargs: Any
) -> None:
"""with_list.

:param body: Required.
:type body: ~specialwords.models.ModelWithList
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
async def with_list(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> None:
"""with_list.

:param body: Required.
:type body: JSON
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
async def with_list(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""with_list.

:param body: Required.
:type body: IO[bytes]
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""

@distributed_trace_async
async def with_list(self, body: Union[_models.ModelWithList, JSON, IO[bytes]], **kwargs: Any) -> None:
"""with_list.

:param body: Is one of the following types: ModelWithList, JSON, IO[bytes] Required.
:type body: ~specialwords.models.ModelWithList or JSON or IO[bytes]
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map: MutableMapping = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})

_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = kwargs.pop("params", {}) or {}

content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[None] = kwargs.pop("cls", None)

content_type = content_type or "application/json"
_content = None
if isinstance(body, (IOBase, bytes)):
_content = body
else:
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore

_request = build_model_properties_with_list_request(
content_type=content_type,
content=_content,
headers=_headers,
params=_params,
)
path_format_arguments = {
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
}
_request.url = self._client.format_url(_request.url, **path_format_arguments)

_stream = False
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
)

response = pipeline_response.http_response

if response.status_code not in [204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

if cls:
return cls(pipeline_response, None, {}) # type: ignore


class Operations: # pylint: disable=too-many-public-methods
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
InModel,
IsModel,
LambdaModel,
ModelWithList,
NotModel,
OrModel,
PassModel,
Expand Down Expand Up @@ -80,6 +81,7 @@
"InModel",
"IsModel",
"LambdaModel",
"ModelWithList",
"NotModel",
"OrModel",
"PassModel",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

from .._utils.model_base import Model as _Model, rest_field

List = list


class AndModel(_Model):
"""AndModel.
Expand Down Expand Up @@ -778,6 +780,34 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)


class ModelWithList(_Model):
"""ModelWithList.

:ivar list: Required.
:vartype list: str
"""

list: str = rest_field(visibility=["read", "create", "update", "delete", "query"])
"""Required."""

@overload
def __init__(
self,
*,
list: str,
) -> None: ...

@overload
def __init__(self, mapping: Mapping[str, Any]) -> None:
"""
:param mapping: raw JSON to initialize the model.
:type mapping: Mapping[str, Any]
"""

def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)


class NotModel(_Model):
"""NotModel.

Expand Down
Loading
Loading