|
| 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 ...models.mixed_case_response_200 import MixedCaseResponse200 |
| 9 | +from ...types import UNSET, Response |
| 10 | + |
| 11 | + |
| 12 | +def _get_kwargs( |
| 13 | + *, |
| 14 | + mixed_case: str, |
| 15 | + mixedCase: str, |
| 16 | +) -> Dict[str, Any]: |
| 17 | + params: Dict[str, Any] = {} |
| 18 | + |
| 19 | + params["mixed_case"] = mixed_case |
| 20 | + |
| 21 | + params["mixedCase"] = mixedCase |
| 22 | + |
| 23 | + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} |
| 24 | + |
| 25 | + _kwargs: Dict[str, Any] = { |
| 26 | + "method": "get", |
| 27 | + "url": "/naming/mixed-case", |
| 28 | + "params": params, |
| 29 | + } |
| 30 | + |
| 31 | + return _kwargs |
| 32 | + |
| 33 | + |
| 34 | +def _parse_response( |
| 35 | + *, client: Union[AuthenticatedClient, Client], response: httpx.Response |
| 36 | +) -> Optional[MixedCaseResponse200]: |
| 37 | + if response.status_code == HTTPStatus.OK: |
| 38 | + response_200 = MixedCaseResponse200.from_dict(response.json()) |
| 39 | + |
| 40 | + return response_200 |
| 41 | + if client.raise_on_unexpected_status: |
| 42 | + raise errors.UnexpectedStatus(response.status_code, response.content) |
| 43 | + else: |
| 44 | + return None |
| 45 | + |
| 46 | + |
| 47 | +def _build_response( |
| 48 | + *, client: Union[AuthenticatedClient, Client], response: httpx.Response |
| 49 | +) -> Response[MixedCaseResponse200]: |
| 50 | + return Response( |
| 51 | + status_code=HTTPStatus(response.status_code), |
| 52 | + content=response.content, |
| 53 | + headers=response.headers, |
| 54 | + parsed=_parse_response(client=client, response=response), |
| 55 | + ) |
| 56 | + |
| 57 | + |
| 58 | +def sync_detailed( |
| 59 | + *, |
| 60 | + client: Union[AuthenticatedClient, Client], |
| 61 | + mixed_case: str, |
| 62 | + mixedCase: str, |
| 63 | +) -> Response[MixedCaseResponse200]: |
| 64 | + """ |
| 65 | + Args: |
| 66 | + mixed_case (str): |
| 67 | + mixedCase (str): |
| 68 | +
|
| 69 | + Raises: |
| 70 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 71 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 72 | +
|
| 73 | + Returns: |
| 74 | + Response[MixedCaseResponse200] |
| 75 | + """ |
| 76 | + |
| 77 | + kwargs = _get_kwargs( |
| 78 | + mixed_case=mixed_case, |
| 79 | + mixedCase=mixedCase, |
| 80 | + ) |
| 81 | + |
| 82 | + response = client.get_httpx_client().request( |
| 83 | + **kwargs, |
| 84 | + ) |
| 85 | + |
| 86 | + return _build_response(client=client, response=response) |
| 87 | + |
| 88 | + |
| 89 | +def sync( |
| 90 | + *, |
| 91 | + client: Union[AuthenticatedClient, Client], |
| 92 | + mixed_case: str, |
| 93 | + mixedCase: str, |
| 94 | +) -> Optional[MixedCaseResponse200]: |
| 95 | + """ |
| 96 | + Args: |
| 97 | + mixed_case (str): |
| 98 | + mixedCase (str): |
| 99 | +
|
| 100 | + Raises: |
| 101 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 102 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 103 | +
|
| 104 | + Returns: |
| 105 | + MixedCaseResponse200 |
| 106 | + """ |
| 107 | + |
| 108 | + return sync_detailed( |
| 109 | + client=client, |
| 110 | + mixed_case=mixed_case, |
| 111 | + mixedCase=mixedCase, |
| 112 | + ).parsed |
| 113 | + |
| 114 | + |
| 115 | +async def asyncio_detailed( |
| 116 | + *, |
| 117 | + client: Union[AuthenticatedClient, Client], |
| 118 | + mixed_case: str, |
| 119 | + mixedCase: str, |
| 120 | +) -> Response[MixedCaseResponse200]: |
| 121 | + """ |
| 122 | + Args: |
| 123 | + mixed_case (str): |
| 124 | + mixedCase (str): |
| 125 | +
|
| 126 | + Raises: |
| 127 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 128 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 129 | +
|
| 130 | + Returns: |
| 131 | + Response[MixedCaseResponse200] |
| 132 | + """ |
| 133 | + |
| 134 | + kwargs = _get_kwargs( |
| 135 | + mixed_case=mixed_case, |
| 136 | + mixedCase=mixedCase, |
| 137 | + ) |
| 138 | + |
| 139 | + response = await client.get_async_httpx_client().request(**kwargs) |
| 140 | + |
| 141 | + return _build_response(client=client, response=response) |
| 142 | + |
| 143 | + |
| 144 | +async def asyncio( |
| 145 | + *, |
| 146 | + client: Union[AuthenticatedClient, Client], |
| 147 | + mixed_case: str, |
| 148 | + mixedCase: str, |
| 149 | +) -> Optional[MixedCaseResponse200]: |
| 150 | + """ |
| 151 | + Args: |
| 152 | + mixed_case (str): |
| 153 | + mixedCase (str): |
| 154 | +
|
| 155 | + Raises: |
| 156 | + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. |
| 157 | + httpx.TimeoutException: If the request takes longer than Client.timeout. |
| 158 | +
|
| 159 | + Returns: |
| 160 | + MixedCaseResponse200 |
| 161 | + """ |
| 162 | + |
| 163 | + return ( |
| 164 | + await asyncio_detailed( |
| 165 | + client=client, |
| 166 | + mixed_case=mixed_case, |
| 167 | + mixedCase=mixedCase, |
| 168 | + ) |
| 169 | + ).parsed |
0 commit comments