33package kernel
44
55import (
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+ }
0 commit comments