Skip to content

Commit 8ae0044

Browse files
authored
feat(apple_silicon): introduce monthly commitment handling (scaleway#2419)
1 parent 428f1d2 commit 8ae0044

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

api/applesilicon/v1alpha1/applesilicon_sdk.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,45 @@ var (
3939
_ = namegenerator.GetRandomName
4040
)
4141

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+
4281
type ConnectivityDiagnosticActionType string
4382

4483
const (
@@ -440,6 +479,14 @@ type ServerTypeNetwork struct {
440479
PublicBandwidthBps uint64 `json:"public_bandwidth_bps"`
441480
}
442481

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+
443490
// ConnectivityDiagnosticServerHealth: connectivity diagnostic server health.
444491
type ConnectivityDiagnosticServerHealth struct {
445492
LastCheckinDate *time.Time `json:"last_checkin_date"`
@@ -577,6 +624,15 @@ type Server struct {
577624
// VpcStatus: activation status of optional Private Network feature support for this server.
578625
// Default value: vpc_unknown_status
579626
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"`
580636
}
581637

582638
// ConnectivityDiagnostic: connectivity diagnostic.
@@ -614,6 +670,10 @@ type CreateServerRequest struct {
614670

615671
// EnableVpc: activate the Private Network feature for this server. This feature is configured through the Apple Silicon - Private Networks API.
616672
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"`
617677
}
618678

619679
// DeleteServerRequest: delete server request.
@@ -929,6 +989,9 @@ type UpdateServerRequest struct {
929989

930990
// EnableVpc: activate or deactivate Private Network support for this server.
931991
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"`
932995
}
933996

934997
// This API allows you to manage your Apple silicon machines.

0 commit comments

Comments
 (0)