Skip to content

Commit

Permalink
Update the generated library with the 23/08/2023 state
Browse files Browse the repository at this point in the history
  • Loading branch information
suda committed Aug 23, 2023
1 parent 9e7d461 commit 2faf5e5
Show file tree
Hide file tree
Showing 32 changed files with 16,770 additions and 47 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ dmypy.json

/coverage.xml
/.coverage
.DS_Store
15,108 changes: 15,108 additions & 0 deletions fixtures/longship_23-08-23.json

Large diffs are not rendered by default.

201 changes: 201 additions & 0 deletions longship_api_client/api/cdrs/cdr_patch.py
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.
Loading

0 comments on commit 2faf5e5

Please sign in to comment.