Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions api/instance/v1/instance_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,8 @@ type IP struct {

Tags []string `json:"tags"`

Project string `json:"project"`

Zone scw.Zone `json:"zone"`
}

Expand Down Expand Up @@ -3952,6 +3954,8 @@ func (s *API) UpdatePlacementGroupServers(req *UpdatePlacementGroupServersReques

type ListIPsRequest struct {
Zone scw.Zone `json:"-"`
// Project: the project ID the IPs are reserved in
Project *string `json:"-"`
// Organization: the organization ID the IPs are reserved in
Organization *string `json:"-"`
// Name: filter on the IP address (Works as a LIKE operation on the IP address)
Expand Down Expand Up @@ -3979,6 +3983,7 @@ func (s *API) ListIPs(req *ListIPsRequest, opts ...scw.RequestOption) (*ListIPsR
}

query := url.Values{}
parameter.AddToQuery(query, "project", req.Project)
parameter.AddToQuery(query, "organization", req.Organization)
parameter.AddToQuery(query, "name", req.Name)
parameter.AddToQuery(query, "per_page", req.PerPage)
Expand Down Expand Up @@ -4026,7 +4031,11 @@ func (r *ListIPsResponse) UnsafeAppend(res interface{}) (uint32, error) {
type CreateIPRequest struct {
Zone scw.Zone `json:"-"`
// Organization: the organization ID the IP is reserved in
Organization string `json:"organization,omitempty"`
// Precisely one of Organization, Project must be set.
Organization *string `json:"organization,omitempty"`
// Project: the project ID the IP is reserved in
// Precisely one of Organization, Project must be set.
Project *string `json:"project,omitempty"`
// Server: UUID of the server you want to attach the IP to
Server *string `json:"server,omitempty"`
// Tags: an array of keywords you want to tag this IP with
Expand All @@ -4037,9 +4046,14 @@ type CreateIPRequest struct {
func (s *API) CreateIP(req *CreateIPRequest, opts ...scw.RequestOption) (*CreateIPResponse, error) {
var err error

if req.Organization == "" {
defaultOrganization, _ := s.client.GetDefaultOrganizationID()
req.Organization = defaultOrganization
defaultProject, exist := s.client.GetDefaultProjectID()
if exist && req.Organization == nil && req.Project == nil {
req.Project = &defaultProject
}

defaultOrganization, exist := s.client.GetDefaultOrganizationID()
if exist && req.Organization == nil && req.Project == nil {
req.Organization = &defaultOrganization
}

if req.Zone == "" {
Expand Down Expand Up @@ -4125,11 +4139,18 @@ type SetIPRequest struct {
Organization string `json:"organization"`

Tags []string `json:"tags"`

Project string `json:"project"`
}

func (s *API) setIP(req *SetIPRequest, opts ...scw.RequestOption) (*setIPResponse, error) {
var err error

if req.Project == "" {
defaultProject, _ := s.client.GetDefaultProjectID()
req.Project = defaultProject
}

if req.Organization == "" {
defaultOrganization, _ := s.client.GetDefaultOrganizationID()
req.Organization = defaultOrganization
Expand Down