Skip to content

Commit f9a0937

Browse files
feat: Neil/kernel 872 templates v3
1 parent 4f7dfd1 commit f9a0937

4 files changed

Lines changed: 120 additions & 4 deletions

File tree

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 97
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-c955031ac0bb644c0aa1d1120e288f703168abeb0e44a166f55119295f737cc5.yml
3-
openapi_spec_hash: 9fbc24cdaccdd21264e995df40b52d3f
4-
config_hash: b470456b217bb9502f5212311d395a6f
1+
configured_endpoints: 98
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-ccbe854895eb34a9562e33979f5f43cd6ad1f529d5924ee56e56f0c94dcf0454.yml
3+
openapi_spec_hash: 2fa4ecbe742fc46fdde481188c1d885e
4+
config_hash: dd218aae3f852dff79e77febc2077b8e

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Response Types:
5353
- <a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#InvocationUpdateResponse">InvocationUpdateResponse</a>
5454
- <a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#InvocationListResponse">InvocationListResponse</a>
5555
- <a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#InvocationFollowResponseUnion">InvocationFollowResponseUnion</a>
56+
- <a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#InvocationListBrowsersResponse">InvocationListBrowsersResponse</a>
5657

5758
Methods:
5859

@@ -62,6 +63,7 @@ Methods:
6263
- <code title="get /invocations">client.Invocations.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#InvocationService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#InvocationListParams">InvocationListParams</a>) (\*<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk/packages/pagination#OffsetPagination">OffsetPagination</a>[<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#InvocationListResponse">InvocationListResponse</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
6364
- <code title="delete /invocations/{id}/browsers">client.Invocations.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#InvocationService.DeleteBrowsers">DeleteBrowsers</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
6465
- <code title="get /invocations/{id}/events">client.Invocations.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#InvocationService.Follow">Follow</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#InvocationFollowParams">InvocationFollowParams</a>) (\*<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#InvocationFollowResponseUnion">InvocationFollowResponseUnion</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
66+
- <code title="get /invocations/{id}/browsers">client.Invocations.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#InvocationService.ListBrowsers">ListBrowsers</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) (\*<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#InvocationListBrowsersResponse">InvocationListBrowsersResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
6567

6668
# Browsers
6769

invocation.go

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ func (r *InvocationService) FollowStreaming(ctx context.Context, id string, quer
133133
return ssestream.NewStream[InvocationFollowResponseUnion](ssestream.NewDecoder(raw), err)
134134
}
135135

136+
// Returns all active browser sessions created within the specified invocation.
137+
func (r *InvocationService) ListBrowsers(ctx context.Context, id string, opts ...option.RequestOption) (res *InvocationListBrowsersResponse, err error) {
138+
opts = slices.Concat(r.Options, opts)
139+
if id == "" {
140+
err = errors.New("missing required id parameter")
141+
return
142+
}
143+
path := fmt.Sprintf("invocations/%s/browsers", id)
144+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
145+
return
146+
}
147+
136148
// An event representing the current state of an invocation.
137149
type InvocationStateEvent struct {
138150
// Event type identifier (always "invocation_state").
@@ -507,6 +519,85 @@ func (r *InvocationFollowResponseUnion) UnmarshalJSON(data []byte) error {
507519
return apijson.UnmarshalRoot(data, r)
508520
}
509521

522+
type InvocationListBrowsersResponse struct {
523+
Browsers []InvocationListBrowsersResponseBrowser `json:"browsers,required"`
524+
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
525+
JSON struct {
526+
Browsers respjson.Field
527+
ExtraFields map[string]respjson.Field
528+
raw string
529+
} `json:"-"`
530+
}
531+
532+
// Returns the unmodified JSON received from the API
533+
func (r InvocationListBrowsersResponse) RawJSON() string { return r.JSON.raw }
534+
func (r *InvocationListBrowsersResponse) UnmarshalJSON(data []byte) error {
535+
return apijson.UnmarshalRoot(data, r)
536+
}
537+
538+
type InvocationListBrowsersResponseBrowser struct {
539+
// Websocket URL for Chrome DevTools Protocol connections to the browser session
540+
CdpWsURL string `json:"cdp_ws_url,required"`
541+
// When the browser session was created.
542+
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
543+
// Whether the browser session is running in headless mode.
544+
Headless bool `json:"headless,required"`
545+
// Unique identifier for the browser session
546+
SessionID string `json:"session_id,required"`
547+
// Whether the browser session is running in stealth mode.
548+
Stealth bool `json:"stealth,required"`
549+
// The number of seconds of inactivity before the browser session is terminated.
550+
TimeoutSeconds int64 `json:"timeout_seconds,required"`
551+
// Remote URL for live viewing the browser session. Only available for non-headless
552+
// browsers.
553+
BrowserLiveViewURL string `json:"browser_live_view_url"`
554+
// When the browser session was soft-deleted. Only present for deleted sessions.
555+
DeletedAt time.Time `json:"deleted_at" format:"date-time"`
556+
// Whether the browser session is running in kiosk mode.
557+
KioskMode bool `json:"kiosk_mode"`
558+
// DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles instead.
559+
//
560+
// Deprecated: deprecated
561+
Persistence BrowserPersistence `json:"persistence"`
562+
// Browser profile metadata.
563+
Profile Profile `json:"profile"`
564+
// ID of the proxy associated with this browser session, if any.
565+
ProxyID string `json:"proxy_id"`
566+
// Initial browser window size in pixels with optional refresh rate. If omitted,
567+
// image defaults apply (1920x1080@25). Only specific viewport configurations are
568+
// supported. The server will reject unsupported combinations. Supported
569+
// resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25, 1440x900@25,
570+
// 1280x800@60, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will
571+
// be automatically determined from the width and height if they match a supported
572+
// configuration exactly. Note: Higher resolutions may affect the responsiveness of
573+
// live view browser
574+
Viewport shared.BrowserViewport `json:"viewport"`
575+
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
576+
JSON struct {
577+
CdpWsURL respjson.Field
578+
CreatedAt respjson.Field
579+
Headless respjson.Field
580+
SessionID respjson.Field
581+
Stealth respjson.Field
582+
TimeoutSeconds respjson.Field
583+
BrowserLiveViewURL respjson.Field
584+
DeletedAt respjson.Field
585+
KioskMode respjson.Field
586+
Persistence respjson.Field
587+
Profile respjson.Field
588+
ProxyID respjson.Field
589+
Viewport respjson.Field
590+
ExtraFields map[string]respjson.Field
591+
raw string
592+
} `json:"-"`
593+
}
594+
595+
// Returns the unmodified JSON received from the API
596+
func (r InvocationListBrowsersResponseBrowser) RawJSON() string { return r.JSON.raw }
597+
func (r *InvocationListBrowsersResponseBrowser) UnmarshalJSON(data []byte) error {
598+
return apijson.UnmarshalRoot(data, r)
599+
}
600+
510601
type InvocationNewParams struct {
511602
// Name of the action to invoke
512603
ActionName string `json:"action_name,required"`

invocation_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,26 @@ func TestInvocationDeleteBrowsers(t *testing.T) {
150150
t.Fatalf("err should be nil: %s", err.Error())
151151
}
152152
}
153+
154+
func TestInvocationListBrowsers(t *testing.T) {
155+
t.Skip("Prism tests are disabled")
156+
baseURL := "http://localhost:4010"
157+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
158+
baseURL = envURL
159+
}
160+
if !testutil.CheckTestServer(t, baseURL) {
161+
return
162+
}
163+
client := kernel.NewClient(
164+
option.WithBaseURL(baseURL),
165+
option.WithAPIKey("My API Key"),
166+
)
167+
_, err := client.Invocations.ListBrowsers(context.TODO(), "id")
168+
if err != nil {
169+
var apierr *kernel.Error
170+
if errors.As(err, &apierr) {
171+
t.Log(string(apierr.DumpRequest(true)))
172+
}
173+
t.Fatalf("err should be nil: %s", err.Error())
174+
}
175+
}

0 commit comments

Comments
 (0)