@@ -11,10 +11,12 @@ import (
1111 "io"
1212 "mime/multipart"
1313 "net/http"
14+ "net/url"
1415 "time"
1516
1617 "github.com/onkernel/kernel-go-sdk/internal/apiform"
1718 "github.com/onkernel/kernel-go-sdk/internal/apijson"
19+ "github.com/onkernel/kernel-go-sdk/internal/apiquery"
1820 "github.com/onkernel/kernel-go-sdk/internal/requestconfig"
1921 "github.com/onkernel/kernel-go-sdk/option"
2022 "github.com/onkernel/kernel-go-sdk/packages/param"
@@ -66,7 +68,7 @@ func (r *DeploymentService) Get(ctx context.Context, id string, opts ...option.R
6668// Establishes a Server-Sent Events (SSE) stream that delivers real-time logs and
6769// status updates for a deployment. The stream terminates automatically once the
6870// deployment reaches a terminal state.
69- func (r * DeploymentService ) FollowStreaming (ctx context.Context , id string , opts ... option.RequestOption ) (stream * ssestream.Stream [DeploymentFollowResponseUnion ]) {
71+ func (r * DeploymentService ) FollowStreaming (ctx context.Context , id string , query DeploymentFollowParams , opts ... option.RequestOption ) (stream * ssestream.Stream [DeploymentFollowResponseUnion ]) {
7072 var (
7173 raw * http.Response
7274 err error
@@ -78,7 +80,7 @@ func (r *DeploymentService) FollowStreaming(ctx context.Context, id string, opts
7880 return
7981 }
8082 path := fmt .Sprintf ("deployments/%s/events" , id )
81- err = requestconfig .ExecuteNewRequest (ctx , http .MethodGet , path , nil , & raw , opts ... )
83+ err = requestconfig .ExecuteNewRequest (ctx , http .MethodGet , path , query , & raw , opts ... )
8284 return ssestream .NewStream [DeploymentFollowResponseUnion ](ssestream .NewDecoder (raw ), err )
8385}
8486
@@ -253,13 +255,14 @@ const (
253255
254256// DeploymentFollowResponseUnion contains all possible properties and values from
255257// [shared.LogEvent], [DeploymentStateEvent],
256- // [DeploymentFollowResponseAppVersionSummaryEvent], [shared.ErrorEvent].
258+ // [DeploymentFollowResponseAppVersionSummaryEvent], [shared.ErrorEvent],
259+ // [shared.HeartbeatEvent].
257260//
258261// Use the [DeploymentFollowResponseUnion.AsAny] method to switch on the variant.
259262//
260263// Use the methods beginning with 'As' to cast the union to one of its variants.
261264type DeploymentFollowResponseUnion struct {
262- // Any of "log", "deployment_state", nil, nil.
265+ // Any of "log", "deployment_state", nil, nil, "sse_heartbeat" .
263266 Event string `json:"event"`
264267 // This field is from variant [shared.LogEvent].
265268 Message string `json:"message"`
@@ -316,6 +319,11 @@ func (u DeploymentFollowResponseUnion) AsErrorEvent() (v shared.ErrorEvent) {
316319 return
317320}
318321
322+ func (u DeploymentFollowResponseUnion ) AsSseHeartbeat () (v shared.HeartbeatEvent ) {
323+ apijson .UnmarshalRoot (json .RawMessage (u .JSON .raw ), & v )
324+ return
325+ }
326+
319327// Returns the unmodified JSON received from the API
320328func (u DeploymentFollowResponseUnion ) RawJSON () string { return u .JSON .raw }
321329
@@ -423,3 +431,17 @@ type DeploymentNewParamsRegion string
423431const (
424432 DeploymentNewParamsRegionAwsUsEast1a DeploymentNewParamsRegion = "aws.us-east-1a"
425433)
434+
435+ type DeploymentFollowParams struct {
436+ // Show logs since the given time (RFC timestamps or durations like 5m).
437+ Since param.Opt [string ] `query:"since,omitzero" json:"-"`
438+ paramObj
439+ }
440+
441+ // URLQuery serializes [DeploymentFollowParams]'s query parameters as `url.Values`.
442+ func (r DeploymentFollowParams ) URLQuery () (v url.Values , err error ) {
443+ return apiquery .MarshalWithSettings (r , apiquery.QuerySettings {
444+ ArrayFormat : apiquery .ArrayQueryFormatComma ,
445+ NestedFormat : apiquery .NestedQueryFormatBrackets ,
446+ })
447+ }
0 commit comments