@@ -82,6 +82,25 @@ func (r *InstanceService) Delete(ctx context.Context, id string, opts ...option.
8282 return
8383}
8484
85+ // Streams instance console logs as Server-Sent Events. Returns the last N lines
86+ // (controlled by `tail` parameter), then optionally continues streaming new lines
87+ // if `follow=true`.
88+ func (r * InstanceService ) LogsStreaming (ctx context.Context , id string , query InstanceLogsParams , opts ... option.RequestOption ) (stream * ssestream.Stream [string ]) {
89+ var (
90+ raw * http.Response
91+ err error
92+ )
93+ opts = slices .Concat (r .Options , opts )
94+ opts = append ([]option.RequestOption {option .WithHeader ("Accept" , "text/event-stream" )}, opts ... )
95+ if id == "" {
96+ err = errors .New ("missing required id parameter" )
97+ return
98+ }
99+ path := fmt .Sprintf ("instances/%s/logs" , id )
100+ err = requestconfig .ExecuteNewRequest (ctx , http .MethodGet , path , query , & raw , opts ... )
101+ return ssestream .NewStream [string ](ssestream .NewDecoder (raw ), err )
102+ }
103+
85104// Put instance in standby (pause, snapshot, delete VMM)
86105func (r * InstanceService ) PutInStandby (ctx context.Context , id string , opts ... option.RequestOption ) (res * Instance , err error ) {
87106 opts = slices .Concat (r .Options , opts )
@@ -106,23 +125,6 @@ func (r *InstanceService) RestoreFromStandby(ctx context.Context, id string, opt
106125 return
107126}
108127
109- // Stream instance logs (SSE)
110- func (r * InstanceService ) StreamLogsStreaming (ctx context.Context , id string , query InstanceStreamLogsParams , opts ... option.RequestOption ) (stream * ssestream.Stream [string ]) {
111- var (
112- raw * http.Response
113- err error
114- )
115- opts = slices .Concat (r .Options , opts )
116- opts = append ([]option.RequestOption {option .WithHeader ("Accept" , "text/event-stream" )}, opts ... )
117- if id == "" {
118- err = errors .New ("missing required id parameter" )
119- return
120- }
121- path := fmt .Sprintf ("instances/%s/logs" , id )
122- err = requestconfig .ExecuteNewRequest (ctx , http .MethodGet , path , query , & raw , opts ... )
123- return ssestream .NewStream [string ](ssestream .NewDecoder (raw ), err )
124- }
125-
126128type Instance struct {
127129 // Auto-generated unique identifier (CUID2 format)
128130 ID string `json:"id,required"`
@@ -278,17 +280,16 @@ func (r *InstanceNewParamsNetwork) UnmarshalJSON(data []byte) error {
278280 return apijson .UnmarshalRoot (data , r )
279281}
280282
281- type InstanceStreamLogsParams struct {
282- // Follow logs (stream with SSE)
283+ type InstanceLogsParams struct {
284+ // Continue streaming new lines after initial output
283285 Follow param.Opt [bool ] `query:"follow,omitzero" json:"-"`
284286 // Number of lines to return from end
285287 Tail param.Opt [int64 ] `query:"tail,omitzero" json:"-"`
286288 paramObj
287289}
288290
289- // URLQuery serializes [InstanceStreamLogsParams]'s query parameters as
290- // `url.Values`.
291- func (r InstanceStreamLogsParams ) URLQuery () (v url.Values , err error ) {
291+ // URLQuery serializes [InstanceLogsParams]'s query parameters as `url.Values`.
292+ func (r InstanceLogsParams ) URLQuery () (v url.Values , err error ) {
292293 return apiquery .MarshalWithSettings (r , apiquery.QuerySettings {
293294 ArrayFormat : apiquery .ArrayQueryFormatComma ,
294295 NestedFormat : apiquery .NestedQueryFormatBrackets ,
0 commit comments