Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.3.0"
".": "0.4.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 10
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-3edc7a0eef4a0d4495782efbdb0d9b777a55aee058dab119f90de56019441326.yml
openapi_spec_hash: dff0b1efa1c1614cf770ed8327cefab2
config_hash: cb04a4d88ee9f530b303ca57ff7090b3
configured_endpoints: 11
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-64ccdff4ca5d73d79d89e817fe83ccfd3d529696df3e6818c3c75e586ae00801.yml
openapi_spec_hash: 21c7b8757fc0cc9415cda1bc06251de6
config_hash: b3fcacd707da56b21d31ce0baf4fb87d
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.4.0 (2025-05-28)

Full Changelog: [v0.3.0...v0.4.0](https://github.com/onkernel/kernel-go-sdk/compare/v0.3.0...v0.4.0)

### Features

* **api:** update via SDK Studio ([ac5cf50](https://github.com/onkernel/kernel-go-sdk/commit/ac5cf50867c042d1da5329f2441855ab89efd686))

## 0.3.0 (2025-05-22)

Full Changelog: [v0.2.0...v0.3.0](https://github.com/onkernel/kernel-go-sdk/compare/v0.2.0...v0.3.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/onkernel/kernel-go-sdk@v0.3.0'
go get -u 'github.com/onkernel/kernel-go-sdk@v0.4.0'
```

<!-- x-release-please-end -->
Expand Down
2 changes: 2 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ Response Types:

- <a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#AppInvocationNewResponse">AppInvocationNewResponse</a>
- <a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#AppInvocationGetResponse">AppInvocationGetResponse</a>
- <a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#AppInvocationUpdateResponse">AppInvocationUpdateResponse</a>

Methods:

- <code title="post /invocations">client.Apps.Invocations.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#AppInvocationService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#AppInvocationNewParams">AppInvocationNewParams</a>) (<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#AppInvocationNewResponse">AppInvocationNewResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /invocations/{id}">client.Apps.Invocations.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#AppInvocationService.Get">Get</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/onkernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#AppInvocationGetResponse">AppInvocationGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="patch /invocations/{id}">client.Apps.Invocations.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#AppInvocationService.Update">Update</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>, body <a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#AppInvocationUpdateParams">AppInvocationUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#AppInvocationUpdateResponse">AppInvocationUpdateResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

# Browsers

Expand Down
96 changes: 96 additions & 0 deletions appinvocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ func (r *AppInvocationService) Get(ctx context.Context, id string, opts ...optio
return
}

// Update invocation status or output
func (r *AppInvocationService) Update(ctx context.Context, id string, body AppInvocationUpdateParams, opts ...option.RequestOption) (res *AppInvocationUpdateResponse, err error) {
opts = append(r.Options[:], opts...)
if id == "" {
err = errors.New("missing required id parameter")
return
}
path := fmt.Sprintf("invocations/%s", id)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
return
}

type AppInvocationNewResponse struct {
// ID of the invocation
ID string `json:"id,required"`
Expand Down Expand Up @@ -149,13 +161,71 @@ const (
AppInvocationGetResponseStatusFailed AppInvocationGetResponseStatus = "failed"
)

type AppInvocationUpdateResponse 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 AppInvocationUpdateResponseStatus `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
raw string
} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r AppInvocationUpdateResponse) RawJSON() string { return r.JSON.raw }
func (r *AppInvocationUpdateResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

// Status of the invocation
type AppInvocationUpdateResponseStatus string

const (
AppInvocationUpdateResponseStatusQueued AppInvocationUpdateResponseStatus = "queued"
AppInvocationUpdateResponseStatusRunning AppInvocationUpdateResponseStatus = "running"
AppInvocationUpdateResponseStatusSucceeded AppInvocationUpdateResponseStatus = "succeeded"
AppInvocationUpdateResponseStatusFailed AppInvocationUpdateResponseStatus = "failed"
)

type AppInvocationNewParams 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"`
paramObj
Expand All @@ -168,3 +238,29 @@ func (r AppInvocationNewParams) MarshalJSON() (data []byte, err error) {
func (r *AppInvocationNewParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

type AppInvocationUpdateParams struct {
// New status for the invocation.
//
// Any of "succeeded", "failed".
Status AppInvocationUpdateParamsStatus `json:"status,omitzero,required"`
// Updated output of the invocation rendered as JSON string.
Output param.Opt[string] `json:"output,omitzero"`
paramObj
}

func (r AppInvocationUpdateParams) MarshalJSON() (data []byte, err error) {
type shadow AppInvocationUpdateParams
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *AppInvocationUpdateParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

// New status for the invocation.
type AppInvocationUpdateParamsStatus string

const (
AppInvocationUpdateParamsStatusSucceeded AppInvocationUpdateParamsStatus = "succeeded"
AppInvocationUpdateParamsStatusFailed AppInvocationUpdateParamsStatus = "failed"
)
31 changes: 31 additions & 0 deletions appinvocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func TestAppInvocationNewWithOptionalParams(t *testing.T) {
ActionName: "analyze",
AppName: "my-app",
Version: "1.0.0",
Async: kernel.Bool(true),
Payload: kernel.String(`{"data":"example input"}`),
})
if err != nil {
Expand Down Expand Up @@ -63,3 +64,33 @@ func TestAppInvocationGet(t *testing.T) {
t.Fatalf("err should be nil: %s", err.Error())
}
}

func TestAppInvocationUpdateWithOptionalParams(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := kernel.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
_, err := client.Apps.Invocations.Update(
context.TODO(),
"id",
kernel.AppInvocationUpdateParams{
Status: kernel.AppInvocationUpdateParamsStatusSucceeded,
Output: kernel.String("output"),
},
)
if err != nil {
var apierr *kernel.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}
2 changes: 1 addition & 1 deletion internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

package internal

const PackageVersion = "0.3.0" // x-release-please-version
const PackageVersion = "0.4.0" // x-release-please-version