Skip to content

Commit 0eba399

Browse files
committed
Refresh snapshots
1 parent 5840d91 commit 0eba399

File tree

2 files changed

+227
-0
lines changed

2 files changed

+227
-0
lines changed
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
from http import HTTPStatus
2+
from typing import Any, Optional, Union
3+
4+
import httpx
5+
6+
from ... import errors
7+
from ...client import AuthenticatedClient, Client
8+
from ...models.http_validation_error import HTTPValidationError
9+
from ...models.upload_array_of_files_in_object_tests_upload_post_body import (
10+
UploadArrayOfFilesInObjectTestsUploadPostBody,
11+
)
12+
from ...types import Response
13+
14+
15+
def _get_kwargs(
16+
*,
17+
body: UploadArrayOfFilesInObjectTestsUploadPostBody,
18+
) -> dict[str, Any]:
19+
headers: dict[str, Any] = {}
20+
21+
_kwargs: dict[str, Any] = {
22+
"method": "post",
23+
"url": "/tests/upload/multiple-files-in-object",
24+
}
25+
26+
_body = body.to_multipart()
27+
28+
_kwargs["files"] = _body
29+
30+
_kwargs["headers"] = headers
31+
return _kwargs
32+
33+
34+
def _parse_response(
35+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
36+
) -> Optional[Union[Any, HTTPValidationError]]:
37+
if response.status_code == 200:
38+
response_200 = response.json()
39+
return response_200
40+
if response.status_code == 422:
41+
response_422 = HTTPValidationError.from_dict(response.json())
42+
43+
return response_422
44+
if client.raise_on_unexpected_status:
45+
raise errors.UnexpectedStatus(response.status_code, response.content)
46+
else:
47+
return None
48+
49+
50+
def _build_response(
51+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
52+
) -> Response[Union[Any, HTTPValidationError]]:
53+
return Response(
54+
status_code=HTTPStatus(response.status_code),
55+
content=response.content,
56+
headers=response.headers,
57+
parsed=_parse_response(client=client, response=response),
58+
)
59+
60+
61+
def sync_detailed(
62+
*,
63+
client: Union[AuthenticatedClient, Client],
64+
body: UploadArrayOfFilesInObjectTestsUploadPostBody,
65+
) -> Response[Union[Any, HTTPValidationError]]:
66+
"""Array of files in object
67+
68+
Upload an array of files as part of an object
69+
70+
Args:
71+
body (UploadArrayOfFilesInObjectTestsUploadPostBody):
72+
73+
Raises:
74+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
75+
httpx.TimeoutException: If the request takes longer than Client.timeout.
76+
77+
Returns:
78+
Response[Union[Any, HTTPValidationError]]
79+
"""
80+
81+
kwargs = _get_kwargs(
82+
body=body,
83+
)
84+
85+
response = client.get_httpx_client().request(
86+
**kwargs,
87+
)
88+
89+
return _build_response(client=client, response=response)
90+
91+
92+
def sync(
93+
*,
94+
client: Union[AuthenticatedClient, Client],
95+
body: UploadArrayOfFilesInObjectTestsUploadPostBody,
96+
) -> Optional[Union[Any, HTTPValidationError]]:
97+
"""Array of files in object
98+
99+
Upload an array of files as part of an object
100+
101+
Args:
102+
body (UploadArrayOfFilesInObjectTestsUploadPostBody):
103+
104+
Raises:
105+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
106+
httpx.TimeoutException: If the request takes longer than Client.timeout.
107+
108+
Returns:
109+
Union[Any, HTTPValidationError]
110+
"""
111+
112+
return sync_detailed(
113+
client=client,
114+
body=body,
115+
).parsed
116+
117+
118+
async def asyncio_detailed(
119+
*,
120+
client: Union[AuthenticatedClient, Client],
121+
body: UploadArrayOfFilesInObjectTestsUploadPostBody,
122+
) -> Response[Union[Any, HTTPValidationError]]:
123+
"""Array of files in object
124+
125+
Upload an array of files as part of an object
126+
127+
Args:
128+
body (UploadArrayOfFilesInObjectTestsUploadPostBody):
129+
130+
Raises:
131+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
132+
httpx.TimeoutException: If the request takes longer than Client.timeout.
133+
134+
Returns:
135+
Response[Union[Any, HTTPValidationError]]
136+
"""
137+
138+
kwargs = _get_kwargs(
139+
body=body,
140+
)
141+
142+
response = await client.get_async_httpx_client().request(**kwargs)
143+
144+
return _build_response(client=client, response=response)
145+
146+
147+
async def asyncio(
148+
*,
149+
client: Union[AuthenticatedClient, Client],
150+
body: UploadArrayOfFilesInObjectTestsUploadPostBody,
151+
) -> Optional[Union[Any, HTTPValidationError]]:
152+
"""Array of files in object
153+
154+
Upload an array of files as part of an object
155+
156+
Args:
157+
body (UploadArrayOfFilesInObjectTestsUploadPostBody):
158+
159+
Raises:
160+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
161+
httpx.TimeoutException: If the request takes longer than Client.timeout.
162+
163+
Returns:
164+
Union[Any, HTTPValidationError]
165+
"""
166+
167+
return (
168+
await asyncio_detailed(
169+
client=client,
170+
body=body,
171+
)
172+
).parsed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from collections.abc import Mapping
2+
from typing import Any, TypeVar
3+
4+
from attrs import define as _attrs_define
5+
from attrs import field as _attrs_field
6+
7+
T = TypeVar("T", bound="UploadArrayOfFilesInObjectTestsUploadPostBody")
8+
9+
10+
@_attrs_define
11+
class UploadArrayOfFilesInObjectTestsUploadPostBody:
12+
""" """
13+
14+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
15+
16+
def to_dict(self) -> dict[str, Any]:
17+
field_dict: dict[str, Any] = {}
18+
field_dict.update(self.additional_properties)
19+
20+
return field_dict
21+
22+
def to_multipart(self) -> list[tuple[str, Any]]:
23+
field_list: list[tuple[str, Any]] = []
24+
25+
field_dict: dict[str, Any] = {}
26+
for prop_name, prop in self.additional_properties.items():
27+
field_dict[prop_name] = (None, str(prop).encode(), "text/plain")
28+
29+
field_list += list(field_dict.items())
30+
31+
return field_list
32+
33+
@classmethod
34+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
35+
d = dict(src_dict)
36+
upload_array_of_files_in_object_tests_upload_post_body = cls()
37+
38+
upload_array_of_files_in_object_tests_upload_post_body.additional_properties = d
39+
return upload_array_of_files_in_object_tests_upload_post_body
40+
41+
@property
42+
def additional_keys(self) -> list[str]:
43+
return list(self.additional_properties.keys())
44+
45+
def __getitem__(self, key: str) -> Any:
46+
return self.additional_properties[key]
47+
48+
def __setitem__(self, key: str, value: Any) -> None:
49+
self.additional_properties[key] = value
50+
51+
def __delitem__(self, key: str) -> None:
52+
del self.additional_properties[key]
53+
54+
def __contains__(self, key: str) -> bool:
55+
return key in self.additional_properties

0 commit comments

Comments
 (0)