Compare commits
55 Commits
Author | SHA1 | Date | |
---|---|---|---|
3467a5d5dd | |||
a93e30c3e8 | |||
d5dbeadda3 | |||
ed36086040 | |||
9f8069decb | |||
faaeb3a472 | |||
bc3d698539 | |||
d9d73522fd | |||
243ed3222a | |||
098e1fa97d | |||
738659dfbc | |||
5054fd19d3 | |||
058b4dc40a | |||
373b5ef4ae | |||
6b8807feea | |||
b6aa9ab98b | |||
be246702fd | |||
68d7a6d9a3 | |||
6b2fe3decb | |||
4f29f55190 | |||
6ad21a2c87 | |||
036965255a | |||
4120a139cd | |||
12c164620b | |||
31cd9e532d | |||
29b0200c4c | |||
ba3fb82a86 | |||
4c10c47b4a | |||
2e279da9c1 | |||
12e5baef9e | |||
0ef8f505ad | |||
01a73859d4 | |||
f63509a1eb | |||
7cb8d5327f | |||
1f9a787c15 | |||
3e2c9450dc | |||
eb8d1b77bb | |||
d5184bf172 | |||
3cad86c5a3 | |||
63824cd04f | |||
816904419e | |||
e68857f4c9 | |||
db1bd33c79 | |||
dea0d637fe | |||
2e1c75769f | |||
8162fa1964 | |||
d737fb4e8f | |||
686ec0cb36 | |||
f522911d7b | |||
1e693890ef | |||
755a4fd789 | |||
581c06a943 | |||
3ce38b0b26 | |||
d8a3120db3 | |||
968e8bbefd |
2
.github/workflows/black.yml
vendored
2
.github/workflows/black.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
||||
black:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
|
||||
|
2
.github/workflows/build-test.yml
vendored
2
.github/workflows/build-test.yml
vendored
@ -22,7 +22,7 @@ jobs:
|
||||
python-version: [3.8, 3.9]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
|
2
.github/workflows/generate-docs.yml
vendored
2
.github/workflows/generate-docs.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
|
2
.github/workflows/generate.yml
vendored
2
.github/workflows/generate.yml
vendored
@ -16,7 +16,7 @@ jobs:
|
||||
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
- name: Run generate
|
||||
|
2
.github/workflows/make-release.yml
vendored
2
.github/workflows/make-release.yml
vendored
@ -8,7 +8,7 @@ jobs:
|
||||
name: make-release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
2
.github/workflows/mypy.yml
vendored
2
.github/workflows/mypy.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
||||
mypy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
|
||||
|
2
.github/workflows/ruff.yml
vendored
2
.github/workflows/ruff.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
||||
ruff:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
|
||||
|
4
.github/workflows/update-spec-for-docs.yml
vendored
4
.github/workflows/update-spec-for-docs.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
||||
name: update-spec
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: make generate
|
||||
shell: bash
|
||||
run: |
|
||||
@ -34,7 +34,7 @@ jobs:
|
||||
echo "No files changed, proceeding";
|
||||
fi
|
||||
# Checkout the docs repo since we will want to update the files there.
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: 'kittycad/website'
|
||||
path: 'docs'
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -22,10 +22,11 @@ dmypy.json
|
||||
/coverage.xml
|
||||
/.coverage
|
||||
|
||||
poetry.lock
|
||||
testing
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
docs/_autosummary/
|
||||
docs/html/_sources/
|
||||
|
||||
snapshot.png
|
||||
|
1939
assets/ORIGINALVOXEL-3.obj
Normal file
1939
assets/ORIGINALVOXEL-3.obj
Normal file
File diff suppressed because it is too large
Load Diff
BIN
docs/.DS_Store
vendored
BIN
docs/.DS_Store
vendored
Binary file not shown.
16
generate/float.py.jinja2
Normal file
16
generate/float.py.jinja2
Normal file
@ -0,0 +1,16 @@
|
||||
from typing import Any
|
||||
|
||||
from pydantic import GetCoreSchemaHandler
|
||||
from pydantic_core import CoreSchema, core_schema
|
||||
|
||||
|
||||
class {{name}}(float):
|
||||
"""{{description}}"""
|
||||
def __float__(self) -> float:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def __get_pydantic_core_schema__(
|
||||
cls, source_type: Any, handler: GetCoreSchemaHandler
|
||||
) -> CoreSchema:
|
||||
return core_schema.no_info_after_validator_function(cls, handler(float))
|
@ -1,4 +1,6 @@
|
||||
from typing import Any, Dict, Optional, Union, List
|
||||
from typing import Iterator, Any, Dict, Optional, Union, List
|
||||
import json
|
||||
import bson
|
||||
|
||||
from websockets.sync.client import connect as ws_connect
|
||||
from websockets.client import connect as ws_connect_async
|
||||
@ -16,26 +18,37 @@ from ...types import Response
|
||||
|
||||
def _get_kwargs(
|
||||
{% for arg in args %}
|
||||
{% if arg.in_query %}
|
||||
{% if arg.is_optional == False %}
|
||||
{{arg.name}}: {{arg.type}},
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
*,
|
||||
client: Client,
|
||||
{% for arg in args %}
|
||||
{% if arg.in_query %}
|
||||
{% if arg.is_optional %}
|
||||
{{arg.name}}: {{arg.type}},
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
) -> Dict[str, Any]:
|
||||
url = "{{url_template}}".format(client.base_url{% for arg in args %}{% if arg.in_url %}, {{arg.name}}={{arg.name}}{% endif %}{% endfor %}) # noqa: E501
|
||||
{% for arg in args %}
|
||||
{% if arg.in_query %}
|
||||
if {{arg.name}} is not None:
|
||||
{% if arg.type == "bool" %}
|
||||
if "?" in url:
|
||||
url = url + "&{{arg.name}}=" + str({{arg.name}}).lower()
|
||||
else:
|
||||
url = url + "?{{arg.name}}=" + str({{arg.name}}).lower()
|
||||
{% else %}
|
||||
if "?" in url:
|
||||
url = url + "&{{arg.name}}=" + str({{arg.name}})
|
||||
else:
|
||||
url = url + "?{{arg.name}}=" + str({{arg.name}})
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
@ -48,66 +61,140 @@ def _get_kwargs(
|
||||
"headers": headers,
|
||||
"cookies": cookies,
|
||||
"timeout": client.get_timeout(),
|
||||
{% if has_request_body %}"content": body,{% endif %}
|
||||
}
|
||||
|
||||
|
||||
def sync(
|
||||
{% for arg in args %}
|
||||
{% if arg.in_query %}
|
||||
{% if arg.is_optional == False %}
|
||||
{{arg.name}}: {{arg.type}},
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
*,
|
||||
client: Client,
|
||||
{% for arg in args %}
|
||||
{% if arg.in_query %}
|
||||
{% if arg.is_optional %}
|
||||
{{arg.name}}: {{arg.type}},
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
) -> ClientConnection:
|
||||
{%if docs%}"""{{docs}}""" # noqa: E501{% endif %}
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
{% for arg in args %}
|
||||
{% if arg.in_query %}
|
||||
{{arg.name}}={{arg.name}},
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
client=client,
|
||||
)
|
||||
|
||||
with ws_connect(kwargs["url"].replace("https://", "wss://"), additional_headers=kwargs["headers"]) as websocket:
|
||||
return websocket # type: ignore
|
||||
|
||||
# Return an error if we got here.
|
||||
return Error(message="An error occurred while connecting to the websocket.")
|
||||
return ws_connect(kwargs["url"].replace("http", "ws"), additional_headers=kwargs["headers"], close_timeout=120, max_size=None) # type: ignore
|
||||
|
||||
|
||||
|
||||
async def asyncio(
|
||||
{% for arg in args %}
|
||||
{% if arg.in_query %}
|
||||
{% if arg.is_optional == False %}
|
||||
{{arg.name}}: {{arg.type}},
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
*,
|
||||
client: Client,
|
||||
{% for arg in args %}
|
||||
{% if arg.in_query %}
|
||||
{% if arg.is_optional %}
|
||||
{{arg.name}}: {{arg.type}},
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
) -> WebSocketClientProtocol:
|
||||
{%if docs%}"""{{docs}}""" # noqa: E501{% endif %}
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
{% for arg in args %}
|
||||
{% if arg.in_query %}
|
||||
{{arg.name}}={{arg.name}},
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
client=client,
|
||||
)
|
||||
|
||||
async with ws_connect_async(kwargs["url"].replace("https://", "wss://"), extra_headers=kwargs["headers"]) as websocket:
|
||||
return websocket
|
||||
return await ws_connect_async(kwargs["url"].replace("http", "ws"), extra_headers=kwargs["headers"], close_timeout=120, max_size=None)
|
||||
|
||||
# Return an error if we got here.
|
||||
return Error(message="An error occurred while connecting to the websocket.")
|
||||
|
||||
{% if has_request_body %}
|
||||
class WebSocket:
|
||||
"""A websocket connection to the API endpoint."""
|
||||
ws: ClientConnection
|
||||
|
||||
def __init__(self,
|
||||
{% for arg in args %}
|
||||
{% if arg.in_query %}
|
||||
{% if arg.is_optional == False %}
|
||||
{{arg.name}}: {{arg.type}},
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
client: Client,
|
||||
{% for arg in args %}
|
||||
{% if arg.in_query %}
|
||||
{% if arg.is_optional %}
|
||||
{{arg.name}}: {{arg.type}},
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
):
|
||||
self.ws = sync(
|
||||
{% for arg in args %}
|
||||
{% if arg.in_query %}
|
||||
{{arg.name}},
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
client=client,
|
||||
)
|
||||
|
||||
def __enter__(self,
|
||||
):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self.close()
|
||||
|
||||
def __iter__(self) -> Iterator[{{response_type}}]:
|
||||
"""
|
||||
Iterate on incoming messages.
|
||||
|
||||
The iterator calls :meth:`recv` and yields messages in an infinite loop.
|
||||
|
||||
It exits when the connection is closed normally. It raises a
|
||||
:exc:`~websockets.exceptions.ConnectionClosedError` exception after a
|
||||
protocol error or a network failure.
|
||||
|
||||
"""
|
||||
for message in self.ws:
|
||||
yield {{response_type}}(**json.loads(message))
|
||||
|
||||
def send(self, data:{% for arg in args %}{%if arg.name == "body" %}{{arg.type}}{% endif %}{% endfor %}):
|
||||
"""Send data to the websocket."""
|
||||
self.ws.send(json.dumps(data.model_dump()))
|
||||
|
||||
def send_binary(self, data:{% for arg in args %}{%if arg.name == "body" %}{{arg.type}}{% endif %}{% endfor %}):
|
||||
"""Send data as bson to the websocket."""
|
||||
self.ws.send(bson.encode(data.model_dump())) # type: ignore
|
||||
|
||||
def recv(self) -> {{response_type}}:
|
||||
"""Receive data from the websocket."""
|
||||
message = self.ws.recv(timeout=60)
|
||||
return {{response_type}}(**json.loads(message))
|
||||
|
||||
def close(self):
|
||||
"""Close the websocket."""
|
||||
self.ws.close()
|
||||
{%endif%}
|
||||
|
@ -28,10 +28,17 @@ def _get_kwargs(
|
||||
{% for arg in args %}
|
||||
{% if arg.in_query %}
|
||||
if {{arg.name}} is not None:
|
||||
{% if arg.type == "bool" %}
|
||||
if "?" in url:
|
||||
url = url + "&{{arg.name}}=" + str({{arg.name}}).lower()
|
||||
else:
|
||||
url = url + "?{{arg.name}}=" + str({{arg.name}}).lower()
|
||||
{% else %}
|
||||
if "?" in url:
|
||||
url = url + "&{{arg.name}}=" + str({{arg.name}})
|
||||
else:
|
||||
url = url + "?{{arg.name}}=" + str({{arg.name}})
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
|
1280
generate/generate.py
1280
generate/generate.py
File diff suppressed because it is too large
Load Diff
16
generate/int.py.jinja2
Normal file
16
generate/int.py.jinja2
Normal file
@ -0,0 +1,16 @@
|
||||
from typing import Any
|
||||
|
||||
from pydantic import GetCoreSchemaHandler
|
||||
from pydantic_core import CoreSchema, core_schema
|
||||
|
||||
|
||||
class {{name}}(int):
|
||||
"""{{description}}"""
|
||||
def __int__(self) -> int:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def __get_pydantic_core_schema__(
|
||||
cls, source_type: Any, handler: GetCoreSchemaHandler
|
||||
) -> CoreSchema:
|
||||
return core_schema.no_info_after_validator_function(cls, handler(int))
|
21
generate/object.py.jinja2
Normal file
21
generate/object.py.jinja2
Normal file
@ -0,0 +1,21 @@
|
||||
import datetime
|
||||
from typing import List, Optional, Dict, Union, Any, Literal
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel, Base64Bytes, AnyUrl
|
||||
from pydantic_extra_types.phone_numbers import PhoneNumber
|
||||
from .base64data import Base64Data
|
||||
|
||||
{% for import in imports %}
|
||||
{{ import }}
|
||||
{% endfor %}
|
||||
|
||||
class {{ name }}(BaseModel):
|
||||
"""{{ description }}"""
|
||||
{% for field in fields %}
|
||||
{% if field.value %}
|
||||
{{ field.name }}: Literal[{{ field.value }}] = {{ field.value }}
|
||||
{% else %}
|
||||
{{ field.name }}: {{ field.type }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
@ -5,10 +5,15 @@ set -o pipefail
|
||||
# Fix for ci.
|
||||
git config --global --add safe.directory /home/user/src
|
||||
|
||||
git add kittycad/models/base64data.py
|
||||
git add kittycad/models/empty.py
|
||||
|
||||
|
||||
# Cleanup old stuff.
|
||||
rm -rf kittycad/models
|
||||
rm -rf kittycad/api
|
||||
git checkout kittycad/api/file/*_with_base64_helper.py &>/dev/null
|
||||
git checkout kittycad/models/base64data.py
|
||||
git checkout kittycad/models/empty.py
|
||||
|
||||
# Generate new.
|
||||
poetry run python generate/generate.py
|
||||
|
16
generate/str.py.jinja2
Normal file
16
generate/str.py.jinja2
Normal file
@ -0,0 +1,16 @@
|
||||
from typing import Any
|
||||
|
||||
from pydantic import GetCoreSchemaHandler
|
||||
from pydantic_core import CoreSchema, core_schema
|
||||
|
||||
|
||||
class {{name}}(str):
|
||||
"""{{description}}"""
|
||||
def __str__(self) -> str:
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def __get_pydantic_core_schema__(
|
||||
cls, source_type: Any, handler: GetCoreSchemaHandler
|
||||
) -> CoreSchema:
|
||||
return core_schema.no_info_after_validator_function(cls, handler(str))
|
21
generate/union-type.py.jinja2
Normal file
21
generate/union-type.py.jinja2
Normal file
@ -0,0 +1,21 @@
|
||||
from typing import Dict, Any, Union, Type, TypeVar
|
||||
from pydantic import RootModel, Field
|
||||
|
||||
from typing_extensions import Annotated
|
||||
|
||||
|
||||
|
||||
{% if tag %}
|
||||
{{name}} = RootModel[Annotated[Union[
|
||||
{% for type in types %}
|
||||
{{type.name}},
|
||||
{% endfor %}
|
||||
], Field(discriminator='{{tag}}')]]
|
||||
{% else %}
|
||||
{{name}} = RootModel[Union[
|
||||
{% for type in types %}
|
||||
{{type.name}},
|
||||
{% endfor %}
|
||||
]]
|
||||
{% endif %}
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,137 +0,0 @@
|
||||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ...client import Client
|
||||
from ...models.error import Error
|
||||
from ...models.file_export_format import FileExportFormat
|
||||
from ...models.image_type import ImageType
|
||||
from ...models.mesh import Mesh
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
input_format: ImageType,
|
||||
output_format: FileExportFormat,
|
||||
body: bytes,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Dict[str, Any]:
|
||||
url = "{}/ai/image-to-3d/{input_format}/{output_format}".format(
|
||||
client.base_url,
|
||||
input_format=input_format,
|
||||
output_format=output_format,
|
||||
) # noqa: E501
|
||||
|
||||
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(),
|
||||
"content": body,
|
||||
}
|
||||
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[Mesh, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = Mesh.from_dict(response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, response: httpx.Response
|
||||
) -> Response[Optional[Union[Mesh, Error]]]:
|
||||
return Response(
|
||||
status_code=response.status_code,
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
input_format: ImageType,
|
||||
output_format: FileExportFormat,
|
||||
body: bytes,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Optional[Union[Mesh, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
input_format=input_format,
|
||||
output_format=output_format,
|
||||
body=body,
|
||||
client=client,
|
||||
)
|
||||
|
||||
response = httpx.post(
|
||||
verify=client.verify_ssl,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
input_format: ImageType,
|
||||
output_format: FileExportFormat,
|
||||
body: bytes,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[Mesh, Error]]:
|
||||
"""This is an alpha endpoint. It will change in the future. The current output is honestly pretty bad. So if you find this endpoint, you get what you pay for, which currently is nothing. But in the future will be made a lot better.""" # noqa: E501
|
||||
|
||||
return sync_detailed(
|
||||
input_format=input_format,
|
||||
output_format=output_format,
|
||||
body=body,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
input_format: ImageType,
|
||||
output_format: FileExportFormat,
|
||||
body: bytes,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Optional[Union[Mesh, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
input_format=input_format,
|
||||
output_format=output_format,
|
||||
body=body,
|
||||
client=client,
|
||||
)
|
||||
|
||||
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
|
||||
response = await _client.post(**kwargs)
|
||||
|
||||
return _build_response(response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
input_format: ImageType,
|
||||
output_format: FileExportFormat,
|
||||
body: bytes,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[Mesh, Error]]:
|
||||
"""This is an alpha endpoint. It will change in the future. The current output is honestly pretty bad. So if you find this endpoint, you get what you pay for, which currently is nothing. But in the future will be made a lot better.""" # noqa: E501
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
input_format=input_format,
|
||||
output_format=output_format,
|
||||
body=body,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
@ -1,131 +0,0 @@
|
||||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ...client import Client
|
||||
from ...models.error import Error
|
||||
from ...models.file_export_format import FileExportFormat
|
||||
from ...models.mesh import Mesh
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
output_format: FileExportFormat,
|
||||
prompt: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Dict[str, Any]:
|
||||
url = "{}/ai/text-to-3d/{output_format}".format(
|
||||
client.base_url,
|
||||
output_format=output_format,
|
||||
) # noqa: E501
|
||||
|
||||
if prompt is not None:
|
||||
if "?" in url:
|
||||
url = url + "&prompt=" + str(prompt)
|
||||
else:
|
||||
url = url + "?prompt=" + str(prompt)
|
||||
|
||||
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[Union[Mesh, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = Mesh.from_dict(response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, response: httpx.Response
|
||||
) -> Response[Optional[Union[Mesh, Error]]]:
|
||||
return Response(
|
||||
status_code=response.status_code,
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
output_format: FileExportFormat,
|
||||
prompt: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Optional[Union[Mesh, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
output_format=output_format,
|
||||
prompt=prompt,
|
||||
client=client,
|
||||
)
|
||||
|
||||
response = httpx.post(
|
||||
verify=client.verify_ssl,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
output_format: FileExportFormat,
|
||||
prompt: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[Mesh, Error]]:
|
||||
"""This is an alpha endpoint. It will change in the future. The current output is honestly pretty bad. So if you find this endpoint, you get what you pay for, which currently is nothing. But in the future will be made a lot better.""" # noqa: E501
|
||||
|
||||
return sync_detailed(
|
||||
output_format=output_format,
|
||||
prompt=prompt,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
output_format: FileExportFormat,
|
||||
prompt: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Optional[Union[Mesh, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
output_format=output_format,
|
||||
prompt=prompt,
|
||||
client=client,
|
||||
)
|
||||
|
||||
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
|
||||
response = await _client.post(**kwargs)
|
||||
|
||||
return _build_response(response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
output_format: FileExportFormat,
|
||||
prompt: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[Mesh, Error]]:
|
||||
"""This is an alpha endpoint. It will change in the future. The current output is honestly pretty bad. So if you find this endpoint, you get what you pay for, which currently is nothing. But in the future will be made a lot better.""" # noqa: E501
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
output_format=output_format,
|
||||
prompt=prompt,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
135
kittycad/api/ai/create_text_to_cad.py
Normal file
135
kittycad/api/ai/create_text_to_cad.py
Normal file
@ -0,0 +1,135 @@
|
||||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ...client import Client
|
||||
from ...models.error import Error
|
||||
from ...models.file_export_format import FileExportFormat
|
||||
from ...models.text_to_cad import TextToCad
|
||||
from ...models.text_to_cad_create_body import TextToCadCreateBody
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
output_format: FileExportFormat,
|
||||
body: TextToCadCreateBody,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Dict[str, Any]:
|
||||
url = "{}/ai/text-to-cad/{output_format}".format(
|
||||
client.base_url,
|
||||
output_format=output_format,
|
||||
) # noqa: E501
|
||||
|
||||
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(),
|
||||
"content": body,
|
||||
}
|
||||
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[TextToCad, Error]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = TextToCad(**response.json())
|
||||
return response_201
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, response: httpx.Response
|
||||
) -> Response[Optional[Union[TextToCad, Error]]]:
|
||||
return Response(
|
||||
status_code=response.status_code,
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
output_format: FileExportFormat,
|
||||
body: TextToCadCreateBody,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Optional[Union[TextToCad, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
output_format=output_format,
|
||||
body=body,
|
||||
client=client,
|
||||
)
|
||||
|
||||
response = httpx.post(
|
||||
verify=client.verify_ssl,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
output_format: FileExportFormat,
|
||||
body: TextToCadCreateBody,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[TextToCad, Error]]:
|
||||
"""Because our source of truth for the resulting model is a STEP file, you will always have STEP file contents when you list your generated models. Any other formats you request here will also be returned when you list your generated models.
|
||||
This operation is performed asynchronously, the `id` of the operation will be returned. You can use the `id` returned from the request to get status information about the async operation from the `/async/operations/{id}` endpoint.
|
||||
One thing to note, if you hit the cache, this endpoint will return right away. So you only have to wait if the status is not `Completed` or `Failed`.
|
||||
This is an alpha endpoint. It will change in the future. The current output is honestly pretty bad. So if you find this endpoint, you get what you pay for, which currently is nothing. But in the future will be made a lot better.
|
||||
""" # noqa: E501
|
||||
|
||||
return sync_detailed(
|
||||
output_format=output_format,
|
||||
body=body,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
output_format: FileExportFormat,
|
||||
body: TextToCadCreateBody,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Optional[Union[TextToCad, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
output_format=output_format,
|
||||
body=body,
|
||||
client=client,
|
||||
)
|
||||
|
||||
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
|
||||
response = await _client.post(**kwargs)
|
||||
|
||||
return _build_response(response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
output_format: FileExportFormat,
|
||||
body: TextToCadCreateBody,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[TextToCad, Error]]:
|
||||
"""Because our source of truth for the resulting model is a STEP file, you will always have STEP file contents when you list your generated models. Any other formats you request here will also be returned when you list your generated models.
|
||||
This operation is performed asynchronously, the `id` of the operation will be returned. You can use the `id` returned from the request to get status information about the async operation from the `/async/operations/{id}` endpoint.
|
||||
One thing to note, if you hit the cache, this endpoint will return right away. So you only have to wait if the status is not `Completed` or `Failed`.
|
||||
This is an alpha endpoint. It will change in the future. The current output is honestly pretty bad. So if you find this endpoint, you get what you pay for, which currently is nothing. But in the future will be made a lot better.
|
||||
""" # noqa: E501
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
output_format=output_format,
|
||||
body=body,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
126
kittycad/api/ai/create_text_to_cad_model_feedback.py
Normal file
126
kittycad/api/ai/create_text_to_cad_model_feedback.py
Normal file
@ -0,0 +1,126 @@
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
import httpx
|
||||
|
||||
from ...client import Client
|
||||
from ...models.ai_feedback import AiFeedback
|
||||
from ...models.error import Error
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
id: str,
|
||||
feedback: AiFeedback,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Dict[str, Any]:
|
||||
url = "{}/user/text-to-cad/{id}".format(
|
||||
client.base_url,
|
||||
id=id,
|
||||
) # noqa: E501
|
||||
|
||||
if feedback is not None:
|
||||
if "?" in url:
|
||||
url = url + "&feedback=" + str(feedback)
|
||||
else:
|
||||
url = url + "?feedback=" + str(feedback)
|
||||
|
||||
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[Error]:
|
||||
return None
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(*, response: httpx.Response) -> Response[Optional[Error]]:
|
||||
return Response(
|
||||
status_code=response.status_code,
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
id: str,
|
||||
feedback: AiFeedback,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Optional[Error]]:
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
feedback=feedback,
|
||||
client=client,
|
||||
)
|
||||
|
||||
response = httpx.post(
|
||||
verify=client.verify_ssl,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
id: str,
|
||||
feedback: AiFeedback,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Error]:
|
||||
"""This endpoint requires authentication by any KittyCAD user. The user must be the owner of the text-to-CAD model, in order to give feedback.""" # noqa: E501
|
||||
|
||||
return sync_detailed(
|
||||
id=id,
|
||||
feedback=feedback,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
id: str,
|
||||
feedback: AiFeedback,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Optional[Error]]:
|
||||
kwargs = _get_kwargs(
|
||||
id=id,
|
||||
feedback=feedback,
|
||||
client=client,
|
||||
)
|
||||
|
||||
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
|
||||
response = await _client.post(**kwargs)
|
||||
|
||||
return _build_response(response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: str,
|
||||
feedback: AiFeedback,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Error]:
|
||||
"""This endpoint requires authentication by any KittyCAD user. The user must be the owner of the text-to-CAD model, in order to give feedback.""" # noqa: E501
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
id=id,
|
||||
feedback=feedback,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
@ -3,18 +3,19 @@ from typing import Any, Dict, Optional, Union
|
||||
import httpx
|
||||
|
||||
from ...client import Client
|
||||
from ...models.ai_prompt import AiPrompt
|
||||
from ...models.error import Error
|
||||
from ...models.modeling_cmd_req import ModelingCmdReq
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
body: ModelingCmdReq,
|
||||
id: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Dict[str, Any]:
|
||||
url = "{}/modeling/cmd".format(
|
||||
url = "{}/ai-prompts/{id}".format(
|
||||
client.base_url,
|
||||
id=id,
|
||||
) # noqa: E501
|
||||
|
||||
headers: Dict[str, Any] = client.get_headers()
|
||||
@ -25,26 +26,25 @@ def _get_kwargs(
|
||||
"headers": headers,
|
||||
"cookies": cookies,
|
||||
"timeout": client.get_timeout(),
|
||||
"content": body,
|
||||
}
|
||||
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[dict, Error]]:
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[AiPrompt, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = response.json()
|
||||
response_200 = AiPrompt(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, response: httpx.Response
|
||||
) -> Response[Optional[Union[dict, Error]]]:
|
||||
) -> Response[Optional[Union[AiPrompt, Error]]]:
|
||||
return Response(
|
||||
status_code=response.status_code,
|
||||
content=response.content,
|
||||
@ -54,16 +54,16 @@ def _build_response(
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
body: ModelingCmdReq,
|
||||
id: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Optional[Union[dict, Error]]]:
|
||||
) -> Response[Optional[Union[AiPrompt, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
|
||||
response = httpx.post(
|
||||
response = httpx.get(
|
||||
verify=client.verify_ssl,
|
||||
**kwargs,
|
||||
)
|
||||
@ -72,44 +72,44 @@ def sync_detailed(
|
||||
|
||||
|
||||
def sync(
|
||||
body: ModelingCmdReq,
|
||||
id: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[dict, Error]]:
|
||||
"""Response depends on which command was submitted, so unfortunately the OpenAPI schema can't generate the right response type.""" # noqa: E501
|
||||
) -> Optional[Union[AiPrompt, Error]]:
|
||||
"""This endpoint requires authentication by a KittyCAD employee.""" # noqa: E501
|
||||
|
||||
return sync_detailed(
|
||||
body=body,
|
||||
id=id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
body: ModelingCmdReq,
|
||||
id: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Optional[Union[dict, Error]]]:
|
||||
) -> Response[Optional[Union[AiPrompt, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
|
||||
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
|
||||
response = await _client.post(**kwargs)
|
||||
response = await _client.get(**kwargs)
|
||||
|
||||
return _build_response(response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
body: ModelingCmdReq,
|
||||
id: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[dict, Error]]:
|
||||
"""Response depends on which command was submitted, so unfortunately the OpenAPI schema can't generate the right response type.""" # noqa: E501
|
||||
) -> Optional[Union[AiPrompt, Error]]:
|
||||
"""This endpoint requires authentication by a KittyCAD employee.""" # noqa: E501
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
body=body,
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
@ -4,18 +4,18 @@ import httpx
|
||||
|
||||
from ...client import Client
|
||||
from ...models.error import Error
|
||||
from ...models.modeling_cmd_req_batch import ModelingCmdReqBatch
|
||||
from ...models.modeling_outcomes import ModelingOutcomes
|
||||
from ...models.text_to_cad import TextToCad
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
body: ModelingCmdReqBatch,
|
||||
id: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Dict[str, Any]:
|
||||
url = "{}/modeling/cmd-batch".format(
|
||||
url = "{}/user/text-to-cad/{id}".format(
|
||||
client.base_url,
|
||||
id=id,
|
||||
) # noqa: E501
|
||||
|
||||
headers: Dict[str, Any] = client.get_headers()
|
||||
@ -26,28 +26,25 @@ def _get_kwargs(
|
||||
"headers": headers,
|
||||
"cookies": cookies,
|
||||
"timeout": client.get_timeout(),
|
||||
"content": body,
|
||||
}
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[ModelingOutcomes, Error]]:
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[TextToCad, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = ModelingOutcomes.from_dict(response.json())
|
||||
response_200 = TextToCad(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, response: httpx.Response
|
||||
) -> Response[Optional[Union[ModelingOutcomes, Error]]]:
|
||||
) -> Response[Optional[Union[TextToCad, Error]]]:
|
||||
return Response(
|
||||
status_code=response.status_code,
|
||||
content=response.content,
|
||||
@ -57,16 +54,16 @@ def _build_response(
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
body: ModelingCmdReqBatch,
|
||||
id: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Optional[Union[ModelingOutcomes, Error]]]:
|
||||
) -> Response[Optional[Union[TextToCad, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
|
||||
response = httpx.post(
|
||||
response = httpx.get(
|
||||
verify=client.verify_ssl,
|
||||
**kwargs,
|
||||
)
|
||||
@ -75,40 +72,44 @@ def sync_detailed(
|
||||
|
||||
|
||||
def sync(
|
||||
body: ModelingCmdReqBatch,
|
||||
id: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[ModelingOutcomes, Error]]:
|
||||
) -> Optional[Union[TextToCad, Error]]:
|
||||
"""This endpoint requires authentication by any KittyCAD user. The user must be the owner of the text-to-CAD model.""" # noqa: E501
|
||||
|
||||
return sync_detailed(
|
||||
body=body,
|
||||
id=id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
body: ModelingCmdReqBatch,
|
||||
id: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Optional[Union[ModelingOutcomes, Error]]]:
|
||||
) -> Response[Optional[Union[TextToCad, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
|
||||
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
|
||||
response = await _client.post(**kwargs)
|
||||
response = await _client.get(**kwargs)
|
||||
|
||||
return _build_response(response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
body: ModelingCmdReqBatch,
|
||||
id: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[ModelingOutcomes, Error]]:
|
||||
) -> Optional[Union[TextToCad, Error]]:
|
||||
"""This endpoint requires authentication by any KittyCAD user. The user must be the owner of the text-to-CAD model.""" # noqa: E501
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
body=body,
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
159
kittycad/api/ai/list_ai_prompts.py
Normal file
159
kittycad/api/ai/list_ai_prompts.py
Normal file
@ -0,0 +1,159 @@
|
||||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ...client import Client
|
||||
from ...models.ai_prompt_results_page import AiPromptResultsPage
|
||||
from ...models.created_at_sort_mode import CreatedAtSortMode
|
||||
from ...models.error import Error
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
sort_by: CreatedAtSortMode,
|
||||
*,
|
||||
client: Client,
|
||||
limit: Optional[int] = None,
|
||||
page_token: Optional[str] = None,
|
||||
) -> Dict[str, Any]:
|
||||
url = "{}/ai-prompts".format(
|
||||
client.base_url,
|
||||
) # noqa: E501
|
||||
|
||||
if limit is not None:
|
||||
if "?" in url:
|
||||
url = url + "&limit=" + str(limit)
|
||||
else:
|
||||
url = url + "?limit=" + str(limit)
|
||||
|
||||
if page_token is not None:
|
||||
if "?" in url:
|
||||
url = url + "&page_token=" + str(page_token)
|
||||
else:
|
||||
url = url + "?page_token=" + str(page_token)
|
||||
|
||||
if sort_by is not None:
|
||||
if "?" in url:
|
||||
url = url + "&sort_by=" + str(sort_by)
|
||||
else:
|
||||
url = url + "?sort_by=" + str(sort_by)
|
||||
|
||||
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[Union[AiPromptResultsPage, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = AiPromptResultsPage(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, response: httpx.Response
|
||||
) -> Response[Optional[Union[AiPromptResultsPage, Error]]]:
|
||||
return Response(
|
||||
status_code=response.status_code,
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
sort_by: CreatedAtSortMode,
|
||||
*,
|
||||
client: Client,
|
||||
limit: Optional[int] = None,
|
||||
page_token: Optional[str] = None,
|
||||
) -> Response[Optional[Union[AiPromptResultsPage, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
limit=limit,
|
||||
page_token=page_token,
|
||||
sort_by=sort_by,
|
||||
client=client,
|
||||
)
|
||||
|
||||
response = httpx.get(
|
||||
verify=client.verify_ssl,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
sort_by: CreatedAtSortMode,
|
||||
*,
|
||||
client: Client,
|
||||
limit: Optional[int] = None,
|
||||
page_token: Optional[str] = None,
|
||||
) -> Optional[Union[AiPromptResultsPage, Error]]:
|
||||
"""For text-to-cad prompts, this will always return the STEP file contents as well as the format the user originally requested.
|
||||
This endpoint requires authentication by a KittyCAD employee.
|
||||
The AI prompts are returned in order of creation, with the most recently created AI prompts first.
|
||||
""" # noqa: E501
|
||||
|
||||
return sync_detailed(
|
||||
limit=limit,
|
||||
page_token=page_token,
|
||||
sort_by=sort_by,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
sort_by: CreatedAtSortMode,
|
||||
*,
|
||||
client: Client,
|
||||
limit: Optional[int] = None,
|
||||
page_token: Optional[str] = None,
|
||||
) -> Response[Optional[Union[AiPromptResultsPage, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
limit=limit,
|
||||
page_token=page_token,
|
||||
sort_by=sort_by,
|
||||
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(
|
||||
sort_by: CreatedAtSortMode,
|
||||
*,
|
||||
client: Client,
|
||||
limit: Optional[int] = None,
|
||||
page_token: Optional[str] = None,
|
||||
) -> Optional[Union[AiPromptResultsPage, Error]]:
|
||||
"""For text-to-cad prompts, this will always return the STEP file contents as well as the format the user originally requested.
|
||||
This endpoint requires authentication by a KittyCAD employee.
|
||||
The AI prompts are returned in order of creation, with the most recently created AI prompts first.
|
||||
""" # noqa: E501
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
limit=limit,
|
||||
page_token=page_token,
|
||||
sort_by=sort_by,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
159
kittycad/api/ai/list_text_to_cad_models_for_user.py
Normal file
159
kittycad/api/ai/list_text_to_cad_models_for_user.py
Normal file
@ -0,0 +1,159 @@
|
||||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ...client import Client
|
||||
from ...models.created_at_sort_mode import CreatedAtSortMode
|
||||
from ...models.error import Error
|
||||
from ...models.text_to_cad_results_page import TextToCadResultsPage
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
sort_by: CreatedAtSortMode,
|
||||
*,
|
||||
client: Client,
|
||||
limit: Optional[int] = None,
|
||||
page_token: Optional[str] = None,
|
||||
) -> Dict[str, Any]:
|
||||
url = "{}/user/text-to-cad".format(
|
||||
client.base_url,
|
||||
) # noqa: E501
|
||||
|
||||
if limit is not None:
|
||||
if "?" in url:
|
||||
url = url + "&limit=" + str(limit)
|
||||
else:
|
||||
url = url + "?limit=" + str(limit)
|
||||
|
||||
if page_token is not None:
|
||||
if "?" in url:
|
||||
url = url + "&page_token=" + str(page_token)
|
||||
else:
|
||||
url = url + "?page_token=" + str(page_token)
|
||||
|
||||
if sort_by is not None:
|
||||
if "?" in url:
|
||||
url = url + "&sort_by=" + str(sort_by)
|
||||
else:
|
||||
url = url + "?sort_by=" + str(sort_by)
|
||||
|
||||
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[Union[TextToCadResultsPage, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = TextToCadResultsPage(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, response: httpx.Response
|
||||
) -> Response[Optional[Union[TextToCadResultsPage, Error]]]:
|
||||
return Response(
|
||||
status_code=response.status_code,
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
sort_by: CreatedAtSortMode,
|
||||
*,
|
||||
client: Client,
|
||||
limit: Optional[int] = None,
|
||||
page_token: Optional[str] = None,
|
||||
) -> Response[Optional[Union[TextToCadResultsPage, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
limit=limit,
|
||||
page_token=page_token,
|
||||
sort_by=sort_by,
|
||||
client=client,
|
||||
)
|
||||
|
||||
response = httpx.get(
|
||||
verify=client.verify_ssl,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
sort_by: CreatedAtSortMode,
|
||||
*,
|
||||
client: Client,
|
||||
limit: Optional[int] = None,
|
||||
page_token: Optional[str] = None,
|
||||
) -> Optional[Union[TextToCadResultsPage, Error]]:
|
||||
"""This will always return the STEP file contents as well as the format the user originally requested.
|
||||
This endpoint requires authentication by any KittyCAD user. It returns the text-to-CAD models for the authenticated user.
|
||||
The text-to-CAD models are returned in order of creation, with the most recently created text-to-CAD models first.
|
||||
""" # noqa: E501
|
||||
|
||||
return sync_detailed(
|
||||
limit=limit,
|
||||
page_token=page_token,
|
||||
sort_by=sort_by,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
sort_by: CreatedAtSortMode,
|
||||
*,
|
||||
client: Client,
|
||||
limit: Optional[int] = None,
|
||||
page_token: Optional[str] = None,
|
||||
) -> Response[Optional[Union[TextToCadResultsPage, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
limit=limit,
|
||||
page_token=page_token,
|
||||
sort_by=sort_by,
|
||||
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(
|
||||
sort_by: CreatedAtSortMode,
|
||||
*,
|
||||
client: Client,
|
||||
limit: Optional[int] = None,
|
||||
page_token: Optional[str] = None,
|
||||
) -> Optional[Union[TextToCadResultsPage, Error]]:
|
||||
"""This will always return the STEP file contents as well as the format the user originally requested.
|
||||
This endpoint requires authentication by any KittyCAD user. It returns the text-to-CAD models for the authenticated user.
|
||||
The text-to-CAD models are returned in order of creation, with the most recently created text-to-CAD models first.
|
||||
""" # noqa: E501
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
limit=limit,
|
||||
page_token=page_token,
|
||||
sort_by=sort_by,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
@ -33,15 +33,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[ApiCallWithPrice, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = ApiCallWithPrice.from_dict(response.json())
|
||||
response_200 = ApiCallWithPrice(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -33,15 +33,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[ApiCallWithPrice, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = ApiCallWithPrice.from_dict(response.json())
|
||||
response_200 = ApiCallWithPrice(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -39,15 +39,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[List[ApiCallQueryGroup], Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = [ApiCallQueryGroup.from_dict(item) for item in response.json()]
|
||||
response_200 = [ApiCallQueryGroup(**item) for item in response.json()]
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -10,6 +10,7 @@ from ...models.file_density import FileDensity
|
||||
from ...models.file_mass import FileMass
|
||||
from ...models.file_surface_area import FileSurfaceArea
|
||||
from ...models.file_volume import FileVolume
|
||||
from ...models.text_to_cad import TextToCad
|
||||
from ...types import Response
|
||||
|
||||
|
||||
@ -44,6 +45,7 @@ def _parse_response(
|
||||
FileVolume,
|
||||
FileDensity,
|
||||
FileSurfaceArea,
|
||||
TextToCad,
|
||||
Error,
|
||||
]
|
||||
]:
|
||||
@ -52,7 +54,7 @@ def _parse_response(
|
||||
try:
|
||||
if not isinstance(data, dict):
|
||||
raise TypeError()
|
||||
option_file_conversion = FileConversion.from_dict(data)
|
||||
option_file_conversion = FileConversion(**data)
|
||||
return option_file_conversion
|
||||
except ValueError:
|
||||
pass
|
||||
@ -61,7 +63,7 @@ def _parse_response(
|
||||
try:
|
||||
if not isinstance(data, dict):
|
||||
raise TypeError()
|
||||
option_file_center_of_mass = FileCenterOfMass.from_dict(data)
|
||||
option_file_center_of_mass = FileCenterOfMass(**data)
|
||||
return option_file_center_of_mass
|
||||
except ValueError:
|
||||
pass
|
||||
@ -70,7 +72,7 @@ def _parse_response(
|
||||
try:
|
||||
if not isinstance(data, dict):
|
||||
raise TypeError()
|
||||
option_file_mass = FileMass.from_dict(data)
|
||||
option_file_mass = FileMass(**data)
|
||||
return option_file_mass
|
||||
except ValueError:
|
||||
pass
|
||||
@ -79,7 +81,7 @@ def _parse_response(
|
||||
try:
|
||||
if not isinstance(data, dict):
|
||||
raise TypeError()
|
||||
option_file_volume = FileVolume.from_dict(data)
|
||||
option_file_volume = FileVolume(**data)
|
||||
return option_file_volume
|
||||
except ValueError:
|
||||
pass
|
||||
@ -88,7 +90,7 @@ def _parse_response(
|
||||
try:
|
||||
if not isinstance(data, dict):
|
||||
raise TypeError()
|
||||
option_file_density = FileDensity.from_dict(data)
|
||||
option_file_density = FileDensity(**data)
|
||||
return option_file_density
|
||||
except ValueError:
|
||||
pass
|
||||
@ -97,19 +99,28 @@ def _parse_response(
|
||||
try:
|
||||
if not isinstance(data, dict):
|
||||
raise TypeError()
|
||||
option_file_surface_area = FileSurfaceArea.from_dict(data)
|
||||
option_file_surface_area = FileSurfaceArea(**data)
|
||||
return option_file_surface_area
|
||||
except ValueError:
|
||||
pass
|
||||
except TypeError:
|
||||
pass
|
||||
try:
|
||||
if not isinstance(data, dict):
|
||||
raise TypeError()
|
||||
option_text_to_cad = TextToCad(**data)
|
||||
return option_text_to_cad
|
||||
except ValueError:
|
||||
raise
|
||||
except TypeError:
|
||||
raise
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
@ -123,6 +134,7 @@ def _build_response(
|
||||
FileVolume,
|
||||
FileDensity,
|
||||
FileSurfaceArea,
|
||||
TextToCad,
|
||||
Error,
|
||||
]
|
||||
]
|
||||
@ -148,6 +160,7 @@ def sync_detailed(
|
||||
FileVolume,
|
||||
FileDensity,
|
||||
FileSurfaceArea,
|
||||
TextToCad,
|
||||
Error,
|
||||
]
|
||||
]
|
||||
@ -177,6 +190,7 @@ def sync(
|
||||
FileVolume,
|
||||
FileDensity,
|
||||
FileSurfaceArea,
|
||||
TextToCad,
|
||||
Error,
|
||||
]
|
||||
]:
|
||||
@ -205,6 +219,7 @@ async def asyncio_detailed(
|
||||
FileVolume,
|
||||
FileDensity,
|
||||
FileSurfaceArea,
|
||||
TextToCad,
|
||||
Error,
|
||||
]
|
||||
]
|
||||
@ -232,6 +247,7 @@ async def asyncio(
|
||||
FileVolume,
|
||||
FileDensity,
|
||||
FileSurfaceArea,
|
||||
TextToCad,
|
||||
Error,
|
||||
]
|
||||
]:
|
||||
|
@ -53,15 +53,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[ApiCallWithPriceResultsPage, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = ApiCallWithPriceResultsPage.from_dict(response.json())
|
||||
response_200 = ApiCallWithPriceResultsPage(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -55,15 +55,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[ApiCallWithPriceResultsPage, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = ApiCallWithPriceResultsPage.from_dict(response.json())
|
||||
response_200 = ApiCallWithPriceResultsPage(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -61,15 +61,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[AsyncApiCallResultsPage, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = AsyncApiCallResultsPage.from_dict(response.json())
|
||||
response_200 = AsyncApiCallResultsPage(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -53,15 +53,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[ApiCallWithPriceResultsPage, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = ApiCallWithPriceResultsPage.from_dict(response.json())
|
||||
response_200 = ApiCallWithPriceResultsPage(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -29,15 +29,15 @@ def _get_kwargs(
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[ApiToken, Error]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = ApiToken.from_dict(response.json())
|
||||
response_201 = ApiToken(**response.json())
|
||||
return response_201
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -31,12 +31,12 @@ def _get_kwargs(
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Error]:
|
||||
return None
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(*, response: httpx.Response) -> Response[Optional[Error]]:
|
||||
|
@ -31,15 +31,15 @@ def _get_kwargs(
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[ApiToken, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = ApiToken.from_dict(response.json())
|
||||
response_200 = ApiToken(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -53,15 +53,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[ApiTokenResultsPage, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = ApiTokenResultsPage.from_dict(response.json())
|
||||
response_200 = ApiTokenResultsPage(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -29,12 +29,12 @@ def _get_kwargs(
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Error]:
|
||||
return None
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(*, response: httpx.Response) -> Response[Optional[Error]]:
|
||||
|
@ -31,15 +31,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[AppClientInfo, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = AppClientInfo.from_dict(response.json())
|
||||
response_200 = AppClientInfo(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -31,12 +31,12 @@ def _get_kwargs(
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Error]:
|
||||
return None
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(*, response: httpx.Response) -> Response[Optional[Error]]:
|
||||
|
@ -4,7 +4,6 @@ from websockets.client import WebSocketClientProtocol, connect as ws_connect_asy
|
||||
from websockets.sync.client import ClientConnection, connect as ws_connect
|
||||
|
||||
from ...client import Client
|
||||
from ...models.error import Error
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
@ -34,14 +33,7 @@ def sync(
|
||||
client=client,
|
||||
)
|
||||
|
||||
with ws_connect(
|
||||
kwargs["url"].replace("https://", "wss://"),
|
||||
additional_headers=kwargs["headers"],
|
||||
) as websocket:
|
||||
return websocket # type: ignore
|
||||
|
||||
# Return an error if we got here.
|
||||
return Error(message="An error occurred while connecting to the websocket.")
|
||||
return ws_connect(kwargs["url"].replace("http", "ws"), additional_headers=kwargs["headers"], close_timeout=120, max_size=None) # type: ignore
|
||||
|
||||
|
||||
async def asyncio(
|
||||
@ -54,10 +46,9 @@ async def asyncio(
|
||||
client=client,
|
||||
)
|
||||
|
||||
async with ws_connect_async(
|
||||
kwargs["url"].replace("https://", "wss://"), extra_headers=kwargs["headers"]
|
||||
) as websocket:
|
||||
return websocket
|
||||
|
||||
# Return an error if we got here.
|
||||
return Error(message="An error occurred while connecting to the websocket.")
|
||||
return await ws_connect_async(
|
||||
kwargs["url"].replace("http", "ws"),
|
||||
extra_headers=kwargs["headers"],
|
||||
close_timeout=120,
|
||||
max_size=None,
|
||||
)
|
||||
|
@ -41,15 +41,15 @@ def _get_kwargs(
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[CodeOutput, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = CodeOutput.from_dict(response.json())
|
||||
response_200 = CodeOutput(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -49,15 +49,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[FileCenterOfMass, Error]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = FileCenterOfMass.from_dict(response.json())
|
||||
response_201 = FileCenterOfMass(**response.json())
|
||||
return response_201
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
@ -101,7 +101,7 @@ def sync(
|
||||
client: Client,
|
||||
) -> Optional[Union[FileCenterOfMass, Error]]:
|
||||
"""We assume any file given to us has one consistent unit throughout. We also assume the file is at the proper scale.
|
||||
This endpoint returns the cartesian co-ordinate in world space measure units.
|
||||
This endpoint returns the cartesian coordinate in world space measure units.
|
||||
In the future, we will use the units inside the file if they are given and do any conversions if necessary for the calculation. But currently, that is not supported.
|
||||
Get the center of mass of an object in a CAD file. If the file is larger than 25MB, it will be performed asynchronously.
|
||||
If the operation is performed asynchronously, the `id` of the operation will be returned. You can use the `id` returned from the request to get status information about the async operation from the `/async/operations/{id}` endpoint.
|
||||
@ -143,7 +143,7 @@ async def asyncio(
|
||||
client: Client,
|
||||
) -> Optional[Union[FileCenterOfMass, Error]]:
|
||||
"""We assume any file given to us has one consistent unit throughout. We also assume the file is at the proper scale.
|
||||
This endpoint returns the cartesian co-ordinate in world space measure units.
|
||||
This endpoint returns the cartesian coordinate in world space measure units.
|
||||
In the future, we will use the units inside the file if they are given and do any conversions if necessary for the calculation. But currently, that is not supported.
|
||||
Get the center of mass of an object in a CAD file. If the file is larger than 25MB, it will be performed asynchronously.
|
||||
If the operation is performed asynchronously, the `id` of the operation will be returned. You can use the `id` returned from the request to get status information about the async operation from the `/async/operations/{id}` endpoint.
|
||||
|
@ -39,15 +39,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[FileConversion, Error]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = FileConversion.from_dict(response.json())
|
||||
response_201 = FileConversion(**response.json())
|
||||
return response_201
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -1,58 +0,0 @@
|
||||
import base64
|
||||
from typing import Any, Optional, Tuple, Union
|
||||
|
||||
from ...api.file.create_file_conversion import asyncio as fc_asyncio, sync as fc_sync
|
||||
from ...client import Client
|
||||
from ...models import Error, FileConversion, FileExportFormat, FileImportFormat
|
||||
|
||||
|
||||
def sync(
|
||||
src_format: FileImportFormat,
|
||||
output_format: FileExportFormat,
|
||||
body: bytes,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[Any, Tuple[FileConversion, bytes], Error]]:
|
||||
"""Convert a CAD file from one format to another. If the file being converted is larger than a certain size it will be performed asynchronously. This function automatically base64 encodes the request body and base64 decodes the request output."""
|
||||
|
||||
encoded = base64.b64encode(body)
|
||||
|
||||
fc = fc_sync(
|
||||
src_format=src_format,
|
||||
output_format=output_format,
|
||||
body=encoded,
|
||||
client=client,
|
||||
)
|
||||
|
||||
if isinstance(fc, FileConversion) and fc.output != "":
|
||||
if isinstance(fc.output, str):
|
||||
b = base64.b64decode(fc.output + "===")
|
||||
return (fc, b)
|
||||
|
||||
return fc
|
||||
|
||||
|
||||
async def asyncio(
|
||||
src_format: FileImportFormat,
|
||||
output_format: FileExportFormat,
|
||||
body: bytes,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[Any, Tuple[FileConversion, bytes], Error]]:
|
||||
"""Convert a CAD file from one format to another. If the file being converted is larger than a certain size it will be performed asynchronously. This function automatically base64 encodes the request body and base64 decodes the request output."""
|
||||
|
||||
encoded = base64.b64encode(body)
|
||||
|
||||
fc = await fc_asyncio(
|
||||
src_format=src_format,
|
||||
output_format=output_format,
|
||||
body=encoded,
|
||||
client=client,
|
||||
)
|
||||
|
||||
if isinstance(fc, FileConversion) and fc.output != "":
|
||||
if isinstance(fc.output, str):
|
||||
b = base64.b64decode(fc.output + "===")
|
||||
return (fc, b)
|
||||
|
||||
return fc
|
@ -62,15 +62,15 @@ def _get_kwargs(
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[FileDensity, Error]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = FileDensity.from_dict(response.json())
|
||||
response_201 = FileDensity(**response.json())
|
||||
return response_201
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -62,15 +62,15 @@ def _get_kwargs(
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[FileMass, Error]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = FileMass.from_dict(response.json())
|
||||
response_201 = FileMass(**response.json())
|
||||
return response_201
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -49,15 +49,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[FileSurfaceArea, Error]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = FileSurfaceArea.from_dict(response.json())
|
||||
response_201 = FileSurfaceArea(**response.json())
|
||||
return response_201
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -47,15 +47,15 @@ def _get_kwargs(
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[FileVolume, Error]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = FileVolume.from_dict(response.json())
|
||||
response_201 = FileVolume(**response.json())
|
||||
return response_201
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -1,47 +0,0 @@
|
||||
import base64
|
||||
from typing import Any, Optional, Tuple, Union
|
||||
|
||||
from ...api.api_calls.get_async_operation import asyncio as fc_asyncio, sync as fc_sync
|
||||
from ...client import Client
|
||||
from ...models import Error
|
||||
from ...models.file_conversion import FileConversion
|
||||
|
||||
|
||||
def sync(
|
||||
id: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[Any, Tuple[FileConversion, bytes], Error]]:
|
||||
"""Get the status of a file conversion. This function automatically base64 decodes the output response if there is one."""
|
||||
|
||||
fc = fc_sync(
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
|
||||
if isinstance(fc, FileConversion) and fc.output != "":
|
||||
if isinstance(fc.output, str):
|
||||
b = base64.b64decode(fc.output + "===")
|
||||
return (fc, b)
|
||||
|
||||
return fc
|
||||
|
||||
|
||||
async def asyncio(
|
||||
id: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[Any, Tuple[FileConversion, bytes], Error]]:
|
||||
"""Get the status of a file conversion. This function automatically base64 decodes the output response if there is one."""
|
||||
|
||||
fc = await fc_asyncio(
|
||||
id=id,
|
||||
client=client,
|
||||
)
|
||||
|
||||
if isinstance(fc, FileConversion) and fc.output != "":
|
||||
if isinstance(fc.output, str):
|
||||
b = base64.b64decode(fc.output + "===")
|
||||
return (fc, b)
|
||||
|
||||
return fc
|
@ -34,15 +34,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[VerificationToken, Error]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = VerificationToken.from_dict(response.json())
|
||||
response_201 = VerificationToken(**response.json())
|
||||
return response_201
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -50,12 +50,12 @@ def _get_kwargs(
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Error]:
|
||||
return None
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(*, response: httpx.Response) -> Response[Optional[Error]]:
|
||||
|
@ -29,12 +29,12 @@ def _get_kwargs(
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Error]:
|
||||
return None
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(*, response: httpx.Response) -> Response[Optional[Error]]:
|
||||
|
@ -31,15 +31,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[AiPluginManifest, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = AiPluginManifest.from_dict(response.json())
|
||||
response_200 = AiPluginManifest(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -29,15 +29,15 @@ def _get_kwargs(
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[Metadata, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = Metadata.from_dict(response.json())
|
||||
response_200 = Metadata(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -31,12 +31,12 @@ def _parse_response(*, response: httpx.Response) -> Optional[Union[dict, Error]]
|
||||
response_200 = response.json()
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -31,12 +31,12 @@ def _parse_response(*, response: httpx.Response) -> Optional[Union[dict, Error]]
|
||||
response_200 = response.json()
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
117
kittycad/api/meta/internal_get_api_token_for_discord_user.py
Normal file
117
kittycad/api/meta/internal_get_api_token_for_discord_user.py
Normal file
@ -0,0 +1,117 @@
|
||||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ...client import Client
|
||||
from ...models.api_token import ApiToken
|
||||
from ...models.error import Error
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
discord_id: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Dict[str, Any]:
|
||||
url = "{}/internal/discord/api-token/{discord_id}".format(
|
||||
client.base_url,
|
||||
discord_id=discord_id,
|
||||
) # noqa: E501
|
||||
|
||||
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[Union[ApiToken, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = ApiToken(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, response: httpx.Response
|
||||
) -> Response[Optional[Union[ApiToken, Error]]]:
|
||||
return Response(
|
||||
status_code=response.status_code,
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
discord_id: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Optional[Union[ApiToken, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
discord_id=discord_id,
|
||||
client=client,
|
||||
)
|
||||
|
||||
response = httpx.get(
|
||||
verify=client.verify_ssl,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
discord_id: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[ApiToken, Error]]:
|
||||
"""This endpoint allows us to run API calls from our discord bot on behalf of a user. The user must have a discord account linked to their KittyCAD Account via oauth2 for this to work.
|
||||
You must be a KittyCAD employee to use this endpoint.""" # noqa: E501
|
||||
|
||||
return sync_detailed(
|
||||
discord_id=discord_id,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
discord_id: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Optional[Union[ApiToken, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
discord_id=discord_id,
|
||||
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(
|
||||
discord_id: str,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[ApiToken, Error]]:
|
||||
"""This endpoint allows us to run API calls from our discord bot on behalf of a user. The user must have a discord account linked to their KittyCAD Account via oauth2 for this to work.
|
||||
You must be a KittyCAD employee to use this endpoint.""" # noqa: E501
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
discord_id=discord_id,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
@ -29,15 +29,15 @@ def _get_kwargs(
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[Pong, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = Pong.from_dict(response.json())
|
||||
response_200 = Pong(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -1,10 +1,13 @@
|
||||
from typing import Any, Dict
|
||||
import json
|
||||
from typing import Any, Dict, Iterator
|
||||
|
||||
import bson
|
||||
from websockets.client import WebSocketClientProtocol, connect as ws_connect_async
|
||||
from websockets.sync.client import ClientConnection, connect as ws_connect
|
||||
|
||||
from ...client import Client
|
||||
from ...models.error import Error
|
||||
from ...models.web_socket_request import WebSocketRequest
|
||||
from ...models.web_socket_response import WebSocketResponse
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
@ -12,6 +15,7 @@ def _get_kwargs(
|
||||
unlocked_framerate: bool,
|
||||
video_res_height: int,
|
||||
video_res_width: int,
|
||||
webrtc: bool,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Dict[str, Any]:
|
||||
@ -25,9 +29,9 @@ def _get_kwargs(
|
||||
|
||||
if unlocked_framerate is not None:
|
||||
if "?" in url:
|
||||
url = url + "&unlocked_framerate=" + str(unlocked_framerate)
|
||||
url = url + "&unlocked_framerate=" + str(unlocked_framerate).lower()
|
||||
else:
|
||||
url = url + "?unlocked_framerate=" + str(unlocked_framerate)
|
||||
url = url + "?unlocked_framerate=" + str(unlocked_framerate).lower()
|
||||
|
||||
if video_res_height is not None:
|
||||
if "?" in url:
|
||||
@ -41,6 +45,12 @@ def _get_kwargs(
|
||||
else:
|
||||
url = url + "?video_res_width=" + str(video_res_width)
|
||||
|
||||
if webrtc is not None:
|
||||
if "?" in url:
|
||||
url = url + "&webrtc=" + str(webrtc).lower()
|
||||
else:
|
||||
url = url + "?webrtc=" + str(webrtc).lower()
|
||||
|
||||
headers: Dict[str, Any] = client.get_headers()
|
||||
cookies: Dict[str, Any] = client.get_cookies()
|
||||
|
||||
@ -57,6 +67,7 @@ def sync(
|
||||
unlocked_framerate: bool,
|
||||
video_res_height: int,
|
||||
video_res_width: int,
|
||||
webrtc: bool,
|
||||
*,
|
||||
client: Client,
|
||||
) -> ClientConnection:
|
||||
@ -67,17 +78,11 @@ def sync(
|
||||
unlocked_framerate=unlocked_framerate,
|
||||
video_res_height=video_res_height,
|
||||
video_res_width=video_res_width,
|
||||
webrtc=webrtc,
|
||||
client=client,
|
||||
)
|
||||
|
||||
with ws_connect(
|
||||
kwargs["url"].replace("https://", "wss://"),
|
||||
additional_headers=kwargs["headers"],
|
||||
) as websocket:
|
||||
return websocket # type: ignore
|
||||
|
||||
# Return an error if we got here.
|
||||
return Error(message="An error occurred while connecting to the websocket.")
|
||||
return ws_connect(kwargs["url"].replace("http", "ws"), additional_headers=kwargs["headers"], close_timeout=120, max_size=None) # type: ignore
|
||||
|
||||
|
||||
async def asyncio(
|
||||
@ -85,6 +90,7 @@ async def asyncio(
|
||||
unlocked_framerate: bool,
|
||||
video_res_height: int,
|
||||
video_res_width: int,
|
||||
webrtc: bool,
|
||||
*,
|
||||
client: Client,
|
||||
) -> WebSocketClientProtocol:
|
||||
@ -95,13 +101,76 @@ async def asyncio(
|
||||
unlocked_framerate=unlocked_framerate,
|
||||
video_res_height=video_res_height,
|
||||
video_res_width=video_res_width,
|
||||
webrtc=webrtc,
|
||||
client=client,
|
||||
)
|
||||
|
||||
async with ws_connect_async(
|
||||
kwargs["url"].replace("https://", "wss://"), extra_headers=kwargs["headers"]
|
||||
) as websocket:
|
||||
return websocket
|
||||
return await ws_connect_async(
|
||||
kwargs["url"].replace("http", "ws"),
|
||||
extra_headers=kwargs["headers"],
|
||||
close_timeout=120,
|
||||
max_size=None,
|
||||
)
|
||||
|
||||
# Return an error if we got here.
|
||||
return Error(message="An error occurred while connecting to the websocket.")
|
||||
|
||||
class WebSocket:
|
||||
"""A websocket connection to the API endpoint."""
|
||||
|
||||
ws: ClientConnection
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
fps: int,
|
||||
unlocked_framerate: bool,
|
||||
video_res_height: int,
|
||||
video_res_width: int,
|
||||
webrtc: bool,
|
||||
client: Client,
|
||||
):
|
||||
self.ws = sync(
|
||||
fps,
|
||||
unlocked_framerate,
|
||||
video_res_height,
|
||||
video_res_width,
|
||||
webrtc,
|
||||
client=client,
|
||||
)
|
||||
|
||||
def __enter__(
|
||||
self,
|
||||
):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self.close()
|
||||
|
||||
def __iter__(self) -> Iterator[WebSocketResponse]:
|
||||
"""
|
||||
Iterate on incoming messages.
|
||||
|
||||
The iterator calls :meth:`recv` and yields messages in an infinite loop.
|
||||
|
||||
It exits when the connection is closed normally. It raises a
|
||||
:exc:`~websockets.exceptions.ConnectionClosedError` exception after a
|
||||
protocol error or a network failure.
|
||||
|
||||
"""
|
||||
for message in self.ws:
|
||||
yield WebSocketResponse(**json.loads(message))
|
||||
|
||||
def send(self, data: WebSocketRequest):
|
||||
"""Send data to the websocket."""
|
||||
self.ws.send(json.dumps(data.model_dump()))
|
||||
|
||||
def send_binary(self, data: WebSocketRequest):
|
||||
"""Send data as bson to the websocket."""
|
||||
self.ws.send(bson.encode(data.model_dump())) # type: ignore
|
||||
|
||||
def recv(self) -> WebSocketResponse:
|
||||
"""Receive data from the websocket."""
|
||||
message = self.ws.recv(timeout=60)
|
||||
return WebSocketResponse(**json.loads(message))
|
||||
|
||||
def close(self):
|
||||
"""Close the websocket."""
|
||||
self.ws.close()
|
||||
|
@ -32,15 +32,15 @@ def _get_kwargs(
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[Customer, Error]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = Customer.from_dict(response.json())
|
||||
response_201 = Customer(**response.json())
|
||||
return response_201
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -31,15 +31,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[PaymentIntent, Error]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = PaymentIntent.from_dict(response.json())
|
||||
response_201 = PaymentIntent(**response.json())
|
||||
return response_201
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -29,12 +29,12 @@ def _get_kwargs(
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Error]:
|
||||
return None
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(*, response: httpx.Response) -> Response[Optional[Error]]:
|
||||
|
@ -31,12 +31,12 @@ def _get_kwargs(
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Error]:
|
||||
return None
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(*, response: httpx.Response) -> Response[Optional[Error]]:
|
||||
|
@ -31,15 +31,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[CustomerBalance, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = CustomerBalance.from_dict(response.json())
|
||||
response_200 = CustomerBalance(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -29,15 +29,15 @@ def _get_kwargs(
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[Customer, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = Customer.from_dict(response.json())
|
||||
response_200 = Customer(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -31,15 +31,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[List[Invoice], Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = [Invoice.from_dict(item) for item in response.json()]
|
||||
response_200 = [Invoice(**item) for item in response.json()]
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -31,15 +31,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[List[PaymentMethod], Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = [PaymentMethod.from_dict(item) for item in response.json()]
|
||||
response_200 = [PaymentMethod(**item) for item in response.json()]
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -32,15 +32,15 @@ def _get_kwargs(
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[Customer, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = Customer.from_dict(response.json())
|
||||
response_200 = Customer(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -29,12 +29,12 @@ def _get_kwargs(
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Error]:
|
||||
return None
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(*, response: httpx.Response) -> Response[Optional[Error]]:
|
||||
|
@ -43,15 +43,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[UnitAngleConversion, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = UnitAngleConversion.from_dict(response.json())
|
||||
response_200 = UnitAngleConversion(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -43,15 +43,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[UnitAreaConversion, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = UnitAreaConversion.from_dict(response.json())
|
||||
response_200 = UnitAreaConversion(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -43,15 +43,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[UnitCurrentConversion, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = UnitCurrentConversion.from_dict(response.json())
|
||||
response_200 = UnitCurrentConversion(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -43,15 +43,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[UnitEnergyConversion, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = UnitEnergyConversion.from_dict(response.json())
|
||||
response_200 = UnitEnergyConversion(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -43,15 +43,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[UnitForceConversion, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = UnitForceConversion.from_dict(response.json())
|
||||
response_200 = UnitForceConversion(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -43,15 +43,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[UnitFrequencyConversion, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = UnitFrequencyConversion.from_dict(response.json())
|
||||
response_200 = UnitFrequencyConversion(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -43,15 +43,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[UnitLengthConversion, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = UnitLengthConversion.from_dict(response.json())
|
||||
response_200 = UnitLengthConversion(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -43,15 +43,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[UnitMassConversion, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = UnitMassConversion.from_dict(response.json())
|
||||
response_200 = UnitMassConversion(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -43,15 +43,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[UnitPowerConversion, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = UnitPowerConversion.from_dict(response.json())
|
||||
response_200 = UnitPowerConversion(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -43,15 +43,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[UnitPressureConversion, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = UnitPressureConversion.from_dict(response.json())
|
||||
response_200 = UnitPressureConversion(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -43,15 +43,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[UnitTemperatureConversion, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = UnitTemperatureConversion.from_dict(response.json())
|
||||
response_200 = UnitTemperatureConversion(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -43,15 +43,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[UnitTorqueConversion, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = UnitTorqueConversion.from_dict(response.json())
|
||||
response_200 = UnitTorqueConversion(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -43,15 +43,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[UnitVolumeConversion, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = UnitVolumeConversion.from_dict(response.json())
|
||||
response_200 = UnitVolumeConversion(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -29,12 +29,12 @@ def _get_kwargs(
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Error]:
|
||||
return None
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(*, response: httpx.Response) -> Response[Optional[Error]]:
|
||||
|
@ -31,15 +31,15 @@ def _get_kwargs(
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[Session, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = Session.from_dict(response.json())
|
||||
response_200 = Session(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -31,15 +31,15 @@ def _get_kwargs(
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[User, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = User.from_dict(response.json())
|
||||
response_200 = User(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -33,15 +33,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[ExtendedUser, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = ExtendedUser.from_dict(response.json())
|
||||
response_200 = ExtendedUser(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -31,12 +31,12 @@ def _parse_response(*, response: httpx.Response) -> Optional[Union[str, Error]]:
|
||||
response_200 = response.text
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -29,15 +29,15 @@ def _get_kwargs(
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[Onboarding, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = Onboarding.from_dict(response.json())
|
||||
response_200 = Onboarding(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -29,15 +29,15 @@ def _get_kwargs(
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[User, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = User.from_dict(response.json())
|
||||
response_200 = User(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -31,15 +31,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[ExtendedUser, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = ExtendedUser.from_dict(response.json())
|
||||
response_200 = ExtendedUser(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -53,15 +53,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[UserResultsPage, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = UserResultsPage.from_dict(response.json())
|
||||
response_200 = UserResultsPage(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -53,15 +53,15 @@ def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[ExtendedUserResultsPage, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = ExtendedUserResultsPage.from_dict(response.json())
|
||||
response_200 = ExtendedUserResultsPage(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -32,15 +32,15 @@ def _get_kwargs(
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[User, Error]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = User.from_dict(response.json())
|
||||
response_200 = User(**response.json())
|
||||
return response_200
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error.from_dict(response.json())
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error.from_dict(response.json())
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error.from_dict(response.json())
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
|
@ -38,6 +38,10 @@ class Client:
|
||||
"""Get a new client matching this one with a new timeout (in seconds)"""
|
||||
return attr.evolve(self, timeout=timeout)
|
||||
|
||||
def with_base_url(self, url: str) -> "Client":
|
||||
"""Get a new client matching this one with a new base url"""
|
||||
return attr.evolve(self, base_url=url)
|
||||
|
||||
|
||||
@attr.s(auto_attribs=True)
|
||||
class ClientFromEnv(Client):
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user