Skip to content

Commit 6e882bf

Browse files
Update api spec (#463)
* YOYO NEW API SPEC! * I have generated the latest API! --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 6fda134 commit 6e882bf

12 files changed

+763
-428
lines changed

kittycad.py.patch.json

Lines changed: 427 additions & 419 deletions
Large diffs are not rendered by default.
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
from typing import Any, Dict, Optional
2+
3+
import httpx
4+
5+
from ...client import Client
6+
from ...models.error import Error
7+
from ...models.uuid import Uuid
8+
from ...types import Response
9+
10+
11+
def _get_kwargs(
12+
org_id: Uuid,
13+
*,
14+
client: Client,
15+
callback_url: Optional[str] = None,
16+
) -> Dict[str, Any]:
17+
url = "{}/auth/saml/org/{org_id}/login".format(
18+
client.base_url,
19+
org_id=org_id,
20+
) # noqa: E501
21+
22+
if callback_url is not None:
23+
if "?" in url:
24+
url = url + "&callback_url=" + str(callback_url)
25+
else:
26+
url = url + "?callback_url=" + str(callback_url)
27+
28+
headers: Dict[str, Any] = client.get_headers()
29+
cookies: Dict[str, Any] = client.get_cookies()
30+
31+
return {
32+
"url": url,
33+
"headers": headers,
34+
"cookies": cookies,
35+
"timeout": client.get_timeout(),
36+
}
37+
38+
39+
def _parse_response(*, response: httpx.Response) -> Optional[Error]:
40+
return None
41+
if response.status_code == 400:
42+
response_4XX = Error(**response.json())
43+
return response_4XX
44+
if response.status_code == 500:
45+
response_5XX = Error(**response.json())
46+
return response_5XX
47+
return Error(**response.json())
48+
49+
50+
def _build_response(*, response: httpx.Response) -> Response[Optional[Error]]:
51+
return Response(
52+
status_code=response.status_code,
53+
content=response.content,
54+
headers=response.headers,
55+
parsed=_parse_response(response=response),
56+
)
57+
58+
59+
def sync_detailed(
60+
org_id: Uuid,
61+
*,
62+
client: Client,
63+
callback_url: Optional[str] = None,
64+
) -> Response[Optional[Error]]:
65+
kwargs = _get_kwargs(
66+
org_id=org_id,
67+
callback_url=callback_url,
68+
client=client,
69+
)
70+
71+
response = httpx.get(
72+
verify=client.verify_ssl,
73+
**kwargs,
74+
)
75+
76+
return _build_response(response=response)
77+
78+
79+
def sync(
80+
org_id: Uuid,
81+
*,
82+
client: Client,
83+
callback_url: Optional[str] = None,
84+
) -> Optional[Error]:
85+
"""Redirects the browser straight to the org’s SAML IdP.""" # noqa: E501
86+
87+
return sync_detailed(
88+
org_id=org_id,
89+
callback_url=callback_url,
90+
client=client,
91+
).parsed
92+
93+
94+
async def asyncio_detailed(
95+
org_id: Uuid,
96+
*,
97+
client: Client,
98+
callback_url: Optional[str] = None,
99+
) -> Response[Optional[Error]]:
100+
kwargs = _get_kwargs(
101+
org_id=org_id,
102+
callback_url=callback_url,
103+
client=client,
104+
)
105+
106+
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
107+
response = await _client.get(**kwargs)
108+
109+
return _build_response(response=response)
110+
111+
112+
async def asyncio(
113+
org_id: Uuid,
114+
*,
115+
client: Client,
116+
callback_url: Optional[str] = None,
117+
) -> Optional[Error]:
118+
"""Redirects the browser straight to the org’s SAML IdP.""" # noqa: E501
119+
120+
return (
121+
await asyncio_detailed(
122+
org_id=org_id,
123+
callback_url=callback_url,
124+
client=client,
125+
)
126+
).parsed

kittycad/examples_test.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
auth_email,
4242
auth_email_callback,
4343
get_auth_saml,
44+
get_auth_saml_by_org,
4445
logout,
4546
post_auth_saml,
4647
redirect_user_shortlink,
@@ -1065,6 +1066,53 @@ async def test_auth_email_callback_async():
10651066
)
10661067

10671068

1069+
@pytest.mark.skip
1070+
def test_get_auth_saml_by_org():
1071+
# Create our client.
1072+
client = ClientFromEnv()
1073+
1074+
result: Optional[Error] = get_auth_saml_by_org.sync(
1075+
client=client,
1076+
org_id=Uuid("<string>"),
1077+
callback_url=None, # Optional[str]
1078+
)
1079+
1080+
if isinstance(result, Error) or result is None:
1081+
print(result)
1082+
raise Exception("Error in response")
1083+
1084+
body: Error = result
1085+
print(body)
1086+
1087+
# OR if you need more info (e.g. status_code)
1088+
response: Response[Optional[Error]] = get_auth_saml_by_org.sync_detailed(
1089+
client=client,
1090+
org_id=Uuid("<string>"),
1091+
callback_url=None, # Optional[str]
1092+
)
1093+
1094+
1095+
# OR run async
1096+
@pytest.mark.asyncio
1097+
@pytest.mark.skip
1098+
async def test_get_auth_saml_by_org_async():
1099+
# Create our client.
1100+
client = ClientFromEnv()
1101+
1102+
result: Optional[Error] = await get_auth_saml_by_org.asyncio(
1103+
client=client,
1104+
org_id=Uuid("<string>"),
1105+
callback_url=None, # Optional[str]
1106+
)
1107+
1108+
# OR run async with more info
1109+
response: Response[Optional[Error]] = await get_auth_saml_by_org.asyncio_detailed(
1110+
client=client,
1111+
org_id=Uuid("<string>"),
1112+
callback_url=None, # Optional[str]
1113+
)
1114+
1115+
10681116
@pytest.mark.skip
10691117
def test_get_auth_saml():
10701118
# Create our client.

kittycad/models/async_api_call_output.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ class OptionTextToCadMultiFileIteration(BaseModel):
297297

298298
completed_at: Optional[datetime.datetime] = None
299299

300+
conversation_id: Uuid
301+
300302
created_at: datetime.datetime
301303

302304
error: Optional[str] = None

kittycad/models/ml_prompt.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class MlPrompt(BaseModel):
1515

1616
completed_at: Optional[datetime.datetime] = None
1717

18+
conversation_id: Optional[Uuid] = None
19+
1820
created_at: datetime.datetime
1921

2022
error: Optional[str] = None

kittycad/models/modeling_app_individual_subscription_tier.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ class ModelingAppIndividualSubscriptionTier(str, Enum):
66

77
"""# The free tier. """ # noqa: E501
88
FREE = "free"
9+
"""# The plus tier. """ # noqa: E501
10+
PLUS = "plus"
911
"""# The pro tier. """ # noqa: E501
1012
PRO = "pro"
1113

kittycad/models/modeling_app_subscription_tier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class ModelingAppSubscriptionTier(BaseModel):
1919
"""A subscription tier we offer for the Modeling App."""
2020

21-
annual_discount: Optional[int] = None
21+
annual_discount: Optional[float] = None
2222

2323
description: str
2424

kittycad/models/modeling_app_subscription_tier_name.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ class ModelingAppSubscriptionTierName(str, Enum):
66

77
"""# The free tier. """ # noqa: E501
88
FREE = "free"
9+
"""# The plus tier. """ # noqa: E501
10+
PLUS = "plus"
911
"""# The pro tier. """ # noqa: E501
1012
PRO = "pro"
1113
"""# The team tier. """ # noqa: E501

kittycad/models/text_to_cad_multi_file_iteration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class TextToCadMultiFileIteration(BaseModel):
1515

1616
completed_at: Optional[datetime.datetime] = None
1717

18+
conversation_id: Uuid
19+
1820
created_at: datetime.datetime
1921

2022
error: Optional[str] = None

kittycad/models/text_to_cad_multi_file_iteration_body.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
from pydantic import BaseModel, ConfigDict
44

55
from ..models.source_range_prompt import SourceRangePrompt
6+
from ..models.uuid import Uuid
67

78

89
class TextToCadMultiFileIterationBody(BaseModel):
910
"""Body for iterating on models from text prompts."""
1011

12+
conversation_id: Optional[Uuid] = None
13+
1114
kcl_version: Optional[str] = None
1215

1316
project_name: Optional[str] = None

0 commit comments

Comments
 (0)