-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstanceinterface.go
More file actions
628 lines (566 loc) · 26 KB
/
instanceinterface.go
File metadata and controls
628 lines (566 loc) · 26 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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package cloud
import (
"context"
"errors"
"fmt"
"net/http"
"slices"
"github.com/G-Core/gcore-go/internal/apijson"
"github.com/G-Core/gcore-go/internal/requestconfig"
"github.com/G-Core/gcore-go/option"
"github.com/G-Core/gcore-go/packages/param"
)
// InstanceInterfaceService contains methods and other services that help with
// interacting with the gcore 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 [NewInstanceInterfaceService] method instead.
type InstanceInterfaceService struct {
Options []option.RequestOption
tasks TaskService
}
// NewInstanceInterfaceService 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 NewInstanceInterfaceService(opts ...option.RequestOption) (r InstanceInterfaceService) {
r = InstanceInterfaceService{}
r.Options = opts
r.tasks = NewTaskService(opts...)
return
}
// List all network interfaces attached to the specified instance.
func (r *InstanceInterfaceService) List(ctx context.Context, instanceID string, query InstanceInterfaceListParams, opts ...option.RequestOption) (res *NetworkInterfaceList, err error) {
opts = slices.Concat(r.Options, opts)
precfg, err := requestconfig.PreRequestOptions(opts...)
if err != nil {
return nil, err
}
requestconfig.UseDefaultParam(&query.ProjectID, precfg.CloudProjectID)
requestconfig.UseDefaultParam(&query.RegionID, precfg.CloudRegionID)
if !query.ProjectID.Valid() {
err = errors.New("missing required project_id parameter")
return nil, err
}
if !query.RegionID.Valid() {
err = errors.New("missing required region_id parameter")
return nil, err
}
if instanceID == "" {
err = errors.New("missing required instance_id parameter")
return nil, err
}
path := fmt.Sprintf("cloud/v1/instances/%v/%v/%s/interfaces", query.ProjectID.Value, query.RegionID.Value, instanceID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
// Attach interface to instance
func (r *InstanceInterfaceService) Attach(ctx context.Context, instanceID string, params InstanceInterfaceAttachParams, opts ...option.RequestOption) (res *TaskIDList, err error) {
opts = slices.Concat(r.Options, opts)
precfg, err := requestconfig.PreRequestOptions(opts...)
if err != nil {
return nil, err
}
requestconfig.UseDefaultParam(¶ms.ProjectID, precfg.CloudProjectID)
requestconfig.UseDefaultParam(¶ms.RegionID, precfg.CloudRegionID)
if !params.ProjectID.Valid() {
err = errors.New("missing required project_id parameter")
return nil, err
}
if !params.RegionID.Valid() {
err = errors.New("missing required region_id parameter")
return nil, err
}
if instanceID == "" {
err = errors.New("missing required instance_id parameter")
return nil, err
}
path := fmt.Sprintf("cloud/v1/instances/%v/%v/%s/attach_interface", params.ProjectID.Value, params.RegionID.Value, instanceID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
return res, err
}
// AttachAndPoll attach interface to instance and poll for the completion of the first task. Use the [TaskService.Poll]
// method if you need to poll for all tasks.
func (r *InstanceInterfaceService) AttachAndPoll(ctx context.Context, instanceID string, params InstanceInterfaceAttachParams, opts ...option.RequestOption) (v *NetworkInterfaceList, err error) {
// Exclude WithResponseBodyInto for the action (Attach returns TaskIDList, must deserialize properly)
actionOpts := requestconfig.ExcludeResponseBodyInto(opts...)
resource, err := r.Attach(ctx, instanceID, params, actionOpts...)
if err != nil {
return
}
precfg, err := requestconfig.PreRequestOptions(slices.Concat(r.Options, opts)...)
if err != nil {
return
}
var listParams InstanceInterfaceListParams
requestconfig.UseDefaultParam(¶ms.ProjectID, precfg.CloudProjectID)
requestconfig.UseDefaultParam(¶ms.RegionID, precfg.CloudRegionID)
listParams.ProjectID = params.ProjectID
listParams.RegionID = params.RegionID
if len(resource.Tasks) == 0 {
return nil, errors.New("expected at least one task to be created")
}
taskID := resource.Tasks[0]
// Exclude WithResponseBodyInto and clear request body for Poll (returns Task, must deserialize properly)
pollOpts := slices.Concat(
requestconfig.ExcludeResponseBodyInto(opts...),
[]option.RequestOption{requestconfig.WithoutRequestBody()},
)
_, err = r.tasks.Poll(ctx, taskID, pollOpts...)
if err != nil {
return
}
// Exclude WithResponseBodyInto and clear request body for List
listOpts := slices.Concat(
requestconfig.ExcludeResponseBodyInto(opts...),
[]option.RequestOption{requestconfig.WithoutRequestBody()},
)
result, err := r.List(ctx, instanceID, listParams, listOpts...)
if err != nil {
return nil, err
}
if err := requestconfig.WriteResponseBodyInto(opts, []byte(result.RawJSON())); err != nil {
return nil, err
}
return result, nil
}
// Detach interface from instance
func (r *InstanceInterfaceService) Detach(ctx context.Context, instanceID string, params InstanceInterfaceDetachParams, opts ...option.RequestOption) (res *TaskIDList, err error) {
opts = slices.Concat(r.Options, opts)
precfg, err := requestconfig.PreRequestOptions(opts...)
if err != nil {
return nil, err
}
requestconfig.UseDefaultParam(¶ms.ProjectID, precfg.CloudProjectID)
requestconfig.UseDefaultParam(¶ms.RegionID, precfg.CloudRegionID)
if !params.ProjectID.Valid() {
err = errors.New("missing required project_id parameter")
return nil, err
}
if !params.RegionID.Valid() {
err = errors.New("missing required region_id parameter")
return nil, err
}
if instanceID == "" {
err = errors.New("missing required instance_id parameter")
return nil, err
}
path := fmt.Sprintf("cloud/v1/instances/%v/%v/%s/detach_interface", params.ProjectID.Value, params.RegionID.Value, instanceID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
return res, err
}
// DetachAndPoll interface from instance and poll for the completion of the first task. Use the [TaskService.Poll]
// method if you need to poll for all tasks.
func (r *InstanceInterfaceService) DetachAndPoll(ctx context.Context, instanceID string, params InstanceInterfaceDetachParams, opts ...option.RequestOption) (v *NetworkInterfaceList, err error) {
// Exclude WithResponseBodyInto for the action (Detach returns TaskIDList, must deserialize properly)
actionOpts := requestconfig.ExcludeResponseBodyInto(opts...)
resource, err := r.Detach(ctx, instanceID, params, actionOpts...)
if err != nil {
return
}
precfg, err := requestconfig.PreRequestOptions(slices.Concat(r.Options, opts)...)
if err != nil {
return
}
var listParams InstanceInterfaceListParams
requestconfig.UseDefaultParam(¶ms.ProjectID, precfg.CloudProjectID)
requestconfig.UseDefaultParam(¶ms.RegionID, precfg.CloudRegionID)
listParams.ProjectID = params.ProjectID
listParams.RegionID = params.RegionID
if len(resource.Tasks) == 0 {
return nil, errors.New("expected at least one task to be created")
}
taskID := resource.Tasks[0]
// Exclude WithResponseBodyInto and clear request body for Poll (returns Task, must deserialize properly)
pollOpts := slices.Concat(
requestconfig.ExcludeResponseBodyInto(opts...),
[]option.RequestOption{requestconfig.WithoutRequestBody()},
)
_, err = r.tasks.Poll(ctx, taskID, pollOpts...)
if err != nil {
return
}
// Exclude WithResponseBodyInto and clear request body for List
listOpts := slices.Concat(
requestconfig.ExcludeResponseBodyInto(opts...),
[]option.RequestOption{requestconfig.WithoutRequestBody()},
)
result, err := r.List(ctx, instanceID, listParams, listOpts...)
if err != nil {
return nil, err
}
if err := requestconfig.WriteResponseBodyInto(opts, []byte(result.RawJSON())); err != nil {
return nil, err
}
return result, nil
}
type InstanceInterfaceListParams struct {
ProjectID param.Opt[int64] `path:"project_id,omitzero" api:"required" json:"-"`
RegionID param.Opt[int64] `path:"region_id,omitzero" api:"required" json:"-"`
paramObj
}
type InstanceInterfaceAttachParams struct {
ProjectID param.Opt[int64] `path:"project_id,omitzero" api:"required" json:"-"`
RegionID param.Opt[int64] `path:"region_id,omitzero" api:"required" json:"-"`
//
// Request body variants
//
// This field is a request body variant, only one variant field can be set.
// Instance will be attached to default external network
OfNewInterfaceExternalExtendSchemaWithDDOS *InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOS `json:",inline"`
// This field is a request body variant, only one variant field can be set.
// Instance will be attached to specified subnet
OfNewInterfaceSpecificSubnetSchema *InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchema `json:",inline"`
// This field is a request body variant, only one variant field can be set.
// Instance will be attached to the network subnet with the largest count of
// available ips
OfNewInterfaceAnySubnetSchema *InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchema `json:",inline"`
// This field is a request body variant, only one variant field can be set.
// Instance will be attached to the given port. Floating IP will be created and
// attached to that IP
OfNewInterfaceReservedFixedIPSchema *InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchema `json:",inline"`
paramObj
}
func (u InstanceInterfaceAttachParams) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfNewInterfaceExternalExtendSchemaWithDDOS, u.OfNewInterfaceSpecificSubnetSchema, u.OfNewInterfaceAnySubnetSchema, u.OfNewInterfaceReservedFixedIPSchema)
}
func (r *InstanceInterfaceAttachParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Instance will be attached to default external network
type InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOS struct {
// Interface name
InterfaceName param.Opt[string] `json:"interface_name,omitzero"`
// Each group will be added to the separate trunk.
PortGroup param.Opt[int64] `json:"port_group,omitzero"`
// Must be 'external'. Union tag
Type param.Opt[string] `json:"type,omitzero"`
// Advanced DDoS protection.
DDOSProfile InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOSDDOSProfile `json:"ddos_profile,omitzero"`
// Which subnets should be selected: IPv4, IPv6 or use dual stack.
//
// Any of "dual", "ipv4", "ipv6".
IPFamily string `json:"ip_family,omitzero"`
// List of security group IDs
SecurityGroups []InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOSSecurityGroup `json:"security_groups,omitzero"`
paramObj
}
func (r InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOS) MarshalJSON() (data []byte, err error) {
type shadow InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOS
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOS) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
func init() {
apijson.RegisterFieldValidator[InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOS](
"ip_family", "dual", "ipv4", "ipv6",
)
}
// Advanced DDoS protection.
//
// The property ProfileTemplate is required.
type InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOSDDOSProfile struct {
// DDoS profile template ID.
ProfileTemplate int64 `json:"profile_template" api:"required"`
// DDoS profile template name.
ProfileTemplateName param.Opt[string] `json:"profile_template_name,omitzero"`
// Protection parameters.
Fields []InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOSDDOSProfileField `json:"fields,omitzero"`
paramObj
}
func (r InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOSDDOSProfile) MarshalJSON() (data []byte, err error) {
type shadow InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOSDDOSProfile
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOSDDOSProfile) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The property BaseField is required.
type InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOSDDOSProfileField struct {
// ID of DDoS profile field
BaseField int64 `json:"base_field" api:"required"`
// Basic type value. Only one of 'value' or 'field_value' must be specified.
Value param.Opt[string] `json:"value,omitzero"`
// Complex value for the DDoS profile field
FieldValue any `json:"field_value,omitzero"`
paramObj
}
func (r InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOSDDOSProfileField) MarshalJSON() (data []byte, err error) {
type shadow InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOSDDOSProfileField
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOSDDOSProfileField) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// MandatoryIdSchema schema
//
// The property ID is required.
type InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOSSecurityGroup struct {
// Resource ID
ID string `json:"id" api:"required" format:"uuid"`
paramObj
}
func (r InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOSSecurityGroup) MarshalJSON() (data []byte, err error) {
type shadow InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOSSecurityGroup
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOSSecurityGroup) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Instance will be attached to specified subnet
//
// The property SubnetID is required.
type InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchema struct {
// Port will get an IP address from this subnet
SubnetID string `json:"subnet_id" api:"required"`
// Interface name
InterfaceName param.Opt[string] `json:"interface_name,omitzero"`
// Each group will be added to the separate trunk.
PortGroup param.Opt[int64] `json:"port_group,omitzero"`
// Must be 'subnet'
Type param.Opt[string] `json:"type,omitzero"`
// Advanced DDoS protection.
DDOSProfile InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchemaDDOSProfile `json:"ddos_profile,omitzero"`
// List of security group IDs
SecurityGroups []InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchemaSecurityGroup `json:"security_groups,omitzero"`
paramObj
}
func (r InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchema) MarshalJSON() (data []byte, err error) {
type shadow InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchema
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchema) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Advanced DDoS protection.
//
// The property ProfileTemplate is required.
type InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchemaDDOSProfile struct {
// DDoS profile template ID.
ProfileTemplate int64 `json:"profile_template" api:"required"`
// DDoS profile template name.
ProfileTemplateName param.Opt[string] `json:"profile_template_name,omitzero"`
// Protection parameters.
Fields []InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchemaDDOSProfileField `json:"fields,omitzero"`
paramObj
}
func (r InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchemaDDOSProfile) MarshalJSON() (data []byte, err error) {
type shadow InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchemaDDOSProfile
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchemaDDOSProfile) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The property BaseField is required.
type InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchemaDDOSProfileField struct {
// ID of DDoS profile field
BaseField int64 `json:"base_field" api:"required"`
// Basic type value. Only one of 'value' or 'field_value' must be specified.
Value param.Opt[string] `json:"value,omitzero"`
// Complex value for the DDoS profile field
FieldValue any `json:"field_value,omitzero"`
paramObj
}
func (r InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchemaDDOSProfileField) MarshalJSON() (data []byte, err error) {
type shadow InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchemaDDOSProfileField
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchemaDDOSProfileField) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// MandatoryIdSchema schema
//
// The property ID is required.
type InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchemaSecurityGroup struct {
// Resource ID
ID string `json:"id" api:"required" format:"uuid"`
paramObj
}
func (r InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchemaSecurityGroup) MarshalJSON() (data []byte, err error) {
type shadow InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchemaSecurityGroup
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *InstanceInterfaceAttachParamsBodyNewInterfaceSpecificSubnetSchemaSecurityGroup) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Instance will be attached to the network subnet with the largest count of
// available ips
//
// The property NetworkID is required.
type InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchema struct {
// Port will get an IP address in this network subnet
NetworkID string `json:"network_id" api:"required"`
// Interface name
InterfaceName param.Opt[string] `json:"interface_name,omitzero"`
// Each group will be added to the separate trunk.
PortGroup param.Opt[int64] `json:"port_group,omitzero"`
// Must be 'any_subnet'
Type param.Opt[string] `json:"type,omitzero"`
// Advanced DDoS protection.
DDOSProfile InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchemaDDOSProfile `json:"ddos_profile,omitzero"`
// Which subnets should be selected: IPv4, IPv6 or use dual stack.
//
// Any of "dual", "ipv4", "ipv6".
IPFamily string `json:"ip_family,omitzero"`
// List of security group IDs
SecurityGroups []InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchemaSecurityGroup `json:"security_groups,omitzero"`
paramObj
}
func (r InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchema) MarshalJSON() (data []byte, err error) {
type shadow InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchema
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchema) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
func init() {
apijson.RegisterFieldValidator[InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchema](
"ip_family", "dual", "ipv4", "ipv6",
)
}
// Advanced DDoS protection.
//
// The property ProfileTemplate is required.
type InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchemaDDOSProfile struct {
// DDoS profile template ID.
ProfileTemplate int64 `json:"profile_template" api:"required"`
// DDoS profile template name.
ProfileTemplateName param.Opt[string] `json:"profile_template_name,omitzero"`
// Protection parameters.
Fields []InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchemaDDOSProfileField `json:"fields,omitzero"`
paramObj
}
func (r InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchemaDDOSProfile) MarshalJSON() (data []byte, err error) {
type shadow InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchemaDDOSProfile
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchemaDDOSProfile) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The property BaseField is required.
type InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchemaDDOSProfileField struct {
// ID of DDoS profile field
BaseField int64 `json:"base_field" api:"required"`
// Basic type value. Only one of 'value' or 'field_value' must be specified.
Value param.Opt[string] `json:"value,omitzero"`
// Complex value for the DDoS profile field
FieldValue any `json:"field_value,omitzero"`
paramObj
}
func (r InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchemaDDOSProfileField) MarshalJSON() (data []byte, err error) {
type shadow InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchemaDDOSProfileField
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchemaDDOSProfileField) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// MandatoryIdSchema schema
//
// The property ID is required.
type InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchemaSecurityGroup struct {
// Resource ID
ID string `json:"id" api:"required" format:"uuid"`
paramObj
}
func (r InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchemaSecurityGroup) MarshalJSON() (data []byte, err error) {
type shadow InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchemaSecurityGroup
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *InstanceInterfaceAttachParamsBodyNewInterfaceAnySubnetSchemaSecurityGroup) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Instance will be attached to the given port. Floating IP will be created and
// attached to that IP
//
// The property PortID is required.
type InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchema struct {
// Port ID
PortID string `json:"port_id" api:"required"`
// Interface name
InterfaceName param.Opt[string] `json:"interface_name,omitzero"`
// Each group will be added to the separate trunk.
PortGroup param.Opt[int64] `json:"port_group,omitzero"`
// Must be 'reserved_fixed_ip'. Union tag
Type param.Opt[string] `json:"type,omitzero"`
// Advanced DDoS protection.
DDOSProfile InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchemaDDOSProfile `json:"ddos_profile,omitzero"`
// List of security group IDs
SecurityGroups []InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchemaSecurityGroup `json:"security_groups,omitzero"`
paramObj
}
func (r InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchema) MarshalJSON() (data []byte, err error) {
type shadow InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchema
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchema) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Advanced DDoS protection.
//
// The property ProfileTemplate is required.
type InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchemaDDOSProfile struct {
// DDoS profile template ID.
ProfileTemplate int64 `json:"profile_template" api:"required"`
// DDoS profile template name.
ProfileTemplateName param.Opt[string] `json:"profile_template_name,omitzero"`
// Protection parameters.
Fields []InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchemaDDOSProfileField `json:"fields,omitzero"`
paramObj
}
func (r InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchemaDDOSProfile) MarshalJSON() (data []byte, err error) {
type shadow InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchemaDDOSProfile
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchemaDDOSProfile) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The property BaseField is required.
type InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchemaDDOSProfileField struct {
// ID of DDoS profile field
BaseField int64 `json:"base_field" api:"required"`
// Basic type value. Only one of 'value' or 'field_value' must be specified.
Value param.Opt[string] `json:"value,omitzero"`
// Complex value for the DDoS profile field
FieldValue any `json:"field_value,omitzero"`
paramObj
}
func (r InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchemaDDOSProfileField) MarshalJSON() (data []byte, err error) {
type shadow InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchemaDDOSProfileField
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchemaDDOSProfileField) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// MandatoryIdSchema schema
//
// The property ID is required.
type InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchemaSecurityGroup struct {
// Resource ID
ID string `json:"id" api:"required" format:"uuid"`
paramObj
}
func (r InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchemaSecurityGroup) MarshalJSON() (data []byte, err error) {
type shadow InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchemaSecurityGroup
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *InstanceInterfaceAttachParamsBodyNewInterfaceReservedFixedIPSchemaSecurityGroup) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type InstanceInterfaceDetachParams struct {
ProjectID param.Opt[int64] `path:"project_id,omitzero" api:"required" json:"-"`
RegionID param.Opt[int64] `path:"region_id,omitzero" api:"required" json:"-"`
// IP address
IPAddress string `json:"ip_address" api:"required"`
// ID of the port
PortID string `json:"port_id" api:"required"`
paramObj
}
func (r InstanceInterfaceDetachParams) MarshalJSON() (data []byte, err error) {
type shadow InstanceInterfaceDetachParams
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *InstanceInterfaceDetachParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}