Skip to content

Commit ce67bf2

Browse files
authored
Sync client with API (#20)
* sync api * get workspace logs * test * bump version
1 parent f39e883 commit ce67bf2

30 files changed

Lines changed: 2919 additions & 24 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Contains endpoint functions for accessing the API"""
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
from http import HTTPStatus
2+
from typing import Any
3+
from urllib.parse import quote
4+
5+
import httpx
6+
7+
from ... import errors
8+
from ...client import Client
9+
from ...types import Response
10+
11+
12+
def _get_kwargs(
13+
id: str,
14+
) -> dict[str, Any]:
15+
_kwargs: dict[str, Any] = {
16+
"method": "post",
17+
"url": "/app-registrations/{id}:approve".format(
18+
id=quote(str(id), safe=""),
19+
),
20+
}
21+
22+
return _kwargs
23+
24+
25+
def _parse_response(*, client: Client, response: httpx.Response) -> Any | None:
26+
if response.status_code == 200:
27+
return None
28+
29+
errors.handle_error_response(response, client.raise_on_unexpected_status)
30+
31+
32+
def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
33+
return Response(
34+
status_code=HTTPStatus(response.status_code),
35+
content=response.content,
36+
headers=response.headers,
37+
parsed=_parse_response(client=client, response=response),
38+
)
39+
40+
41+
def sync_detailed(
42+
id: str,
43+
*,
44+
client: Client,
45+
) -> Response[Any]:
46+
"""Approve application
47+
48+
Mark application as approved by an administrator.
49+
50+
Args:
51+
id (str):
52+
client (Client): instance of the API client
53+
54+
Raises:
55+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
56+
httpx.TimeoutException: If the request takes longer than Client.timeout.
57+
58+
Returns:
59+
Response[Any]
60+
"""
61+
62+
kwargs = _get_kwargs(
63+
id=id,
64+
)
65+
66+
response = client.get_httpx_client().request(
67+
auth=client.get_auth(),
68+
**kwargs,
69+
)
70+
71+
return _build_response(client=client, response=response)
72+
73+
74+
async def asyncio_detailed(
75+
id: str,
76+
*,
77+
client: Client,
78+
) -> Response[Any]:
79+
"""Approve application
80+
81+
Mark application as approved by an administrator.
82+
83+
Args:
84+
id (str):
85+
client (Client): instance of the API client
86+
87+
Raises:
88+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
89+
httpx.TimeoutException: If the request takes longer than Client.timeout.
90+
91+
Returns:
92+
Response[Any]
93+
"""
94+
95+
kwargs = _get_kwargs(
96+
id=id,
97+
)
98+
99+
response = await client.get_async_httpx_client().request(auth=client.get_auth(), **kwargs)
100+
101+
return _build_response(client=client, response=response)
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
from http import HTTPStatus
2+
from typing import Any
3+
from urllib.parse import quote
4+
5+
import httpx
6+
7+
from ... import errors
8+
from ...client import Client
9+
from ...types import Response
10+
11+
12+
def _get_kwargs(
13+
id: str,
14+
) -> dict[str, Any]:
15+
_kwargs: dict[str, Any] = {
16+
"method": "delete",
17+
"url": "/app-registrations/{id}".format(
18+
id=quote(str(id), safe=""),
19+
),
20+
}
21+
22+
return _kwargs
23+
24+
25+
def _parse_response(*, client: Client, response: httpx.Response) -> Any | None:
26+
if response.status_code == 200:
27+
return None
28+
29+
errors.handle_error_response(response, client.raise_on_unexpected_status)
30+
31+
32+
def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
33+
return Response(
34+
status_code=HTTPStatus(response.status_code),
35+
content=response.content,
36+
headers=response.headers,
37+
parsed=_parse_response(client=client, response=response),
38+
)
39+
40+
41+
def sync_detailed(
42+
id: str,
43+
*,
44+
client: Client,
45+
) -> Response[Any]:
46+
"""Archive app registration
47+
48+
Archives an app registration. Archived registrations cannot authenticate.
49+
50+
Args:
51+
id (str):
52+
client (Client): instance of the API client
53+
54+
Raises:
55+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
56+
httpx.TimeoutException: If the request takes longer than Client.timeout.
57+
58+
Returns:
59+
Response[Any]
60+
"""
61+
62+
kwargs = _get_kwargs(
63+
id=id,
64+
)
65+
66+
response = client.get_httpx_client().request(
67+
auth=client.get_auth(),
68+
**kwargs,
69+
)
70+
71+
return _build_response(client=client, response=response)
72+
73+
74+
async def asyncio_detailed(
75+
id: str,
76+
*,
77+
client: Client,
78+
) -> Response[Any]:
79+
"""Archive app registration
80+
81+
Archives an app registration. Archived registrations cannot authenticate.
82+
83+
Args:
84+
id (str):
85+
client (Client): instance of the API client
86+
87+
Raises:
88+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
89+
httpx.TimeoutException: If the request takes longer than Client.timeout.
90+
91+
Returns:
92+
Response[Any]
93+
"""
94+
95+
kwargs = _get_kwargs(
96+
id=id,
97+
)
98+
99+
response = await client.get_async_httpx_client().request(auth=client.get_auth(), **kwargs)
100+
101+
return _build_response(client=client, response=response)
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
from http import HTTPStatus
2+
from typing import Any
3+
4+
import httpx
5+
6+
from ... import errors
7+
from ...client import Client
8+
from ...models.app_registration_input import AppRegistrationInput
9+
from ...models.app_registration_secret_response import AppRegistrationSecretResponse
10+
from ...types import Response
11+
12+
13+
def _get_kwargs(
14+
*,
15+
body: AppRegistrationInput,
16+
) -> dict[str, Any]:
17+
headers: dict[str, Any] = {}
18+
19+
_kwargs: dict[str, Any] = {
20+
"method": "post",
21+
"url": "/app-registrations",
22+
}
23+
24+
_kwargs["json"] = body.to_dict()
25+
26+
headers["Content-Type"] = "application/json"
27+
28+
_kwargs["headers"] = headers
29+
return _kwargs
30+
31+
32+
def _parse_response(*, client: Client, response: httpx.Response) -> AppRegistrationSecretResponse | None:
33+
if response.status_code == 201:
34+
response_201 = AppRegistrationSecretResponse.from_dict(response.json())
35+
36+
return response_201
37+
38+
errors.handle_error_response(response, client.raise_on_unexpected_status)
39+
40+
41+
def _build_response(*, client: Client, response: httpx.Response) -> Response[AppRegistrationSecretResponse]:
42+
return Response(
43+
status_code=HTTPStatus(response.status_code),
44+
content=response.content,
45+
headers=response.headers,
46+
parsed=_parse_response(client=client, response=response),
47+
)
48+
49+
50+
def sync_detailed(
51+
*,
52+
client: Client,
53+
body: AppRegistrationInput,
54+
) -> Response[AppRegistrationSecretResponse]:
55+
"""Create app registration
56+
57+
Creates a new OAuth client app registration. Returns the client secret which is only shown once.
58+
59+
Args:
60+
body (AppRegistrationInput):
61+
client (Client): instance of the API client
62+
63+
Raises:
64+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
65+
httpx.TimeoutException: If the request takes longer than Client.timeout.
66+
67+
Returns:
68+
Response[AppRegistrationSecretResponse]
69+
"""
70+
71+
kwargs = _get_kwargs(
72+
body=body,
73+
)
74+
75+
response = client.get_httpx_client().request(
76+
auth=client.get_auth(),
77+
**kwargs,
78+
)
79+
80+
return _build_response(client=client, response=response)
81+
82+
83+
def sync(
84+
*,
85+
client: Client,
86+
body: AppRegistrationInput,
87+
) -> AppRegistrationSecretResponse | None:
88+
"""Create app registration
89+
90+
Creates a new OAuth client app registration. Returns the client secret which is only shown once.
91+
92+
Args:
93+
body (AppRegistrationInput):
94+
client (Client): instance of the API client
95+
96+
Raises:
97+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
98+
httpx.TimeoutException: If the request takes longer than Client.timeout.
99+
100+
Returns:
101+
AppRegistrationSecretResponse
102+
"""
103+
104+
try:
105+
return sync_detailed(
106+
client=client,
107+
body=body,
108+
).parsed
109+
except errors.NotFoundException:
110+
return None
111+
112+
113+
async def asyncio_detailed(
114+
*,
115+
client: Client,
116+
body: AppRegistrationInput,
117+
) -> Response[AppRegistrationSecretResponse]:
118+
"""Create app registration
119+
120+
Creates a new OAuth client app registration. Returns the client secret which is only shown once.
121+
122+
Args:
123+
body (AppRegistrationInput):
124+
client (Client): instance of the API client
125+
126+
Raises:
127+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
128+
httpx.TimeoutException: If the request takes longer than Client.timeout.
129+
130+
Returns:
131+
Response[AppRegistrationSecretResponse]
132+
"""
133+
134+
kwargs = _get_kwargs(
135+
body=body,
136+
)
137+
138+
response = await client.get_async_httpx_client().request(auth=client.get_auth(), **kwargs)
139+
140+
return _build_response(client=client, response=response)
141+
142+
143+
async def asyncio(
144+
*,
145+
client: Client,
146+
body: AppRegistrationInput,
147+
) -> AppRegistrationSecretResponse | None:
148+
"""Create app registration
149+
150+
Creates a new OAuth client app registration. Returns the client secret which is only shown once.
151+
152+
Args:
153+
body (AppRegistrationInput):
154+
client (Client): instance of the API client
155+
156+
Raises:
157+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
158+
httpx.TimeoutException: If the request takes longer than Client.timeout.
159+
160+
Returns:
161+
AppRegistrationSecretResponse
162+
"""
163+
164+
try:
165+
return (
166+
await asyncio_detailed(
167+
client=client,
168+
body=body,
169+
)
170+
).parsed
171+
except errors.NotFoundException:
172+
return None

0 commit comments

Comments
 (0)