kernel

package module
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

README

Kernel Go API Library

Go Reference

The Kernel Go library provides convenient access to the Kernel REST API from applications written in Go.

It is generated with Stainless.

Installation

import (
	"github.com/onkernel/kernel-go-sdk" // imported as kernel
)

Or to pin the version:

go get -u 'github.com/onkernel/kernel-go-sdk@v0.9.1'

Requirements

This library requires Go 1.18+.

Usage

The full API of this library can be found in api.md.

package main

import (
	"context"
	"fmt"

	"github.com/onkernel/kernel-go-sdk"
	"github.com/onkernel/kernel-go-sdk/option"
)

func main() {
	client := kernel.NewClient(
		option.WithAPIKey("My API Key"),     // defaults to os.LookupEnv("KERNEL_API_KEY")
		option.WithEnvironmentDevelopment(), // defaults to option.WithEnvironmentProduction()
	)
	browser, err := client.Browsers.New(context.TODO(), kernel.BrowserNewParams{
		Persistence: kernel.BrowserPersistenceParam{
			ID: "browser-for-user-1234",
		},
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", browser.SessionID)
}

Request fields

The kernel library uses the omitzero semantics from the Go 1.24+ encoding/json release for request fields.

Required primitive fields (int64, string, etc.) feature the tag `json:"...,required"`. These fields are always serialized, even their zero values.

Optional primitive types are wrapped in a param.Opt[T]. These fields can be set with the provided constructors, kernel.String(string), kernel.Int(int64), etc.

Any param.Opt[T], map, slice, struct or string enum uses the tag `json:"...,omitzero"`. Its zero value is considered omitted.

The param.IsOmitted(any) function can confirm the presence of any omitzero field.

p := kernel.ExampleParams{
	ID:   "id_xxx",             // required property
	Name: kernel.String("..."), // optional property

	Point: kernel.Point{
		X: 0,             // required field will serialize as 0
		Y: kernel.Int(1), // optional field will serialize as 1
		// ... omitted non-required fields will not be serialized
	},

	Origin: kernel.Origin{}, // the zero value of [Origin] is considered omitted
}

To send null instead of a param.Opt[T], use param.Null[T](). To send null instead of a struct T, use param.NullStruct[T]().

p.Name = param.Null[string]()       // 'null' instead of string
p.Point = param.NullStruct[Point]() // 'null' instead of struct

param.IsNull(p.Name)  // true
param.IsNull(p.Point) // true

Request structs contain a .SetExtraFields(map[string]any) method which can send non-conforming fields in the request body. Extra fields overwrite any struct fields with a matching key. For security reasons, only use SetExtraFields with trusted data.

To send a custom value instead of a struct, use param.Override[T](value).

// In cases where the API specifies a given type,
// but you want to send something else, use [SetExtraFields]:
p.SetExtraFields(map[string]any{
	"x": 0.01, // send "x" as a float instead of int
})

// Send a number instead of an object
custom := param.Override[kernel.FooParams](12)
Request unions

Unions are represented as a struct with fields prefixed by "Of" for each of it's variants, only one field can be non-zero. The non-zero field will be serialized.

Sub-properties of the union can be accessed via methods on the union struct. These methods return a mutable pointer to the underlying data, if present.

// Only one field can be non-zero, use param.IsOmitted() to check if a field is set
type AnimalUnionParam struct {
	OfCat *Cat `json:",omitzero,inline`
	OfDog *Dog `json:",omitzero,inline`
}

animal := AnimalUnionParam{
	OfCat: &Cat{
		Name: "Whiskers",
		Owner: PersonParam{
			Address: AddressParam{Street: "3333 Coyote Hill Rd", Zip: 0},
		},
	},
}

// Mutating a field
if address := animal.GetOwner().GetAddress(); address != nil {
	address.ZipCode = 94304
}
Response objects

All fields in response structs are ordinary value types (not pointers or wrappers). Response structs also include a special JSON field containing metadata about each property.

type Animal struct {
	Name   string `json:"name,nullable"`
	Owners int    `json:"owners"`
	Age    int    `json:"age"`
	JSON   struct {
		Name        respjson.Field
		Owner       respjson.Field
		Age         respjson.Field
		ExtraFields map[string]respjson.Field
	} `json:"-"`
}

To handle optional data, use the .Valid() method on the JSON field. .Valid() returns true if a field is not null, not present, or couldn't be marshaled.

If .Valid() is false, the corresponding field will simply be its zero value.

raw := `{"owners": 1, "name": null}`

var res Animal
json.Unmarshal([]byte(raw), &res)

// Accessing regular fields

res.Owners // 1
res.Name   // ""
res.Age    // 0

// Optional field checks

res.JSON.Owners.Valid() // true
res.JSON.Name.Valid()   // false
res.JSON.Age.Valid()    // false

// Raw JSON values

res.JSON.Owners.Raw()                  // "1"
res.JSON.Name.Raw() == "null"          // true
res.JSON.Name.Raw() == respjson.Null   // true
res.JSON.Age.Raw() == ""               // true
res.JSON.Age.Raw() == respjson.Omitted // true

These .JSON structs also include an ExtraFields map containing any properties in the json response that were not specified in the struct. This can be useful for API features not yet present in the SDK.

body := res.JSON.ExtraFields["my_unexpected_field"].Raw()
Response Unions

In responses, unions are represented by a flattened struct containing all possible fields from each of the object variants. To convert it to a variant use the .AsFooVariant() method or the .AsAny() method if present.

If a response value union contains primitive values, primitive fields will be alongside the properties but prefixed with Of and feature the tag json:"...,inline".

type AnimalUnion struct {
	// From variants [Dog], [Cat]
	Owner Person `json:"owner"`
	// From variant [Dog]
	DogBreed string `json:"dog_breed"`
	// From variant [Cat]
	CatBreed string `json:"cat_breed"`
	// ...

	JSON struct {
		Owner respjson.Field
		// ...
	} `json:"-"`
}

// If animal variant
if animal.Owner.Address.ZipCode == "" {
	panic("missing zip code")
}

// Switch on the variant
switch variant := animal.AsAny().(type) {
case Dog:
case Cat:
default:
	panic("unexpected type")
}
RequestOptions

This library uses the functional options pattern. Functions defined in the option package return a RequestOption, which is a closure that mutates a RequestConfig. These options can be supplied to the client or at individual requests. For example:

client := kernel.NewClient(
	// Adds a header to every request made by the client
	option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.Browsers.New(context.TODO(), ...,
	// Override the header
	option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
	// Add an undocumented field to the request body, using sjson syntax
	option.WithJSONSet("some.json.path", map[string]string{"my": "object"}),
)

The request option option.WithDebugLog(nil) may be helpful while debugging.

See the full list of request options.

Pagination

This library provides some conveniences for working with paginated list endpoints.

You can use .ListAutoPaging() methods to iterate through items across all pages:

Or you can use simple .List() methods to fetch a single page and receive a standard response object with additional helper methods like .GetNextPage(), e.g.:

Errors

When the API returns a non-success status code, we return an error with type *kernel.Error. This contains the StatusCode, *http.Request, and *http.Response values of the request, as well as the JSON of the error body (much like other response objects in the SDK).

To handle errors, we recommend that you use the errors.As pattern:

_, err := client.Browsers.New(context.TODO(), kernel.BrowserNewParams{
	Persistence: kernel.BrowserPersistenceParam{
		ID: "browser-for-user-1234",
	},
})
if err != nil {
	var apierr *kernel.Error
	if errors.As(err, &apierr) {
		println(string(apierr.DumpRequest(true)))  // Prints the serialized HTTP request
		println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
	}
	panic(err.Error()) // GET "/browsers": 400 Bad Request { ... }
}

When other errors occur, they are returned unwrapped; for example, if HTTP transport fails, you might receive *url.Error wrapping *net.OpError.

Timeouts

Requests do not time out by default; use context to configure a timeout for a request lifecycle.

Note that if a request is retried, the context timeout does not start over. To set a per-retry timeout, use option.WithRequestTimeout().

// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
client.Browsers.New(
	ctx,
	kernel.BrowserNewParams{
		Persistence: kernel.BrowserPersistenceParam{
			ID: "browser-for-user-1234",
		},
	},
	// This sets the per-retry timeout
	option.WithRequestTimeout(20*time.Second),
)
File uploads

Request parameters that correspond to file uploads in multipart requests are typed as io.Reader. The contents of the io.Reader will by default be sent as a multipart form part with the file name of "anonymous_file" and content-type of "application/octet-stream".

The file name and content-type can be customized by implementing Name() string or ContentType() string on the run-time type of io.Reader. Note that os.File implements Name() string, so a file returned by os.Open will be sent with the file name on disk.

We also provide a helper kernel.File(reader io.Reader, filename string, contentType string) which can be used to wrap any io.Reader with the appropriate file name and content type.

// A file from the file system
file, err := os.Open("/path/to/file")
kernel.DeploymentNewParams{
	EntrypointRelPath: "src/app.py",
	File:              file,
}

// A file from a string
kernel.DeploymentNewParams{
	EntrypointRelPath: "src/app.py",
	File:              strings.NewReader("my file contents"),
}

// With a custom filename and contentType
kernel.DeploymentNewParams{
	EntrypointRelPath: "src/app.py",
	File:              kernel.File(strings.NewReader(`{"hello": "foo"}`), "file.go", "application/json"),
}
Retries

Certain errors will be automatically retried 2 times by default, with a short exponential backoff. We retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors.

You can use the WithMaxRetries option to configure or disable this:

// Configure the default for all requests:
client := kernel.NewClient(
	option.WithMaxRetries(0), // default is 2
)

// Override per-request:
client.Browsers.New(
	context.TODO(),
	kernel.BrowserNewParams{
		Persistence: kernel.BrowserPersistenceParam{
			ID: "browser-for-user-1234",
		},
	},
	option.WithMaxRetries(5),
)
Accessing raw response data (e.g. response headers)

You can access the raw HTTP response data by using the option.WithResponseInto() request option. This is useful when you need to examine response headers, status codes, or other details.

// Create a variable to store the HTTP response
var response *http.Response
browser, err := client.Browsers.New(
	context.TODO(),
	kernel.BrowserNewParams{
		Persistence: kernel.BrowserPersistenceParam{
			ID: "browser-for-user-1234",
		},
	},
	option.WithResponseInto(&response),
)
if err != nil {
	// handle error
}
fmt.Printf("%+v\n", browser)

fmt.Printf("Status Code: %d\n", response.StatusCode)
fmt.Printf("Headers: %+#v\n", response.Header)
Making custom/undocumented requests

This library is typed for convenient access to the documented API. If you need to access undocumented endpoints, params, or response properties, the library can still be used.

Undocumented endpoints

To make requests to undocumented endpoints, you can use client.Get, client.Post, and other HTTP verbs. RequestOptions on the client, such as retries, will be respected when making these requests.

var (
    // params can be an io.Reader, a []byte, an encoding/json serializable object,
    // or a "…Params" struct defined in this library.
    params map[string]any

    // result can be an []byte, *http.Response, a encoding/json deserializable object,
    // or a model defined in this library.
    result *http.Response
)
err := client.Post(context.Background(), "/unspecified", params, &result)
if err != nil {
    …
}
Undocumented request params

To make requests using undocumented parameters, you may use either the option.WithQuerySet() or the option.WithJSONSet() methods.

params := FooNewParams{
    ID:   "id_xxxx",
    Data: FooNewParamsData{
        FirstName: kernel.String("John"),
    },
}
client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe"))
Undocumented response properties

To access undocumented response properties, you may either access the raw JSON of the response as a string with result.JSON.RawJSON(), or get the raw JSON of a particular field on the result with result.JSON.Foo.Raw().

Any fields that are not present on the response struct will be saved and can be accessed by result.JSON.ExtraFields() which returns the extra fields as a map[string]Field.

Middleware

We provide option.WithMiddleware which applies the given middleware to requests.

func Logger(req *http.Request, next option.MiddlewareNext) (res *http.Response, err error) {
	// Before the request
	start := time.Now()
	LogReq(req)

	// Forward the request to the next handler
	res, err = next(req)

	// Handle stuff after the request
	end := time.Now()
	LogRes(res, err, start - end)

    return res, err
}

client := kernel.NewClient(
	option.WithMiddleware(Logger),
)

When multiple middlewares are provided as variadic arguments, the middlewares are applied left to right. If option.WithMiddleware is given multiple times, for example first in the client then the method, the middleware in the client will run first and the middleware given in the method will run next.

You may also replace the default http.Client with option.WithHTTPClient(client). Only one http client is accepted (this overwrites any previous client) and receives requests after any middleware has been applied.

Semantic versioning

This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:

  1. Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals.)
  2. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an issue with questions, bugs, or suggestions.

Contributing

See the contributing documentation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(b bool) param.Opt[bool]

func BoolPtr

func BoolPtr(v bool) *bool

func DefaultClientOptions

func DefaultClientOptions() []option.RequestOption

DefaultClientOptions read from the environment (KERNEL_API_KEY, KERNEL_BASE_URL). This should be used to initialize new clients.

func File

func File(rdr io.Reader, filename string, contentType string) file

func Float

func Float(f float64) param.Opt[float64]

func FloatPtr

func FloatPtr(v float64) *float64

func Int

func Int(i int64) param.Opt[int64]

func IntPtr

func IntPtr(v int64) *int64

func Opt

func Opt[T comparable](v T) param.Opt[T]

func Ptr

func Ptr[T any](v T) *T

func String

func String(s string) param.Opt[string]

func StringPtr

func StringPtr(v string) *string

func Time

func Time(t time.Time) param.Opt[time.Time]

func TimePtr

func TimePtr(v time.Time) *time.Time

Types

type AppAction added in v0.6.4

type AppAction = shared.AppAction

An action available on the app

This is an alias to an internal type.

type AppListParams

type AppListParams struct {
	// Filter results by application name.
	AppName param.Opt[string] `query:"app_name,omitzero" json:"-"`
	// Filter results by version label.
	Version param.Opt[string] `query:"version,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (AppListParams) URLQuery

func (r AppListParams) URLQuery() (v url.Values, err error)

URLQuery serializes AppListParams's query parameters as `url.Values`.

type AppListResponse

type AppListResponse struct {
	// Unique identifier for the app version
	ID string `json:"id,required"`
	// List of actions available on the app
	Actions []shared.AppAction `json:"actions,required"`
	// Name of the application
	AppName string `json:"app_name,required"`
	// Deployment ID
	Deployment string `json:"deployment,required"`
	// Environment variables configured for this app version
	EnvVars map[string]string `json:"env_vars,required"`
	// Deployment region code
	Region constant.AwsUsEast1a `json:"region,required"`
	// Version label for the application
	Version string `json:"version,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Actions     respjson.Field
		AppName     respjson.Field
		Deployment  respjson.Field
		EnvVars     respjson.Field
		Region      respjson.Field
		Version     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Summary of an application version.

func (AppListResponse) RawJSON

func (r AppListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*AppListResponse) UnmarshalJSON

func (r *AppListResponse) UnmarshalJSON(data []byte) error

type AppService

type AppService struct {
	Options []option.RequestOption
}

AppService contains methods and other services that help with interacting with the kernel API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewAppService method instead.

func NewAppService

func NewAppService(opts ...option.RequestOption) (r AppService)

NewAppService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*AppService) List

func (r *AppService) List(ctx context.Context, query AppListParams, opts ...option.RequestOption) (res *[]AppListResponse, err error)

List applications. Optionally filter by app name and/or version label.

type BrowserDeleteParams added in v0.3.0

type BrowserDeleteParams struct {
	// Persistent browser identifier
	PersistentID string `query:"persistent_id,required" json:"-"`
	// contains filtered or unexported fields
}

func (BrowserDeleteParams) URLQuery added in v0.3.0

func (r BrowserDeleteParams) URLQuery() (v url.Values, err error)

URLQuery serializes BrowserDeleteParams's query parameters as `url.Values`.

type BrowserFDeleteDirectoryParams added in v0.9.1

type BrowserFDeleteDirectoryParams struct {
	// Absolute path to delete.
	Path string `json:"path,required"`
	// contains filtered or unexported fields
}

func (BrowserFDeleteDirectoryParams) MarshalJSON added in v0.9.1

func (r BrowserFDeleteDirectoryParams) MarshalJSON() (data []byte, err error)

func (*BrowserFDeleteDirectoryParams) UnmarshalJSON added in v0.9.1

func (r *BrowserFDeleteDirectoryParams) UnmarshalJSON(data []byte) error

type BrowserFDeleteFileParams added in v0.9.1

type BrowserFDeleteFileParams struct {
	// Absolute path to delete.
	Path string `json:"path,required"`
	// contains filtered or unexported fields
}

func (BrowserFDeleteFileParams) MarshalJSON added in v0.9.1

func (r BrowserFDeleteFileParams) MarshalJSON() (data []byte, err error)

func (*BrowserFDeleteFileParams) UnmarshalJSON added in v0.9.1

func (r *BrowserFDeleteFileParams) UnmarshalJSON(data []byte) error

type BrowserFFileInfoParams added in v0.9.1

type BrowserFFileInfoParams struct {
	// Absolute path of the file or directory.
	Path string `query:"path,required" json:"-"`
	// contains filtered or unexported fields
}

func (BrowserFFileInfoParams) URLQuery added in v0.9.1

func (r BrowserFFileInfoParams) URLQuery() (v url.Values, err error)

URLQuery serializes BrowserFFileInfoParams's query parameters as `url.Values`.

type BrowserFFileInfoResponse added in v0.9.1

type BrowserFFileInfoResponse struct {
	// Whether the path is a directory.
	IsDir bool `json:"is_dir,required"`
	// Last modification time.
	ModTime time.Time `json:"mod_time,required" format:"date-time"`
	// File mode bits (e.g., "drwxr-xr-x" or "-rw-r--r--").
	Mode string `json:"mode,required"`
	// Base name of the file or directory.
	Name string `json:"name,required"`
	// Absolute path.
	Path string `json:"path,required"`
	// Size in bytes. 0 for directories.
	SizeBytes int64 `json:"size_bytes,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		IsDir       respjson.Field
		ModTime     respjson.Field
		Mode        respjson.Field
		Name        respjson.Field
		Path        respjson.Field
		SizeBytes   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BrowserFFileInfoResponse) RawJSON added in v0.9.1

func (r BrowserFFileInfoResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BrowserFFileInfoResponse) UnmarshalJSON added in v0.9.1

func (r *BrowserFFileInfoResponse) UnmarshalJSON(data []byte) error

type BrowserFListFilesParams added in v0.9.1

type BrowserFListFilesParams struct {
	// Absolute directory path.
	Path string `query:"path,required" json:"-"`
	// contains filtered or unexported fields
}

func (BrowserFListFilesParams) URLQuery added in v0.9.1

func (r BrowserFListFilesParams) URLQuery() (v url.Values, err error)

URLQuery serializes BrowserFListFilesParams's query parameters as `url.Values`.

type BrowserFListFilesResponse added in v0.9.1

type BrowserFListFilesResponse struct {
	// Whether the path is a directory.
	IsDir bool `json:"is_dir,required"`
	// Last modification time.
	ModTime time.Time `json:"mod_time,required" format:"date-time"`
	// File mode bits (e.g., "drwxr-xr-x" or "-rw-r--r--").
	Mode string `json:"mode,required"`
	// Base name of the file or directory.
	Name string `json:"name,required"`
	// Absolute path.
	Path string `json:"path,required"`
	// Size in bytes. 0 for directories.
	SizeBytes int64 `json:"size_bytes,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		IsDir       respjson.Field
		ModTime     respjson.Field
		Mode        respjson.Field
		Name        respjson.Field
		Path        respjson.Field
		SizeBytes   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BrowserFListFilesResponse) RawJSON added in v0.9.1

func (r BrowserFListFilesResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BrowserFListFilesResponse) UnmarshalJSON added in v0.9.1

func (r *BrowserFListFilesResponse) UnmarshalJSON(data []byte) error

type BrowserFMoveParams added in v0.9.1

type BrowserFMoveParams struct {
	// Absolute destination path.
	DestPath string `json:"dest_path,required"`
	// Absolute source path.
	SrcPath string `json:"src_path,required"`
	// contains filtered or unexported fields
}

func (BrowserFMoveParams) MarshalJSON added in v0.9.1

func (r BrowserFMoveParams) MarshalJSON() (data []byte, err error)

func (*BrowserFMoveParams) UnmarshalJSON added in v0.9.1

func (r *BrowserFMoveParams) UnmarshalJSON(data []byte) error

type BrowserFNewDirectoryParams added in v0.9.1

type BrowserFNewDirectoryParams struct {
	// Absolute directory path to create.
	Path string `json:"path,required"`
	// Optional directory mode (octal string, e.g. 755). Defaults to 755.
	Mode param.Opt[string] `json:"mode,omitzero"`
	// contains filtered or unexported fields
}

func (BrowserFNewDirectoryParams) MarshalJSON added in v0.9.1

func (r BrowserFNewDirectoryParams) MarshalJSON() (data []byte, err error)

func (*BrowserFNewDirectoryParams) UnmarshalJSON added in v0.9.1

func (r *BrowserFNewDirectoryParams) UnmarshalJSON(data []byte) error

type BrowserFReadFileParams added in v0.9.1

type BrowserFReadFileParams struct {
	// Absolute file path to read.
	Path string `query:"path,required" json:"-"`
	// contains filtered or unexported fields
}

func (BrowserFReadFileParams) URLQuery added in v0.9.1

func (r BrowserFReadFileParams) URLQuery() (v url.Values, err error)

URLQuery serializes BrowserFReadFileParams's query parameters as `url.Values`.

type BrowserFService added in v0.9.1

type BrowserFService struct {
	Options []option.RequestOption
	Watch   BrowserFWatchService
}

BrowserFService contains methods and other services that help with interacting with the kernel API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewBrowserFService method instead.

func NewBrowserFService added in v0.9.1

func NewBrowserFService(opts ...option.RequestOption) (r BrowserFService)

NewBrowserFService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*BrowserFService) DeleteDirectory added in v0.9.1

func (r *BrowserFService) DeleteDirectory(ctx context.Context, id string, body BrowserFDeleteDirectoryParams, opts ...option.RequestOption) (err error)

Delete a directory

func (*BrowserFService) DeleteFile added in v0.9.1

func (r *BrowserFService) DeleteFile(ctx context.Context, id string, body BrowserFDeleteFileParams, opts ...option.RequestOption) (err error)

Delete a file

func (*BrowserFService) FileInfo added in v0.9.1

Get information about a file or directory

func (*BrowserFService) ListFiles added in v0.9.1

List files in a directory

func (*BrowserFService) Move added in v0.9.1

func (r *BrowserFService) Move(ctx context.Context, id string, body BrowserFMoveParams, opts ...option.RequestOption) (err error)

Move or rename a file or directory

func (*BrowserFService) NewDirectory added in v0.9.1

func (r *BrowserFService) NewDirectory(ctx context.Context, id string, body BrowserFNewDirectoryParams, opts ...option.RequestOption) (err error)

Create a new directory

func (*BrowserFService) ReadFile added in v0.9.1

func (r *BrowserFService) ReadFile(ctx context.Context, id string, query BrowserFReadFileParams, opts ...option.RequestOption) (res *http.Response, err error)

Read file contents

func (*BrowserFService) SetFilePermissions added in v0.9.1

func (r *BrowserFService) SetFilePermissions(ctx context.Context, id string, body BrowserFSetFilePermissionsParams, opts ...option.RequestOption) (err error)

Set file or directory permissions/ownership

func (*BrowserFService) WriteFile added in v0.9.1

func (r *BrowserFService) WriteFile(ctx context.Context, id string, contents io.Reader, body BrowserFWriteFileParams, opts ...option.RequestOption) (err error)

Write or create a file

type BrowserFSetFilePermissionsParams added in v0.9.1

type BrowserFSetFilePermissionsParams struct {
	// File mode bits (octal string, e.g. 644).
	Mode string `json:"mode,required"`
	// Absolute path whose permissions are to be changed.
	Path string `json:"path,required"`
	// New group name or GID.
	Group param.Opt[string] `json:"group,omitzero"`
	// New owner username or UID.
	Owner param.Opt[string] `json:"owner,omitzero"`
	// contains filtered or unexported fields
}

func (BrowserFSetFilePermissionsParams) MarshalJSON added in v0.9.1

func (r BrowserFSetFilePermissionsParams) MarshalJSON() (data []byte, err error)

func (*BrowserFSetFilePermissionsParams) UnmarshalJSON added in v0.9.1

func (r *BrowserFSetFilePermissionsParams) UnmarshalJSON(data []byte) error

type BrowserFWatchEventsParams added in v0.9.1

type BrowserFWatchEventsParams struct {
	ID string `path:"id,required" json:"-"`
	// contains filtered or unexported fields
}

type BrowserFWatchEventsResponse added in v0.9.1

type BrowserFWatchEventsResponse struct {
	// Absolute path of the file or directory.
	Path string `json:"path,required"`
	// Event type.
	//
	// Any of "CREATE", "WRITE", "DELETE", "RENAME".
	Type BrowserFWatchEventsResponseType `json:"type,required"`
	// Whether the affected path is a directory.
	IsDir bool `json:"is_dir"`
	// Base name of the file or directory affected.
	Name string `json:"name"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Path        respjson.Field
		Type        respjson.Field
		IsDir       respjson.Field
		Name        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Filesystem change event.

func (BrowserFWatchEventsResponse) RawJSON added in v0.9.1

func (r BrowserFWatchEventsResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BrowserFWatchEventsResponse) UnmarshalJSON added in v0.9.1

func (r *BrowserFWatchEventsResponse) UnmarshalJSON(data []byte) error

type BrowserFWatchEventsResponseType added in v0.9.1

type BrowserFWatchEventsResponseType string

Event type.

const (
	BrowserFWatchEventsResponseTypeCreate BrowserFWatchEventsResponseType = "CREATE"
	BrowserFWatchEventsResponseTypeWrite  BrowserFWatchEventsResponseType = "WRITE"
	BrowserFWatchEventsResponseTypeDelete BrowserFWatchEventsResponseType = "DELETE"
	BrowserFWatchEventsResponseTypeRename BrowserFWatchEventsResponseType = "RENAME"
)

type BrowserFWatchService added in v0.9.1

type BrowserFWatchService struct {
	Options []option.RequestOption
}

BrowserFWatchService contains methods and other services that help with interacting with the kernel API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewBrowserFWatchService method instead.

func NewBrowserFWatchService added in v0.9.1

func NewBrowserFWatchService(opts ...option.RequestOption) (r BrowserFWatchService)

NewBrowserFWatchService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*BrowserFWatchService) EventsStreaming added in v0.9.1

Stream filesystem events for a watch

func (*BrowserFWatchService) Start added in v0.9.1

Watch a directory for changes

func (*BrowserFWatchService) Stop added in v0.9.1

func (r *BrowserFWatchService) Stop(ctx context.Context, watchID string, body BrowserFWatchStopParams, opts ...option.RequestOption) (err error)

Stop watching a directory

type BrowserFWatchStartParams added in v0.9.1

type BrowserFWatchStartParams struct {
	// Directory to watch.
	Path string `json:"path,required"`
	// Whether to watch recursively.
	Recursive param.Opt[bool] `json:"recursive,omitzero"`
	// contains filtered or unexported fields
}

func (BrowserFWatchStartParams) MarshalJSON added in v0.9.1

func (r BrowserFWatchStartParams) MarshalJSON() (data []byte, err error)

func (*BrowserFWatchStartParams) UnmarshalJSON added in v0.9.1

func (r *BrowserFWatchStartParams) UnmarshalJSON(data []byte) error

type BrowserFWatchStartResponse added in v0.9.1

type BrowserFWatchStartResponse struct {
	// Unique identifier for the directory watch
	WatchID string `json:"watch_id"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		WatchID     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BrowserFWatchStartResponse) RawJSON added in v0.9.1

func (r BrowserFWatchStartResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BrowserFWatchStartResponse) UnmarshalJSON added in v0.9.1

func (r *BrowserFWatchStartResponse) UnmarshalJSON(data []byte) error

type BrowserFWatchStopParams added in v0.9.1

type BrowserFWatchStopParams struct {
	ID string `path:"id,required" json:"-"`
	// contains filtered or unexported fields
}

type BrowserFWriteFileParams added in v0.9.1

type BrowserFWriteFileParams struct {
	// Destination absolute file path.
	Path string `query:"path,required" json:"-"`
	// Optional file mode (octal string, e.g. 644). Defaults to 644.
	Mode param.Opt[string] `query:"mode,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BrowserFWriteFileParams) MarshalMultipart added in v0.9.1

func (r BrowserFWriteFileParams) MarshalMultipart() (data []byte, contentType string, err error)

func (BrowserFWriteFileParams) URLQuery added in v0.9.1

func (r BrowserFWriteFileParams) URLQuery() (v url.Values, err error)

URLQuery serializes BrowserFWriteFileParams's query parameters as `url.Values`.

type BrowserGetResponse

type BrowserGetResponse struct {
	// Websocket URL for Chrome DevTools Protocol connections to the browser session
	CdpWsURL string `json:"cdp_ws_url,required"`
	// When the browser session was created.
	CreatedAt time.Time `json:"created_at,required" format:"date-time"`
	// Whether the browser session is running in headless mode.
	Headless bool `json:"headless,required"`
	// Unique identifier for the browser session
	SessionID string `json:"session_id,required"`
	// Whether the browser session is running in stealth mode.
	Stealth bool `json:"stealth,required"`
	// The number of seconds of inactivity before the browser session is terminated.
	TimeoutSeconds int64 `json:"timeout_seconds,required"`
	// Remote URL for live viewing the browser session. Only available for non-headless
	// browsers.
	BrowserLiveViewURL string `json:"browser_live_view_url"`
	// Optional persistence configuration for the browser session.
	Persistence BrowserPersistence `json:"persistence"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CdpWsURL           respjson.Field
		CreatedAt          respjson.Field
		Headless           respjson.Field
		SessionID          respjson.Field
		Stealth            respjson.Field
		TimeoutSeconds     respjson.Field
		BrowserLiveViewURL respjson.Field
		Persistence        respjson.Field
		ExtraFields        map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BrowserGetResponse) RawJSON

func (r BrowserGetResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BrowserGetResponse) UnmarshalJSON

func (r *BrowserGetResponse) UnmarshalJSON(data []byte) error

type BrowserListResponse added in v0.3.0

type BrowserListResponse struct {
	// Websocket URL for Chrome DevTools Protocol connections to the browser session
	CdpWsURL string `json:"cdp_ws_url,required"`
	// When the browser session was created.
	CreatedAt time.Time `json:"created_at,required" format:"date-time"`
	// Whether the browser session is running in headless mode.
	Headless bool `json:"headless,required"`
	// Unique identifier for the browser session
	SessionID string `json:"session_id,required"`
	// Whether the browser session is running in stealth mode.
	Stealth bool `json:"stealth,required"`
	// The number of seconds of inactivity before the browser session is terminated.
	TimeoutSeconds int64 `json:"timeout_seconds,required"`
	// Remote URL for live viewing the browser session. Only available for non-headless
	// browsers.
	BrowserLiveViewURL string `json:"browser_live_view_url"`
	// Optional persistence configuration for the browser session.
	Persistence BrowserPersistence `json:"persistence"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CdpWsURL           respjson.Field
		CreatedAt          respjson.Field
		Headless           respjson.Field
		SessionID          respjson.Field
		Stealth            respjson.Field
		TimeoutSeconds     respjson.Field
		BrowserLiveViewURL respjson.Field
		Persistence        respjson.Field
		ExtraFields        map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BrowserListResponse) RawJSON added in v0.3.0

func (r BrowserListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BrowserListResponse) UnmarshalJSON added in v0.3.0

func (r *BrowserListResponse) UnmarshalJSON(data []byte) error

type BrowserNewParams

type BrowserNewParams struct {
	// If true, launches the browser using a headless image (no VNC/GUI). Defaults to
	// false.
	Headless param.Opt[bool] `json:"headless,omitzero"`
	// action invocation ID
	InvocationID param.Opt[string] `json:"invocation_id,omitzero"`
	// If true, launches the browser in stealth mode to reduce detection by anti-bot
	// mechanisms.
	Stealth param.Opt[bool] `json:"stealth,omitzero"`
	// The number of seconds of inactivity before the browser session is terminated.
	// Only applicable to non-persistent browsers. Activity includes CDP connections
	// and live view connections. Defaults to 60 seconds.
	TimeoutSeconds param.Opt[int64] `json:"timeout_seconds,omitzero"`
	// Optional persistence configuration for the browser session.
	Persistence BrowserPersistenceParam `json:"persistence,omitzero"`
	// contains filtered or unexported fields
}

func (BrowserNewParams) MarshalJSON

func (r BrowserNewParams) MarshalJSON() (data []byte, err error)

func (*BrowserNewParams) UnmarshalJSON

func (r *BrowserNewParams) UnmarshalJSON(data []byte) error

type BrowserNewResponse

type BrowserNewResponse struct {
	// Websocket URL for Chrome DevTools Protocol connections to the browser session
	CdpWsURL string `json:"cdp_ws_url,required"`
	// When the browser session was created.
	CreatedAt time.Time `json:"created_at,required" format:"date-time"`
	// Whether the browser session is running in headless mode.
	Headless bool `json:"headless,required"`
	// Unique identifier for the browser session
	SessionID string `json:"session_id,required"`
	// Whether the browser session is running in stealth mode.
	Stealth bool `json:"stealth,required"`
	// The number of seconds of inactivity before the browser session is terminated.
	TimeoutSeconds int64 `json:"timeout_seconds,required"`
	// Remote URL for live viewing the browser session. Only available for non-headless
	// browsers.
	BrowserLiveViewURL string `json:"browser_live_view_url"`
	// Optional persistence configuration for the browser session.
	Persistence BrowserPersistence `json:"persistence"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CdpWsURL           respjson.Field
		CreatedAt          respjson.Field
		Headless           respjson.Field
		SessionID          respjson.Field
		Stealth            respjson.Field
		TimeoutSeconds     respjson.Field
		BrowserLiveViewURL respjson.Field
		Persistence        respjson.Field
		ExtraFields        map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BrowserNewResponse) RawJSON

func (r BrowserNewResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BrowserNewResponse) UnmarshalJSON

func (r *BrowserNewResponse) UnmarshalJSON(data []byte) error

type BrowserPersistence added in v0.3.0

type BrowserPersistence struct {
	// Unique identifier for the persistent browser session.
	ID string `json:"id,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Optional persistence configuration for the browser session.

func (BrowserPersistence) RawJSON added in v0.3.0

func (r BrowserPersistence) RawJSON() string

Returns the unmodified JSON received from the API

func (BrowserPersistence) ToParam added in v0.3.0

ToParam converts this BrowserPersistence to a BrowserPersistenceParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with BrowserPersistenceParam.Overrides()

func (*BrowserPersistence) UnmarshalJSON added in v0.3.0

func (r *BrowserPersistence) UnmarshalJSON(data []byte) error

type BrowserPersistenceParam added in v0.3.0

type BrowserPersistenceParam struct {
	// Unique identifier for the persistent browser session.
	ID string `json:"id,required"`
	// contains filtered or unexported fields
}

Optional persistence configuration for the browser session.

The property ID is required.

func (BrowserPersistenceParam) MarshalJSON added in v0.3.0

func (r BrowserPersistenceParam) MarshalJSON() (data []byte, err error)

func (*BrowserPersistenceParam) UnmarshalJSON added in v0.3.0

func (r *BrowserPersistenceParam) UnmarshalJSON(data []byte) error

type BrowserReplayDownloadParams added in v0.8.0

type BrowserReplayDownloadParams struct {
	ID string `path:"id,required" json:"-"`
	// contains filtered or unexported fields
}

type BrowserReplayListResponse added in v0.8.0

type BrowserReplayListResponse struct {
	// Unique identifier for the replay recording.
	ReplayID string `json:"replay_id,required"`
	// Timestamp when replay finished
	FinishedAt time.Time `json:"finished_at,nullable" format:"date-time"`
	// URL for viewing the replay recording.
	ReplayViewURL string `json:"replay_view_url"`
	// Timestamp when replay started
	StartedAt time.Time `json:"started_at,nullable" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ReplayID      respjson.Field
		FinishedAt    respjson.Field
		ReplayViewURL respjson.Field
		StartedAt     respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Information about a browser replay recording.

func (BrowserReplayListResponse) RawJSON added in v0.8.0

func (r BrowserReplayListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BrowserReplayListResponse) UnmarshalJSON added in v0.8.0

func (r *BrowserReplayListResponse) UnmarshalJSON(data []byte) error

type BrowserReplayService added in v0.8.0

type BrowserReplayService struct {
	Options []option.RequestOption
}

BrowserReplayService contains methods and other services that help with interacting with the kernel API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewBrowserReplayService method instead.

func NewBrowserReplayService added in v0.8.0

func NewBrowserReplayService(opts ...option.RequestOption) (r BrowserReplayService)

NewBrowserReplayService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*BrowserReplayService) Download added in v0.8.0

func (r *BrowserReplayService) Download(ctx context.Context, replayID string, query BrowserReplayDownloadParams, opts ...option.RequestOption) (res *http.Response, err error)

Download or stream the specified replay recording.

func (*BrowserReplayService) List added in v0.8.0

List all replays for the specified browser session.

func (*BrowserReplayService) Start added in v0.8.0

Start recording the browser session and return a replay ID.

func (*BrowserReplayService) Stop added in v0.8.0

func (r *BrowserReplayService) Stop(ctx context.Context, replayID string, body BrowserReplayStopParams, opts ...option.RequestOption) (err error)

Stop the specified replay recording and persist the video.

type BrowserReplayStartParams added in v0.8.0

type BrowserReplayStartParams struct {
	// Recording framerate in fps.
	Framerate param.Opt[int64] `json:"framerate,omitzero"`
	// Maximum recording duration in seconds.
	MaxDurationInSeconds param.Opt[int64] `json:"max_duration_in_seconds,omitzero"`
	// contains filtered or unexported fields
}

func (BrowserReplayStartParams) MarshalJSON added in v0.8.0

func (r BrowserReplayStartParams) MarshalJSON() (data []byte, err error)

func (*BrowserReplayStartParams) UnmarshalJSON added in v0.8.0

func (r *BrowserReplayStartParams) UnmarshalJSON(data []byte) error

type BrowserReplayStartResponse added in v0.8.0

type BrowserReplayStartResponse struct {
	// Unique identifier for the replay recording.
	ReplayID string `json:"replay_id,required"`
	// Timestamp when replay finished
	FinishedAt time.Time `json:"finished_at,nullable" format:"date-time"`
	// URL for viewing the replay recording.
	ReplayViewURL string `json:"replay_view_url"`
	// Timestamp when replay started
	StartedAt time.Time `json:"started_at,nullable" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ReplayID      respjson.Field
		FinishedAt    respjson.Field
		ReplayViewURL respjson.Field
		StartedAt     respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Information about a browser replay recording.

func (BrowserReplayStartResponse) RawJSON added in v0.8.0

func (r BrowserReplayStartResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BrowserReplayStartResponse) UnmarshalJSON added in v0.8.0

func (r *BrowserReplayStartResponse) UnmarshalJSON(data []byte) error

type BrowserReplayStopParams added in v0.8.0

type BrowserReplayStopParams struct {
	ID string `path:"id,required" json:"-"`
	// contains filtered or unexported fields
}

type BrowserService

type BrowserService struct {
	Options []option.RequestOption
	Replays BrowserReplayService
	Fs      BrowserFService
}

BrowserService contains methods and other services that help with interacting with the kernel API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewBrowserService method instead.

func NewBrowserService

func NewBrowserService(opts ...option.RequestOption) (r BrowserService)

NewBrowserService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*BrowserService) Delete added in v0.3.0

func (r *BrowserService) Delete(ctx context.Context, body BrowserDeleteParams, opts ...option.RequestOption) (err error)

Delete a persistent browser session by its persistent_id.

func (*BrowserService) DeleteByID added in v0.3.0

func (r *BrowserService) DeleteByID(ctx context.Context, id string, opts ...option.RequestOption) (err error)

Delete a browser session by ID

func (*BrowserService) Get

func (r *BrowserService) Get(ctx context.Context, id string, opts ...option.RequestOption) (res *BrowserGetResponse, err error)

Get information about a browser session.

func (*BrowserService) List added in v0.3.0

func (r *BrowserService) List(ctx context.Context, opts ...option.RequestOption) (res *[]BrowserListResponse, err error)

List active browser sessions

func (*BrowserService) New

Create a new browser session from within an action.

type Client

type Client struct {
	Options     []option.RequestOption
	Deployments DeploymentService
	Apps        AppService
	Invocations InvocationService
	Browsers    BrowserService
}

Client creates a struct with services and top level methods that help with interacting with the kernel API. You should not instantiate this client directly, and instead use the NewClient method instead.

func NewClient

func NewClient(opts ...option.RequestOption) (r Client)

NewClient generates a new client with the default option read from the environment (KERNEL_API_KEY, KERNEL_BASE_URL). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.

func (*Client) Delete

func (r *Client) Delete(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Execute

func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error

Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.

If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.

The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned url.Values will be used as query strings to the url.

If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.

Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.

The response body will be deserialized into the res variable, depending on its type:

  • A pointer to a *http.Response is populated by the raw response.
  • A pointer to a byte array will be populated with the contents of the request body.
  • A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
  • A nil value will not read the response body.

For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.

func (*Client) Get

func (r *Client) Get(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Patch

func (r *Client) Patch(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Post

func (r *Client) Post(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Put

func (r *Client) Put(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Put makes a PUT request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

type DeploymentFollowParams added in v0.6.2

type DeploymentFollowParams struct {
	// Show logs since the given time (RFC timestamps or durations like 5m).
	Since param.Opt[string] `query:"since,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (DeploymentFollowParams) URLQuery added in v0.6.2

func (r DeploymentFollowParams) URLQuery() (v url.Values, err error)

URLQuery serializes DeploymentFollowParams's query parameters as `url.Values`.

type DeploymentFollowResponseAppVersionSummaryEvent added in v0.6.0

type DeploymentFollowResponseAppVersionSummaryEvent struct {
	// Unique identifier for the app version
	ID string `json:"id,required"`
	// List of actions available on the app
	Actions []shared.AppAction `json:"actions,required"`
	// Name of the application
	AppName string `json:"app_name,required"`
	// Event type identifier (always "app_version_summary").
	Event constant.AppVersionSummary `json:"event,required"`
	// Deployment region code
	Region constant.AwsUsEast1a `json:"region,required"`
	// Time the state was reported.
	Timestamp time.Time `json:"timestamp,required" format:"date-time"`
	// Version label for the application
	Version string `json:"version,required"`
	// Environment variables configured for this app version
	EnvVars map[string]string `json:"env_vars"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Actions     respjson.Field
		AppName     respjson.Field
		Event       respjson.Field
		Region      respjson.Field
		Timestamp   respjson.Field
		Version     respjson.Field
		EnvVars     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Summary of an application version.

func (DeploymentFollowResponseAppVersionSummaryEvent) RawJSON added in v0.6.0

Returns the unmodified JSON received from the API

func (*DeploymentFollowResponseAppVersionSummaryEvent) UnmarshalJSON added in v0.6.0

type DeploymentFollowResponseUnion added in v0.6.0

type DeploymentFollowResponseUnion struct {
	// Any of "log", "deployment_state", nil, nil, "sse_heartbeat".
	Event string `json:"event"`
	// This field is from variant [shared.LogEvent].
	Message   string    `json:"message"`
	Timestamp time.Time `json:"timestamp"`
	// This field is from variant [DeploymentStateEvent].
	Deployment DeploymentStateEventDeployment `json:"deployment"`
	// This field is from variant [DeploymentFollowResponseAppVersionSummaryEvent].
	ID string `json:"id"`
	// This field is from variant [DeploymentFollowResponseAppVersionSummaryEvent].
	Actions []shared.AppAction `json:"actions"`
	// This field is from variant [DeploymentFollowResponseAppVersionSummaryEvent].
	AppName string `json:"app_name"`
	// This field is from variant [DeploymentFollowResponseAppVersionSummaryEvent].
	Region constant.AwsUsEast1a `json:"region"`
	// This field is from variant [DeploymentFollowResponseAppVersionSummaryEvent].
	Version string `json:"version"`
	// This field is from variant [DeploymentFollowResponseAppVersionSummaryEvent].
	EnvVars map[string]string `json:"env_vars"`
	// This field is from variant [shared.ErrorEvent].
	Error shared.ErrorModel `json:"error"`
	JSON  struct {
		Event      respjson.Field
		Message    respjson.Field
		Timestamp  respjson.Field
		Deployment respjson.Field
		ID         respjson.Field
		Actions    respjson.Field
		AppName    respjson.Field
		Region     respjson.Field
		Version    respjson.Field
		EnvVars    respjson.Field
		Error      respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

DeploymentFollowResponseUnion contains all possible properties and values from shared.LogEvent, DeploymentStateEvent, DeploymentFollowResponseAppVersionSummaryEvent, shared.ErrorEvent, shared.HeartbeatEvent.

Use the [DeploymentFollowResponseUnion.AsAny] method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (DeploymentFollowResponseUnion) AsDeploymentFollowResponseAppVersionSummaryEvent added in v0.6.0

func (u DeploymentFollowResponseUnion) AsDeploymentFollowResponseAppVersionSummaryEvent() (v DeploymentFollowResponseAppVersionSummaryEvent)

func (DeploymentFollowResponseUnion) AsDeploymentState added in v0.6.0

func (u DeploymentFollowResponseUnion) AsDeploymentState() (v DeploymentStateEvent)

func (DeploymentFollowResponseUnion) AsErrorEvent added in v0.6.0

func (u DeploymentFollowResponseUnion) AsErrorEvent() (v shared.ErrorEvent)

func (DeploymentFollowResponseUnion) AsLog added in v0.6.0

func (DeploymentFollowResponseUnion) AsSseHeartbeat added in v0.6.2

func (u DeploymentFollowResponseUnion) AsSseHeartbeat() (v shared.HeartbeatEvent)

func (DeploymentFollowResponseUnion) RawJSON added in v0.6.0

Returns the unmodified JSON received from the API

func (*DeploymentFollowResponseUnion) UnmarshalJSON added in v0.6.0

func (r *DeploymentFollowResponseUnion) UnmarshalJSON(data []byte) error

type DeploymentGetResponse added in v0.6.0

type DeploymentGetResponse struct {
	// Unique identifier for the deployment
	ID string `json:"id,required"`
	// Timestamp when the deployment was created
	CreatedAt time.Time `json:"created_at,required" format:"date-time"`
	// Deployment region code
	Region constant.AwsUsEast1a `json:"region,required"`
	// Current status of the deployment
	//
	// Any of "queued", "in_progress", "running", "failed", "stopped".
	Status DeploymentGetResponseStatus `json:"status,required"`
	// Relative path to the application entrypoint
	EntrypointRelPath string `json:"entrypoint_rel_path"`
	// Environment variables configured for this deployment
	EnvVars map[string]string `json:"env_vars"`
	// Status reason
	StatusReason string `json:"status_reason"`
	// Timestamp when the deployment was last updated
	UpdatedAt time.Time `json:"updated_at,nullable" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                respjson.Field
		CreatedAt         respjson.Field
		Region            respjson.Field
		Status            respjson.Field
		EntrypointRelPath respjson.Field
		EnvVars           respjson.Field
		StatusReason      respjson.Field
		UpdatedAt         respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Deployment record information.

func (DeploymentGetResponse) RawJSON added in v0.6.0

func (r DeploymentGetResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*DeploymentGetResponse) UnmarshalJSON added in v0.6.0

func (r *DeploymentGetResponse) UnmarshalJSON(data []byte) error

type DeploymentGetResponseStatus added in v0.6.0

type DeploymentGetResponseStatus string

Current status of the deployment

const (
	DeploymentGetResponseStatusQueued     DeploymentGetResponseStatus = "queued"
	DeploymentGetResponseStatusInProgress DeploymentGetResponseStatus = "in_progress"
	DeploymentGetResponseStatusRunning    DeploymentGetResponseStatus = "running"
	DeploymentGetResponseStatusFailed     DeploymentGetResponseStatus = "failed"
	DeploymentGetResponseStatusStopped    DeploymentGetResponseStatus = "stopped"
)

type DeploymentListParams added in v0.6.4

type DeploymentListParams struct {
	// Filter results by application name.
	AppName param.Opt[string] `query:"app_name,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (DeploymentListParams) URLQuery added in v0.6.4

func (r DeploymentListParams) URLQuery() (v url.Values, err error)

URLQuery serializes DeploymentListParams's query parameters as `url.Values`.

type DeploymentListResponse added in v0.6.4

type DeploymentListResponse struct {
	// Unique identifier for the deployment
	ID string `json:"id,required"`
	// Timestamp when the deployment was created
	CreatedAt time.Time `json:"created_at,required" format:"date-time"`
	// Deployment region code
	Region constant.AwsUsEast1a `json:"region,required"`
	// Current status of the deployment
	//
	// Any of "queued", "in_progress", "running", "failed", "stopped".
	Status DeploymentListResponseStatus `json:"status,required"`
	// Relative path to the application entrypoint
	EntrypointRelPath string `json:"entrypoint_rel_path"`
	// Environment variables configured for this deployment
	EnvVars map[string]string `json:"env_vars"`
	// Status reason
	StatusReason string `json:"status_reason"`
	// Timestamp when the deployment was last updated
	UpdatedAt time.Time `json:"updated_at,nullable" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                respjson.Field
		CreatedAt         respjson.Field
		Region            respjson.Field
		Status            respjson.Field
		EntrypointRelPath respjson.Field
		EnvVars           respjson.Field
		StatusReason      respjson.Field
		UpdatedAt         respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Deployment record information.

func (DeploymentListResponse) RawJSON added in v0.6.4

func (r DeploymentListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*DeploymentListResponse) UnmarshalJSON added in v0.6.4

func (r *DeploymentListResponse) UnmarshalJSON(data []byte) error

type DeploymentListResponseStatus added in v0.6.4

type DeploymentListResponseStatus string

Current status of the deployment

const (
	DeploymentListResponseStatusQueued     DeploymentListResponseStatus = "queued"
	DeploymentListResponseStatusInProgress DeploymentListResponseStatus = "in_progress"
	DeploymentListResponseStatusRunning    DeploymentListResponseStatus = "running"
	DeploymentListResponseStatusFailed     DeploymentListResponseStatus = "failed"
	DeploymentListResponseStatusStopped    DeploymentListResponseStatus = "stopped"
)

type DeploymentNewParams added in v0.6.0

type DeploymentNewParams struct {
	// Relative path to the entrypoint of the application
	EntrypointRelPath string `json:"entrypoint_rel_path,required"`
	// ZIP file containing the application source directory
	File io.Reader `json:"file,omitzero,required" format:"binary"`
	// Allow overwriting an existing app version
	Force param.Opt[bool] `json:"force,omitzero"`
	// Version of the application. Can be any string.
	Version param.Opt[string] `json:"version,omitzero"`
	// Map of environment variables to set for the deployed application. Each key-value
	// pair represents an environment variable.
	EnvVars map[string]string `json:"env_vars,omitzero"`
	// Region for deployment. Currently we only support "aws.us-east-1a"
	//
	// Any of "aws.us-east-1a".
	Region DeploymentNewParamsRegion `json:"region,omitzero"`
	// contains filtered or unexported fields
}

func (DeploymentNewParams) MarshalMultipart added in v0.6.0

func (r DeploymentNewParams) MarshalMultipart() (data []byte, contentType string, err error)

type DeploymentNewParamsRegion added in v0.6.0

type DeploymentNewParamsRegion string

Region for deployment. Currently we only support "aws.us-east-1a"

const (
	DeploymentNewParamsRegionAwsUsEast1a DeploymentNewParamsRegion = "aws.us-east-1a"
)

type DeploymentNewResponse added in v0.6.0

type DeploymentNewResponse struct {
	// Unique identifier for the deployment
	ID string `json:"id,required"`
	// Timestamp when the deployment was created
	CreatedAt time.Time `json:"created_at,required" format:"date-time"`
	// Deployment region code
	Region constant.AwsUsEast1a `json:"region,required"`
	// Current status of the deployment
	//
	// Any of "queued", "in_progress", "running", "failed", "stopped".
	Status DeploymentNewResponseStatus `json:"status,required"`
	// Relative path to the application entrypoint
	EntrypointRelPath string `json:"entrypoint_rel_path"`
	// Environment variables configured for this deployment
	EnvVars map[string]string `json:"env_vars"`
	// Status reason
	StatusReason string `json:"status_reason"`
	// Timestamp when the deployment was last updated
	UpdatedAt time.Time `json:"updated_at,nullable" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                respjson.Field
		CreatedAt         respjson.Field
		Region            respjson.Field
		Status            respjson.Field
		EntrypointRelPath respjson.Field
		EnvVars           respjson.Field
		StatusReason      respjson.Field
		UpdatedAt         respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Deployment record information.

func (DeploymentNewResponse) RawJSON added in v0.6.0

func (r DeploymentNewResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*DeploymentNewResponse) UnmarshalJSON added in v0.6.0

func (r *DeploymentNewResponse) UnmarshalJSON(data []byte) error

type DeploymentNewResponseStatus added in v0.6.0

type DeploymentNewResponseStatus string

Current status of the deployment

const (
	DeploymentNewResponseStatusQueued     DeploymentNewResponseStatus = "queued"
	DeploymentNewResponseStatusInProgress DeploymentNewResponseStatus = "in_progress"
	DeploymentNewResponseStatusRunning    DeploymentNewResponseStatus = "running"
	DeploymentNewResponseStatusFailed     DeploymentNewResponseStatus = "failed"
	DeploymentNewResponseStatusStopped    DeploymentNewResponseStatus = "stopped"
)

type DeploymentService added in v0.6.0

type DeploymentService struct {
	Options []option.RequestOption
}

DeploymentService contains methods and other services that help with interacting with the kernel API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewDeploymentService method instead.

func NewDeploymentService added in v0.6.0

func NewDeploymentService(opts ...option.RequestOption) (r DeploymentService)

NewDeploymentService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*DeploymentService) FollowStreaming added in v0.6.0

Establishes a Server-Sent Events (SSE) stream that delivers real-time logs and status updates for a deployment. The stream terminates automatically once the deployment reaches a terminal state.

func (*DeploymentService) Get added in v0.6.0

Get information about a deployment's status.

func (*DeploymentService) List added in v0.6.4

List deployments. Optionally filter by application name.

func (*DeploymentService) New added in v0.6.0

Create a new deployment.

type DeploymentStateEvent added in v0.6.0

type DeploymentStateEvent struct {
	// Deployment record information.
	Deployment DeploymentStateEventDeployment `json:"deployment,required"`
	// Event type identifier (always "deployment_state").
	Event constant.DeploymentState `json:"event,required"`
	// Time the state was reported.
	Timestamp time.Time `json:"timestamp,required" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Deployment  respjson.Field
		Event       respjson.Field
		Timestamp   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

An event representing the current state of a deployment.

func (DeploymentStateEvent) RawJSON added in v0.6.0

func (r DeploymentStateEvent) RawJSON() string

Returns the unmodified JSON received from the API

func (*DeploymentStateEvent) UnmarshalJSON added in v0.6.0

func (r *DeploymentStateEvent) UnmarshalJSON(data []byte) error

type DeploymentStateEventDeployment added in v0.6.0

type DeploymentStateEventDeployment struct {
	// Unique identifier for the deployment
	ID string `json:"id,required"`
	// Timestamp when the deployment was created
	CreatedAt time.Time `json:"created_at,required" format:"date-time"`
	// Deployment region code
	Region constant.AwsUsEast1a `json:"region,required"`
	// Current status of the deployment
	//
	// Any of "queued", "in_progress", "running", "failed", "stopped".
	Status string `json:"status,required"`
	// Relative path to the application entrypoint
	EntrypointRelPath string `json:"entrypoint_rel_path"`
	// Environment variables configured for this deployment
	EnvVars map[string]string `json:"env_vars"`
	// Status reason
	StatusReason string `json:"status_reason"`
	// Timestamp when the deployment was last updated
	UpdatedAt time.Time `json:"updated_at,nullable" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                respjson.Field
		CreatedAt         respjson.Field
		Region            respjson.Field
		Status            respjson.Field
		EntrypointRelPath respjson.Field
		EnvVars           respjson.Field
		StatusReason      respjson.Field
		UpdatedAt         respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Deployment record information.

func (DeploymentStateEventDeployment) RawJSON added in v0.6.0

Returns the unmodified JSON received from the API

func (*DeploymentStateEventDeployment) UnmarshalJSON added in v0.6.0

func (r *DeploymentStateEventDeployment) UnmarshalJSON(data []byte) error

type Error

type Error = apierror.Error

type ErrorDetail added in v0.6.0

type ErrorDetail = shared.ErrorDetail

This is an alias to an internal type.

type ErrorEvent added in v0.6.0

type ErrorEvent = shared.ErrorEvent

An error event from the application.

This is an alias to an internal type.

type ErrorModel added in v0.6.0

type ErrorModel = shared.ErrorModel

This is an alias to an internal type.

type HeartbeatEvent added in v0.6.2

type HeartbeatEvent = shared.HeartbeatEvent

Heartbeat event sent periodically to keep SSE connection alive.

This is an alias to an internal type.

type InvocationFollowResponseUnion added in v0.6.0

type InvocationFollowResponseUnion struct {
	// Any of "log", "invocation_state", "error", "sse_heartbeat".
	Event string `json:"event"`
	// This field is from variant [shared.LogEvent].
	Message   string    `json:"message"`
	Timestamp time.Time `json:"timestamp"`
	// This field is from variant [InvocationStateEvent].
	Invocation InvocationStateEventInvocation `json:"invocation"`
	// This field is from variant [shared.ErrorEvent].
	Error shared.ErrorModel `json:"error"`
	JSON  struct {
		Event      respjson.Field
		Message    respjson.Field
		Timestamp  respjson.Field
		Invocation respjson.Field
		Error      respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

InvocationFollowResponseUnion contains all possible properties and values from shared.LogEvent, InvocationStateEvent, shared.ErrorEvent, shared.HeartbeatEvent.

Use the InvocationFollowResponseUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (InvocationFollowResponseUnion) AsAny added in v0.6.0

func (u InvocationFollowResponseUnion) AsAny() anyInvocationFollowResponse

Use the following switch statement to find the correct variant

switch variant := InvocationFollowResponseUnion.AsAny().(type) {
case shared.LogEvent:
case kernel.InvocationStateEvent:
case shared.ErrorEvent:
case shared.HeartbeatEvent:
default:
  fmt.Errorf("no variant present")
}

func (InvocationFollowResponseUnion) AsError added in v0.6.0

func (InvocationFollowResponseUnion) AsInvocationState added in v0.6.0

func (u InvocationFollowResponseUnion) AsInvocationState() (v InvocationStateEvent)

func (InvocationFollowResponseUnion) AsLog added in v0.6.0

func (InvocationFollowResponseUnion) AsSseHeartbeat added in v0.6.2

func (u InvocationFollowResponseUnion) AsSseHeartbeat() (v shared.HeartbeatEvent)

func (InvocationFollowResponseUnion) RawJSON added in v0.6.0

Returns the unmodified JSON received from the API

func (*InvocationFollowResponseUnion) UnmarshalJSON added in v0.6.0

func (r *InvocationFollowResponseUnion) UnmarshalJSON(data []byte) error

type InvocationGetResponse added in v0.6.0

type InvocationGetResponse struct {
	// ID of the invocation
	ID string `json:"id,required"`
	// Name of the action invoked
	ActionName string `json:"action_name,required"`
	// Name of the application
	AppName string `json:"app_name,required"`
	// RFC 3339 Nanoseconds timestamp when the invocation started
	StartedAt time.Time `json:"started_at,required" format:"date-time"`
	// Status of the invocation
	//
	// Any of "queued", "running", "succeeded", "failed".
	Status InvocationGetResponseStatus `json:"status,required"`
	// RFC 3339 Nanoseconds timestamp when the invocation finished (null if still
	// running)
	FinishedAt time.Time `json:"finished_at,nullable" format:"date-time"`
	// Output produced by the action, rendered as a JSON string. This could be: string,
	// number, boolean, array, object, or null.
	Output string `json:"output"`
	// Payload provided to the invocation. This is a string that can be parsed as JSON.
	Payload string `json:"payload"`
	// Status reason
	StatusReason string `json:"status_reason"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		ActionName   respjson.Field
		AppName      respjson.Field
		StartedAt    respjson.Field
		Status       respjson.Field
		FinishedAt   respjson.Field
		Output       respjson.Field
		Payload      respjson.Field
		StatusReason respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (InvocationGetResponse) RawJSON added in v0.6.0

func (r InvocationGetResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*InvocationGetResponse) UnmarshalJSON added in v0.6.0

func (r *InvocationGetResponse) UnmarshalJSON(data []byte) error

type InvocationGetResponseStatus added in v0.6.0

type InvocationGetResponseStatus string

Status of the invocation

const (
	InvocationGetResponseStatusQueued    InvocationGetResponseStatus = "queued"
	InvocationGetResponseStatusRunning   InvocationGetResponseStatus = "running"
	InvocationGetResponseStatusSucceeded InvocationGetResponseStatus = "succeeded"
	InvocationGetResponseStatusFailed    InvocationGetResponseStatus = "failed"
)

type InvocationNewParams added in v0.6.0

type InvocationNewParams struct {
	// Name of the action to invoke
	ActionName string `json:"action_name,required"`
	// Name of the application
	AppName string `json:"app_name,required"`
	// Version of the application
	Version string `json:"version,required"`
	// If true, invoke asynchronously. When set, the API responds 202 Accepted with
	// status "queued".
	Async param.Opt[bool] `json:"async,omitzero"`
	// Input data for the action, sent as a JSON string.
	Payload param.Opt[string] `json:"payload,omitzero"`
	// contains filtered or unexported fields
}

func (InvocationNewParams) MarshalJSON added in v0.6.0

func (r InvocationNewParams) MarshalJSON() (data []byte, err error)

func (*InvocationNewParams) UnmarshalJSON added in v0.6.0

func (r *InvocationNewParams) UnmarshalJSON(data []byte) error

type InvocationNewResponse added in v0.6.0

type InvocationNewResponse struct {
	// ID of the invocation
	ID string `json:"id,required"`
	// Name of the action invoked
	ActionName string `json:"action_name,required"`
	// Status of the invocation
	//
	// Any of "queued", "running", "succeeded", "failed".
	Status InvocationNewResponseStatus `json:"status,required"`
	// The return value of the action that was invoked, rendered as a JSON string. This
	// could be: string, number, boolean, array, object, or null.
	Output string `json:"output"`
	// Status reason
	StatusReason string `json:"status_reason"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		ActionName   respjson.Field
		Status       respjson.Field
		Output       respjson.Field
		StatusReason respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (InvocationNewResponse) RawJSON added in v0.6.0

func (r InvocationNewResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*InvocationNewResponse) UnmarshalJSON added in v0.6.0

func (r *InvocationNewResponse) UnmarshalJSON(data []byte) error

type InvocationNewResponseStatus added in v0.6.0

type InvocationNewResponseStatus string

Status of the invocation

const (
	InvocationNewResponseStatusQueued    InvocationNewResponseStatus = "queued"
	InvocationNewResponseStatusRunning   InvocationNewResponseStatus = "running"
	InvocationNewResponseStatusSucceeded InvocationNewResponseStatus = "succeeded"
	InvocationNewResponseStatusFailed    InvocationNewResponseStatus = "failed"
)

type InvocationService added in v0.6.0

type InvocationService struct {
	Options []option.RequestOption
}

InvocationService contains methods and other services that help with interacting with the kernel API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewInvocationService method instead.

func NewInvocationService added in v0.6.0

func NewInvocationService(opts ...option.RequestOption) (r InvocationService)

NewInvocationService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*InvocationService) DeleteBrowsers added in v0.6.1

func (r *InvocationService) DeleteBrowsers(ctx context.Context, id string, opts ...option.RequestOption) (err error)

Delete all browser sessions created within the specified invocation.

func (*InvocationService) FollowStreaming added in v0.6.0

Establishes a Server-Sent Events (SSE) stream that delivers real-time logs and status updates for an invocation. The stream terminates automatically once the invocation reaches a terminal state.

func (*InvocationService) Get added in v0.6.0

Get details about an invocation's status and output.

func (*InvocationService) New added in v0.6.0

Invoke an action.

func (*InvocationService) Update added in v0.6.0

Update an invocation's status or output.

type InvocationStateEvent added in v0.6.0

type InvocationStateEvent struct {
	// Event type identifier (always "invocation_state").
	Event      constant.InvocationState       `json:"event,required"`
	Invocation InvocationStateEventInvocation `json:"invocation,required"`
	// Time the state was reported.
	Timestamp time.Time `json:"timestamp,required" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Event       respjson.Field
		Invocation  respjson.Field
		Timestamp   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

An event representing the current state of an invocation.

func (InvocationStateEvent) ImplInvocationFollowResponseUnion added in v0.6.0

func (InvocationStateEvent) ImplInvocationFollowResponseUnion()

func (InvocationStateEvent) RawJSON added in v0.6.0

func (r InvocationStateEvent) RawJSON() string

Returns the unmodified JSON received from the API

func (*InvocationStateEvent) UnmarshalJSON added in v0.6.0

func (r *InvocationStateEvent) UnmarshalJSON(data []byte) error

type InvocationStateEventInvocation added in v0.6.0

type InvocationStateEventInvocation struct {
	// ID of the invocation
	ID string `json:"id,required"`
	// Name of the action invoked
	ActionName string `json:"action_name,required"`
	// Name of the application
	AppName string `json:"app_name,required"`
	// RFC 3339 Nanoseconds timestamp when the invocation started
	StartedAt time.Time `json:"started_at,required" format:"date-time"`
	// Status of the invocation
	//
	// Any of "queued", "running", "succeeded", "failed".
	Status string `json:"status,required"`
	// RFC 3339 Nanoseconds timestamp when the invocation finished (null if still
	// running)
	FinishedAt time.Time `json:"finished_at,nullable" format:"date-time"`
	// Output produced by the action, rendered as a JSON string. This could be: string,
	// number, boolean, array, object, or null.
	Output string `json:"output"`
	// Payload provided to the invocation. This is a string that can be parsed as JSON.
	Payload string `json:"payload"`
	// Status reason
	StatusReason string `json:"status_reason"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		ActionName   respjson.Field
		AppName      respjson.Field
		StartedAt    respjson.Field
		Status       respjson.Field
		FinishedAt   respjson.Field
		Output       respjson.Field
		Payload      respjson.Field
		StatusReason respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (InvocationStateEventInvocation) RawJSON added in v0.6.0

Returns the unmodified JSON received from the API

func (*InvocationStateEventInvocation) UnmarshalJSON added in v0.6.0

func (r *InvocationStateEventInvocation) UnmarshalJSON(data []byte) error

type InvocationUpdateParams added in v0.6.0

type InvocationUpdateParams struct {
	// New status for the invocation.
	//
	// Any of "succeeded", "failed".
	Status InvocationUpdateParamsStatus `json:"status,omitzero,required"`
	// Updated output of the invocation rendered as JSON string.
	Output param.Opt[string] `json:"output,omitzero"`
	// contains filtered or unexported fields
}

func (InvocationUpdateParams) MarshalJSON added in v0.6.0

func (r InvocationUpdateParams) MarshalJSON() (data []byte, err error)

func (*InvocationUpdateParams) UnmarshalJSON added in v0.6.0

func (r *InvocationUpdateParams) UnmarshalJSON(data []byte) error

type InvocationUpdateParamsStatus added in v0.6.0

type InvocationUpdateParamsStatus string

New status for the invocation.

const (
	InvocationUpdateParamsStatusSucceeded InvocationUpdateParamsStatus = "succeeded"
	InvocationUpdateParamsStatusFailed    InvocationUpdateParamsStatus = "failed"
)

type InvocationUpdateResponse added in v0.6.0

type InvocationUpdateResponse struct {
	// ID of the invocation
	ID string `json:"id,required"`
	// Name of the action invoked
	ActionName string `json:"action_name,required"`
	// Name of the application
	AppName string `json:"app_name,required"`
	// RFC 3339 Nanoseconds timestamp when the invocation started
	StartedAt time.Time `json:"started_at,required" format:"date-time"`
	// Status of the invocation
	//
	// Any of "queued", "running", "succeeded", "failed".
	Status InvocationUpdateResponseStatus `json:"status,required"`
	// RFC 3339 Nanoseconds timestamp when the invocation finished (null if still
	// running)
	FinishedAt time.Time `json:"finished_at,nullable" format:"date-time"`
	// Output produced by the action, rendered as a JSON string. This could be: string,
	// number, boolean, array, object, or null.
	Output string `json:"output"`
	// Payload provided to the invocation. This is a string that can be parsed as JSON.
	Payload string `json:"payload"`
	// Status reason
	StatusReason string `json:"status_reason"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		ActionName   respjson.Field
		AppName      respjson.Field
		StartedAt    respjson.Field
		Status       respjson.Field
		FinishedAt   respjson.Field
		Output       respjson.Field
		Payload      respjson.Field
		StatusReason respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (InvocationUpdateResponse) RawJSON added in v0.6.0

func (r InvocationUpdateResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*InvocationUpdateResponse) UnmarshalJSON added in v0.6.0

func (r *InvocationUpdateResponse) UnmarshalJSON(data []byte) error

type InvocationUpdateResponseStatus added in v0.6.0

type InvocationUpdateResponseStatus string

Status of the invocation

const (
	InvocationUpdateResponseStatusQueued    InvocationUpdateResponseStatus = "queued"
	InvocationUpdateResponseStatusRunning   InvocationUpdateResponseStatus = "running"
	InvocationUpdateResponseStatusSucceeded InvocationUpdateResponseStatus = "succeeded"
	InvocationUpdateResponseStatusFailed    InvocationUpdateResponseStatus = "failed"
)

type LogEvent added in v0.6.0

type LogEvent = shared.LogEvent

A log entry from the application.

This is an alias to an internal type.

Directories

Path Synopsis
encoding/json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
Package json implements encoding and decoding of JSON as defined in RFC 7159.
encoding/json/shims
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.21, and used by the Go 1.24 encoding/json package.
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.21, and used by the Go 1.24 encoding/json package.
packages

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL