Skip to content

Commit 2f5051e

Browse files
feat(api): update via SDK Studio
1 parent 368ec0a commit 2f5051e

4 files changed

Lines changed: 116 additions & 4 deletions

File tree

.stats.yml

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

api.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Apps
22

3+
Response Types:
4+
5+
- <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#AppListResponse">AppListResponse</a>
6+
7+
Methods:
8+
9+
- <code title="get /apps">client.Apps.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#AppService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#AppListParams">AppListParams</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#AppListResponse">AppListResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
10+
311
## Deployments
412

513
Response Types:

app.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@
33
package kernel
44

55
import (
6+
"context"
7+
"net/http"
8+
"net/url"
9+
10+
"github.com/onkernel/kernel-go-sdk/internal/apijson"
11+
"github.com/onkernel/kernel-go-sdk/internal/apiquery"
12+
"github.com/onkernel/kernel-go-sdk/internal/requestconfig"
613
"github.com/onkernel/kernel-go-sdk/option"
14+
"github.com/onkernel/kernel-go-sdk/packages/param"
15+
"github.com/onkernel/kernel-go-sdk/packages/respjson"
716
)
817

918
// AppService contains methods and other services that help with interacting with
@@ -28,3 +37,58 @@ func NewAppService(opts ...option.RequestOption) (r AppService) {
2837
r.Invocations = NewAppInvocationService(opts...)
2938
return
3039
}
40+
41+
// List application versions for the authenticated user. Optionally filter by app
42+
// name and/or version label.
43+
func (r *AppService) List(ctx context.Context, query AppListParams, opts ...option.RequestOption) (res *[]AppListResponse, err error) {
44+
opts = append(r.Options[:], opts...)
45+
path := "apps"
46+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
47+
return
48+
}
49+
50+
// Summary of an application version.
51+
type AppListResponse struct {
52+
// Unique identifier for the app version
53+
ID string `json:"id,required"`
54+
// Name of the application
55+
AppName string `json:"app_name,required"`
56+
// Deployment region code
57+
Region string `json:"region,required"`
58+
// Version label for the application
59+
Version string `json:"version,required"`
60+
// Environment variables configured for this app version
61+
EnvVars map[string]string `json:"env_vars"`
62+
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
63+
JSON struct {
64+
ID respjson.Field
65+
AppName respjson.Field
66+
Region respjson.Field
67+
Version respjson.Field
68+
EnvVars respjson.Field
69+
ExtraFields map[string]respjson.Field
70+
raw string
71+
} `json:"-"`
72+
}
73+
74+
// Returns the unmodified JSON received from the API
75+
func (r AppListResponse) RawJSON() string { return r.JSON.raw }
76+
func (r *AppListResponse) UnmarshalJSON(data []byte) error {
77+
return apijson.UnmarshalRoot(data, r)
78+
}
79+
80+
type AppListParams struct {
81+
// Filter results by application name.
82+
AppName param.Opt[string] `query:"app_name,omitzero" json:"-"`
83+
// Filter results by version label.
84+
Version param.Opt[string] `query:"version,omitzero" json:"-"`
85+
paramObj
86+
}
87+
88+
// URLQuery serializes [AppListParams]'s query parameters as `url.Values`.
89+
func (r AppListParams) URLQuery() (v url.Values, err error) {
90+
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
91+
ArrayFormat: apiquery.ArrayQueryFormatComma,
92+
NestedFormat: apiquery.NestedQueryFormatBrackets,
93+
})
94+
}

app_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package kernel_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/onkernel/kernel-go-sdk"
12+
"github.com/onkernel/kernel-go-sdk/internal/testutil"
13+
"github.com/onkernel/kernel-go-sdk/option"
14+
)
15+
16+
func TestAppListWithOptionalParams(t *testing.T) {
17+
t.Skip("skipped: tests are disabled for the time being")
18+
baseURL := "http://localhost:4010"
19+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
20+
baseURL = envURL
21+
}
22+
if !testutil.CheckTestServer(t, baseURL) {
23+
return
24+
}
25+
client := kernel.NewClient(
26+
option.WithBaseURL(baseURL),
27+
option.WithAPIKey("My API Key"),
28+
)
29+
_, err := client.Apps.List(context.TODO(), kernel.AppListParams{
30+
AppName: kernel.String("app_name"),
31+
Version: kernel.String("version"),
32+
})
33+
if err != nil {
34+
var apierr *kernel.Error
35+
if errors.As(err, &apierr) {
36+
t.Log(string(apierr.DumpRequest(true)))
37+
}
38+
t.Fatalf("err should be nil: %s", err.Error())
39+
}
40+
}

0 commit comments

Comments
 (0)