-
Notifications
You must be signed in to change notification settings - Fork 211
Expand file tree
/
Copy pathbetadeployment.go
More file actions
2255 lines (2004 loc) · 90.9 KB
/
Copy pathbetadeployment.go
File metadata and controls
2255 lines (2004 loc) · 90.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package anthropic
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"slices"
"time"
"github.com/anthropics/anthropic-sdk-go/internal/apijson"
"github.com/anthropics/anthropic-sdk-go/internal/apiquery"
"github.com/anthropics/anthropic-sdk-go/internal/requestconfig"
"github.com/anthropics/anthropic-sdk-go/option"
"github.com/anthropics/anthropic-sdk-go/packages/pagination"
"github.com/anthropics/anthropic-sdk-go/packages/param"
"github.com/anthropics/anthropic-sdk-go/packages/respjson"
)
// BetaDeploymentService contains methods and other services that help with
// interacting with the anthropic API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewBetaDeploymentService] method instead.
type BetaDeploymentService struct {
Options []option.RequestOption
}
// NewBetaDeploymentService generates a new service that applies the given options
// to each request. These options are applied after the parent client's options (if
// there is one), and before any request-specific options.
func NewBetaDeploymentService(opts ...option.RequestOption) (r BetaDeploymentService) {
r = BetaDeploymentService{}
r.Options = opts
return
}
// Create Deployment
func (r *BetaDeploymentService) New(ctx context.Context, params BetaDeploymentNewParams, opts ...option.RequestOption) (res *BetaManagedAgentsDeployment, err error) {
for _, v := range params.Betas {
opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
}
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
path := "v1/deployments?beta=true"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
return res, err
}
// Get Deployment
func (r *BetaDeploymentService) Get(ctx context.Context, deploymentID string, query BetaDeploymentGetParams, opts ...option.RequestOption) (res *BetaManagedAgentsDeployment, err error) {
for _, v := range query.Betas {
opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
}
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
if deploymentID == "" {
err = errors.New("missing required deployment_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/deployments/%s?beta=true", deploymentID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
// Update Deployment
func (r *BetaDeploymentService) Update(ctx context.Context, deploymentID string, params BetaDeploymentUpdateParams, opts ...option.RequestOption) (res *BetaManagedAgentsDeployment, err error) {
for _, v := range params.Betas {
opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
}
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
if deploymentID == "" {
err = errors.New("missing required deployment_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/deployments/%s?beta=true", deploymentID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
return res, err
}
// List Deployments
func (r *BetaDeploymentService) List(ctx context.Context, params BetaDeploymentListParams, opts ...option.RequestOption) (res *pagination.PageCursor[BetaManagedAgentsDeployment], err error) {
var raw *http.Response
for _, v := range params.Betas {
opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
}
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01"), option.WithResponseInto(&raw)}, opts...)
path := "v1/deployments?beta=true"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// List Deployments
func (r *BetaDeploymentService) ListAutoPaging(ctx context.Context, params BetaDeploymentListParams, opts ...option.RequestOption) *pagination.PageCursorAutoPager[BetaManagedAgentsDeployment] {
return pagination.NewPageCursorAutoPager(r.List(ctx, params, opts...))
}
// Archive Deployment
func (r *BetaDeploymentService) Archive(ctx context.Context, deploymentID string, body BetaDeploymentArchiveParams, opts ...option.RequestOption) (res *BetaManagedAgentsDeployment, err error) {
for _, v := range body.Betas {
opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
}
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
if deploymentID == "" {
err = errors.New("missing required deployment_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/deployments/%s/archive?beta=true", deploymentID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
return res, err
}
// Pause Deployment
func (r *BetaDeploymentService) Pause(ctx context.Context, deploymentID string, body BetaDeploymentPauseParams, opts ...option.RequestOption) (res *BetaManagedAgentsDeployment, err error) {
for _, v := range body.Betas {
opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
}
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
if deploymentID == "" {
err = errors.New("missing required deployment_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/deployments/%s/pause?beta=true", deploymentID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
return res, err
}
// Run Deployment Now
func (r *BetaDeploymentService) Run(ctx context.Context, deploymentID string, body BetaDeploymentRunParams, opts ...option.RequestOption) (res *BetaManagedAgentsDeploymentRun, err error) {
for _, v := range body.Betas {
opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
}
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
if deploymentID == "" {
err = errors.New("missing required deployment_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/deployments/%s/run?beta=true", deploymentID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
return res, err
}
// Unpause Deployment
func (r *BetaDeploymentService) Unpause(ctx context.Context, deploymentID string, body BetaDeploymentUnpauseParams, opts ...option.RequestOption) (res *BetaManagedAgentsDeployment, err error) {
for _, v := range body.Betas {
opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v)))
}
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...)
if deploymentID == "" {
err = errors.New("missing required deployment_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/deployments/%s/unpause?beta=true", deploymentID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
return res, err
}
// The deployment's agent was archived.
type BetaManagedAgentsAgentArchivedDeploymentPausedReasonError struct {
// Any of "agent_archived_error".
Type BetaManagedAgentsAgentArchivedDeploymentPausedReasonErrorType `json:"type" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Type respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r BetaManagedAgentsAgentArchivedDeploymentPausedReasonError) RawJSON() string {
return r.JSON.raw
}
func (r *BetaManagedAgentsAgentArchivedDeploymentPausedReasonError) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type BetaManagedAgentsAgentArchivedDeploymentPausedReasonErrorType string
const (
BetaManagedAgentsAgentArchivedDeploymentPausedReasonErrorTypeAgentArchivedError BetaManagedAgentsAgentArchivedDeploymentPausedReasonErrorType = "agent_archived_error"
)
// A deployment is a configured instance of an agent — it binds the agent to
// everything needed to run it autonomously: an environment, credentials, initial
// events, and an optional schedule.
type BetaManagedAgentsDeployment struct {
// Unique identifier for this deployment.
ID string `json:"id" api:"required"`
// A resolved agent reference with a concrete version.
Agent BetaManagedAgentsAgentReference `json:"agent" api:"required"`
// A timestamp in RFC 3339 format
ArchivedAt time.Time `json:"archived_at" api:"required" format:"date-time"`
// A timestamp in RFC 3339 format
CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"`
// Description of what the deployment does.
Description string `json:"description" api:"required"`
// ID of the `environment` where sessions run.
EnvironmentID string `json:"environment_id" api:"required"`
// Events sent to each session immediately after creation.
InitialEvents []BetaManagedAgentsDeploymentInitialEventUnion `json:"initial_events" api:"required"`
// Arbitrary key-value metadata. Maximum 16 pairs.
Metadata map[string]string `json:"metadata" api:"required"`
// Human-readable name.
Name string `json:"name" api:"required"`
// Why a deployment is paused. Non-null exactly when `status` is `paused`.
PausedReason BetaManagedAgentsDeploymentPausedReasonUnion `json:"paused_reason" api:"required"`
// Resources attached to sessions created from this deployment. Echoes the input
// minus write-only credentials.
Resources []BetaManagedAgentsSessionResourceConfigUnion `json:"resources" api:"required"`
// 5-field POSIX cron schedule with computed runtime timestamps.
Schedule BetaManagedAgentsSchedule `json:"schedule" api:"required"`
// Lifecycle status of a deployment.
//
// Any of "active", "paused".
Status BetaManagedAgentsDeploymentStatus `json:"status" api:"required"`
// Any of "deployment".
Type BetaManagedAgentsDeploymentType `json:"type" api:"required"`
// A timestamp in RFC 3339 format
UpdatedAt time.Time `json:"updated_at" api:"required" format:"date-time"`
// Vault IDs supplying stored credentials for sessions created from this
// deployment.
VaultIDs []string `json:"vault_ids" api:"required"`
// A hard spend ceiling. The session stops issuing new model requests once the
// tracked list cost reaches `max_list_cost`.
Budget BetaManagedAgentsBudgetLimit `json:"budget" api:"nullable"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Agent respjson.Field
ArchivedAt respjson.Field
CreatedAt respjson.Field
Description respjson.Field
EnvironmentID respjson.Field
InitialEvents respjson.Field
Metadata respjson.Field
Name respjson.Field
PausedReason respjson.Field
Resources respjson.Field
Schedule respjson.Field
Status respjson.Field
Type respjson.Field
UpdatedAt respjson.Field
VaultIDs respjson.Field
Budget respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r BetaManagedAgentsDeployment) RawJSON() string { return r.JSON.raw }
func (r *BetaManagedAgentsDeployment) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type BetaManagedAgentsDeploymentType string
const (
BetaManagedAgentsDeploymentTypeDeployment BetaManagedAgentsDeploymentType = "deployment"
)
// BetaManagedAgentsDeploymentInitialEventUnion contains all possible properties
// and values from [BetaManagedAgentsDeploymentUserMessageEvent],
// [BetaManagedAgentsDeploymentUserDefineOutcomeEvent],
// [BetaManagedAgentsDeploymentSystemMessageEvent].
//
// Use the [BetaManagedAgentsDeploymentInitialEventUnion.AsAny] method to switch on
// the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaManagedAgentsDeploymentInitialEventUnion struct {
// This field is a union of
// [[]BetaManagedAgentsDeploymentUserMessageEventContentUnion],
// [[]BetaManagedAgentsSystemContentBlock]
Content BetaManagedAgentsDeploymentInitialEventUnionContent `json:"content"`
// Any of "user.message", "user.define_outcome", "system.message".
Type string `json:"type"`
// This field is from variant [BetaManagedAgentsDeploymentUserDefineOutcomeEvent].
Description string `json:"description"`
// This field is from variant [BetaManagedAgentsDeploymentUserDefineOutcomeEvent].
Rubric BetaManagedAgentsDeploymentUserDefineOutcomeEventRubricUnion `json:"rubric"`
// This field is from variant [BetaManagedAgentsDeploymentUserDefineOutcomeEvent].
MaxIterations int64 `json:"max_iterations"`
JSON struct {
Content respjson.Field
Type respjson.Field
Description respjson.Field
Rubric respjson.Field
MaxIterations respjson.Field
raw string
} `json:"-"`
}
// anyBetaManagedAgentsDeploymentInitialEvent is implemented by each variant of
// [BetaManagedAgentsDeploymentInitialEventUnion] to add type safety for the return
// type of [BetaManagedAgentsDeploymentInitialEventUnion.AsAny]
type anyBetaManagedAgentsDeploymentInitialEvent interface {
implBetaManagedAgentsDeploymentInitialEventUnion()
}
func (BetaManagedAgentsDeploymentUserMessageEvent) implBetaManagedAgentsDeploymentInitialEventUnion() {
}
func (BetaManagedAgentsDeploymentUserDefineOutcomeEvent) implBetaManagedAgentsDeploymentInitialEventUnion() {
}
func (BetaManagedAgentsDeploymentSystemMessageEvent) implBetaManagedAgentsDeploymentInitialEventUnion() {
}
// Use the following switch statement to find the correct variant
//
// switch variant := BetaManagedAgentsDeploymentInitialEventUnion.AsAny().(type) {
// case anthropic.BetaManagedAgentsDeploymentUserMessageEvent:
// case anthropic.BetaManagedAgentsDeploymentUserDefineOutcomeEvent:
// case anthropic.BetaManagedAgentsDeploymentSystemMessageEvent:
// default:
// fmt.Errorf("no variant present")
// }
func (u BetaManagedAgentsDeploymentInitialEventUnion) AsAny() anyBetaManagedAgentsDeploymentInitialEvent {
switch u.Type {
case "user.message":
return u.AsUserMessage()
case "user.define_outcome":
return u.AsUserDefineOutcome()
case "system.message":
return u.AsSystemMessage()
}
return nil
}
func (u BetaManagedAgentsDeploymentInitialEventUnion) AsUserMessage() (v BetaManagedAgentsDeploymentUserMessageEvent) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsDeploymentInitialEventUnion) AsUserDefineOutcome() (v BetaManagedAgentsDeploymentUserDefineOutcomeEvent) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsDeploymentInitialEventUnion) AsSystemMessage() (v BetaManagedAgentsDeploymentSystemMessageEvent) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
// Returns the unmodified JSON received from the API
func (u BetaManagedAgentsDeploymentInitialEventUnion) RawJSON() string { return u.JSON.raw }
func (r *BetaManagedAgentsDeploymentInitialEventUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// BetaManagedAgentsDeploymentInitialEventUnionContent is an implicit subunion of
// [BetaManagedAgentsDeploymentInitialEventUnion].
// BetaManagedAgentsDeploymentInitialEventUnionContent provides convenient access
// to the sub-properties of the union.
//
// For type safety it is recommended to directly use a variant of the
// [BetaManagedAgentsDeploymentInitialEventUnion].
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfBetaManagedAgentsDeploymentUserMessageEventContentArray
// OfBetaManagedAgentsSystemContentBlockArray]
type BetaManagedAgentsDeploymentInitialEventUnionContent struct {
// This field will be present if the value is a
// [[]BetaManagedAgentsDeploymentUserMessageEventContentUnion] instead of an
// object.
OfBetaManagedAgentsDeploymentUserMessageEventContentArray []BetaManagedAgentsDeploymentUserMessageEventContentUnion `json:",inline"`
// This field will be present if the value is a
// [[]BetaManagedAgentsSystemContentBlock] instead of an object.
OfBetaManagedAgentsSystemContentBlockArray []BetaManagedAgentsSystemContentBlock `json:",inline"`
JSON struct {
OfBetaManagedAgentsDeploymentUserMessageEventContentArray respjson.Field
OfBetaManagedAgentsSystemContentBlockArray respjson.Field
raw string
} `json:"-"`
}
func (r *BetaManagedAgentsDeploymentInitialEventUnionContent) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
func BetaManagedAgentsDeploymentInitialEventParamsOfUserMessage(content []BetaManagedAgentsUserMessageEventParamsContentUnion) BetaManagedAgentsDeploymentInitialEventParamsUnion {
var userMessage BetaManagedAgentsUserMessageEventParams
userMessage.Content = content
return BetaManagedAgentsDeploymentInitialEventParamsUnion{OfUserMessage: &userMessage}
}
func BetaManagedAgentsDeploymentInitialEventParamsOfUserDefineOutcome[
T BetaManagedAgentsFileRubricParams | BetaManagedAgentsTextRubricParams,
](description string, rubric T, type_ BetaManagedAgentsUserDefineOutcomeEventParamsType) BetaManagedAgentsDeploymentInitialEventParamsUnion {
var userDefineOutcome BetaManagedAgentsUserDefineOutcomeEventParams
userDefineOutcome.Description = description
switch v := any(rubric).(type) {
case BetaManagedAgentsFileRubricParams:
userDefineOutcome.Rubric.OfFile = &v
case BetaManagedAgentsTextRubricParams:
userDefineOutcome.Rubric.OfText = &v
}
userDefineOutcome.Type = type_
return BetaManagedAgentsDeploymentInitialEventParamsUnion{OfUserDefineOutcome: &userDefineOutcome}
}
func BetaManagedAgentsDeploymentInitialEventParamsOfSystemMessage(content []BetaManagedAgentsSystemContentBlockParam) BetaManagedAgentsDeploymentInitialEventParamsUnion {
var systemMessage BetaManagedAgentsSystemMessageEventParams
systemMessage.Content = content
return BetaManagedAgentsDeploymentInitialEventParamsUnion{OfSystemMessage: &systemMessage}
}
// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type BetaManagedAgentsDeploymentInitialEventParamsUnion struct {
OfUserMessage *BetaManagedAgentsUserMessageEventParams `json:",omitzero,inline"`
OfUserDefineOutcome *BetaManagedAgentsUserDefineOutcomeEventParams `json:",omitzero,inline"`
OfSystemMessage *BetaManagedAgentsSystemMessageEventParams `json:",omitzero,inline"`
paramUnion
}
func (u BetaManagedAgentsDeploymentInitialEventParamsUnion) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfUserMessage, u.OfUserDefineOutcome, u.OfSystemMessage)
}
func (u *BetaManagedAgentsDeploymentInitialEventParamsUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
}
func (u *BetaManagedAgentsDeploymentInitialEventParamsUnion) asAny() any {
if !param.IsOmitted(u.OfUserMessage) {
return u.OfUserMessage
} else if !param.IsOmitted(u.OfUserDefineOutcome) {
return u.OfUserDefineOutcome
} else if !param.IsOmitted(u.OfSystemMessage) {
return u.OfSystemMessage
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u BetaManagedAgentsDeploymentInitialEventParamsUnion) GetDescription() *string {
if vt := u.OfUserDefineOutcome; vt != nil {
return &vt.Description
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u BetaManagedAgentsDeploymentInitialEventParamsUnion) GetRubric() *BetaManagedAgentsUserDefineOutcomeEventParamsRubricUnion {
if vt := u.OfUserDefineOutcome; vt != nil {
return &vt.Rubric
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u BetaManagedAgentsDeploymentInitialEventParamsUnion) GetMaxIterations() *int64 {
if vt := u.OfUserDefineOutcome; vt != nil && vt.MaxIterations.Valid() {
return &vt.MaxIterations.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u BetaManagedAgentsDeploymentInitialEventParamsUnion) GetType() *string {
if vt := u.OfUserMessage; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfUserDefineOutcome; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfSystemMessage; vt != nil {
return (*string)(&vt.Type)
}
return nil
}
// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u BetaManagedAgentsDeploymentInitialEventParamsUnion) GetContent() (res betaManagedAgentsDeploymentInitialEventParamsUnionContent) {
if vt := u.OfUserMessage; vt != nil {
res.any = &vt.Content
} else if vt := u.OfSystemMessage; vt != nil {
res.any = &vt.Content
}
return
}
// Can have the runtime types
// [_[]BetaManagedAgentsUserMessageEventParamsContentUnion],
// [_[]BetaManagedAgentsSystemContentBlockParam]
type betaManagedAgentsDeploymentInitialEventParamsUnionContent struct{ any }
// Use the following switch statement to get the type of the union:
//
// switch u.AsAny().(type) {
// case *[]anthropic.BetaManagedAgentsUserMessageEventParamsContentUnion:
// case *[]anthropic.BetaManagedAgentsSystemContentBlockParam:
// default:
// fmt.Errorf("not present")
// }
func (u betaManagedAgentsDeploymentInitialEventParamsUnionContent) AsAny() any { return u.any }
func init() {
apijson.RegisterUnion[BetaManagedAgentsDeploymentInitialEventParamsUnion](
"type",
apijson.Discriminator[BetaManagedAgentsUserMessageEventParams]("user.message"),
apijson.Discriminator[BetaManagedAgentsUserDefineOutcomeEventParams]("user.define_outcome"),
apijson.Discriminator[BetaManagedAgentsSystemMessageEventParams]("system.message"),
)
}
// BetaManagedAgentsDeploymentPausedReasonUnion contains all possible properties
// and values from [BetaManagedAgentsManualDeploymentPausedReason],
// [BetaManagedAgentsErrorDeploymentPausedReason].
//
// Use the [BetaManagedAgentsDeploymentPausedReasonUnion.AsAny] method to switch on
// the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaManagedAgentsDeploymentPausedReasonUnion struct {
// Any of "manual", "error".
Type string `json:"type"`
// This field is from variant [BetaManagedAgentsErrorDeploymentPausedReason].
Error BetaManagedAgentsDeploymentPausedReasonErrorUnion `json:"error"`
JSON struct {
Type respjson.Field
Error respjson.Field
raw string
} `json:"-"`
}
// anyBetaManagedAgentsDeploymentPausedReason is implemented by each variant of
// [BetaManagedAgentsDeploymentPausedReasonUnion] to add type safety for the return
// type of [BetaManagedAgentsDeploymentPausedReasonUnion.AsAny]
type anyBetaManagedAgentsDeploymentPausedReason interface {
implBetaManagedAgentsDeploymentPausedReasonUnion()
}
func (BetaManagedAgentsManualDeploymentPausedReason) implBetaManagedAgentsDeploymentPausedReasonUnion() {
}
func (BetaManagedAgentsErrorDeploymentPausedReason) implBetaManagedAgentsDeploymentPausedReasonUnion() {
}
// Use the following switch statement to find the correct variant
//
// switch variant := BetaManagedAgentsDeploymentPausedReasonUnion.AsAny().(type) {
// case anthropic.BetaManagedAgentsManualDeploymentPausedReason:
// case anthropic.BetaManagedAgentsErrorDeploymentPausedReason:
// default:
// fmt.Errorf("no variant present")
// }
func (u BetaManagedAgentsDeploymentPausedReasonUnion) AsAny() anyBetaManagedAgentsDeploymentPausedReason {
switch u.Type {
case "manual":
return u.AsManual()
case "error":
return u.AsError()
}
return nil
}
func (u BetaManagedAgentsDeploymentPausedReasonUnion) AsManual() (v BetaManagedAgentsManualDeploymentPausedReason) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsDeploymentPausedReasonUnion) AsError() (v BetaManagedAgentsErrorDeploymentPausedReason) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
// Returns the unmodified JSON received from the API
func (u BetaManagedAgentsDeploymentPausedReasonUnion) RawJSON() string { return u.JSON.raw }
func (r *BetaManagedAgentsDeploymentPausedReasonUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// BetaManagedAgentsDeploymentPausedReasonErrorUnion contains all possible
// properties and values from
// [BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError],
// [BetaManagedAgentsAgentArchivedDeploymentPausedReasonError],
// [BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError],
// [BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError],
// [BetaManagedAgentsFileNotFoundDeploymentPausedReasonError],
// [BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError],
// [BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError],
// [BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError],
// [BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError],
// [BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError],
// [BetaManagedAgentsVaultArchivedDeploymentPausedReasonError],
// [BetaManagedAgentsUnknownDeploymentPausedReasonError],
// [BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError],
// [BetaManagedAgentsMCPEgressBlockedDeploymentPausedReasonError].
//
// Use the [BetaManagedAgentsDeploymentPausedReasonErrorUnion.AsAny] method to
// switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaManagedAgentsDeploymentPausedReasonErrorUnion struct {
// Any of "environment_archived_error", "agent_archived_error",
// "environment_not_found_error", "vault_not_found_error", "file_not_found_error",
// "session_resource_not_found_error", "workspace_archived_error",
// "organization_disabled_error", "memory_store_archived_error",
// "skill_not_found_error", "vault_archived_error", "unknown_error",
// "self_hosted_resources_unsupported_error", "mcp_egress_blocked_error".
Type string `json:"type"`
JSON struct {
Type respjson.Field
raw string
} `json:"-"`
}
// anyBetaManagedAgentsDeploymentPausedReasonError is implemented by each variant
// of [BetaManagedAgentsDeploymentPausedReasonErrorUnion] to add type safety for
// the return type of [BetaManagedAgentsDeploymentPausedReasonErrorUnion.AsAny]
type anyBetaManagedAgentsDeploymentPausedReasonError interface {
implBetaManagedAgentsDeploymentPausedReasonErrorUnion()
}
func (BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError) implBetaManagedAgentsDeploymentPausedReasonErrorUnion() {
}
func (BetaManagedAgentsAgentArchivedDeploymentPausedReasonError) implBetaManagedAgentsDeploymentPausedReasonErrorUnion() {
}
func (BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError) implBetaManagedAgentsDeploymentPausedReasonErrorUnion() {
}
func (BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError) implBetaManagedAgentsDeploymentPausedReasonErrorUnion() {
}
func (BetaManagedAgentsFileNotFoundDeploymentPausedReasonError) implBetaManagedAgentsDeploymentPausedReasonErrorUnion() {
}
func (BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError) implBetaManagedAgentsDeploymentPausedReasonErrorUnion() {
}
func (BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError) implBetaManagedAgentsDeploymentPausedReasonErrorUnion() {
}
func (BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError) implBetaManagedAgentsDeploymentPausedReasonErrorUnion() {
}
func (BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError) implBetaManagedAgentsDeploymentPausedReasonErrorUnion() {
}
func (BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError) implBetaManagedAgentsDeploymentPausedReasonErrorUnion() {
}
func (BetaManagedAgentsVaultArchivedDeploymentPausedReasonError) implBetaManagedAgentsDeploymentPausedReasonErrorUnion() {
}
func (BetaManagedAgentsUnknownDeploymentPausedReasonError) implBetaManagedAgentsDeploymentPausedReasonErrorUnion() {
}
func (BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError) implBetaManagedAgentsDeploymentPausedReasonErrorUnion() {
}
func (BetaManagedAgentsMCPEgressBlockedDeploymentPausedReasonError) implBetaManagedAgentsDeploymentPausedReasonErrorUnion() {
}
// Use the following switch statement to find the correct variant
//
// switch variant := BetaManagedAgentsDeploymentPausedReasonErrorUnion.AsAny().(type) {
// case anthropic.BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError:
// case anthropic.BetaManagedAgentsAgentArchivedDeploymentPausedReasonError:
// case anthropic.BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError:
// case anthropic.BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError:
// case anthropic.BetaManagedAgentsFileNotFoundDeploymentPausedReasonError:
// case anthropic.BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError:
// case anthropic.BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError:
// case anthropic.BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError:
// case anthropic.BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError:
// case anthropic.BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError:
// case anthropic.BetaManagedAgentsVaultArchivedDeploymentPausedReasonError:
// case anthropic.BetaManagedAgentsUnknownDeploymentPausedReasonError:
// case anthropic.BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError:
// case anthropic.BetaManagedAgentsMCPEgressBlockedDeploymentPausedReasonError:
// default:
// fmt.Errorf("no variant present")
// }
func (u BetaManagedAgentsDeploymentPausedReasonErrorUnion) AsAny() anyBetaManagedAgentsDeploymentPausedReasonError {
switch u.Type {
case "environment_archived_error":
return u.AsEnvironmentArchivedError()
case "agent_archived_error":
return u.AsAgentArchivedError()
case "environment_not_found_error":
return u.AsEnvironmentNotFoundError()
case "vault_not_found_error":
return u.AsVaultNotFoundError()
case "file_not_found_error":
return u.AsFileNotFoundError()
case "session_resource_not_found_error":
return u.AsSessionResourceNotFoundError()
case "workspace_archived_error":
return u.AsWorkspaceArchivedError()
case "organization_disabled_error":
return u.AsOrganizationDisabledError()
case "memory_store_archived_error":
return u.AsMemoryStoreArchivedError()
case "skill_not_found_error":
return u.AsSkillNotFoundError()
case "vault_archived_error":
return u.AsVaultArchivedError()
case "unknown_error":
return u.AsUnknownError()
case "self_hosted_resources_unsupported_error":
return u.AsSelfHostedResourcesUnsupportedError()
case "mcp_egress_blocked_error":
return u.AsMCPEgressBlockedError()
}
return nil
}
func (u BetaManagedAgentsDeploymentPausedReasonErrorUnion) AsEnvironmentArchivedError() (v BetaManagedAgentsEnvironmentArchivedDeploymentPausedReasonError) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsDeploymentPausedReasonErrorUnion) AsAgentArchivedError() (v BetaManagedAgentsAgentArchivedDeploymentPausedReasonError) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsDeploymentPausedReasonErrorUnion) AsEnvironmentNotFoundError() (v BetaManagedAgentsEnvironmentNotFoundDeploymentPausedReasonError) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsDeploymentPausedReasonErrorUnion) AsVaultNotFoundError() (v BetaManagedAgentsVaultNotFoundDeploymentPausedReasonError) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsDeploymentPausedReasonErrorUnion) AsFileNotFoundError() (v BetaManagedAgentsFileNotFoundDeploymentPausedReasonError) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsDeploymentPausedReasonErrorUnion) AsSessionResourceNotFoundError() (v BetaManagedAgentsSessionResourceNotFoundDeploymentPausedReasonError) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsDeploymentPausedReasonErrorUnion) AsWorkspaceArchivedError() (v BetaManagedAgentsWorkspaceArchivedDeploymentPausedReasonError) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsDeploymentPausedReasonErrorUnion) AsOrganizationDisabledError() (v BetaManagedAgentsOrganizationDisabledDeploymentPausedReasonError) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsDeploymentPausedReasonErrorUnion) AsMemoryStoreArchivedError() (v BetaManagedAgentsMemoryStoreArchivedDeploymentPausedReasonError) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsDeploymentPausedReasonErrorUnion) AsSkillNotFoundError() (v BetaManagedAgentsSkillNotFoundDeploymentPausedReasonError) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsDeploymentPausedReasonErrorUnion) AsVaultArchivedError() (v BetaManagedAgentsVaultArchivedDeploymentPausedReasonError) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsDeploymentPausedReasonErrorUnion) AsUnknownError() (v BetaManagedAgentsUnknownDeploymentPausedReasonError) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsDeploymentPausedReasonErrorUnion) AsSelfHostedResourcesUnsupportedError() (v BetaManagedAgentsSelfHostedResourcesUnsupportedDeploymentPausedReasonError) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsDeploymentPausedReasonErrorUnion) AsMCPEgressBlockedError() (v BetaManagedAgentsMCPEgressBlockedDeploymentPausedReasonError) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
// Returns the unmodified JSON received from the API
func (u BetaManagedAgentsDeploymentPausedReasonErrorUnion) RawJSON() string { return u.JSON.raw }
func (r *BetaManagedAgentsDeploymentPausedReasonErrorUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Lifecycle status of a deployment.
type BetaManagedAgentsDeploymentStatus string
const (
BetaManagedAgentsDeploymentStatusActive BetaManagedAgentsDeploymentStatus = "active"
BetaManagedAgentsDeploymentStatusPaused BetaManagedAgentsDeploymentStatus = "paused"
)
// Privileged context for the accompanying turn and all subsequent turns, appended
// to the session's system context as a `role: "system"` turn rather than replacing
// the top-level system prompt.
type BetaManagedAgentsDeploymentSystemMessageEvent struct {
// System content blocks to append. Text-only.
Content []BetaManagedAgentsSystemContentBlock `json:"content" api:"required"`
// Any of "system.message".
Type BetaManagedAgentsDeploymentSystemMessageEventType `json:"type" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Content respjson.Field
Type respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r BetaManagedAgentsDeploymentSystemMessageEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaManagedAgentsDeploymentSystemMessageEvent) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type BetaManagedAgentsDeploymentSystemMessageEventType string
const (
BetaManagedAgentsDeploymentSystemMessageEventTypeSystemMessage BetaManagedAgentsDeploymentSystemMessageEventType = "system.message"
)
// An outcome the agent should work toward. The agent begins work on receipt.
type BetaManagedAgentsDeploymentUserDefineOutcomeEvent struct {
// What the agent should produce. This is the task specification.
Description string `json:"description" api:"required"`
// Rubric for grading the quality of an outcome.
Rubric BetaManagedAgentsDeploymentUserDefineOutcomeEventRubricUnion `json:"rubric" api:"required"`
// Any of "user.define_outcome".
Type BetaManagedAgentsDeploymentUserDefineOutcomeEventType `json:"type" api:"required"`
// Eval→revision cycles before giving up. Default 3, max 20.
MaxIterations int64 `json:"max_iterations" api:"nullable"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Description respjson.Field
Rubric respjson.Field
Type respjson.Field
MaxIterations respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r BetaManagedAgentsDeploymentUserDefineOutcomeEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaManagedAgentsDeploymentUserDefineOutcomeEvent) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// BetaManagedAgentsDeploymentUserDefineOutcomeEventRubricUnion contains all
// possible properties and values from [BetaManagedAgentsFileRubric],
// [BetaManagedAgentsTextRubric].
//
// Use the [BetaManagedAgentsDeploymentUserDefineOutcomeEventRubricUnion.AsAny]
// method to switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaManagedAgentsDeploymentUserDefineOutcomeEventRubricUnion struct {
// This field is from variant [BetaManagedAgentsFileRubric].
FileID string `json:"file_id"`
// Any of "file", "text".
Type string `json:"type"`
// This field is from variant [BetaManagedAgentsTextRubric].
Content string `json:"content"`
JSON struct {
FileID respjson.Field
Type respjson.Field
Content respjson.Field
raw string
} `json:"-"`
}
// anyBetaManagedAgentsDeploymentUserDefineOutcomeEventRubric is implemented by
// each variant of [BetaManagedAgentsDeploymentUserDefineOutcomeEventRubricUnion]
// to add type safety for the return type of
// [BetaManagedAgentsDeploymentUserDefineOutcomeEventRubricUnion.AsAny]
type anyBetaManagedAgentsDeploymentUserDefineOutcomeEventRubric interface {
implBetaManagedAgentsDeploymentUserDefineOutcomeEventRubricUnion()
}
func (BetaManagedAgentsFileRubric) implBetaManagedAgentsDeploymentUserDefineOutcomeEventRubricUnion() {
}
func (BetaManagedAgentsTextRubric) implBetaManagedAgentsDeploymentUserDefineOutcomeEventRubricUnion() {
}
// Use the following switch statement to find the correct variant
//
// switch variant := BetaManagedAgentsDeploymentUserDefineOutcomeEventRubricUnion.AsAny().(type) {
// case anthropic.BetaManagedAgentsFileRubric:
// case anthropic.BetaManagedAgentsTextRubric:
// default:
// fmt.Errorf("no variant present")
// }
func (u BetaManagedAgentsDeploymentUserDefineOutcomeEventRubricUnion) AsAny() anyBetaManagedAgentsDeploymentUserDefineOutcomeEventRubric {
switch u.Type {
case "file":
return u.AsFile()
case "text":
return u.AsText()
}
return nil
}
func (u BetaManagedAgentsDeploymentUserDefineOutcomeEventRubricUnion) AsFile() (v BetaManagedAgentsFileRubric) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsDeploymentUserDefineOutcomeEventRubricUnion) AsText() (v BetaManagedAgentsTextRubric) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
// Returns the unmodified JSON received from the API
func (u BetaManagedAgentsDeploymentUserDefineOutcomeEventRubricUnion) RawJSON() string {
return u.JSON.raw
}
func (r *BetaManagedAgentsDeploymentUserDefineOutcomeEventRubricUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type BetaManagedAgentsDeploymentUserDefineOutcomeEventType string
const (
BetaManagedAgentsDeploymentUserDefineOutcomeEventTypeUserDefineOutcome BetaManagedAgentsDeploymentUserDefineOutcomeEventType = "user.define_outcome"
)
// A user message sent to the session.
type BetaManagedAgentsDeploymentUserMessageEvent struct {
// Array of content blocks for the user message.
Content []BetaManagedAgentsDeploymentUserMessageEventContentUnion `json:"content" api:"required"`
// Any of "user.message".
Type BetaManagedAgentsDeploymentUserMessageEventType `json:"type" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Content respjson.Field
Type respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r BetaManagedAgentsDeploymentUserMessageEvent) RawJSON() string { return r.JSON.raw }
func (r *BetaManagedAgentsDeploymentUserMessageEvent) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// BetaManagedAgentsDeploymentUserMessageEventContentUnion contains all possible
// properties and values from [BetaManagedAgentsTextBlock],
// [BetaManagedAgentsImageBlock], [BetaManagedAgentsDocumentBlock],
// [BetaManagedAgentsRedactedBlock].
//
// Use the [BetaManagedAgentsDeploymentUserMessageEventContentUnion.AsAny] method
// to switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaManagedAgentsDeploymentUserMessageEventContentUnion struct {
// This field is from variant [BetaManagedAgentsTextBlock].
Text string `json:"text"`
// Any of "text", "image", "document", "redacted".
Type string `json:"type"`
// This field is a union of [BetaManagedAgentsImageBlockSourceUnion],
// [BetaManagedAgentsDocumentBlockSourceUnion]
Source BetaManagedAgentsDeploymentUserMessageEventContentUnionSource `json:"source"`
// This field is from variant [BetaManagedAgentsDocumentBlock].
Context string `json:"context"`
// This field is from variant [BetaManagedAgentsDocumentBlock].
Title string `json:"title"`
JSON struct {
Text respjson.Field
Type respjson.Field
Source respjson.Field
Context respjson.Field
Title respjson.Field
raw string
} `json:"-"`
}
// anyBetaManagedAgentsDeploymentUserMessageEventContent is implemented by each
// variant of [BetaManagedAgentsDeploymentUserMessageEventContentUnion] to add type
// safety for the return type of
// [BetaManagedAgentsDeploymentUserMessageEventContentUnion.AsAny]
type anyBetaManagedAgentsDeploymentUserMessageEventContent interface {
implBetaManagedAgentsDeploymentUserMessageEventContentUnion()
}
func (BetaManagedAgentsTextBlock) implBetaManagedAgentsDeploymentUserMessageEventContentUnion() {}