1
.github/workflows/generate.yml
vendored
1
.github/workflows/generate.yml
vendored
@ -35,5 +35,6 @@ jobs:
|
|||||||
git config --local user.name "github-actions[bot]"
|
git config --local user.name "github-actions[bot]"
|
||||||
git remote set-url origin https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
|
git remote set-url origin https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
|
||||||
git fetch origin
|
git fetch origin
|
||||||
|
git add .
|
||||||
git commit -am "I have generated the latest API!" || true
|
git commit -am "I have generated the latest API!" || true
|
||||||
git push origin ${{github.event.pull_request.head.ref }} || true
|
git push origin ${{github.event.pull_request.head.ref }} || true
|
||||||
|
1
kittycad/api/unit/__init__.py
Normal file
1
kittycad/api/unit/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
""" Contains methods for accessing the unit API paths: Unit conversion operations. """
|
129
kittycad/api/unit/create_unit_conversion.py
Normal file
129
kittycad/api/unit/create_unit_conversion.py
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
from typing import Any, Dict, Optional, Union, cast
|
||||||
|
|
||||||
|
import httpx
|
||||||
|
|
||||||
|
from ...client import Client
|
||||||
|
from ...models.unit_conversion import UnitConversion
|
||||||
|
from ...models.error import Error
|
||||||
|
from ...models.unit_metric_format import UnitMetricFormat
|
||||||
|
from ...models.unit_metric_format import UnitMetricFormat
|
||||||
|
from ...types import Response
|
||||||
|
|
||||||
|
def _get_kwargs(
|
||||||
|
output_format: UnitMetricFormat,
|
||||||
|
src_format: UnitMetricFormat,
|
||||||
|
value: float,
|
||||||
|
*,
|
||||||
|
client: Client,
|
||||||
|
) -> Dict[str, Any]:
|
||||||
|
url = "{}/unit/conversion/{src_format}/{output_format}?value={value}".format(client.base_url, output_format=output_format, src_format=src_format, value=value)
|
||||||
|
|
||||||
|
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[Any, UnitConversion, Error]]:
|
||||||
|
if response.status_code == 201:
|
||||||
|
response_201 = UnitConversion.from_dict(response.json())
|
||||||
|
return response_201
|
||||||
|
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 None
|
||||||
|
|
||||||
|
|
||||||
|
def _build_response(*, response: httpx.Response) -> Response[Union[Any, UnitConversion, Error]]:
|
||||||
|
return Response(
|
||||||
|
status_code=response.status_code,
|
||||||
|
content=response.content,
|
||||||
|
headers=response.headers,
|
||||||
|
parsed=_parse_response(response=response),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def sync_detailed(
|
||||||
|
output_format: UnitMetricFormat,
|
||||||
|
src_format: UnitMetricFormat,
|
||||||
|
value: float,
|
||||||
|
*,
|
||||||
|
client: Client,
|
||||||
|
) -> Response[Union[Any, UnitConversion, Error]]:
|
||||||
|
kwargs = _get_kwargs(
|
||||||
|
output_format=output_format,
|
||||||
|
src_format=src_format,
|
||||||
|
value=value,
|
||||||
|
client=client,
|
||||||
|
)
|
||||||
|
|
||||||
|
response = httpx.post(
|
||||||
|
verify=client.verify_ssl,
|
||||||
|
**kwargs,
|
||||||
|
)
|
||||||
|
|
||||||
|
return _build_response(response=response)
|
||||||
|
|
||||||
|
|
||||||
|
def sync(
|
||||||
|
output_format: UnitMetricFormat,
|
||||||
|
src_format: UnitMetricFormat,
|
||||||
|
value: float,
|
||||||
|
*,
|
||||||
|
client: Client,
|
||||||
|
) -> Optional[Union[Any, UnitConversion, Error]]:
|
||||||
|
""" Convert a metric unit value to another metric unit value. This is a nice endpoint to use for helper functions. """
|
||||||
|
|
||||||
|
return sync_detailed(
|
||||||
|
output_format=output_format,
|
||||||
|
src_format=src_format,
|
||||||
|
value=value,
|
||||||
|
client=client,
|
||||||
|
).parsed
|
||||||
|
|
||||||
|
|
||||||
|
async def asyncio_detailed(
|
||||||
|
output_format: UnitMetricFormat,
|
||||||
|
src_format: UnitMetricFormat,
|
||||||
|
value: float,
|
||||||
|
*,
|
||||||
|
client: Client,
|
||||||
|
) -> Response[Union[Any, UnitConversion, Error]]:
|
||||||
|
kwargs = _get_kwargs(
|
||||||
|
output_format=output_format,
|
||||||
|
src_format=src_format,
|
||||||
|
value=value,
|
||||||
|
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: UnitMetricFormat,
|
||||||
|
src_format: UnitMetricFormat,
|
||||||
|
value: float,
|
||||||
|
*,
|
||||||
|
client: Client,
|
||||||
|
) -> Optional[Union[Any, UnitConversion, Error]]:
|
||||||
|
""" Convert a metric unit value to another metric unit value. This is a nice endpoint to use for helper functions. """
|
||||||
|
|
||||||
|
return (
|
||||||
|
await asyncio_detailed(
|
||||||
|
output_format=output_format,
|
||||||
|
src_format=src_format,
|
||||||
|
value=value,
|
||||||
|
client=client,
|
||||||
|
)
|
||||||
|
).parsed
|
185
kittycad/models/unit_conversion.py
Normal file
185
kittycad/models/unit_conversion.py
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
import datetime
|
||||||
|
from typing import Any, Dict, List, Type, TypeVar, Union, cast
|
||||||
|
|
||||||
|
import attr
|
||||||
|
from dateutil.parser import isoparse
|
||||||
|
|
||||||
|
from ..models.uuid import Uuid
|
||||||
|
from ..models.unit_metric_format import UnitMetricFormat
|
||||||
|
from ..models.api_call_status import APICallStatus
|
||||||
|
from ..types import UNSET, Unset
|
||||||
|
|
||||||
|
T = TypeVar("T", bound="UnitConversion")
|
||||||
|
|
||||||
|
|
||||||
|
@attr.s(auto_attribs=True)
|
||||||
|
class UnitConversion:
|
||||||
|
""" """
|
||||||
|
completed_at: Union[Unset, datetime.datetime] = UNSET
|
||||||
|
created_at: Union[Unset, datetime.datetime] = UNSET
|
||||||
|
error: Union[Unset, str] = UNSET
|
||||||
|
id: Union[Unset, str] = UNSET
|
||||||
|
input: Union[Unset, float] = UNSET
|
||||||
|
output: Union[Unset, float] = UNSET
|
||||||
|
output_format: Union[Unset, UnitMetricFormat] = UNSET
|
||||||
|
src_format: Union[Unset, UnitMetricFormat] = UNSET
|
||||||
|
started_at: Union[Unset, datetime.datetime] = UNSET
|
||||||
|
status: Union[Unset, APICallStatus] = UNSET
|
||||||
|
updated_at: Union[Unset, datetime.datetime] = UNSET
|
||||||
|
user_id: Union[Unset, str] = UNSET
|
||||||
|
|
||||||
|
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
|
||||||
|
|
||||||
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
|
completed_at: Union[Unset, str] = UNSET
|
||||||
|
if not isinstance(self.completed_at, Unset):
|
||||||
|
completed_at = self.completed_at.isoformat()
|
||||||
|
created_at: Union[Unset, str] = UNSET
|
||||||
|
if not isinstance(self.created_at, Unset):
|
||||||
|
created_at = self.created_at.isoformat()
|
||||||
|
error = self.error
|
||||||
|
id = self.id
|
||||||
|
input = self.input
|
||||||
|
output = self.output
|
||||||
|
output_format: Union[Unset, str] = UNSET
|
||||||
|
if not isinstance(self.output_format, Unset):
|
||||||
|
output_format = self.output_format.value
|
||||||
|
src_format: Union[Unset, str] = UNSET
|
||||||
|
if not isinstance(self.src_format, Unset):
|
||||||
|
src_format = self.src_format.value
|
||||||
|
started_at: Union[Unset, str] = UNSET
|
||||||
|
if not isinstance(self.started_at, Unset):
|
||||||
|
started_at = self.started_at.isoformat()
|
||||||
|
status: Union[Unset, str] = UNSET
|
||||||
|
if not isinstance(self.status, Unset):
|
||||||
|
status = self.status.value
|
||||||
|
updated_at: Union[Unset, str] = UNSET
|
||||||
|
if not isinstance(self.updated_at, Unset):
|
||||||
|
updated_at = self.updated_at.isoformat()
|
||||||
|
user_id = self.user_id
|
||||||
|
|
||||||
|
field_dict: Dict[str, Any] = {}
|
||||||
|
field_dict.update(self.additional_properties)
|
||||||
|
field_dict.update({})
|
||||||
|
if completed_at is not UNSET:
|
||||||
|
field_dict['completed_at'] = completed_at
|
||||||
|
if created_at is not UNSET:
|
||||||
|
field_dict['created_at'] = created_at
|
||||||
|
if error is not UNSET:
|
||||||
|
field_dict['error'] = error
|
||||||
|
if id is not UNSET:
|
||||||
|
field_dict['id'] = id
|
||||||
|
if input is not UNSET:
|
||||||
|
field_dict['input'] = input
|
||||||
|
if output is not UNSET:
|
||||||
|
field_dict['output'] = output
|
||||||
|
if output_format is not UNSET:
|
||||||
|
field_dict['output_format'] = output_format
|
||||||
|
if src_format is not UNSET:
|
||||||
|
field_dict['src_format'] = src_format
|
||||||
|
if started_at is not UNSET:
|
||||||
|
field_dict['started_at'] = started_at
|
||||||
|
if status is not UNSET:
|
||||||
|
field_dict['status'] = status
|
||||||
|
if updated_at is not UNSET:
|
||||||
|
field_dict['updated_at'] = updated_at
|
||||||
|
if user_id is not UNSET:
|
||||||
|
field_dict['user_id'] = user_id
|
||||||
|
|
||||||
|
return field_dict
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
|
||||||
|
d = src_dict.copy()
|
||||||
|
_completed_at = d.pop("completed_at", UNSET)
|
||||||
|
completed_at: Union[Unset, datetime.datetime]
|
||||||
|
if isinstance(_completed_at, Unset):
|
||||||
|
completed_at = UNSET
|
||||||
|
else:
|
||||||
|
completed_at = isoparse(_completed_at)
|
||||||
|
|
||||||
|
_created_at = d.pop("created_at", UNSET)
|
||||||
|
created_at: Union[Unset, datetime.datetime]
|
||||||
|
if isinstance(_created_at, Unset):
|
||||||
|
created_at = UNSET
|
||||||
|
else:
|
||||||
|
created_at = isoparse(_created_at)
|
||||||
|
|
||||||
|
error = d.pop("error", UNSET)
|
||||||
|
|
||||||
|
id = d.pop("id", UNSET)
|
||||||
|
|
||||||
|
input = d.pop("input", UNSET)
|
||||||
|
|
||||||
|
output = d.pop("output", UNSET)
|
||||||
|
|
||||||
|
_output_format = d.pop("output_format", UNSET)
|
||||||
|
output_format: Union[Unset, UnitMetricFormat]
|
||||||
|
if isinstance(_output_format, Unset):
|
||||||
|
output_format = UNSET
|
||||||
|
else:
|
||||||
|
output_format = UnitMetricFormat(_output_format)
|
||||||
|
|
||||||
|
_src_format = d.pop("src_format", UNSET)
|
||||||
|
src_format: Union[Unset, UnitMetricFormat]
|
||||||
|
if isinstance(_src_format, Unset):
|
||||||
|
src_format = UNSET
|
||||||
|
else:
|
||||||
|
src_format = UnitMetricFormat(_src_format)
|
||||||
|
|
||||||
|
_started_at = d.pop("started_at", UNSET)
|
||||||
|
started_at: Union[Unset, datetime.datetime]
|
||||||
|
if isinstance(_started_at, Unset):
|
||||||
|
started_at = UNSET
|
||||||
|
else:
|
||||||
|
started_at = isoparse(_started_at)
|
||||||
|
|
||||||
|
_status = d.pop("status", UNSET)
|
||||||
|
status: Union[Unset, APICallStatus]
|
||||||
|
if isinstance(_status, Unset):
|
||||||
|
status = UNSET
|
||||||
|
else:
|
||||||
|
status = APICallStatus(_status)
|
||||||
|
|
||||||
|
_updated_at = d.pop("updated_at", UNSET)
|
||||||
|
updated_at: Union[Unset, datetime.datetime]
|
||||||
|
if isinstance(_updated_at, Unset):
|
||||||
|
updated_at = UNSET
|
||||||
|
else:
|
||||||
|
updated_at = isoparse(_updated_at)
|
||||||
|
|
||||||
|
user_id = d.pop("user_id", UNSET)
|
||||||
|
|
||||||
|
unit_conversion = cls(
|
||||||
|
completed_at=completed_at,
|
||||||
|
created_at=created_at,
|
||||||
|
error=error,
|
||||||
|
id=id,
|
||||||
|
input=input,
|
||||||
|
output=output,
|
||||||
|
output_format=output_format,
|
||||||
|
src_format=src_format,
|
||||||
|
started_at=started_at,
|
||||||
|
status=status,
|
||||||
|
updated_at=updated_at,
|
||||||
|
user_id=user_id,
|
||||||
|
)
|
||||||
|
|
||||||
|
unit_conversion.additional_properties = d
|
||||||
|
return unit_conversion
|
||||||
|
|
||||||
|
@property
|
||||||
|
def additional_keys(self) -> List[str]:
|
||||||
|
return list(self.additional_properties.keys())
|
||||||
|
|
||||||
|
def __getitem__(self, key: str) -> Any:
|
||||||
|
return self.additional_properties[key]
|
||||||
|
|
||||||
|
def __setitem__(self, key: str, value: Any) -> None:
|
||||||
|
self.additional_properties[key] = value
|
||||||
|
|
||||||
|
def __delitem__(self, key: str) -> None:
|
||||||
|
del self.additional_properties[key]
|
||||||
|
|
||||||
|
def __contains__(self, key: str) -> bool:
|
||||||
|
return key in self.additional_properties
|
24
kittycad/models/unit_metric_format.py
Normal file
24
kittycad/models/unit_metric_format.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class UnitMetricFormat(str, Enum):
|
||||||
|
ATTO = 'atto'
|
||||||
|
FEMTO = 'femto'
|
||||||
|
PICO = 'pico'
|
||||||
|
NANO = 'nano'
|
||||||
|
MICRO = 'micro'
|
||||||
|
MILLI = 'milli'
|
||||||
|
CENTI = 'centi'
|
||||||
|
DECI = 'deci'
|
||||||
|
METRIC_UNIT = 'metric_unit'
|
||||||
|
DECA = 'deca'
|
||||||
|
HECTO = 'hecto'
|
||||||
|
KILO = 'kilo'
|
||||||
|
MEGA = 'mega'
|
||||||
|
GIGA = 'giga'
|
||||||
|
TERA = 'tera'
|
||||||
|
PETA = 'peta'
|
||||||
|
EXA = 'exa'
|
||||||
|
|
||||||
|
def __str__(self) -> str:
|
||||||
|
return str(self.value)
|
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "kittycad"
|
name = "kittycad"
|
||||||
version = "0.2.2"
|
version = "0.2.3"
|
||||||
description = "A client library for accessing KittyCAD"
|
description = "A client library for accessing KittyCAD"
|
||||||
|
|
||||||
authors = []
|
authors = []
|
||||||
|
Reference in New Issue
Block a user