Skip to content

Commit 8d738b4

Browse files
authored
feat(instance): create CheckQuotasOrganizationBlockMigration endpoint (scaleway#2337)
1 parent ade887d commit 8d738b4

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

api/instance/v1/instance_sdk.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,6 +2108,14 @@ type AttachServerVolumeResponse struct {
21082108
Server *Server `json:"server"`
21092109
}
21102110

2111+
// CheckBlockMigrationOrganizationQuotasRequest: check block migration organization quotas request.
2112+
type CheckBlockMigrationOrganizationQuotasRequest struct {
2113+
// Zone: zone to target. If none is passed will use default zone from the config.
2114+
Zone scw.Zone `json:"-"`
2115+
2116+
Organization string `json:"organization,omitempty"`
2117+
}
2118+
21112119
// CreateIPRequest: create ip request.
21122120
type CreateIPRequest struct {
21132121
// Zone: zone to target. If none is passed will use default zone from the config.
@@ -6641,3 +6649,38 @@ func (s *API) ApplyBlockMigration(req *ApplyBlockMigrationRequest, opts ...scw.R
66416649
}
66426650
return nil
66436651
}
6652+
6653+
// CheckBlockMigrationOrganizationQuotas:
6654+
func (s *API) CheckBlockMigrationOrganizationQuotas(req *CheckBlockMigrationOrganizationQuotasRequest, opts ...scw.RequestOption) error {
6655+
var err error
6656+
6657+
if req.Zone == "" {
6658+
defaultZone, _ := s.client.GetDefaultZone()
6659+
req.Zone = defaultZone
6660+
}
6661+
6662+
if req.Organization == "" {
6663+
defaultOrganization, _ := s.client.GetDefaultOrganizationID()
6664+
req.Organization = defaultOrganization
6665+
}
6666+
6667+
if fmt.Sprint(req.Zone) == "" {
6668+
return errors.New("field Zone cannot be empty in request")
6669+
}
6670+
6671+
scwReq := &scw.ScalewayRequest{
6672+
Method: "POST",
6673+
Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/block-migration/check-organization-quotas",
6674+
}
6675+
6676+
err = scwReq.SetBody(req)
6677+
if err != nil {
6678+
return err
6679+
}
6680+
6681+
err = s.client.Do(scwReq, nil, opts...)
6682+
if err != nil {
6683+
return err
6684+
}
6685+
return nil
6686+
}

0 commit comments

Comments
 (0)