|
| 1 | +from http import HTTPStatus |
| 2 | +from typing import Any, Dict, Optional, Union |
| 3 | + |
| 4 | +import httpx |
| 5 | + |
| 6 | +from ... import errors |
| 7 | +from ...client import AuthenticatedClient, Client |
| 8 | +from ...types import UNSET, Response |
| 9 | + |
| 10 | + |
| 11 | +def _get_kwargs( |
| 12 | + *, |
| 13 | + bool_enum: bool, |
| 14 | +) -> Dict[str, Any]: |
| 15 | + params: Dict[str, Any] = {} |
| 16 | + |
| 17 | + params["bool_enum"] = bool_enum |
| 18 | + |
| 19 | + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} |
| 20 | + |
| 21 | + _kwargs: Dict[str, Any] = { |
| 22 | + "method": "post", |
| 23 | + "url": "/enum/bool", |
| 24 | + "params": params, |
| 25 | + } |
| 26 | + |
| 27 | + return _kwargs |
| 28 | + |
| 29 | + |
| 30 | +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: |
| 31 | + if response.status_code == HTTPStatus.OK: |
| 32 | + return None |
| 33 | + if client.raise_on_unexpected_status: |
| 34 | + raise errors.UnexpectedStatus(response.status_code, response.content) |
| 35 | + else: |
| 36 | + return None |
| 37 | + |
| 38 | + |
| 39 | +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: |
| 40 | + return Response( |
| 41 | + status_code=HTTPStatus(response.status_code), |
| 42 | + content=response.content, |
| 43 | + headers=response.headers, |
| 44 | + parsed=_parse_response(client=client, response=response), |
| 45 | + ) |
| 46 | + |
| 47 | + |
| 48 | +def sync_detailed( |
| 49 | + *, |
| 50 | + client: Union[AuthenticatedClient, Client], |
| 51 | + bool_enum: bool, |
| 52 | +) -> Response[Any]: |
| 53 | + """Bool Enum |
| 54 | +
|
| 55 | + Args: |
| 56 | + bool_enum (bool): |
| 57 | +
|
| 58 | + Raises: |
| 59 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 60 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 61 | +
|
| 62 | + Returns: |
| 63 | + Response[Any] |
| 64 | + """ |
| 65 | + |
| 66 | + kwargs = _get_kwargs( |
| 67 | + bool_enum=bool_enum, |
| 68 | + ) |
| 69 | + |
| 70 | + response = client.get_httpx_client().request( |
| 71 | + **kwargs, |
| 72 | + ) |
| 73 | + |
| 74 | + return _build_response(client=client, response=response) |
| 75 | + |
| 76 | + |
| 77 | +async def asyncio_detailed( |
| 78 | + *, |
| 79 | + client: Union[AuthenticatedClient, Client], |
| 80 | + bool_enum: bool, |
| 81 | +) -> Response[Any]: |
| 82 | + """Bool Enum |
| 83 | +
|
| 84 | + Args: |
| 85 | + bool_enum (bool): |
| 86 | +
|
| 87 | + Raises: |
| 88 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 89 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 90 | +
|
| 91 | + Returns: |
| 92 | + Response[Any] |
| 93 | + """ |
| 94 | + |
| 95 | + kwargs = _get_kwargs( |
| 96 | + bool_enum=bool_enum, |
| 97 | + ) |
| 98 | + |
| 99 | + response = await client.get_async_httpx_client().request(**kwargs) |
| 100 | + |
| 101 | + return _build_response(client=client, response=response) |
0 commit comments