From 09ab9ac4f62aa7e61b488d0aab4f7837c720c742 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Thu, 3 Jul 2025 14:26:33 +0000 Subject: [PATCH] feat: update generated APIs --- api/applesilicon/v1alpha1/applesilicon_sdk.go | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/api/applesilicon/v1alpha1/applesilicon_sdk.go b/api/applesilicon/v1alpha1/applesilicon_sdk.go index 0d7d74be2..da427ce02 100644 --- a/api/applesilicon/v1alpha1/applesilicon_sdk.go +++ b/api/applesilicon/v1alpha1/applesilicon_sdk.go @@ -489,6 +489,11 @@ type ServerTypeNetwork struct { SupportedBandwidth []uint64 `json:"supported_bandwidth"` } +// BatchCreateServersRequestBatchInnerCreateServerRequest: batch create servers request batch inner create server request. +type BatchCreateServersRequestBatchInnerCreateServerRequest struct { + Name string `json:"name"` +} + // Server: server. type Server struct { // ID: UUID of the server. @@ -640,6 +645,40 @@ type CommitmentTypeValue struct { CommitmentType CommitmentType `json:"commitment_type"` } +// BatchCreateServersRequest: batch create servers request. +type BatchCreateServersRequest struct { + // Zone: zone to target. If none is passed will use default zone from the config. + Zone scw.Zone `json:"-"` + + // ProjectID: create servers in the given project ID. + ProjectID string `json:"project_id"` + + // Type: create servers of the given type. + Type string `json:"type"` + + // 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. + OsID *string `json:"os_id,omitempty"` + + // EnableVpc: activate the Private Network feature for these servers. This feature is configured through the Apple Silicon - Private Networks API. + EnableVpc bool `json:"enable_vpc"` + + // 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. + // Default value: duration_24h + CommitmentType CommitmentType `json:"commitment_type"` + + // 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. + PublicBandwidthBps uint64 `json:"public_bandwidth_bps"` + + // Requests: list of servers to create. + Requests []*BatchCreateServersRequestBatchInnerCreateServerRequest `json:"requests"` +} + +// BatchCreateServersResponse: batch create servers response. +type BatchCreateServersResponse struct { + // Servers: list of created servers. + Servers []*Server `json:"servers"` +} + // ConnectivityDiagnostic: connectivity diagnostic. type ConnectivityDiagnostic struct { ID string `json:"id"` @@ -1120,6 +1159,43 @@ func (s *API) CreateServer(req *CreateServerRequest, opts ...scw.RequestOption) return &resp, nil } +// BatchCreateServers: Create multiple servers in the targeted zone specifying their configurations. If the request cannot entirely be fullfilled, no servers are created. +func (s *API) BatchCreateServers(req *BatchCreateServersRequest, opts ...scw.RequestOption) (*BatchCreateServersResponse, error) { + var err error + + if req.Zone == "" { + defaultZone, _ := s.client.GetDefaultZone() + req.Zone = defaultZone + } + + if req.ProjectID == "" { + defaultProjectID, _ := s.client.GetDefaultProjectID() + req.ProjectID = defaultProjectID + } + + if fmt.Sprint(req.Zone) == "" { + return nil, errors.New("field Zone cannot be empty in request") + } + + scwReq := &scw.ScalewayRequest{ + Method: "POST", + Path: "/apple-silicon/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/batch-create-servers", + } + + err = scwReq.SetBody(req) + if err != nil { + return nil, err + } + + var resp BatchCreateServersResponse + + err = s.client.Do(scwReq, &resp, opts...) + if err != nil { + return nil, err + } + return &resp, nil +} + // 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. func (s *API) ListServers(req *ListServersRequest, opts ...scw.RequestOption) (*ListServersResponse, error) { var err error