|
39 | 39 | _ = namegenerator.GetRandomName |
40 | 40 | ) |
41 | 41 |
|
| 42 | +type CommitmentType string |
| 43 | + |
| 44 | +const ( |
| 45 | + CommitmentTypeDuration24h = CommitmentType("duration_24h") |
| 46 | + CommitmentTypeRenewedMonthly = CommitmentType("renewed_monthly") |
| 47 | + CommitmentTypeNone = CommitmentType("none") |
| 48 | +) |
| 49 | + |
| 50 | +func (enum CommitmentType) String() string { |
| 51 | + if enum == "" { |
| 52 | + // return default value if empty |
| 53 | + return "duration_24h" |
| 54 | + } |
| 55 | + return string(enum) |
| 56 | +} |
| 57 | + |
| 58 | +func (enum CommitmentType) Values() []CommitmentType { |
| 59 | + return []CommitmentType{ |
| 60 | + "duration_24h", |
| 61 | + "renewed_monthly", |
| 62 | + "none", |
| 63 | + } |
| 64 | +} |
| 65 | + |
| 66 | +func (enum CommitmentType) MarshalJSON() ([]byte, error) { |
| 67 | + return []byte(fmt.Sprintf(`"%s"`, enum)), nil |
| 68 | +} |
| 69 | + |
| 70 | +func (enum *CommitmentType) UnmarshalJSON(data []byte) error { |
| 71 | + tmp := "" |
| 72 | + |
| 73 | + if err := json.Unmarshal(data, &tmp); err != nil { |
| 74 | + return err |
| 75 | + } |
| 76 | + |
| 77 | + *enum = CommitmentType(CommitmentType(tmp).String()) |
| 78 | + return nil |
| 79 | +} |
| 80 | + |
42 | 81 | type ConnectivityDiagnosticActionType string |
43 | 82 |
|
44 | 83 | const ( |
@@ -440,6 +479,14 @@ type ServerTypeNetwork struct { |
440 | 479 | PublicBandwidthBps uint64 `json:"public_bandwidth_bps"` |
441 | 480 | } |
442 | 481 |
|
| 482 | +// Commitment: commitment. |
| 483 | +type Commitment struct { |
| 484 | + // Type: default value: duration_24h |
| 485 | + Type CommitmentType `json:"type"` |
| 486 | + |
| 487 | + Cancelled bool `json:"cancelled"` |
| 488 | +} |
| 489 | + |
443 | 490 | // ConnectivityDiagnosticServerHealth: connectivity diagnostic server health. |
444 | 491 | type ConnectivityDiagnosticServerHealth struct { |
445 | 492 | LastCheckinDate *time.Time `json:"last_checkin_date"` |
@@ -577,6 +624,15 @@ type Server struct { |
577 | 624 | // VpcStatus: activation status of optional Private Network feature support for this server. |
578 | 625 | // Default value: vpc_unknown_status |
579 | 626 | VpcStatus ServerPrivateNetworkStatus `json:"vpc_status"` |
| 627 | + |
| 628 | + // Commitment: commitment scheme applied to this server. |
| 629 | + Commitment *Commitment `json:"commitment"` |
| 630 | +} |
| 631 | + |
| 632 | +// CommitmentTypeValue: commitment type value. |
| 633 | +type CommitmentTypeValue struct { |
| 634 | + // CommitmentType: default value: duration_24h |
| 635 | + CommitmentType CommitmentType `json:"commitment_type"` |
580 | 636 | } |
581 | 637 |
|
582 | 638 | // ConnectivityDiagnostic: connectivity diagnostic. |
@@ -614,6 +670,10 @@ type CreateServerRequest struct { |
614 | 670 |
|
615 | 671 | // EnableVpc: activate the Private Network feature for this server. This feature is configured through the Apple Silicon - Private Networks API. |
616 | 672 | EnableVpc bool `json:"enable_vpc"` |
| 673 | + |
| 674 | + // CommitmentType: activate commitment for this server. If not specified, there is a 24h commitment due to Apple licensing. It can be updated with the Update Server request. Available commitment depends on server type. |
| 675 | + // Default value: duration_24h |
| 676 | + CommitmentType CommitmentType `json:"commitment_type"` |
617 | 677 | } |
618 | 678 |
|
619 | 679 | // DeleteServerRequest: delete server request. |
@@ -929,6 +989,9 @@ type UpdateServerRequest struct { |
929 | 989 |
|
930 | 990 | // EnableVpc: activate or deactivate Private Network support for this server. |
931 | 991 | EnableVpc *bool `json:"enable_vpc,omitempty"` |
| 992 | + |
| 993 | + // CommitmentType: change commitment. Use 'none' to automatically cancel a renewing commitment. |
| 994 | + CommitmentType *CommitmentTypeValue `json:"commitment_type,omitempty"` |
932 | 995 | } |
933 | 996 |
|
934 | 997 | // This API allows you to manage your Apple silicon machines. |
|
0 commit comments