Skip to content
Merged
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
22 changes: 18 additions & 4 deletions api/baremetal/v1alpha1/baremetal_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,8 @@ type IPFailover struct {
ID string `json:"id"`
// OrganizationID: organization ID the IP failover is attached to
OrganizationID string `json:"organization_id"`
// ProjectID: project ID the IP failover is attached to
ProjectID string `json:"project_id"`
// Description: description of the IP failover
Description string `json:"description"`
// Tags: tags associated to the IP failover
Expand Down Expand Up @@ -1640,7 +1642,11 @@ func (s *API) UpdateIP(req *UpdateIPRequest, opts ...scw.RequestOption) (*IP, er
type CreateIPFailoverRequest struct {
Zone scw.Zone `json:"-"`
// OrganizationID: ID of the organization to associate to the IP failover
OrganizationID string `json:"organization_id"`
// Precisely one of OrganizationID, ProjectID must be set.
OrganizationID *string `json:"organization_id,omitempty"`
// ProjectID: ID of the project to associate to the IP failover
// Precisely one of OrganizationID, ProjectID must be set.
ProjectID *string `json:"project_id,omitempty"`
// Description: description to associate to the IP failover, max 255 characters
Description string `json:"description"`
// Tags: tags to associate to the IP failover
Expand All @@ -1659,9 +1665,14 @@ type CreateIPFailoverRequest struct {
func (s *API) CreateIPFailover(req *CreateIPFailoverRequest, opts ...scw.RequestOption) (*IPFailover, error) {
var err error

if req.OrganizationID == "" {
defaultOrganizationID, _ := s.client.GetDefaultOrganizationID()
req.OrganizationID = defaultOrganizationID
defaultProjectID, exist := s.client.GetDefaultProjectID()
if exist && req.OrganizationID == nil && req.ProjectID == nil {
req.ProjectID = &defaultProjectID
}

defaultOrganizationID, exist := s.client.GetDefaultOrganizationID()
if exist && req.OrganizationID == nil && req.ProjectID == nil {
req.OrganizationID = &defaultOrganizationID
}

if req.Zone == "" {
Expand Down Expand Up @@ -1751,6 +1762,8 @@ type ListIPFailoversRequest struct {
ServerIDs []string `json:"-"`
// OrganizationID: filter servers by organization ID
OrganizationID *string `json:"-"`
// ProjectID: filter servers by project ID
ProjectID *string `json:"-"`
}

// ListIPFailovers: list IP failovers
Expand All @@ -1777,6 +1790,7 @@ func (s *API) ListIPFailovers(req *ListIPFailoversRequest, opts ...scw.RequestOp
parameter.AddToQuery(query, "status", req.Status)
parameter.AddToQuery(query, "server_ids", req.ServerIDs)
parameter.AddToQuery(query, "organization_id", req.OrganizationID)
parameter.AddToQuery(query, "project_id", req.ProjectID)

if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
Expand Down