Skip to content

Commit e3d80a1

Browse files
feat(api): deployments
1 parent 1c3e7a0 commit e3d80a1

File tree

9 files changed

+230
-14
lines changed

9 files changed

+230
-14
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 16
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-ff8ccba8b5409eaa1128df9027582cb63f66e8accd75e511f70b7c27ef26c9ae.yml
3-
openapi_spec_hash: 1dbacc339695a7c78718f90f791d3f01
1+
configured_endpoints: 17
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-2eeb61205775c5997abf8154cd6f6fe81a1e83870eff10050b17ed415aa7860b.yml
3+
openapi_spec_hash: 63405add4a3f53718f8183cbb8c1a22f
44
config_hash: 00ec9df250b9dc077f8d3b93a442d252

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ from kernel.types import (
1313
DeploymentStateEvent,
1414
DeploymentCreateResponse,
1515
DeploymentRetrieveResponse,
16+
DeploymentListResponse,
1617
DeploymentFollowResponse,
1718
)
1819
```
@@ -21,6 +22,7 @@ Methods:
2122

2223
- <code title="post /deployments">client.deployments.<a href="./src/kernel/resources/deployments.py">create</a>(\*\*<a href="src/kernel/types/deployment_create_params.py">params</a>) -> <a href="./src/kernel/types/deployment_create_response.py">DeploymentCreateResponse</a></code>
2324
- <code title="get /deployments/{id}">client.deployments.<a href="./src/kernel/resources/deployments.py">retrieve</a>(id) -> <a href="./src/kernel/types/deployment_retrieve_response.py">DeploymentRetrieveResponse</a></code>
25+
- <code title="get /deployments">client.deployments.<a href="./src/kernel/resources/deployments.py">list</a>(\*\*<a href="src/kernel/types/deployment_list_params.py">params</a>) -> <a href="./src/kernel/types/deployment_list_response.py">DeploymentListResponse</a></code>
2426
- <code title="get /deployments/{id}/events">client.deployments.<a href="./src/kernel/resources/deployments.py">follow</a>(id, \*\*<a href="src/kernel/types/deployment_follow_params.py">params</a>) -> <a href="./src/kernel/types/deployment_follow_response.py">DeploymentFollowResponse</a></code>
2527

2628
# Apps

src/kernel/resources/deployments.py

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import httpx
99

10-
from ..types import deployment_create_params, deployment_follow_params
10+
from ..types import deployment_list_params, deployment_create_params, deployment_follow_params
1111
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
1212
from .._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
1313
from .._compat import cached_property
@@ -20,6 +20,7 @@
2020
)
2121
from .._streaming import Stream, AsyncStream
2222
from .._base_client import make_request_options
23+
from ..types.deployment_list_response import DeploymentListResponse
2324
from ..types.deployment_create_response import DeploymentCreateResponse
2425
from ..types.deployment_follow_response import DeploymentFollowResponse
2526
from ..types.deployment_retrieve_response import DeploymentRetrieveResponse
@@ -146,6 +147,44 @@ def retrieve(
146147
cast_to=DeploymentRetrieveResponse,
147148
)
148149

150+
def list(
151+
self,
152+
*,
153+
app_name: str | NotGiven = NOT_GIVEN,
154+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
155+
# The extra values given here take precedence over values defined on the client or passed to this method.
156+
extra_headers: Headers | None = None,
157+
extra_query: Query | None = None,
158+
extra_body: Body | None = None,
159+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
160+
) -> DeploymentListResponse:
161+
"""List deployments.
162+
163+
Optionally filter by application name.
164+
165+
Args:
166+
app_name: Filter results by application name.
167+
168+
extra_headers: Send extra headers
169+
170+
extra_query: Add additional query parameters to the request
171+
172+
extra_body: Add additional JSON properties to the request
173+
174+
timeout: Override the client-level default timeout for this request, in seconds
175+
"""
176+
return self._get(
177+
"/deployments",
178+
options=make_request_options(
179+
extra_headers=extra_headers,
180+
extra_query=extra_query,
181+
extra_body=extra_body,
182+
timeout=timeout,
183+
query=maybe_transform({"app_name": app_name}, deployment_list_params.DeploymentListParams),
184+
),
185+
cast_to=DeploymentListResponse,
186+
)
187+
149188
def follow(
150189
self,
151190
id: str,
@@ -313,6 +352,44 @@ async def retrieve(
313352
cast_to=DeploymentRetrieveResponse,
314353
)
315354

355+
async def list(
356+
self,
357+
*,
358+
app_name: str | NotGiven = NOT_GIVEN,
359+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
360+
# The extra values given here take precedence over values defined on the client or passed to this method.
361+
extra_headers: Headers | None = None,
362+
extra_query: Query | None = None,
363+
extra_body: Body | None = None,
364+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
365+
) -> DeploymentListResponse:
366+
"""List deployments.
367+
368+
Optionally filter by application name.
369+
370+
Args:
371+
app_name: Filter results by application name.
372+
373+
extra_headers: Send extra headers
374+
375+
extra_query: Add additional query parameters to the request
376+
377+
extra_body: Add additional JSON properties to the request
378+
379+
timeout: Override the client-level default timeout for this request, in seconds
380+
"""
381+
return await self._get(
382+
"/deployments",
383+
options=make_request_options(
384+
extra_headers=extra_headers,
385+
extra_query=extra_query,
386+
extra_body=extra_body,
387+
timeout=timeout,
388+
query=await async_maybe_transform({"app_name": app_name}, deployment_list_params.DeploymentListParams),
389+
),
390+
cast_to=DeploymentListResponse,
391+
)
392+
316393
async def follow(
317394
self,
318395
id: str,
@@ -371,6 +448,9 @@ def __init__(self, deployments: DeploymentsResource) -> None:
371448
self.retrieve = to_raw_response_wrapper(
372449
deployments.retrieve,
373450
)
451+
self.list = to_raw_response_wrapper(
452+
deployments.list,
453+
)
374454
self.follow = to_raw_response_wrapper(
375455
deployments.follow,
376456
)
@@ -386,6 +466,9 @@ def __init__(self, deployments: AsyncDeploymentsResource) -> None:
386466
self.retrieve = async_to_raw_response_wrapper(
387467
deployments.retrieve,
388468
)
469+
self.list = async_to_raw_response_wrapper(
470+
deployments.list,
471+
)
389472
self.follow = async_to_raw_response_wrapper(
390473
deployments.follow,
391474
)
@@ -401,6 +484,9 @@ def __init__(self, deployments: DeploymentsResource) -> None:
401484
self.retrieve = to_streamed_response_wrapper(
402485
deployments.retrieve,
403486
)
487+
self.list = to_streamed_response_wrapper(
488+
deployments.list,
489+
)
404490
self.follow = to_streamed_response_wrapper(
405491
deployments.follow,
406492
)
@@ -416,6 +502,9 @@ def __init__(self, deployments: AsyncDeploymentsResource) -> None:
416502
self.retrieve = async_to_streamed_response_wrapper(
417503
deployments.retrieve,
418504
)
505+
self.list = async_to_streamed_response_wrapper(
506+
deployments.list,
507+
)
419508
self.follow = async_to_streamed_response_wrapper(
420509
deployments.follow,
421510
)

src/kernel/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
from .browser_create_params import BrowserCreateParams as BrowserCreateParams
1717
from .browser_delete_params import BrowserDeleteParams as BrowserDeleteParams
1818
from .browser_list_response import BrowserListResponse as BrowserListResponse
19+
from .deployment_list_params import DeploymentListParams as DeploymentListParams
1920
from .deployment_state_event import DeploymentStateEvent as DeploymentStateEvent
2021
from .invocation_state_event import InvocationStateEvent as InvocationStateEvent
2122
from .browser_create_response import BrowserCreateResponse as BrowserCreateResponse
2223
from .deployment_create_params import DeploymentCreateParams as DeploymentCreateParams
2324
from .deployment_follow_params import DeploymentFollowParams as DeploymentFollowParams
25+
from .deployment_list_response import DeploymentListResponse as DeploymentListResponse
2426
from .invocation_create_params import InvocationCreateParams as InvocationCreateParams
2527
from .invocation_update_params import InvocationUpdateParams as InvocationUpdateParams
2628
from .browser_persistence_param import BrowserPersistenceParam as BrowserPersistenceParam

src/kernel/types/app_list_response.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Dict, List, Optional
3+
from typing import Dict, List
44
from typing_extensions import Literal, TypeAlias
55

66
from .._models import BaseModel
7+
from .shared.app_action import AppAction
78

89
__all__ = ["AppListResponse", "AppListResponseItem"]
910

@@ -12,20 +13,23 @@ class AppListResponseItem(BaseModel):
1213
id: str
1314
"""Unique identifier for the app version"""
1415

16+
actions: List[AppAction]
17+
"""List of actions available on the app"""
18+
1519
app_name: str
1620
"""Name of the application"""
1721

1822
deployment: str
1923
"""Deployment ID"""
2024

25+
env_vars: Dict[str, str]
26+
"""Environment variables configured for this app version"""
27+
2128
region: Literal["aws.us-east-1a"]
2229
"""Deployment region code"""
2330

2431
version: str
2532
"""Version label for the application"""
2633

27-
env_vars: Optional[Dict[str, str]] = None
28-
"""Environment variables configured for this app version"""
29-
3034

3135
AppListResponse: TypeAlias = List[AppListResponseItem]

src/kernel/types/apps/deployment_create_response.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@
44
from typing_extensions import Literal
55

66
from ..._models import BaseModel
7+
from ..shared.app_action import AppAction
78

8-
__all__ = ["DeploymentCreateResponse", "App", "AppAction"]
9-
10-
11-
class AppAction(BaseModel):
12-
name: str
13-
"""Name of the action"""
9+
__all__ = ["DeploymentCreateResponse", "App"]
1410

1511

1612
class App(BaseModel):
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing_extensions import TypedDict
6+
7+
__all__ = ["DeploymentListParams"]
8+
9+
10+
class DeploymentListParams(TypedDict, total=False):
11+
app_name: str
12+
"""Filter results by application name."""
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import Dict, List, Optional
4+
from datetime import datetime
5+
from typing_extensions import Literal, TypeAlias
6+
7+
from .._models import BaseModel
8+
9+
__all__ = ["DeploymentListResponse", "DeploymentListResponseItem"]
10+
11+
12+
class DeploymentListResponseItem(BaseModel):
13+
id: str
14+
"""Unique identifier for the deployment"""
15+
16+
created_at: datetime
17+
"""Timestamp when the deployment was created"""
18+
19+
region: Literal["aws.us-east-1a"]
20+
"""Deployment region code"""
21+
22+
status: Literal["queued", "in_progress", "running", "failed", "stopped"]
23+
"""Current status of the deployment"""
24+
25+
entrypoint_rel_path: Optional[str] = None
26+
"""Relative path to the application entrypoint"""
27+
28+
env_vars: Optional[Dict[str, str]] = None
29+
"""Environment variables configured for this deployment"""
30+
31+
status_reason: Optional[str] = None
32+
"""Status reason"""
33+
34+
updated_at: Optional[datetime] = None
35+
"""Timestamp when the deployment was last updated"""
36+
37+
38+
DeploymentListResponse: TypeAlias = List[DeploymentListResponseItem]

tests/api_resources/test_deployments.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from kernel import Kernel, AsyncKernel
1111
from tests.utils import assert_matches_type
1212
from kernel.types import (
13+
DeploymentListResponse,
1314
DeploymentCreateResponse,
1415
DeploymentRetrieveResponse,
1516
)
@@ -112,6 +113,42 @@ def test_path_params_retrieve(self, client: Kernel) -> None:
112113
"",
113114
)
114115

116+
@pytest.mark.skip()
117+
@parametrize
118+
def test_method_list(self, client: Kernel) -> None:
119+
deployment = client.deployments.list()
120+
assert_matches_type(DeploymentListResponse, deployment, path=["response"])
121+
122+
@pytest.mark.skip()
123+
@parametrize
124+
def test_method_list_with_all_params(self, client: Kernel) -> None:
125+
deployment = client.deployments.list(
126+
app_name="app_name",
127+
)
128+
assert_matches_type(DeploymentListResponse, deployment, path=["response"])
129+
130+
@pytest.mark.skip()
131+
@parametrize
132+
def test_raw_response_list(self, client: Kernel) -> None:
133+
response = client.deployments.with_raw_response.list()
134+
135+
assert response.is_closed is True
136+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
137+
deployment = response.parse()
138+
assert_matches_type(DeploymentListResponse, deployment, path=["response"])
139+
140+
@pytest.mark.skip()
141+
@parametrize
142+
def test_streaming_response_list(self, client: Kernel) -> None:
143+
with client.deployments.with_streaming_response.list() as response:
144+
assert not response.is_closed
145+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
146+
147+
deployment = response.parse()
148+
assert_matches_type(DeploymentListResponse, deployment, path=["response"])
149+
150+
assert cast(Any, response.is_closed) is True
151+
115152
@pytest.mark.skip(
116153
reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail"
117154
)
@@ -270,6 +307,42 @@ async def test_path_params_retrieve(self, async_client: AsyncKernel) -> None:
270307
"",
271308
)
272309

310+
@pytest.mark.skip()
311+
@parametrize
312+
async def test_method_list(self, async_client: AsyncKernel) -> None:
313+
deployment = await async_client.deployments.list()
314+
assert_matches_type(DeploymentListResponse, deployment, path=["response"])
315+
316+
@pytest.mark.skip()
317+
@parametrize
318+
async def test_method_list_with_all_params(self, async_client: AsyncKernel) -> None:
319+
deployment = await async_client.deployments.list(
320+
app_name="app_name",
321+
)
322+
assert_matches_type(DeploymentListResponse, deployment, path=["response"])
323+
324+
@pytest.mark.skip()
325+
@parametrize
326+
async def test_raw_response_list(self, async_client: AsyncKernel) -> None:
327+
response = await async_client.deployments.with_raw_response.list()
328+
329+
assert response.is_closed is True
330+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
331+
deployment = await response.parse()
332+
assert_matches_type(DeploymentListResponse, deployment, path=["response"])
333+
334+
@pytest.mark.skip()
335+
@parametrize
336+
async def test_streaming_response_list(self, async_client: AsyncKernel) -> None:
337+
async with async_client.deployments.with_streaming_response.list() as response:
338+
assert not response.is_closed
339+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
340+
341+
deployment = await response.parse()
342+
assert_matches_type(DeploymentListResponse, deployment, path=["response"])
343+
344+
assert cast(Any, response.is_closed) is True
345+
273346
@pytest.mark.skip(
274347
reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail"
275348
)

0 commit comments

Comments
 (0)