-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the generated library with the 23/08/2023 state
- Loading branch information
Showing
32 changed files
with
16,770 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ dmypy.json | |
|
||
/coverage.xml | ||
/.coverage | ||
.DS_Store |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
from http import HTTPStatus | ||
from typing import Any, Dict, Optional, Union | ||
|
||
import httpx | ||
|
||
from ... import errors | ||
from ...client import Client | ||
from ...models.cdr_dto import CdrDto | ||
from ...models.cdr_patch_dto import CdrPatchDto | ||
from ...models.longship_error import LongshipError | ||
from ...types import Response | ||
|
||
|
||
def _get_kwargs( | ||
id: str, | ||
*, | ||
client: Client, | ||
json_body: CdrPatchDto, | ||
) -> Dict[str, Any]: | ||
url = "{}/v1/cdrs/{id}".format(client.base_url, id=id) | ||
|
||
headers: Dict[str, str] = client.get_headers() | ||
cookies: Dict[str, Any] = client.get_cookies() | ||
|
||
json_json_body = json_body.to_dict() | ||
|
||
return { | ||
"method": "patch", | ||
"url": url, | ||
"headers": headers, | ||
"cookies": cookies, | ||
"timeout": client.get_timeout(), | ||
"follow_redirects": client.follow_redirects, | ||
"json": json_json_body, | ||
} | ||
|
||
|
||
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[CdrDto, LongshipError]]: | ||
if response.status_code == HTTPStatus.OK: | ||
response_200 = CdrDto.from_dict(response.json()) | ||
|
||
return response_200 | ||
if response.status_code == HTTPStatus.UNAUTHORIZED: | ||
response_401 = LongshipError.from_dict(response.json()) | ||
|
||
return response_401 | ||
if response.status_code == HTTPStatus.INTERNAL_SERVER_ERROR: | ||
response_500 = LongshipError.from_dict(response.json()) | ||
|
||
return response_500 | ||
if response.status_code == HTTPStatus.NOT_FOUND: | ||
response_404 = LongshipError.from_dict(response.json()) | ||
|
||
return response_404 | ||
if response.status_code == HTTPStatus.FORBIDDEN: | ||
response_403 = LongshipError.from_dict(response.json()) | ||
|
||
return response_403 | ||
if client.raise_on_unexpected_status: | ||
raise errors.UnexpectedStatus(response.status_code, response.content) | ||
else: | ||
return None | ||
|
||
|
||
def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[CdrDto, LongshipError]]: | ||
return Response( | ||
status_code=HTTPStatus(response.status_code), | ||
content=response.content, | ||
headers=response.headers, | ||
parsed=_parse_response(client=client, response=response), | ||
) | ||
|
||
|
||
def sync_detailed( | ||
id: str, | ||
*, | ||
client: Client, | ||
json_body: CdrPatchDto, | ||
) -> Response[Union[CdrDto, LongshipError]]: | ||
"""Patches the cdr. | ||
Patches the cdr based on the id. | ||
Args: | ||
id (str): | ||
json_body (CdrPatchDto): | ||
Raises: | ||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. | ||
httpx.TimeoutException: If the request takes longer than Client.timeout. | ||
Returns: | ||
Response[Union[CdrDto, LongshipError]] | ||
""" | ||
|
||
kwargs = _get_kwargs( | ||
id=id, | ||
client=client, | ||
json_body=json_body, | ||
) | ||
|
||
response = httpx.request( | ||
verify=client.verify_ssl, | ||
**kwargs, | ||
) | ||
|
||
return _build_response(client=client, response=response) | ||
|
||
|
||
def sync( | ||
id: str, | ||
*, | ||
client: Client, | ||
json_body: CdrPatchDto, | ||
) -> Optional[Union[CdrDto, LongshipError]]: | ||
"""Patches the cdr. | ||
Patches the cdr based on the id. | ||
Args: | ||
id (str): | ||
json_body (CdrPatchDto): | ||
Raises: | ||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. | ||
httpx.TimeoutException: If the request takes longer than Client.timeout. | ||
Returns: | ||
Union[CdrDto, LongshipError] | ||
""" | ||
|
||
return sync_detailed( | ||
id=id, | ||
client=client, | ||
json_body=json_body, | ||
).parsed | ||
|
||
|
||
async def asyncio_detailed( | ||
id: str, | ||
*, | ||
client: Client, | ||
json_body: CdrPatchDto, | ||
) -> Response[Union[CdrDto, LongshipError]]: | ||
"""Patches the cdr. | ||
Patches the cdr based on the id. | ||
Args: | ||
id (str): | ||
json_body (CdrPatchDto): | ||
Raises: | ||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. | ||
httpx.TimeoutException: If the request takes longer than Client.timeout. | ||
Returns: | ||
Response[Union[CdrDto, LongshipError]] | ||
""" | ||
|
||
kwargs = _get_kwargs( | ||
id=id, | ||
client=client, | ||
json_body=json_body, | ||
) | ||
|
||
async with httpx.AsyncClient(verify=client.verify_ssl) as _client: | ||
response = await _client.request(**kwargs) | ||
|
||
return _build_response(client=client, response=response) | ||
|
||
|
||
async def asyncio( | ||
id: str, | ||
*, | ||
client: Client, | ||
json_body: CdrPatchDto, | ||
) -> Optional[Union[CdrDto, LongshipError]]: | ||
"""Patches the cdr. | ||
Patches the cdr based on the id. | ||
Args: | ||
id (str): | ||
json_body (CdrPatchDto): | ||
Raises: | ||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. | ||
httpx.TimeoutException: If the request takes longer than Client.timeout. | ||
Returns: | ||
Union[CdrDto, LongshipError] | ||
""" | ||
|
||
return ( | ||
await asyncio_detailed( | ||
id=id, | ||
client=client, | ||
json_body=json_body, | ||
) | ||
).parsed |
Empty file.
Oops, something went wrong.