@@ -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.
316317type 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-
437367type InvocationNewParams struct {
438368 // Name of the action to invoke
439369 ActionName string `json:"action_name,required"`
0 commit comments