forked from openai/openai-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontainer.go
More file actions
648 lines (586 loc) · 23 KB
/
container.go
File metadata and controls
648 lines (586 loc) · 23 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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package openai
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"slices"
"github.com/openai/openai-go/v3/internal/apijson"
"github.com/openai/openai-go/v3/internal/apiquery"
"github.com/openai/openai-go/v3/internal/requestconfig"
"github.com/openai/openai-go/v3/option"
"github.com/openai/openai-go/v3/packages/pagination"
"github.com/openai/openai-go/v3/packages/param"
"github.com/openai/openai-go/v3/packages/respjson"
"github.com/openai/openai-go/v3/responses"
)
// ContainerService contains methods and other services that help with interacting
// with the openai 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 [NewContainerService] method instead.
type ContainerService struct {
Options []option.RequestOption
Files ContainerFileService
}
// NewContainerService 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 NewContainerService(opts ...option.RequestOption) (r ContainerService) {
r = ContainerService{}
r.Options = opts
r.Files = NewContainerFileService(opts...)
return
}
// Create Container
func (r *ContainerService) New(ctx context.Context, body ContainerNewParams, opts ...option.RequestOption) (res *ContainerNewResponse, err error) {
opts = slices.Concat(r.Options, opts)
path := "containers"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
// Retrieve Container
func (r *ContainerService) Get(ctx context.Context, containerID string, opts ...option.RequestOption) (res *ContainerGetResponse, err error) {
opts = slices.Concat(r.Options, opts)
if containerID == "" {
err = errors.New("missing required container_id parameter")
return nil, err
}
path := fmt.Sprintf("containers/%s", containerID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
// List Containers
func (r *ContainerService) List(ctx context.Context, query ContainerListParams, opts ...option.RequestOption) (res *pagination.CursorPage[ContainerListResponse], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "containers"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &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 Containers
func (r *ContainerService) ListAutoPaging(ctx context.Context, query ContainerListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[ContainerListResponse] {
return pagination.NewCursorPageAutoPager(r.List(ctx, query, opts...))
}
// Delete Container
func (r *ContainerService) Delete(ctx context.Context, containerID string, opts ...option.RequestOption) (err error) {
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
if containerID == "" {
err = errors.New("missing required container_id parameter")
return err
}
path := fmt.Sprintf("containers/%s", containerID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
return err
}
type ContainerNewResponse struct {
// Unique identifier for the container.
ID string `json:"id" api:"required"`
// Unix timestamp (in seconds) when the container was created.
CreatedAt int64 `json:"created_at" api:"required"`
// Name of the container.
Name string `json:"name" api:"required"`
// The type of this object.
Object string `json:"object" api:"required"`
// Status of the container (e.g., active, deleted).
Status string `json:"status" api:"required"`
// The container will expire after this time period. The anchor is the reference
// point for the expiration. The minutes is the number of minutes after the anchor
// before the container expires.
ExpiresAfter ContainerNewResponseExpiresAfter `json:"expires_after"`
// Unix timestamp (in seconds) when the container was last active.
LastActiveAt int64 `json:"last_active_at"`
// The memory limit configured for the container.
//
// Any of "1g", "4g", "16g", "64g".
MemoryLimit ContainerNewResponseMemoryLimit `json:"memory_limit"`
// Network access policy for the container.
NetworkPolicy ContainerNewResponseNetworkPolicy `json:"network_policy"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
CreatedAt respjson.Field
Name respjson.Field
Object respjson.Field
Status respjson.Field
ExpiresAfter respjson.Field
LastActiveAt respjson.Field
MemoryLimit respjson.Field
NetworkPolicy respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r ContainerNewResponse) RawJSON() string { return r.JSON.raw }
func (r *ContainerNewResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The container will expire after this time period. The anchor is the reference
// point for the expiration. The minutes is the number of minutes after the anchor
// before the container expires.
type ContainerNewResponseExpiresAfter struct {
// The reference point for the expiration.
//
// Any of "last_active_at".
Anchor string `json:"anchor"`
// The number of minutes after the anchor before the container expires.
Minutes int64 `json:"minutes"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Anchor respjson.Field
Minutes respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r ContainerNewResponseExpiresAfter) RawJSON() string { return r.JSON.raw }
func (r *ContainerNewResponseExpiresAfter) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The memory limit configured for the container.
type ContainerNewResponseMemoryLimit string
const (
ContainerNewResponseMemoryLimit1g ContainerNewResponseMemoryLimit = "1g"
ContainerNewResponseMemoryLimit4g ContainerNewResponseMemoryLimit = "4g"
ContainerNewResponseMemoryLimit16g ContainerNewResponseMemoryLimit = "16g"
ContainerNewResponseMemoryLimit64g ContainerNewResponseMemoryLimit = "64g"
)
// Network access policy for the container.
type ContainerNewResponseNetworkPolicy struct {
// The network policy mode.
//
// Any of "allowlist", "disabled".
Type string `json:"type" api:"required"`
// Allowed outbound domains when `type` is `allowlist`.
AllowedDomains []string `json:"allowed_domains"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Type respjson.Field
AllowedDomains respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r ContainerNewResponseNetworkPolicy) RawJSON() string { return r.JSON.raw }
func (r *ContainerNewResponseNetworkPolicy) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type ContainerGetResponse struct {
// Unique identifier for the container.
ID string `json:"id" api:"required"`
// Unix timestamp (in seconds) when the container was created.
CreatedAt int64 `json:"created_at" api:"required"`
// Name of the container.
Name string `json:"name" api:"required"`
// The type of this object.
Object string `json:"object" api:"required"`
// Status of the container (e.g., active, deleted).
Status string `json:"status" api:"required"`
// The container will expire after this time period. The anchor is the reference
// point for the expiration. The minutes is the number of minutes after the anchor
// before the container expires.
ExpiresAfter ContainerGetResponseExpiresAfter `json:"expires_after"`
// Unix timestamp (in seconds) when the container was last active.
LastActiveAt int64 `json:"last_active_at"`
// The memory limit configured for the container.
//
// Any of "1g", "4g", "16g", "64g".
MemoryLimit ContainerGetResponseMemoryLimit `json:"memory_limit"`
// Network access policy for the container.
NetworkPolicy ContainerGetResponseNetworkPolicy `json:"network_policy"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
CreatedAt respjson.Field
Name respjson.Field
Object respjson.Field
Status respjson.Field
ExpiresAfter respjson.Field
LastActiveAt respjson.Field
MemoryLimit respjson.Field
NetworkPolicy respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r ContainerGetResponse) RawJSON() string { return r.JSON.raw }
func (r *ContainerGetResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The container will expire after this time period. The anchor is the reference
// point for the expiration. The minutes is the number of minutes after the anchor
// before the container expires.
type ContainerGetResponseExpiresAfter struct {
// The reference point for the expiration.
//
// Any of "last_active_at".
Anchor string `json:"anchor"`
// The number of minutes after the anchor before the container expires.
Minutes int64 `json:"minutes"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Anchor respjson.Field
Minutes respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r ContainerGetResponseExpiresAfter) RawJSON() string { return r.JSON.raw }
func (r *ContainerGetResponseExpiresAfter) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The memory limit configured for the container.
type ContainerGetResponseMemoryLimit string
const (
ContainerGetResponseMemoryLimit1g ContainerGetResponseMemoryLimit = "1g"
ContainerGetResponseMemoryLimit4g ContainerGetResponseMemoryLimit = "4g"
ContainerGetResponseMemoryLimit16g ContainerGetResponseMemoryLimit = "16g"
ContainerGetResponseMemoryLimit64g ContainerGetResponseMemoryLimit = "64g"
)
// Network access policy for the container.
type ContainerGetResponseNetworkPolicy struct {
// The network policy mode.
//
// Any of "allowlist", "disabled".
Type string `json:"type" api:"required"`
// Allowed outbound domains when `type` is `allowlist`.
AllowedDomains []string `json:"allowed_domains"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Type respjson.Field
AllowedDomains respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r ContainerGetResponseNetworkPolicy) RawJSON() string { return r.JSON.raw }
func (r *ContainerGetResponseNetworkPolicy) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type ContainerListResponse struct {
// Unique identifier for the container.
ID string `json:"id" api:"required"`
// Unix timestamp (in seconds) when the container was created.
CreatedAt int64 `json:"created_at" api:"required"`
// Name of the container.
Name string `json:"name" api:"required"`
// The type of this object.
Object string `json:"object" api:"required"`
// Status of the container (e.g., active, deleted).
Status string `json:"status" api:"required"`
// The container will expire after this time period. The anchor is the reference
// point for the expiration. The minutes is the number of minutes after the anchor
// before the container expires.
ExpiresAfter ContainerListResponseExpiresAfter `json:"expires_after"`
// Unix timestamp (in seconds) when the container was last active.
LastActiveAt int64 `json:"last_active_at"`
// The memory limit configured for the container.
//
// Any of "1g", "4g", "16g", "64g".
MemoryLimit ContainerListResponseMemoryLimit `json:"memory_limit"`
// Network access policy for the container.
NetworkPolicy ContainerListResponseNetworkPolicy `json:"network_policy"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
CreatedAt respjson.Field
Name respjson.Field
Object respjson.Field
Status respjson.Field
ExpiresAfter respjson.Field
LastActiveAt respjson.Field
MemoryLimit respjson.Field
NetworkPolicy respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r ContainerListResponse) RawJSON() string { return r.JSON.raw }
func (r *ContainerListResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The container will expire after this time period. The anchor is the reference
// point for the expiration. The minutes is the number of minutes after the anchor
// before the container expires.
type ContainerListResponseExpiresAfter struct {
// The reference point for the expiration.
//
// Any of "last_active_at".
Anchor string `json:"anchor"`
// The number of minutes after the anchor before the container expires.
Minutes int64 `json:"minutes"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Anchor respjson.Field
Minutes respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r ContainerListResponseExpiresAfter) RawJSON() string { return r.JSON.raw }
func (r *ContainerListResponseExpiresAfter) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The memory limit configured for the container.
type ContainerListResponseMemoryLimit string
const (
ContainerListResponseMemoryLimit1g ContainerListResponseMemoryLimit = "1g"
ContainerListResponseMemoryLimit4g ContainerListResponseMemoryLimit = "4g"
ContainerListResponseMemoryLimit16g ContainerListResponseMemoryLimit = "16g"
ContainerListResponseMemoryLimit64g ContainerListResponseMemoryLimit = "64g"
)
// Network access policy for the container.
type ContainerListResponseNetworkPolicy struct {
// The network policy mode.
//
// Any of "allowlist", "disabled".
Type string `json:"type" api:"required"`
// Allowed outbound domains when `type` is `allowlist`.
AllowedDomains []string `json:"allowed_domains"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Type respjson.Field
AllowedDomains respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r ContainerListResponseNetworkPolicy) RawJSON() string { return r.JSON.raw }
func (r *ContainerListResponseNetworkPolicy) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type ContainerNewParams struct {
// Name of the container to create.
Name string `json:"name" api:"required"`
// Container expiration time in seconds relative to the 'anchor' time.
ExpiresAfter ContainerNewParamsExpiresAfter `json:"expires_after,omitzero"`
// IDs of files to copy to the container.
FileIDs []string `json:"file_ids,omitzero"`
// Optional memory limit for the container. Defaults to "1g".
//
// Any of "1g", "4g", "16g", "64g".
MemoryLimit ContainerNewParamsMemoryLimit `json:"memory_limit,omitzero"`
// Network access policy for the container.
NetworkPolicy ContainerNewParamsNetworkPolicyUnion `json:"network_policy,omitzero"`
// An optional list of skills referenced by id or inline data.
Skills []ContainerNewParamsSkillUnion `json:"skills,omitzero"`
paramObj
}
func (r ContainerNewParams) MarshalJSON() (data []byte, err error) {
type shadow ContainerNewParams
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *ContainerNewParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Container expiration time in seconds relative to the 'anchor' time.
//
// The properties Anchor, Minutes are required.
type ContainerNewParamsExpiresAfter struct {
// Time anchor for the expiration time. Currently only 'last_active_at' is
// supported.
//
// Any of "last_active_at".
Anchor string `json:"anchor,omitzero" api:"required"`
Minutes int64 `json:"minutes" api:"required"`
paramObj
}
func (r ContainerNewParamsExpiresAfter) MarshalJSON() (data []byte, err error) {
type shadow ContainerNewParamsExpiresAfter
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *ContainerNewParamsExpiresAfter) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
func init() {
apijson.RegisterFieldValidator[ContainerNewParamsExpiresAfter](
"anchor", "last_active_at",
)
}
// Optional memory limit for the container. Defaults to "1g".
type ContainerNewParamsMemoryLimit string
const (
ContainerNewParamsMemoryLimit1g ContainerNewParamsMemoryLimit = "1g"
ContainerNewParamsMemoryLimit4g ContainerNewParamsMemoryLimit = "4g"
ContainerNewParamsMemoryLimit16g ContainerNewParamsMemoryLimit = "16g"
ContainerNewParamsMemoryLimit64g ContainerNewParamsMemoryLimit = "64g"
)
// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type ContainerNewParamsNetworkPolicyUnion struct {
OfDisabled *responses.ContainerNetworkPolicyDisabledParam `json:",omitzero,inline"`
OfAllowlist *responses.ContainerNetworkPolicyAllowlistParam `json:",omitzero,inline"`
paramUnion
}
func (u ContainerNewParamsNetworkPolicyUnion) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfDisabled, u.OfAllowlist)
}
func (u *ContainerNewParamsNetworkPolicyUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
}
func (u *ContainerNewParamsNetworkPolicyUnion) asAny() any {
if !param.IsOmitted(u.OfDisabled) {
return u.OfDisabled
} else if !param.IsOmitted(u.OfAllowlist) {
return u.OfAllowlist
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u ContainerNewParamsNetworkPolicyUnion) GetAllowedDomains() []string {
if vt := u.OfAllowlist; vt != nil {
return vt.AllowedDomains
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u ContainerNewParamsNetworkPolicyUnion) GetDomainSecrets() []responses.ContainerNetworkPolicyDomainSecretParam {
if vt := u.OfAllowlist; vt != nil {
return vt.DomainSecrets
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u ContainerNewParamsNetworkPolicyUnion) GetType() *string {
if vt := u.OfDisabled; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfAllowlist; vt != nil {
return (*string)(&vt.Type)
}
return nil
}
func init() {
apijson.RegisterUnion[ContainerNewParamsNetworkPolicyUnion](
"type",
apijson.Discriminator[responses.ContainerNetworkPolicyDisabledParam]("disabled"),
apijson.Discriminator[responses.ContainerNetworkPolicyAllowlistParam]("allowlist"),
)
}
// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type ContainerNewParamsSkillUnion struct {
OfSkillReference *responses.SkillReferenceParam `json:",omitzero,inline"`
OfInline *responses.InlineSkillParam `json:",omitzero,inline"`
paramUnion
}
func (u ContainerNewParamsSkillUnion) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfSkillReference, u.OfInline)
}
func (u *ContainerNewParamsSkillUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
}
func (u *ContainerNewParamsSkillUnion) asAny() any {
if !param.IsOmitted(u.OfSkillReference) {
return u.OfSkillReference
} else if !param.IsOmitted(u.OfInline) {
return u.OfInline
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u ContainerNewParamsSkillUnion) GetSkillID() *string {
if vt := u.OfSkillReference; vt != nil {
return &vt.SkillID
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u ContainerNewParamsSkillUnion) GetVersion() *string {
if vt := u.OfSkillReference; vt != nil && vt.Version.Valid() {
return &vt.Version.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u ContainerNewParamsSkillUnion) GetDescription() *string {
if vt := u.OfInline; vt != nil {
return &vt.Description
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u ContainerNewParamsSkillUnion) GetName() *string {
if vt := u.OfInline; vt != nil {
return &vt.Name
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u ContainerNewParamsSkillUnion) GetSource() *responses.InlineSkillSourceParam {
if vt := u.OfInline; vt != nil {
return &vt.Source
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u ContainerNewParamsSkillUnion) GetType() *string {
if vt := u.OfSkillReference; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfInline; vt != nil {
return (*string)(&vt.Type)
}
return nil
}
func init() {
apijson.RegisterUnion[ContainerNewParamsSkillUnion](
"type",
apijson.Discriminator[responses.SkillReferenceParam]("skill_reference"),
apijson.Discriminator[responses.InlineSkillParam]("inline"),
)
}
type ContainerListParams struct {
// A cursor for use in pagination. `after` is an object ID that defines your place
// in the list. For instance, if you make a list request and receive 100 objects,
// ending with obj_foo, your subsequent call can include after=obj_foo in order to
// fetch the next page of the list.
After param.Opt[string] `query:"after,omitzero" json:"-"`
// A limit on the number of objects to be returned. Limit can range between 1 and
// 100, and the default is 20.
Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
// Filter results by container name.
Name param.Opt[string] `query:"name,omitzero" json:"-"`
// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
// order and `desc` for descending order.
//
// Any of "asc", "desc".
Order ContainerListParamsOrder `query:"order,omitzero" json:"-"`
paramObj
}
// URLQuery serializes [ContainerListParams]'s query parameters as `url.Values`.
func (r ContainerListParams) URLQuery() (v url.Values, err error) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatBrackets,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
// order and `desc` for descending order.
type ContainerListParamsOrder string
const (
ContainerListParamsOrderAsc ContainerListParamsOrder = "asc"
ContainerListParamsOrderDesc ContainerListParamsOrder = "desc"
)