Skip to content

Commit 0fec1e5

Browse files
feat(api): update via SDK Studio
1 parent b44c90e commit 0fec1e5

6 files changed

Lines changed: 78 additions & 140 deletions

File tree

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 15
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-5d4e11bc46eeecee7363d56a9dfe946acee997d5b352c2b0a50c20e742c54d2d.yml
3-
openapi_spec_hash: 333e53ad9c706296b9afdb8ff73bec8f
4-
config_hash: 4e2f9aebc2153d5caf7bb8b2eb107026
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-b1b412b00906fca75bfa73cff7267dbb5bf975581778072e0a90c73ad7ba9cb1.yml
3+
openapi_spec_hash: 9b7a1b29bcb4963fe6da37005c357d27
4+
config_hash: df959c379e1145106030a4869b006afe

aliases.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@ type paramObj = param.APIObject
1616

1717
type Error = apierror.Error
1818

19+
// This is an alias to an internal type.
20+
type Error = shared.Error
21+
1922
// This is an alias to an internal type.
2023
type ErrorDetail = shared.ErrorDetail
2124

25+
// An error event from the application.
26+
//
27+
// This is an alias to an internal type.
28+
type ErrorEvent = shared.ErrorEvent
29+
2230
// A log entry from the application.
2331
//
2432
// This is an alias to an internal type.

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Shared Response Types
22

3+
- <a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk/shared">shared</a>.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk/shared#Error">Error</a>
34
- <a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk/shared">shared</a>.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk/shared#ErrorDetail">ErrorDetail</a>
5+
- <a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk/shared">shared</a>.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk/shared#ErrorEvent">ErrorEvent</a>
46
- <a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk/shared">shared</a>.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk/shared#LogEvent">LogEvent</a>
57

68
# Deployments

deployment.go

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,7 @@ const (
253253

254254
// DeploymentFollowResponseUnion contains all possible properties and values from
255255
// [shared.LogEvent], [DeploymentStateEvent],
256-
// [DeploymentFollowResponseAppVersionSummaryEvent],
257-
// [DeploymentFollowResponseErrorEvent].
256+
// [DeploymentFollowResponseAppVersionSummaryEvent], [shared.ErrorEvent].
258257
//
259258
// Use the [DeploymentFollowResponseUnion.AsAny] method to switch on the variant.
260259
//
@@ -279,8 +278,8 @@ type DeploymentFollowResponseUnion struct {
279278
Version string `json:"version"`
280279
// This field is from variant [DeploymentFollowResponseAppVersionSummaryEvent].
281280
EnvVars map[string]string `json:"env_vars"`
282-
// This field is from variant [DeploymentFollowResponseErrorEvent].
283-
Error DeploymentFollowResponseErrorEventError `json:"error"`
281+
// This field is from variant [shared.ErrorEvent].
282+
Error shared.Error `json:"error"`
284283
JSON struct {
285284
Event respjson.Field
286285
Message respjson.Field
@@ -312,7 +311,7 @@ func (u DeploymentFollowResponseUnion) AsDeploymentFollowResponseAppVersionSumma
312311
return
313312
}
314313

315-
func (u DeploymentFollowResponseUnion) AsDeploymentFollowResponseErrorEvent() (v DeploymentFollowResponseErrorEvent) {
314+
func (u DeploymentFollowResponseUnion) AsErrorEvent() (v shared.ErrorEvent) {
316315
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
317316
return
318317
}
@@ -381,54 +380,6 @@ func (r *DeploymentFollowResponseAppVersionSummaryEventAction) UnmarshalJSON(dat
381380
return apijson.UnmarshalRoot(data, r)
382381
}
383382

384-
// An error event from the application.
385-
type DeploymentFollowResponseErrorEvent struct {
386-
Error DeploymentFollowResponseErrorEventError `json:"error,required"`
387-
// Event type identifier (always "error").
388-
Event constant.Error `json:"event,required"`
389-
// Time the error occurred.
390-
Timestamp time.Time `json:"timestamp,required" format:"date-time"`
391-
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
392-
JSON struct {
393-
Error respjson.Field
394-
Event respjson.Field
395-
Timestamp respjson.Field
396-
ExtraFields map[string]respjson.Field
397-
raw string
398-
} `json:"-"`
399-
}
400-
401-
// Returns the unmodified JSON received from the API
402-
func (r DeploymentFollowResponseErrorEvent) RawJSON() string { return r.JSON.raw }
403-
func (r *DeploymentFollowResponseErrorEvent) UnmarshalJSON(data []byte) error {
404-
return apijson.UnmarshalRoot(data, r)
405-
}
406-
407-
type DeploymentFollowResponseErrorEventError struct {
408-
// Application-specific error code (machine-readable)
409-
Code string `json:"code,required"`
410-
// Human-readable error description for debugging
411-
Message string `json:"message,required"`
412-
// Additional error details (for multiple errors)
413-
Details []shared.ErrorDetail `json:"details"`
414-
InnerError shared.ErrorDetail `json:"inner_error"`
415-
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
416-
JSON struct {
417-
Code respjson.Field
418-
Message respjson.Field
419-
Details respjson.Field
420-
InnerError respjson.Field
421-
ExtraFields map[string]respjson.Field
422-
raw string
423-
} `json:"-"`
424-
}
425-
426-
// Returns the unmodified JSON received from the API
427-
func (r DeploymentFollowResponseErrorEventError) RawJSON() string { return r.JSON.raw }
428-
func (r *DeploymentFollowResponseErrorEventError) UnmarshalJSON(data []byte) error {
429-
return apijson.UnmarshalRoot(data, r)
430-
}
431-
432383
type DeploymentNewParams struct {
433384
// Relative path to the entrypoint of the application
434385
EntrypointRelPath string `json:"entrypoint_rel_path,required"`

invocation.go

Lines changed: 13 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -308,63 +308,41 @@ const (
308308
)
309309

310310
// InvocationFollowResponseUnion contains all possible properties and values from
311-
// [shared.LogEvent], [InvocationStateEvent], [InvocationFollowResponseError].
311+
// [shared.LogEvent], [DeploymentStateEvent], [InvocationStateEvent],
312+
// [shared.ErrorEvent].
312313
//
313314
// Use the [InvocationFollowResponseUnion.AsAny] method to switch on the variant.
314315
//
315316
// Use the methods beginning with 'As' to cast the union to one of its variants.
316317
type InvocationFollowResponseUnion struct {
317-
// Any of "log", "invocation_state", "error".
318+
// Any of "log", nil, "invocation_state", "error".
318319
Event string `json:"event"`
319320
// This field is from variant [shared.LogEvent].
320321
Message string `json:"message"`
321322
Timestamp time.Time `json:"timestamp"`
323+
// This field is from variant [DeploymentStateEvent].
324+
Deployment DeploymentStateEventDeployment `json:"deployment"`
322325
// This field is from variant [InvocationStateEvent].
323326
Invocation InvocationStateEventInvocation `json:"invocation"`
324-
// This field is from variant [InvocationFollowResponseError].
325-
Error InvocationFollowResponseErrorError `json:"error"`
327+
// This field is from variant [shared.ErrorEvent].
328+
Error shared.Error `json:"error"`
326329
JSON struct {
327330
Event respjson.Field
328331
Message respjson.Field
329332
Timestamp respjson.Field
333+
Deployment respjson.Field
330334
Invocation respjson.Field
331335
Error respjson.Field
332336
raw string
333337
} `json:"-"`
334338
}
335339

336-
// anyInvocationFollowResponse is implemented by each variant of
337-
// [InvocationFollowResponseUnion] to add type safety for the return type of
338-
// [InvocationFollowResponseUnion.AsAny]
339-
type anyInvocationFollowResponse interface {
340-
ImplInvocationFollowResponseUnion()
341-
}
342-
343-
func (InvocationStateEvent) ImplInvocationFollowResponseUnion() {}
344-
func (InvocationFollowResponseError) ImplInvocationFollowResponseUnion() {}
345-
346-
// Use the following switch statement to find the correct variant
347-
//
348-
// switch variant := InvocationFollowResponseUnion.AsAny().(type) {
349-
// case shared.LogEvent:
350-
// case kernel.InvocationStateEvent:
351-
// case kernel.InvocationFollowResponseError:
352-
// default:
353-
// fmt.Errorf("no variant present")
354-
// }
355-
func (u InvocationFollowResponseUnion) AsAny() anyInvocationFollowResponse {
356-
switch u.Event {
357-
case "log":
358-
return u.AsLog()
359-
case "invocation_state":
360-
return u.AsInvocationState()
361-
case "error":
362-
return u.AsError()
363-
}
364-
return nil
340+
func (u InvocationFollowResponseUnion) AsLog() (v shared.LogEvent) {
341+
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
342+
return
365343
}
366344

367-
func (u InvocationFollowResponseUnion) AsLog() (v shared.LogEvent) {
345+
func (u InvocationFollowResponseUnion) AsDeploymentStateEvent() (v DeploymentStateEvent) {
368346
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
369347
return
370348
}
@@ -374,7 +352,7 @@ func (u InvocationFollowResponseUnion) AsInvocationState() (v InvocationStateEve
374352
return
375353
}
376354

377-
func (u InvocationFollowResponseUnion) AsError() (v InvocationFollowResponseError) {
355+
func (u InvocationFollowResponseUnion) AsError() (v shared.ErrorEvent) {
378356
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
379357
return
380358
}
@@ -386,54 +364,6 @@ func (r *InvocationFollowResponseUnion) UnmarshalJSON(data []byte) error {
386364
return apijson.UnmarshalRoot(data, r)
387365
}
388366

389-
// An error event from the application.
390-
type InvocationFollowResponseError struct {
391-
Error InvocationFollowResponseErrorError `json:"error,required"`
392-
// Event type identifier (always "error").
393-
Event constant.Error `json:"event,required"`
394-
// Time the error occurred.
395-
Timestamp time.Time `json:"timestamp,required" format:"date-time"`
396-
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
397-
JSON struct {
398-
Error respjson.Field
399-
Event respjson.Field
400-
Timestamp respjson.Field
401-
ExtraFields map[string]respjson.Field
402-
raw string
403-
} `json:"-"`
404-
}
405-
406-
// Returns the unmodified JSON received from the API
407-
func (r InvocationFollowResponseError) RawJSON() string { return r.JSON.raw }
408-
func (r *InvocationFollowResponseError) UnmarshalJSON(data []byte) error {
409-
return apijson.UnmarshalRoot(data, r)
410-
}
411-
412-
type InvocationFollowResponseErrorError struct {
413-
// Application-specific error code (machine-readable)
414-
Code string `json:"code,required"`
415-
// Human-readable error description for debugging
416-
Message string `json:"message,required"`
417-
// Additional error details (for multiple errors)
418-
Details []shared.ErrorDetail `json:"details"`
419-
InnerError shared.ErrorDetail `json:"inner_error"`
420-
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
421-
JSON struct {
422-
Code respjson.Field
423-
Message respjson.Field
424-
Details respjson.Field
425-
InnerError respjson.Field
426-
ExtraFields map[string]respjson.Field
427-
raw string
428-
} `json:"-"`
429-
}
430-
431-
// Returns the unmodified JSON received from the API
432-
func (r InvocationFollowResponseErrorError) RawJSON() string { return r.JSON.raw }
433-
func (r *InvocationFollowResponseErrorError) UnmarshalJSON(data []byte) error {
434-
return apijson.UnmarshalRoot(data, r)
435-
}
436-
437367
type InvocationNewParams struct {
438368
// Name of the action to invoke
439369
ActionName string `json:"action_name,required"`

shared/shared.go

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,31 @@ type paramUnion = param.APIUnion
1717
// aliased to make [param.APIObject] private when embedding
1818
type paramObj = param.APIObject
1919

20+
type Error struct {
21+
// Application-specific error code (machine-readable)
22+
Code string `json:"code,required"`
23+
// Human-readable error description for debugging
24+
Message string `json:"message,required"`
25+
// Additional error details (for multiple errors)
26+
Details []ErrorDetail `json:"details"`
27+
InnerError ErrorDetail `json:"inner_error"`
28+
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
29+
JSON struct {
30+
Code respjson.Field
31+
Message respjson.Field
32+
Details respjson.Field
33+
InnerError respjson.Field
34+
ExtraFields map[string]respjson.Field
35+
raw string
36+
} `json:"-"`
37+
}
38+
39+
// Returns the unmodified JSON received from the API
40+
func (r Error) RawJSON() string { return r.JSON.raw }
41+
func (r *Error) UnmarshalJSON(data []byte) error {
42+
return apijson.UnmarshalRoot(data, r)
43+
}
44+
2045
type ErrorDetail struct {
2146
// Lower-level error code providing more specific detail
2247
Code string `json:"code"`
@@ -37,6 +62,29 @@ func (r *ErrorDetail) UnmarshalJSON(data []byte) error {
3762
return apijson.UnmarshalRoot(data, r)
3863
}
3964

65+
// An error event from the application.
66+
type ErrorEvent struct {
67+
Error Error `json:"error,required"`
68+
// Event type identifier (always "error").
69+
Event constant.Error `json:"event,required"`
70+
// Time the error occurred.
71+
Timestamp time.Time `json:"timestamp,required" format:"date-time"`
72+
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
73+
JSON struct {
74+
Error respjson.Field
75+
Event respjson.Field
76+
Timestamp respjson.Field
77+
ExtraFields map[string]respjson.Field
78+
raw string
79+
} `json:"-"`
80+
}
81+
82+
// Returns the unmodified JSON received from the API
83+
func (r ErrorEvent) RawJSON() string { return r.JSON.raw }
84+
func (r *ErrorEvent) UnmarshalJSON(data []byte) error {
85+
return apijson.UnmarshalRoot(data, r)
86+
}
87+
4088
// A log entry from the application.
4189
type LogEvent struct {
4290
// Event type identifier (always "log").
@@ -62,4 +110,3 @@ func (r *LogEvent) UnmarshalJSON(data []byte) error {
62110
}
63111

64112
func (LogEvent) ImplAppDeploymentFollowResponseUnion() {}
65-
func (LogEvent) ImplInvocationFollowResponseUnion() {}

0 commit comments

Comments
 (0)