move around files

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2021-12-15 01:05:44 -08:00
parent 7ee7964440
commit 3ee3ae9a6c
26 changed files with 45 additions and 47 deletions

95
kittycad/api/meta/ping.py Normal file
View File

@ -0,0 +1,95 @@
from typing import Any, Dict, Optional
import httpx
from ...client import Client
from ...models.message import Message
from ...types import Response
def _get_kwargs(
*,
client: Client,
) -> Dict[str, Any]:
url = "{}/ping".format(client.base_url)
headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
return {
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
}
def _parse_response(*, response: httpx.Response) -> Optional[Message]:
if response.status_code == 200:
response_200 = Message.from_dict(response.json())
return response_200
return None
def _build_response(*, response: httpx.Response) -> Response[Message]:
return Response(
status_code=response.status_code,
content=response.content,
headers=response.headers,
parsed=_parse_response(response=response),
)
def sync_detailed(
*,
client: Client,
) -> Response[Message]:
kwargs = _get_kwargs(
client=client,
)
response = httpx.get(
verify=client.verify_ssl,
**kwargs,
)
return _build_response(response=response)
def sync(
*,
client: Client,
) -> Optional[Message]:
"""Simple ping to the server."""
return sync_detailed(
client=client,
).parsed
async def asyncio_detailed(
*,
client: Client,
) -> Response[Message]:
kwargs = _get_kwargs(
client=client,
)
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
response = await _client.get(**kwargs)
return _build_response(response=response)
async def asyncio(
*,
client: Client,
) -> Optional[Message]:
"""Simple ping to the server."""
return (
await asyncio_detailed(
client=client,
)
).parsed