Skip to content

Commit 1ee40e1

Browse files
feat(apple_silicon): fix typo in applesilicon SDK comment (#2634)
Co-authored-by: Jonathan R. <jremy@scaleway.com>
1 parent f36e6d4 commit 1ee40e1

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

api/applesilicon/v1alpha1/applesilicon_sdk.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,11 @@ type ServerTypeNetwork struct {
489489
SupportedBandwidth []uint64 `json:"supported_bandwidth"`
490490
}
491491

492+
// BatchCreateServersRequestBatchInnerCreateServerRequest: batch create servers request batch inner create server request.
493+
type BatchCreateServersRequestBatchInnerCreateServerRequest struct {
494+
Name string `json:"name"`
495+
}
496+
492497
// Server: server.
493498
type Server struct {
494499
// ID: UUID of the server.
@@ -640,6 +645,40 @@ type CommitmentTypeValue struct {
640645
CommitmentType CommitmentType `json:"commitment_type"`
641646
}
642647

648+
// BatchCreateServersRequest: batch create servers request.
649+
type BatchCreateServersRequest struct {
650+
// Zone: zone to target. If none is passed will use default zone from the config.
651+
Zone scw.Zone `json:"-"`
652+
653+
// ProjectID: create servers in the given project ID.
654+
ProjectID string `json:"project_id"`
655+
656+
// Type: create servers of the given type.
657+
Type string `json:"type"`
658+
659+
// OsID: create servers & install the given os_id, when no os_id provided the default OS for this server type is chosen. Requesting a non-default OS will induce an extended delivery time.
660+
OsID *string `json:"os_id,omitempty"`
661+
662+
// EnableVpc: activate the Private Network feature for these servers. This feature is configured through the Apple Silicon - Private Networks API.
663+
EnableVpc bool `json:"enable_vpc"`
664+
665+
// CommitmentType: activate commitment for these servers. If not specified, there is a 24h commitment due to Apple licensing (commitment_type `duration_24h`). It can be updated with the Update Server request. Available commitment depends on server type.
666+
// Default value: duration_24h
667+
CommitmentType CommitmentType `json:"commitment_type"`
668+
669+
// PublicBandwidthBps: public bandwidth to configure for these servers. This defaults to the minimum bandwidth for the corresponding server type. For compatible server types, the bandwidth can be increased which incurs additional costs.
670+
PublicBandwidthBps uint64 `json:"public_bandwidth_bps"`
671+
672+
// Requests: list of servers to create.
673+
Requests []*BatchCreateServersRequestBatchInnerCreateServerRequest `json:"requests"`
674+
}
675+
676+
// BatchCreateServersResponse: batch create servers response.
677+
type BatchCreateServersResponse struct {
678+
// Servers: list of created servers.
679+
Servers []*Server `json:"servers"`
680+
}
681+
643682
// ConnectivityDiagnostic: connectivity diagnostic.
644683
type ConnectivityDiagnostic struct {
645684
ID string `json:"id"`
@@ -1120,6 +1159,43 @@ func (s *API) CreateServer(req *CreateServerRequest, opts ...scw.RequestOption)
11201159
return &resp, nil
11211160
}
11221161

1162+
// BatchCreateServers: Create multiple servers in the targeted zone specifying their configurations. If the request cannot entirely be fulfilled, no servers are created.
1163+
func (s *API) BatchCreateServers(req *BatchCreateServersRequest, opts ...scw.RequestOption) (*BatchCreateServersResponse, error) {
1164+
var err error
1165+
1166+
if req.Zone == "" {
1167+
defaultZone, _ := s.client.GetDefaultZone()
1168+
req.Zone = defaultZone
1169+
}
1170+
1171+
if req.ProjectID == "" {
1172+
defaultProjectID, _ := s.client.GetDefaultProjectID()
1173+
req.ProjectID = defaultProjectID
1174+
}
1175+
1176+
if fmt.Sprint(req.Zone) == "" {
1177+
return nil, errors.New("field Zone cannot be empty in request")
1178+
}
1179+
1180+
scwReq := &scw.ScalewayRequest{
1181+
Method: "POST",
1182+
Path: "/apple-silicon/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/batch-create-servers",
1183+
}
1184+
1185+
err = scwReq.SetBody(req)
1186+
if err != nil {
1187+
return nil, err
1188+
}
1189+
1190+
var resp BatchCreateServersResponse
1191+
1192+
err = s.client.Do(scwReq, &resp, opts...)
1193+
if err != nil {
1194+
return nil, err
1195+
}
1196+
return &resp, nil
1197+
}
1198+
11231199
// ListServers: List all servers in the specified zone. By default, returned servers in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field.
11241200
func (s *API) ListServers(req *ListServersRequest, opts ...scw.RequestOption) (*ListServersResponse, error) {
11251201
var err error

0 commit comments

Comments
 (0)