/
int_enum_tests_int_enum_post.py
115 lines (87 loc) · 2.51 KB
/
int_enum_tests_int_enum_post.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
from typing import Any, Dict, Optional, Union
import httpx
from ...client import Client
from ...models.an_int_enum import AnIntEnum
from ...models.http_validation_error import HTTPValidationError
from ...types import UNSET, Response
def _get_kwargs(
*,
client: Client,
int_enum: AnIntEnum,
) -> Dict[str, Any]:
url = "{}/tests/int_enum".format(client.base_url)
headers: Dict[str, Any] = client.get_headers()
json_int_enum = int_enum.value
params: Dict[str, Any] = {
"int_enum": json_int_enum,
}
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
return {
"url": url,
"headers": headers,
"cookies": client.get_cookies(),
"timeout": client.get_timeout(),
"params": params,
}
def _parse_response(*, response: httpx.Response) -> Optional[Union[None, HTTPValidationError]]:
if response.status_code == 200:
response_200 = None
return response_200
if response.status_code == 422:
response_422 = HTTPValidationError.from_dict(response.json())
return response_422
return None
def _build_response(*, response: httpx.Response) -> Response[Union[None, HTTPValidationError]]:
return Response(
status_code=response.status_code,
content=response.content,
headers=response.headers,
parsed=_parse_response(response=response),
)
def sync_detailed(
*,
client: Client,
int_enum: AnIntEnum,
) -> Response[Union[None, HTTPValidationError]]:
kwargs = _get_kwargs(
client=client,
int_enum=int_enum,
)
response = httpx.post(
**kwargs,
)
return _build_response(response=response)
def sync(
*,
client: Client,
int_enum: AnIntEnum,
) -> Optional[Union[None, HTTPValidationError]]:
""" """
return sync_detailed(
client=client,
int_enum=int_enum,
).parsed
async def asyncio_detailed(
*,
client: Client,
int_enum: AnIntEnum,
) -> Response[Union[None, HTTPValidationError]]:
kwargs = _get_kwargs(
client=client,
int_enum=int_enum,
)
async with httpx.AsyncClient() as _client:
response = await _client.post(**kwargs)
return _build_response(response=response)
async def asyncio(
*,
client: Client,
int_enum: AnIntEnum,
) -> Optional[Union[None, HTTPValidationError]]:
""" """
return (
await asyncio_detailed(
client=client,
int_enum=int_enum,
)
).parsed