-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathbetasessionresource.go
More file actions
619 lines (556 loc) · 23.6 KB
/
betasessionresource.go
File metadata and controls
619 lines (556 loc) · 23.6 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
// 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"
shimjson "github.com/anthropics/anthropic-sdk-go/internal/encoding/json"
"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"
)
// BetaSessionResourceService 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 [NewBetaSessionResourceService] method instead.
type BetaSessionResourceService struct {
Options []option.RequestOption
}
// NewBetaSessionResourceService 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 NewBetaSessionResourceService(opts ...option.RequestOption) (r BetaSessionResourceService) {
r = BetaSessionResourceService{}
r.Options = opts
return
}
// Get Session Resource
func (r *BetaSessionResourceService) Get(ctx context.Context, resourceID string, params BetaSessionResourceGetParams, opts ...option.RequestOption) (res *BetaSessionResourceGetResponseUnion, 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 params.SessionID == "" {
err = errors.New("missing required session_id parameter")
return nil, err
}
if resourceID == "" {
err = errors.New("missing required resource_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/sessions/%s/resources/%s?beta=true", params.SessionID, resourceID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
// Update Session Resource
func (r *BetaSessionResourceService) Update(ctx context.Context, resourceID string, params BetaSessionResourceUpdateParams, opts ...option.RequestOption) (res *BetaSessionResourceUpdateResponseUnion, 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 params.SessionID == "" {
err = errors.New("missing required session_id parameter")
return nil, err
}
if resourceID == "" {
err = errors.New("missing required resource_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/sessions/%s/resources/%s?beta=true", params.SessionID, resourceID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
return res, err
}
// List Session Resources
func (r *BetaSessionResourceService) List(ctx context.Context, sessionID string, params BetaSessionResourceListParams, opts ...option.RequestOption) (res *pagination.PageCursor[BetaManagedAgentsSessionResourceUnion], 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...)
if sessionID == "" {
err = errors.New("missing required session_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/sessions/%s/resources?beta=true", sessionID)
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 Session Resources
func (r *BetaSessionResourceService) ListAutoPaging(ctx context.Context, sessionID string, params BetaSessionResourceListParams, opts ...option.RequestOption) *pagination.PageCursorAutoPager[BetaManagedAgentsSessionResourceUnion] {
return pagination.NewPageCursorAutoPager(r.List(ctx, sessionID, params, opts...))
}
// Delete Session Resource
func (r *BetaSessionResourceService) Delete(ctx context.Context, resourceID string, params BetaSessionResourceDeleteParams, opts ...option.RequestOption) (res *BetaManagedAgentsDeleteSessionResource, 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 params.SessionID == "" {
err = errors.New("missing required session_id parameter")
return nil, err
}
if resourceID == "" {
err = errors.New("missing required resource_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/sessions/%s/resources/%s?beta=true", params.SessionID, resourceID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return res, err
}
// Add Session Resource
func (r *BetaSessionResourceService) Add(ctx context.Context, sessionID string, params BetaSessionResourceAddParams, opts ...option.RequestOption) (res *BetaManagedAgentsFileResource, 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 sessionID == "" {
err = errors.New("missing required session_id parameter")
return nil, err
}
path := fmt.Sprintf("v1/sessions/%s/resources?beta=true", sessionID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
return res, err
}
// Confirmation of resource deletion.
type BetaManagedAgentsDeleteSessionResource struct {
ID string `json:"id" api:"required"`
// Any of "session_resource_deleted".
Type BetaManagedAgentsDeleteSessionResourceType `json:"type" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Type respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r BetaManagedAgentsDeleteSessionResource) RawJSON() string { return r.JSON.raw }
func (r *BetaManagedAgentsDeleteSessionResource) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type BetaManagedAgentsDeleteSessionResourceType string
const (
BetaManagedAgentsDeleteSessionResourceTypeSessionResourceDeleted BetaManagedAgentsDeleteSessionResourceType = "session_resource_deleted"
)
type BetaManagedAgentsFileResource struct {
ID string `json:"id" api:"required"`
// A timestamp in RFC 3339 format
CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"`
FileID string `json:"file_id" api:"required"`
MountPath string `json:"mount_path" api:"required"`
// Any of "file".
Type BetaManagedAgentsFileResourceType `json:"type" api:"required"`
// A timestamp in RFC 3339 format
UpdatedAt time.Time `json:"updated_at" api:"required" format:"date-time"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
CreatedAt respjson.Field
FileID respjson.Field
MountPath respjson.Field
Type respjson.Field
UpdatedAt respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r BetaManagedAgentsFileResource) RawJSON() string { return r.JSON.raw }
func (r *BetaManagedAgentsFileResource) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type BetaManagedAgentsFileResourceType string
const (
BetaManagedAgentsFileResourceTypeFile BetaManagedAgentsFileResourceType = "file"
)
type BetaManagedAgentsGitHubRepositoryResource struct {
ID string `json:"id" api:"required"`
// A timestamp in RFC 3339 format
CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"`
MountPath string `json:"mount_path" api:"required"`
// Any of "github_repository".
Type BetaManagedAgentsGitHubRepositoryResourceType `json:"type" api:"required"`
// A timestamp in RFC 3339 format
UpdatedAt time.Time `json:"updated_at" api:"required" format:"date-time"`
URL string `json:"url" api:"required"`
Checkout BetaManagedAgentsGitHubRepositoryResourceCheckoutUnion `json:"checkout" api:"nullable"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
CreatedAt respjson.Field
MountPath respjson.Field
Type respjson.Field
UpdatedAt respjson.Field
URL respjson.Field
Checkout respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r BetaManagedAgentsGitHubRepositoryResource) RawJSON() string { return r.JSON.raw }
func (r *BetaManagedAgentsGitHubRepositoryResource) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type BetaManagedAgentsGitHubRepositoryResourceType string
const (
BetaManagedAgentsGitHubRepositoryResourceTypeGitHubRepository BetaManagedAgentsGitHubRepositoryResourceType = "github_repository"
)
// BetaManagedAgentsGitHubRepositoryResourceCheckoutUnion contains all possible
// properties and values from [BetaManagedAgentsBranchCheckout],
// [BetaManagedAgentsCommitCheckout].
//
// Use the [BetaManagedAgentsGitHubRepositoryResourceCheckoutUnion.AsAny] method to
// switch on the variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaManagedAgentsGitHubRepositoryResourceCheckoutUnion struct {
// This field is from variant [BetaManagedAgentsBranchCheckout].
Name string `json:"name"`
// Any of "branch", "commit".
Type string `json:"type"`
// This field is from variant [BetaManagedAgentsCommitCheckout].
Sha string `json:"sha"`
JSON struct {
Name respjson.Field
Type respjson.Field
Sha respjson.Field
raw string
} `json:"-"`
}
// anyBetaManagedAgentsGitHubRepositoryResourceCheckout is implemented by each
// variant of [BetaManagedAgentsGitHubRepositoryResourceCheckoutUnion] to add type
// safety for the return type of
// [BetaManagedAgentsGitHubRepositoryResourceCheckoutUnion.AsAny]
type anyBetaManagedAgentsGitHubRepositoryResourceCheckout interface {
implBetaManagedAgentsGitHubRepositoryResourceCheckoutUnion()
}
func (BetaManagedAgentsBranchCheckout) implBetaManagedAgentsGitHubRepositoryResourceCheckoutUnion() {}
func (BetaManagedAgentsCommitCheckout) implBetaManagedAgentsGitHubRepositoryResourceCheckoutUnion() {}
// Use the following switch statement to find the correct variant
//
// switch variant := BetaManagedAgentsGitHubRepositoryResourceCheckoutUnion.AsAny().(type) {
// case anthropic.BetaManagedAgentsBranchCheckout:
// case anthropic.BetaManagedAgentsCommitCheckout:
// default:
// fmt.Errorf("no variant present")
// }
func (u BetaManagedAgentsGitHubRepositoryResourceCheckoutUnion) AsAny() anyBetaManagedAgentsGitHubRepositoryResourceCheckout {
switch u.Type {
case "branch":
return u.AsBranch()
case "commit":
return u.AsCommit()
}
return nil
}
func (u BetaManagedAgentsGitHubRepositoryResourceCheckoutUnion) AsBranch() (v BetaManagedAgentsBranchCheckout) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsGitHubRepositoryResourceCheckoutUnion) AsCommit() (v BetaManagedAgentsCommitCheckout) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
// Returns the unmodified JSON received from the API
func (u BetaManagedAgentsGitHubRepositoryResourceCheckoutUnion) RawJSON() string { return u.JSON.raw }
func (r *BetaManagedAgentsGitHubRepositoryResourceCheckoutUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// BetaManagedAgentsSessionResourceUnion contains all possible properties and
// values from [BetaManagedAgentsGitHubRepositoryResource],
// [BetaManagedAgentsFileResource].
//
// Use the [BetaManagedAgentsSessionResourceUnion.AsAny] method to switch on the
// variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaManagedAgentsSessionResourceUnion struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
MountPath string `json:"mount_path"`
// Any of "github_repository", "file".
Type string `json:"type"`
UpdatedAt time.Time `json:"updated_at"`
// This field is from variant [BetaManagedAgentsGitHubRepositoryResource].
URL string `json:"url"`
// This field is from variant [BetaManagedAgentsGitHubRepositoryResource].
Checkout BetaManagedAgentsGitHubRepositoryResourceCheckoutUnion `json:"checkout"`
// This field is from variant [BetaManagedAgentsFileResource].
FileID string `json:"file_id"`
JSON struct {
ID respjson.Field
CreatedAt respjson.Field
MountPath respjson.Field
Type respjson.Field
UpdatedAt respjson.Field
URL respjson.Field
Checkout respjson.Field
FileID respjson.Field
raw string
} `json:"-"`
}
// anyBetaManagedAgentsSessionResource is implemented by each variant of
// [BetaManagedAgentsSessionResourceUnion] to add type safety for the return type
// of [BetaManagedAgentsSessionResourceUnion.AsAny]
type anyBetaManagedAgentsSessionResource interface {
implBetaManagedAgentsSessionResourceUnion()
}
func (BetaManagedAgentsGitHubRepositoryResource) implBetaManagedAgentsSessionResourceUnion() {}
func (BetaManagedAgentsFileResource) implBetaManagedAgentsSessionResourceUnion() {}
// Use the following switch statement to find the correct variant
//
// switch variant := BetaManagedAgentsSessionResourceUnion.AsAny().(type) {
// case anthropic.BetaManagedAgentsGitHubRepositoryResource:
// case anthropic.BetaManagedAgentsFileResource:
// default:
// fmt.Errorf("no variant present")
// }
func (u BetaManagedAgentsSessionResourceUnion) AsAny() anyBetaManagedAgentsSessionResource {
switch u.Type {
case "github_repository":
return u.AsGitHubRepository()
case "file":
return u.AsFile()
}
return nil
}
func (u BetaManagedAgentsSessionResourceUnion) AsGitHubRepository() (v BetaManagedAgentsGitHubRepositoryResource) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaManagedAgentsSessionResourceUnion) AsFile() (v BetaManagedAgentsFileResource) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
// Returns the unmodified JSON received from the API
func (u BetaManagedAgentsSessionResourceUnion) RawJSON() string { return u.JSON.raw }
func (r *BetaManagedAgentsSessionResourceUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// BetaSessionResourceGetResponseUnion contains all possible properties and values
// from [BetaManagedAgentsGitHubRepositoryResource],
// [BetaManagedAgentsFileResource].
//
// Use the [BetaSessionResourceGetResponseUnion.AsAny] method to switch on the
// variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaSessionResourceGetResponseUnion struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
MountPath string `json:"mount_path"`
// Any of "github_repository", "file".
Type string `json:"type"`
UpdatedAt time.Time `json:"updated_at"`
// This field is from variant [BetaManagedAgentsGitHubRepositoryResource].
URL string `json:"url"`
// This field is from variant [BetaManagedAgentsGitHubRepositoryResource].
Checkout BetaManagedAgentsGitHubRepositoryResourceCheckoutUnion `json:"checkout"`
// This field is from variant [BetaManagedAgentsFileResource].
FileID string `json:"file_id"`
JSON struct {
ID respjson.Field
CreatedAt respjson.Field
MountPath respjson.Field
Type respjson.Field
UpdatedAt respjson.Field
URL respjson.Field
Checkout respjson.Field
FileID respjson.Field
raw string
} `json:"-"`
}
// anyBetaSessionResourceGetResponse is implemented by each variant of
// [BetaSessionResourceGetResponseUnion] to add type safety for the return type of
// [BetaSessionResourceGetResponseUnion.AsAny]
type anyBetaSessionResourceGetResponse interface {
implBetaSessionResourceGetResponseUnion()
}
func (BetaManagedAgentsGitHubRepositoryResource) implBetaSessionResourceGetResponseUnion() {}
func (BetaManagedAgentsFileResource) implBetaSessionResourceGetResponseUnion() {}
// Use the following switch statement to find the correct variant
//
// switch variant := BetaSessionResourceGetResponseUnion.AsAny().(type) {
// case anthropic.BetaManagedAgentsGitHubRepositoryResource:
// case anthropic.BetaManagedAgentsFileResource:
// default:
// fmt.Errorf("no variant present")
// }
func (u BetaSessionResourceGetResponseUnion) AsAny() anyBetaSessionResourceGetResponse {
switch u.Type {
case "github_repository":
return u.AsGitHubRepository()
case "file":
return u.AsFile()
}
return nil
}
func (u BetaSessionResourceGetResponseUnion) AsGitHubRepository() (v BetaManagedAgentsGitHubRepositoryResource) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaSessionResourceGetResponseUnion) AsFile() (v BetaManagedAgentsFileResource) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
// Returns the unmodified JSON received from the API
func (u BetaSessionResourceGetResponseUnion) RawJSON() string { return u.JSON.raw }
func (r *BetaSessionResourceGetResponseUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// BetaSessionResourceUpdateResponseUnion contains all possible properties and
// values from [BetaManagedAgentsGitHubRepositoryResource],
// [BetaManagedAgentsFileResource].
//
// Use the [BetaSessionResourceUpdateResponseUnion.AsAny] method to switch on the
// variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaSessionResourceUpdateResponseUnion struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
MountPath string `json:"mount_path"`
// Any of "github_repository", "file".
Type string `json:"type"`
UpdatedAt time.Time `json:"updated_at"`
// This field is from variant [BetaManagedAgentsGitHubRepositoryResource].
URL string `json:"url"`
// This field is from variant [BetaManagedAgentsGitHubRepositoryResource].
Checkout BetaManagedAgentsGitHubRepositoryResourceCheckoutUnion `json:"checkout"`
// This field is from variant [BetaManagedAgentsFileResource].
FileID string `json:"file_id"`
JSON struct {
ID respjson.Field
CreatedAt respjson.Field
MountPath respjson.Field
Type respjson.Field
UpdatedAt respjson.Field
URL respjson.Field
Checkout respjson.Field
FileID respjson.Field
raw string
} `json:"-"`
}
// anyBetaSessionResourceUpdateResponse is implemented by each variant of
// [BetaSessionResourceUpdateResponseUnion] to add type safety for the return type
// of [BetaSessionResourceUpdateResponseUnion.AsAny]
type anyBetaSessionResourceUpdateResponse interface {
implBetaSessionResourceUpdateResponseUnion()
}
func (BetaManagedAgentsGitHubRepositoryResource) implBetaSessionResourceUpdateResponseUnion() {}
func (BetaManagedAgentsFileResource) implBetaSessionResourceUpdateResponseUnion() {}
// Use the following switch statement to find the correct variant
//
// switch variant := BetaSessionResourceUpdateResponseUnion.AsAny().(type) {
// case anthropic.BetaManagedAgentsGitHubRepositoryResource:
// case anthropic.BetaManagedAgentsFileResource:
// default:
// fmt.Errorf("no variant present")
// }
func (u BetaSessionResourceUpdateResponseUnion) AsAny() anyBetaSessionResourceUpdateResponse {
switch u.Type {
case "github_repository":
return u.AsGitHubRepository()
case "file":
return u.AsFile()
}
return nil
}
func (u BetaSessionResourceUpdateResponseUnion) AsGitHubRepository() (v BetaManagedAgentsGitHubRepositoryResource) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u BetaSessionResourceUpdateResponseUnion) AsFile() (v BetaManagedAgentsFileResource) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
// Returns the unmodified JSON received from the API
func (u BetaSessionResourceUpdateResponseUnion) RawJSON() string { return u.JSON.raw }
func (r *BetaSessionResourceUpdateResponseUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type BetaSessionResourceGetParams struct {
SessionID string `path:"session_id" api:"required" json:"-"`
// Optional header to specify the beta version(s) you want to use.
Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
paramObj
}
type BetaSessionResourceUpdateParams struct {
SessionID string `path:"session_id" api:"required" json:"-"`
// New authorization token for the resource. Currently only `github_repository`
// resources support token rotation.
AuthorizationToken string `json:"authorization_token" api:"required"`
// Optional header to specify the beta version(s) you want to use.
Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
paramObj
}
func (r BetaSessionResourceUpdateParams) MarshalJSON() (data []byte, err error) {
type shadow BetaSessionResourceUpdateParams
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BetaSessionResourceUpdateParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type BetaSessionResourceListParams struct {
// Maximum number of resources to return per page (max 1000). If omitted, returns
// all resources.
Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
// Opaque cursor from a previous response's next_page field.
Page param.Opt[string] `query:"page,omitzero" json:"-"`
// Optional header to specify the beta version(s) you want to use.
Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
paramObj
}
// URLQuery serializes [BetaSessionResourceListParams]'s query parameters as
// `url.Values`.
func (r BetaSessionResourceListParams) URLQuery() (v url.Values, err error) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
type BetaSessionResourceDeleteParams struct {
SessionID string `path:"session_id" api:"required" json:"-"`
// Optional header to specify the beta version(s) you want to use.
Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
paramObj
}
type BetaSessionResourceAddParams struct {
// Mount a file uploaded via the Files API into the session.
BetaManagedAgentsFileResourceParams BetaManagedAgentsFileResourceParams
// Optional header to specify the beta version(s) you want to use.
Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
paramObj
}
func (r BetaSessionResourceAddParams) MarshalJSON() (data []byte, err error) {
return shimjson.Marshal(r.BetaManagedAgentsFileResourceParams)
}
func (r *BetaSessionResourceAddParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}