Skip to content

Commit 774f846

Browse files
authored
feat(instance): add release IP to IPAM endpoint (#2710)
1 parent 93812d2 commit 774f846

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
@@ -3562,6 +3562,15 @@ type PlanBlockMigrationRequest struct {
35623562
SnapshotID *string `json:"snapshot_id,omitempty"`
35633563
}
35643564

3565+
// ReleaseIPToIpamRequest: release ip to ipam request.
3566+
type ReleaseIPToIpamRequest struct {
3567+
// Zone: zone to target. If none is passed will use default zone from the config.
3568+
Zone scw.Zone `json:"-"`
3569+
3570+
// IPID: ID of the IP you want to release from the Instance but retain in IPAM.
3571+
IPID string `json:"-"`
3572+
}
3573+
35653574
// ServerActionRequest: server action request.
35663575
type ServerActionRequest struct {
35673576
// Zone: zone to target. If none is passed will use default zone from the config.
@@ -6916,3 +6925,37 @@ func (s *API) CheckBlockMigrationOrganizationQuotas(req *CheckBlockMigrationOrga
69166925
}
69176926
return nil
69186927
}
6928+
6929+
// ReleaseIPToIpam: **The IP remains available in IPAM**, which means that it is still reserved by the Organization, and can be reattached to another resource (Instance or other product).
6930+
func (s *API) ReleaseIPToIpam(req *ReleaseIPToIpamRequest, opts ...scw.RequestOption) error {
6931+
var err error
6932+
6933+
if req.Zone == "" {
6934+
defaultZone, _ := s.client.GetDefaultZone()
6935+
req.Zone = defaultZone
6936+
}
6937+
6938+
if fmt.Sprint(req.Zone) == "" {
6939+
return errors.New("field Zone cannot be empty in request")
6940+
}
6941+
6942+
if fmt.Sprint(req.IPID) == "" {
6943+
return errors.New("field IPID cannot be empty in request")
6944+
}
6945+
6946+
scwReq := &scw.ScalewayRequest{
6947+
Method: "POST",
6948+
Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/ips/" + fmt.Sprint(req.IPID) + "/release-to-ipam",
6949+
}
6950+
6951+
err = scwReq.SetBody(req)
6952+
if err != nil {
6953+
return err
6954+
}
6955+
6956+
err = s.client.Do(scwReq, nil, opts...)
6957+
if err != nil {
6958+
return err
6959+
}
6960+
return nil
6961+
}

0 commit comments

Comments
 (0)