Skip to content

Commit bb2718f

Browse files
Update api spec (#458)
* 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 b922adf commit bb2718f

File tree

6 files changed

+746
-416
lines changed

6 files changed

+746
-416
lines changed

kittycad.py.patch.json

Lines changed: 424 additions & 416 deletions
Large diffs are not rendered by default.

kittycad/api/hidden/auth_api_key.py

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
from typing import Any, Dict, Optional, Union
2+
3+
import httpx
4+
5+
from ...client import Client
6+
from ...models.auth_api_key_response import AuthApiKeyResponse
7+
from ...models.error import Error
8+
from ...types import Response
9+
10+
11+
def _get_kwargs(
12+
*,
13+
client: Client,
14+
) -> Dict[str, Any]:
15+
url = "{}/auth/api-key".format(
16+
client.base_url,
17+
) # noqa: E501
18+
19+
headers: Dict[str, Any] = client.get_headers()
20+
cookies: Dict[str, Any] = client.get_cookies()
21+
22+
return {
23+
"url": url,
24+
"headers": headers,
25+
"cookies": cookies,
26+
"timeout": client.get_timeout(),
27+
}
28+
29+
30+
def _parse_response(
31+
*, response: httpx.Response
32+
) -> Optional[Union[AuthApiKeyResponse, Error]]:
33+
if response.status_code == 200:
34+
response_200 = AuthApiKeyResponse(**response.json())
35+
return response_200
36+
if response.status_code == 400:
37+
response_4XX = Error(**response.json())
38+
return response_4XX
39+
if response.status_code == 500:
40+
response_5XX = Error(**response.json())
41+
return response_5XX
42+
return Error(**response.json())
43+
44+
45+
def _build_response(
46+
*, response: httpx.Response
47+
) -> Response[Optional[Union[AuthApiKeyResponse, Error]]]:
48+
return Response(
49+
status_code=response.status_code,
50+
content=response.content,
51+
headers=response.headers,
52+
parsed=_parse_response(response=response),
53+
)
54+
55+
56+
def sync_detailed(
57+
*,
58+
client: Client,
59+
) -> Response[Optional[Union[AuthApiKeyResponse, Error]]]:
60+
kwargs = _get_kwargs(
61+
client=client,
62+
)
63+
64+
response = httpx.post(
65+
verify=client.verify_ssl,
66+
**kwargs,
67+
)
68+
69+
return _build_response(response=response)
70+
71+
72+
def sync(
73+
*,
74+
client: Client,
75+
) -> Optional[Union[AuthApiKeyResponse, Error]]:
76+
"""This returns a session token.""" # noqa: E501
77+
78+
return sync_detailed(
79+
client=client,
80+
).parsed
81+
82+
83+
async def asyncio_detailed(
84+
*,
85+
client: Client,
86+
) -> Response[Optional[Union[AuthApiKeyResponse, Error]]]:
87+
kwargs = _get_kwargs(
88+
client=client,
89+
)
90+
91+
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
92+
response = await _client.post(**kwargs)
93+
94+
return _build_response(response=response)
95+
96+
97+
async def asyncio(
98+
*,
99+
client: Client,
100+
) -> Optional[Union[AuthApiKeyResponse, Error]]:
101+
"""This returns a session token.""" # noqa: E501
102+
103+
return (
104+
await asyncio_detailed(
105+
client=client,
106+
)
107+
).parsed

kittycad/examples_test.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
create_file_volume,
3838
)
3939
from kittycad.api.hidden import (
40+
auth_api_key,
4041
auth_email,
4142
auth_email_callback,
4243
get_auth_saml,
@@ -176,6 +177,7 @@
176177
ApiTokenResultsPage,
177178
AppClientInfo,
178179
AsyncApiCallResultsPage,
180+
AuthApiKeyResponse,
179181
CodeOutput,
180182
CreateShortlinkResponse,
181183
Customer,
@@ -907,6 +909,49 @@ async def test_get_async_operation_async():
907909
)
908910

909911

912+
@pytest.mark.skip
913+
def test_auth_api_key():
914+
# Create our client.
915+
client = ClientFromEnv()
916+
917+
result: Optional[Union[AuthApiKeyResponse, Error]] = auth_api_key.sync(
918+
client=client,
919+
)
920+
921+
if isinstance(result, Error) or result is None:
922+
print(result)
923+
raise Exception("Error in response")
924+
925+
body: AuthApiKeyResponse = result
926+
print(body)
927+
928+
# OR if you need more info (e.g. status_code)
929+
response: Response[Optional[Union[AuthApiKeyResponse, Error]]] = (
930+
auth_api_key.sync_detailed(
931+
client=client,
932+
)
933+
)
934+
935+
936+
# OR run async
937+
@pytest.mark.asyncio
938+
@pytest.mark.skip
939+
async def test_auth_api_key_async():
940+
# Create our client.
941+
client = ClientFromEnv()
942+
943+
result: Optional[Union[AuthApiKeyResponse, Error]] = await auth_api_key.asyncio(
944+
client=client,
945+
)
946+
947+
# OR run async with more info
948+
response: Response[
949+
Optional[Union[AuthApiKeyResponse, Error]]
950+
] = await auth_api_key.asyncio_detailed(
951+
client=client,
952+
)
953+
954+
910955
@pytest.mark.skip
911956
def test_auth_email():
912957
# Create our client.

kittycad/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from .async_api_call_output import AsyncApiCallOutput
2929
from .async_api_call_results_page import AsyncApiCallResultsPage
3030
from .async_api_call_type import AsyncApiCallType
31+
from .auth_api_key_response import AuthApiKeyResponse
3132
from .auth_callback import AuthCallback
3233
from .axis import Axis
3334
from .axis_direction_pair import AxisDirectionPair
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from pydantic import BaseModel, ConfigDict
2+
3+
4+
class AuthApiKeyResponse(BaseModel):
5+
"""The response from the `/auth/api-key` endpoint."""
6+
7+
session_token: str
8+
9+
model_config = ConfigDict(protected_namespaces=())

spec.json

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,153 @@
11671167
}
11681168
}
11691169
},
1170+
"/auth/api-key": {
1171+
"post": {
1172+
"tags": [
1173+
"hidden"
1174+
],
1175+
"summary": "Authenticate using an api-key. This is disabled on production but can be used in dev to login without email magic.",
1176+
"description": "This returns a session token.",
1177+
"operationId": "auth_api_key",
1178+
"responses": {
1179+
"200": {
1180+
"description": "successful operation",
1181+
"headers": {
1182+
"Access-Control-Allow-Credentials": {
1183+
"description": "Access-Control-Allow-Credentials header.",
1184+
"style": "simple",
1185+
"schema": {
1186+
"nullable": true,
1187+
"type": "string"
1188+
}
1189+
},
1190+
"Access-Control-Allow-Headers": {
1191+
"description": "Access-Control-Allow-Headers header. This is a comma-separated list of headers.",
1192+
"style": "simple",
1193+
"schema": {
1194+
"nullable": true,
1195+
"type": "string"
1196+
}
1197+
},
1198+
"Access-Control-Allow-Methods": {
1199+
"description": "Access-Control-Allow-Methods header.",
1200+
"style": "simple",
1201+
"schema": {
1202+
"nullable": true,
1203+
"type": "string"
1204+
}
1205+
},
1206+
"Access-Control-Allow-Origin": {
1207+
"description": "Access-Control-Allow-Origin header.",
1208+
"style": "simple",
1209+
"schema": {
1210+
"nullable": true,
1211+
"type": "string"
1212+
}
1213+
},
1214+
"Set-Cookie": {
1215+
"description": "Set-Cookie header.",
1216+
"style": "simple",
1217+
"schema": {
1218+
"nullable": true,
1219+
"type": "string"
1220+
}
1221+
},
1222+
"X-Api-Call-Id": {
1223+
"description": "ID for this request. We return it so that users can report this to us and help us debug their problems.",
1224+
"style": "simple",
1225+
"required": true,
1226+
"schema": {
1227+
"type": "string"
1228+
}
1229+
}
1230+
},
1231+
"content": {
1232+
"application/json": {
1233+
"schema": {
1234+
"$ref": "#/components/schemas/AuthApiKeyResponse"
1235+
}
1236+
}
1237+
}
1238+
},
1239+
"4XX": {
1240+
"$ref": "#/components/responses/Error"
1241+
},
1242+
"5XX": {
1243+
"$ref": "#/components/responses/Error"
1244+
}
1245+
}
1246+
},
1247+
"options": {
1248+
"tags": [
1249+
"hidden"
1250+
],
1251+
"summary": "OPTIONS endpoint.",
1252+
"description": "This is necessary for some preflight requests, specifically POST, PUT, and DELETE.",
1253+
"operationId": "options_auth_api_key",
1254+
"responses": {
1255+
"204": {
1256+
"description": "resource updated",
1257+
"headers": {
1258+
"Access-Control-Allow-Credentials": {
1259+
"description": "Access-Control-Allow-Credentials header.",
1260+
"style": "simple",
1261+
"schema": {
1262+
"nullable": true,
1263+
"type": "string"
1264+
}
1265+
},
1266+
"Access-Control-Allow-Headers": {
1267+
"description": "Access-Control-Allow-Headers header. This is a comma-separated list of headers.",
1268+
"style": "simple",
1269+
"schema": {
1270+
"nullable": true,
1271+
"type": "string"
1272+
}
1273+
},
1274+
"Access-Control-Allow-Methods": {
1275+
"description": "Access-Control-Allow-Methods header.",
1276+
"style": "simple",
1277+
"schema": {
1278+
"nullable": true,
1279+
"type": "string"
1280+
}
1281+
},
1282+
"Access-Control-Allow-Origin": {
1283+
"description": "Access-Control-Allow-Origin header.",
1284+
"style": "simple",
1285+
"schema": {
1286+
"nullable": true,
1287+
"type": "string"
1288+
}
1289+
},
1290+
"Set-Cookie": {
1291+
"description": "Set-Cookie header.",
1292+
"style": "simple",
1293+
"schema": {
1294+
"nullable": true,
1295+
"type": "string"
1296+
}
1297+
},
1298+
"X-Api-Call-Id": {
1299+
"description": "ID for this request. We return it so that users can report this to us and help us debug their problems.",
1300+
"style": "simple",
1301+
"required": true,
1302+
"schema": {
1303+
"type": "string"
1304+
}
1305+
}
1306+
}
1307+
},
1308+
"4XX": {
1309+
"$ref": "#/components/responses/Error"
1310+
},
1311+
"5XX": {
1312+
"$ref": "#/components/responses/Error"
1313+
}
1314+
}
1315+
}
1316+
},
11701317
"/auth/email": {
11711318
"post": {
11721319
"tags": [
@@ -19367,6 +19514,19 @@
1936719514
}
1936819515
]
1936919516
},
19517+
"AuthApiKeyResponse": {
19518+
"description": "The response from the `/auth/api-key` endpoint.",
19519+
"type": "object",
19520+
"properties": {
19521+
"session_token": {
19522+
"description": "The session token",
19523+
"type": "string"
19524+
}
19525+
},
19526+
"required": [
19527+
"session_token"
19528+
]
19529+
},
1937019530
"AuthCallback": {
1937119531
"description": "The authentication callback from the OAuth 2.0 client. This is typically posted to the redirect URL as query params after authenticating.",
1937219532
"type": "object",

0 commit comments

Comments
 (0)