Skip to content

Commit 6359d12

Browse files
feat(api): update via SDK Studio
1 parent af16985 commit 6359d12

File tree

6 files changed

+258
-5
lines changed

6 files changed

+258
-5
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 5
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-3b19f5e2b96ede3193aa7a24d3f82d1406b8a16ea25e98ba3956e4a1a2376ad7.yml
3-
openapi_spec_hash: b62a6e73ddcec71674973f795a5790ac
4-
config_hash: df889df131f7438197abd59faace3c77
1+
configured_endpoints: 6
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-19b0d17ba368f32827ee322d15a7f4ff7e1f3bbf66606fad227b3465f8ffc5ab.yml
3+
openapi_spec_hash: 4a3cb766898e8a134ef99fe6c4c87736
4+
config_hash: 9018b7ff17f8de1bc3e99a0ae2f2df68

api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
Types:
66

77
```python
8-
from kernel.types.apps import DeploymentCreateResponse
8+
from kernel.types.apps import DeploymentCreateResponse, DeploymentFollowResponse
99
```
1010

1111
Methods:
1212

1313
- <code title="post /deploy">client.apps.deployments.<a href="./src/kernel/resources/apps/deployments.py">create</a>(\*\*<a href="src/kernel/types/apps/deployment_create_params.py">params</a>) -> <a href="./src/kernel/types/apps/deployment_create_response.py">DeploymentCreateResponse</a></code>
14+
- <code title="get /apps/{id}/events">client.apps.deployments.<a href="./src/kernel/resources/apps/deployments.py">follow</a>(id) -> <a href="./src/kernel/types/apps/deployment_follow_response.py">DeploymentFollowResponse</a></code>
1415

1516
## Invocations
1617

src/kernel/resources/apps/deployments.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
async_to_raw_response_wrapper,
1818
async_to_streamed_response_wrapper,
1919
)
20+
from ..._streaming import Stream, AsyncStream
2021
from ...types.apps import deployment_create_params
2122
from ..._base_client import make_request_options
2223
from ...types.apps.deployment_create_response import DeploymentCreateResponse
24+
from ...types.apps.deployment_follow_response import DeploymentFollowResponse
2325

2426
__all__ = ["DeploymentsResource", "AsyncDeploymentsResource"]
2527

@@ -110,6 +112,44 @@ def create(
110112
cast_to=DeploymentCreateResponse,
111113
)
112114

115+
def follow(
116+
self,
117+
id: str,
118+
*,
119+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
120+
# The extra values given here take precedence over values defined on the client or passed to this method.
121+
extra_headers: Headers | None = None,
122+
extra_query: Query | None = None,
123+
extra_body: Body | None = None,
124+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
125+
) -> Stream[DeploymentFollowResponse]:
126+
"""
127+
Establishes a Server-Sent Events (SSE) stream that delivers real-time logs and
128+
status updates for a deployed application. The stream terminates automatically
129+
once the application reaches a terminal state.
130+
131+
Args:
132+
extra_headers: Send extra headers
133+
134+
extra_query: Add additional query parameters to the request
135+
136+
extra_body: Add additional JSON properties to the request
137+
138+
timeout: Override the client-level default timeout for this request, in seconds
139+
"""
140+
if not id:
141+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
142+
extra_headers = {"Accept": "text/event-stream", **(extra_headers or {})}
143+
return self._get(
144+
f"/apps/{id}/events",
145+
options=make_request_options(
146+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
147+
),
148+
cast_to=DeploymentFollowResponse,
149+
stream=True,
150+
stream_cls=Stream[DeploymentFollowResponse],
151+
)
152+
113153

114154
class AsyncDeploymentsResource(AsyncAPIResource):
115155
@cached_property
@@ -197,6 +237,44 @@ async def create(
197237
cast_to=DeploymentCreateResponse,
198238
)
199239

240+
async def follow(
241+
self,
242+
id: str,
243+
*,
244+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
245+
# The extra values given here take precedence over values defined on the client or passed to this method.
246+
extra_headers: Headers | None = None,
247+
extra_query: Query | None = None,
248+
extra_body: Body | None = None,
249+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
250+
) -> AsyncStream[DeploymentFollowResponse]:
251+
"""
252+
Establishes a Server-Sent Events (SSE) stream that delivers real-time logs and
253+
status updates for a deployed application. The stream terminates automatically
254+
once the application reaches a terminal state.
255+
256+
Args:
257+
extra_headers: Send extra headers
258+
259+
extra_query: Add additional query parameters to the request
260+
261+
extra_body: Add additional JSON properties to the request
262+
263+
timeout: Override the client-level default timeout for this request, in seconds
264+
"""
265+
if not id:
266+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
267+
extra_headers = {"Accept": "text/event-stream", **(extra_headers or {})}
268+
return await self._get(
269+
f"/apps/{id}/events",
270+
options=make_request_options(
271+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
272+
),
273+
cast_to=DeploymentFollowResponse,
274+
stream=True,
275+
stream_cls=AsyncStream[DeploymentFollowResponse],
276+
)
277+
200278

201279
class DeploymentsResourceWithRawResponse:
202280
def __init__(self, deployments: DeploymentsResource) -> None:
@@ -205,6 +283,9 @@ def __init__(self, deployments: DeploymentsResource) -> None:
205283
self.create = to_raw_response_wrapper(
206284
deployments.create,
207285
)
286+
self.follow = to_raw_response_wrapper(
287+
deployments.follow,
288+
)
208289

209290

210291
class AsyncDeploymentsResourceWithRawResponse:
@@ -214,6 +295,9 @@ def __init__(self, deployments: AsyncDeploymentsResource) -> None:
214295
self.create = async_to_raw_response_wrapper(
215296
deployments.create,
216297
)
298+
self.follow = async_to_raw_response_wrapper(
299+
deployments.follow,
300+
)
217301

218302

219303
class DeploymentsResourceWithStreamingResponse:
@@ -223,6 +307,9 @@ def __init__(self, deployments: DeploymentsResource) -> None:
223307
self.create = to_streamed_response_wrapper(
224308
deployments.create,
225309
)
310+
self.follow = to_streamed_response_wrapper(
311+
deployments.follow,
312+
)
226313

227314

228315
class AsyncDeploymentsResourceWithStreamingResponse:
@@ -232,3 +319,6 @@ def __init__(self, deployments: AsyncDeploymentsResource) -> None:
232319
self.create = async_to_streamed_response_wrapper(
233320
deployments.create,
234321
)
322+
self.follow = async_to_streamed_response_wrapper(
323+
deployments.follow,
324+
)

src/kernel/types/apps/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
from .deployment_create_params import DeploymentCreateParams as DeploymentCreateParams
66
from .invocation_create_params import InvocationCreateParams as InvocationCreateParams
77
from .deployment_create_response import DeploymentCreateResponse as DeploymentCreateResponse
8+
from .deployment_follow_response import DeploymentFollowResponse as DeploymentFollowResponse
89
from .invocation_create_response import InvocationCreateResponse as InvocationCreateResponse
910
from .invocation_retrieve_response import InvocationRetrieveResponse as InvocationRetrieveResponse
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import List, Union, Optional
4+
from datetime import datetime
5+
from typing_extensions import Literal, Annotated, TypeAlias
6+
7+
from ..._utils import PropertyInfo
8+
from ..._models import BaseModel
9+
10+
__all__ = [
11+
"DeploymentFollowResponse",
12+
"DeploymentFollowResponseItem",
13+
"DeploymentFollowResponseItemStateEvent",
14+
"DeploymentFollowResponseItemStateUpdateEvent",
15+
"DeploymentFollowResponseItemLogEvent",
16+
]
17+
18+
19+
class DeploymentFollowResponseItemStateEvent(BaseModel):
20+
event: Literal["state"]
21+
"""Event type identifier (always "state")."""
22+
23+
state: str
24+
"""
25+
Current application state (e.g., "deploying", "running", "succeeded", "failed").
26+
"""
27+
28+
timestamp: Optional[datetime] = None
29+
"""Time the state was reported."""
30+
31+
32+
class DeploymentFollowResponseItemStateUpdateEvent(BaseModel):
33+
event: Literal["state_update"]
34+
"""Event type identifier (always "state_update")."""
35+
36+
state: str
37+
"""New application state (e.g., "running", "succeeded", "failed")."""
38+
39+
timestamp: Optional[datetime] = None
40+
"""Time the state change occurred."""
41+
42+
43+
class DeploymentFollowResponseItemLogEvent(BaseModel):
44+
event: Literal["log"]
45+
"""Event type identifier (always "log")."""
46+
47+
message: str
48+
"""Log message text."""
49+
50+
timestamp: Optional[datetime] = None
51+
"""Time the log entry was produced."""
52+
53+
54+
DeploymentFollowResponseItem: TypeAlias = Annotated[
55+
Union[
56+
DeploymentFollowResponseItemStateEvent,
57+
DeploymentFollowResponseItemStateUpdateEvent,
58+
DeploymentFollowResponseItemLogEvent,
59+
],
60+
PropertyInfo(discriminator="event"),
61+
]
62+
63+
DeploymentFollowResponse: TypeAlias = List[DeploymentFollowResponseItem]

tests/api_resources/apps/test_deployments.py

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,55 @@ def test_streaming_response_create(self, client: Kernel) -> None:
6767

6868
assert cast(Any, response.is_closed) is True
6969

70+
@pytest.mark.skip(
71+
reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail"
72+
)
73+
@parametrize
74+
def test_method_follow(self, client: Kernel) -> None:
75+
deployment_stream = client.apps.deployments.follow(
76+
"id",
77+
)
78+
deployment_stream.response.close()
79+
80+
@pytest.mark.skip(
81+
reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail"
82+
)
83+
@parametrize
84+
def test_raw_response_follow(self, client: Kernel) -> None:
85+
response = client.apps.deployments.with_raw_response.follow(
86+
"id",
87+
)
88+
89+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
90+
stream = response.parse()
91+
stream.close()
92+
93+
@pytest.mark.skip(
94+
reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail"
95+
)
96+
@parametrize
97+
def test_streaming_response_follow(self, client: Kernel) -> None:
98+
with client.apps.deployments.with_streaming_response.follow(
99+
"id",
100+
) as response:
101+
assert not response.is_closed
102+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
103+
104+
stream = response.parse()
105+
stream.close()
106+
107+
assert cast(Any, response.is_closed) is True
108+
109+
@pytest.mark.skip(
110+
reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail"
111+
)
112+
@parametrize
113+
def test_path_params_follow(self, client: Kernel) -> None:
114+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
115+
client.apps.deployments.with_raw_response.follow(
116+
"",
117+
)
118+
70119

71120
class TestAsyncDeployments:
72121
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
@@ -120,3 +169,52 @@ async def test_streaming_response_create(self, async_client: AsyncKernel) -> Non
120169
assert_matches_type(DeploymentCreateResponse, deployment, path=["response"])
121170

122171
assert cast(Any, response.is_closed) is True
172+
173+
@pytest.mark.skip(
174+
reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail"
175+
)
176+
@parametrize
177+
async def test_method_follow(self, async_client: AsyncKernel) -> None:
178+
deployment_stream = await async_client.apps.deployments.follow(
179+
"id",
180+
)
181+
await deployment_stream.response.aclose()
182+
183+
@pytest.mark.skip(
184+
reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail"
185+
)
186+
@parametrize
187+
async def test_raw_response_follow(self, async_client: AsyncKernel) -> None:
188+
response = await async_client.apps.deployments.with_raw_response.follow(
189+
"id",
190+
)
191+
192+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
193+
stream = await response.parse()
194+
await stream.close()
195+
196+
@pytest.mark.skip(
197+
reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail"
198+
)
199+
@parametrize
200+
async def test_streaming_response_follow(self, async_client: AsyncKernel) -> None:
201+
async with async_client.apps.deployments.with_streaming_response.follow(
202+
"id",
203+
) as response:
204+
assert not response.is_closed
205+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
206+
207+
stream = await response.parse()
208+
await stream.close()
209+
210+
assert cast(Any, response.is_closed) is True
211+
212+
@pytest.mark.skip(
213+
reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail"
214+
)
215+
@parametrize
216+
async def test_path_params_follow(self, async_client: AsyncKernel) -> None:
217+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
218+
await async_client.apps.deployments.with_raw_response.follow(
219+
"",
220+
)

0 commit comments

Comments
 (0)