Skip to content

Commit 83ccedb

Browse files
feat: getInvocations endpoint
1 parent 1d89a86 commit 83ccedb

File tree

7 files changed

+330
-6
lines changed

7 files changed

+330
-6
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: 50
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-5ee2116982adf46664acf84b8ba4b56ba65780983506c63d9b005dab49def757.yml
3-
openapi_spec_hash: 42a3a519301d0e2bb2b5a71018915b55
4-
config_hash: 0d150b61cae2dc57d3648ceae7784966
1+
configured_endpoints: 51
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-8b5a722e4964d2d1dcdc34afccb6d742e1c927cbbd622264c8734f132e31a0f5.yml
3+
openapi_spec_hash: ed101ff177c2e962653ca65acf939336
4+
config_hash: 49c2ff978aaa5ccb4ce324a72f116010

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ from kernel.types import (
4747
InvocationCreateResponse,
4848
InvocationRetrieveResponse,
4949
InvocationUpdateResponse,
50+
InvocationListResponse,
5051
InvocationFollowResponse,
5152
)
5253
```
@@ -56,6 +57,7 @@ Methods:
5657
- <code title="post /invocations">client.invocations.<a href="./src/kernel/resources/invocations.py">create</a>(\*\*<a href="src/kernel/types/invocation_create_params.py">params</a>) -> <a href="./src/kernel/types/invocation_create_response.py">InvocationCreateResponse</a></code>
5758
- <code title="get /invocations/{id}">client.invocations.<a href="./src/kernel/resources/invocations.py">retrieve</a>(id) -> <a href="./src/kernel/types/invocation_retrieve_response.py">InvocationRetrieveResponse</a></code>
5859
- <code title="patch /invocations/{id}">client.invocations.<a href="./src/kernel/resources/invocations.py">update</a>(id, \*\*<a href="src/kernel/types/invocation_update_params.py">params</a>) -> <a href="./src/kernel/types/invocation_update_response.py">InvocationUpdateResponse</a></code>
60+
- <code title="get /invocations">client.invocations.<a href="./src/kernel/resources/invocations.py">list</a>(\*\*<a href="src/kernel/types/invocation_list_params.py">params</a>) -> <a href="./src/kernel/types/invocation_list_response.py">SyncOffsetPagination[InvocationListResponse]</a></code>
5961
- <code title="delete /invocations/{id}/browsers">client.invocations.<a href="./src/kernel/resources/invocations.py">delete_browsers</a>(id) -> None</code>
6062
- <code title="get /invocations/{id}/events">client.invocations.<a href="./src/kernel/resources/invocations.py">follow</a>(id, \*\*<a href="src/kernel/types/invocation_follow_params.py">params</a>) -> <a href="./src/kernel/types/invocation_follow_response.py">InvocationFollowResponse</a></code>
6163

src/kernel/resources/invocations.py

Lines changed: 156 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import httpx
99

10-
from ..types import invocation_create_params, invocation_follow_params, invocation_update_params
10+
from ..types import invocation_list_params, invocation_create_params, invocation_follow_params, invocation_update_params
1111
from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given
1212
from .._utils import maybe_transform, async_maybe_transform
1313
from .._compat import cached_property
@@ -19,7 +19,9 @@
1919
async_to_streamed_response_wrapper,
2020
)
2121
from .._streaming import Stream, AsyncStream
22-
from .._base_client import make_request_options
22+
from ..pagination import SyncOffsetPagination, AsyncOffsetPagination
23+
from .._base_client import AsyncPaginator, make_request_options
24+
from ..types.invocation_list_response import InvocationListResponse
2325
from ..types.invocation_create_response import InvocationCreateResponse
2426
from ..types.invocation_follow_response import InvocationFollowResponse
2527
from ..types.invocation_update_response import InvocationUpdateResponse
@@ -185,6 +187,76 @@ def update(
185187
cast_to=InvocationUpdateResponse,
186188
)
187189

190+
def list(
191+
self,
192+
*,
193+
action_name: str | Omit = omit,
194+
app_name: str | Omit = omit,
195+
deployment_id: str | Omit = omit,
196+
limit: int | Omit = omit,
197+
offset: int | Omit = omit,
198+
since: str | Omit = omit,
199+
status: Literal["queued", "running", "succeeded", "failed"] | Omit = omit,
200+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
201+
# The extra values given here take precedence over values defined on the client or passed to this method.
202+
extra_headers: Headers | None = None,
203+
extra_query: Query | None = None,
204+
extra_body: Body | None = None,
205+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
206+
) -> SyncOffsetPagination[InvocationListResponse]:
207+
"""List invocations.
208+
209+
Optionally filter by application name, action name, status,
210+
deployment ID, or start time.
211+
212+
Args:
213+
action_name: Filter results by action name.
214+
215+
app_name: Filter results by application name.
216+
217+
deployment_id: Filter results by deployment ID.
218+
219+
limit: Limit the number of invocations to return.
220+
221+
offset: Offset the number of invocations to return.
222+
223+
since: Show invocations that have started since the given time (RFC timestamps or
224+
durations like 5m).
225+
226+
status: Filter results by invocation status.
227+
228+
extra_headers: Send extra headers
229+
230+
extra_query: Add additional query parameters to the request
231+
232+
extra_body: Add additional JSON properties to the request
233+
234+
timeout: Override the client-level default timeout for this request, in seconds
235+
"""
236+
return self._get_api_list(
237+
"/invocations",
238+
page=SyncOffsetPagination[InvocationListResponse],
239+
options=make_request_options(
240+
extra_headers=extra_headers,
241+
extra_query=extra_query,
242+
extra_body=extra_body,
243+
timeout=timeout,
244+
query=maybe_transform(
245+
{
246+
"action_name": action_name,
247+
"app_name": app_name,
248+
"deployment_id": deployment_id,
249+
"limit": limit,
250+
"offset": offset,
251+
"since": since,
252+
"status": status,
253+
},
254+
invocation_list_params.InvocationListParams,
255+
),
256+
),
257+
model=InvocationListResponse,
258+
)
259+
188260
def delete_browsers(
189261
self,
190262
id: str,
@@ -424,6 +496,76 @@ async def update(
424496
cast_to=InvocationUpdateResponse,
425497
)
426498

499+
def list(
500+
self,
501+
*,
502+
action_name: str | Omit = omit,
503+
app_name: str | Omit = omit,
504+
deployment_id: str | Omit = omit,
505+
limit: int | Omit = omit,
506+
offset: int | Omit = omit,
507+
since: str | Omit = omit,
508+
status: Literal["queued", "running", "succeeded", "failed"] | Omit = omit,
509+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
510+
# The extra values given here take precedence over values defined on the client or passed to this method.
511+
extra_headers: Headers | None = None,
512+
extra_query: Query | None = None,
513+
extra_body: Body | None = None,
514+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
515+
) -> AsyncPaginator[InvocationListResponse, AsyncOffsetPagination[InvocationListResponse]]:
516+
"""List invocations.
517+
518+
Optionally filter by application name, action name, status,
519+
deployment ID, or start time.
520+
521+
Args:
522+
action_name: Filter results by action name.
523+
524+
app_name: Filter results by application name.
525+
526+
deployment_id: Filter results by deployment ID.
527+
528+
limit: Limit the number of invocations to return.
529+
530+
offset: Offset the number of invocations to return.
531+
532+
since: Show invocations that have started since the given time (RFC timestamps or
533+
durations like 5m).
534+
535+
status: Filter results by invocation status.
536+
537+
extra_headers: Send extra headers
538+
539+
extra_query: Add additional query parameters to the request
540+
541+
extra_body: Add additional JSON properties to the request
542+
543+
timeout: Override the client-level default timeout for this request, in seconds
544+
"""
545+
return self._get_api_list(
546+
"/invocations",
547+
page=AsyncOffsetPagination[InvocationListResponse],
548+
options=make_request_options(
549+
extra_headers=extra_headers,
550+
extra_query=extra_query,
551+
extra_body=extra_body,
552+
timeout=timeout,
553+
query=maybe_transform(
554+
{
555+
"action_name": action_name,
556+
"app_name": app_name,
557+
"deployment_id": deployment_id,
558+
"limit": limit,
559+
"offset": offset,
560+
"since": since,
561+
"status": status,
562+
},
563+
invocation_list_params.InvocationListParams,
564+
),
565+
),
566+
model=InvocationListResponse,
567+
)
568+
427569
async def delete_browsers(
428570
self,
429571
id: str,
@@ -519,6 +661,9 @@ def __init__(self, invocations: InvocationsResource) -> None:
519661
self.update = to_raw_response_wrapper(
520662
invocations.update,
521663
)
664+
self.list = to_raw_response_wrapper(
665+
invocations.list,
666+
)
522667
self.delete_browsers = to_raw_response_wrapper(
523668
invocations.delete_browsers,
524669
)
@@ -540,6 +685,9 @@ def __init__(self, invocations: AsyncInvocationsResource) -> None:
540685
self.update = async_to_raw_response_wrapper(
541686
invocations.update,
542687
)
688+
self.list = async_to_raw_response_wrapper(
689+
invocations.list,
690+
)
543691
self.delete_browsers = async_to_raw_response_wrapper(
544692
invocations.delete_browsers,
545693
)
@@ -561,6 +709,9 @@ def __init__(self, invocations: InvocationsResource) -> None:
561709
self.update = to_streamed_response_wrapper(
562710
invocations.update,
563711
)
712+
self.list = to_streamed_response_wrapper(
713+
invocations.list,
714+
)
564715
self.delete_browsers = to_streamed_response_wrapper(
565716
invocations.delete_browsers,
566717
)
@@ -582,6 +733,9 @@ def __init__(self, invocations: AsyncInvocationsResource) -> None:
582733
self.update = async_to_streamed_response_wrapper(
583734
invocations.update,
584735
)
736+
self.list = async_to_streamed_response_wrapper(
737+
invocations.list,
738+
)
585739
self.delete_browsers = async_to_streamed_response_wrapper(
586740
invocations.delete_browsers,
587741
)

src/kernel/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from .proxy_create_response import ProxyCreateResponse as ProxyCreateResponse
2525
from .deployment_list_params import DeploymentListParams as DeploymentListParams
2626
from .deployment_state_event import DeploymentStateEvent as DeploymentStateEvent
27+
from .invocation_list_params import InvocationListParams as InvocationListParams
2728
from .invocation_state_event import InvocationStateEvent as InvocationStateEvent
2829
from .browser_create_response import BrowserCreateResponse as BrowserCreateResponse
2930
from .proxy_retrieve_response import ProxyRetrieveResponse as ProxyRetrieveResponse
@@ -32,6 +33,7 @@
3233
from .deployment_list_response import DeploymentListResponse as DeploymentListResponse
3334
from .invocation_create_params import InvocationCreateParams as InvocationCreateParams
3435
from .invocation_follow_params import InvocationFollowParams as InvocationFollowParams
36+
from .invocation_list_response import InvocationListResponse as InvocationListResponse
3537
from .invocation_update_params import InvocationUpdateParams as InvocationUpdateParams
3638
from .browser_persistence_param import BrowserPersistenceParam as BrowserPersistenceParam
3739
from .browser_retrieve_response import BrowserRetrieveResponse as BrowserRetrieveResponse
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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 Literal, TypedDict
6+
7+
__all__ = ["InvocationListParams"]
8+
9+
10+
class InvocationListParams(TypedDict, total=False):
11+
action_name: str
12+
"""Filter results by action name."""
13+
14+
app_name: str
15+
"""Filter results by application name."""
16+
17+
deployment_id: str
18+
"""Filter results by deployment ID."""
19+
20+
limit: int
21+
"""Limit the number of invocations to return."""
22+
23+
offset: int
24+
"""Offset the number of invocations to return."""
25+
26+
since: str
27+
"""
28+
Show invocations that have started since the given time (RFC timestamps or
29+
durations like 5m).
30+
"""
31+
32+
status: Literal["queued", "running", "succeeded", "failed"]
33+
"""Filter results by invocation status."""
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import Optional
4+
from datetime import datetime
5+
from typing_extensions import Literal
6+
7+
from .._models import BaseModel
8+
9+
__all__ = ["InvocationListResponse"]
10+
11+
12+
class InvocationListResponse(BaseModel):
13+
id: str
14+
"""ID of the invocation"""
15+
16+
action_name: str
17+
"""Name of the action invoked"""
18+
19+
app_name: str
20+
"""Name of the application"""
21+
22+
started_at: datetime
23+
"""RFC 3339 Nanoseconds timestamp when the invocation started"""
24+
25+
status: Literal["queued", "running", "succeeded", "failed"]
26+
"""Status of the invocation"""
27+
28+
finished_at: Optional[datetime] = None
29+
"""
30+
RFC 3339 Nanoseconds timestamp when the invocation finished (null if still
31+
running)
32+
"""
33+
34+
output: Optional[str] = None
35+
"""Output produced by the action, rendered as a JSON string.
36+
37+
This could be: string, number, boolean, array, object, or null.
38+
"""
39+
40+
payload: Optional[str] = None
41+
"""Payload provided to the invocation.
42+
43+
This is a string that can be parsed as JSON.
44+
"""
45+
46+
status_reason: Optional[str] = None
47+
"""Status reason"""

0 commit comments

Comments
 (0)