Skip to content

Commit 4e94f1f

Browse files
authored
feat(baremetal): add project-id to ipfailover v1alpha1 (#559)
1 parent df3096a commit 4e94f1f

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

api/baremetal/v1alpha1/baremetal_sdk.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,8 @@ type IPFailover struct {
649649
ID string `json:"id"`
650650
// OrganizationID: organization ID the IP failover is attached to
651651
OrganizationID string `json:"organization_id"`
652+
// ProjectID: project ID the IP failover is attached to
653+
ProjectID string `json:"project_id"`
652654
// Description: description of the IP failover
653655
Description string `json:"description"`
654656
// Tags: tags associated to the IP failover
@@ -1640,7 +1642,11 @@ func (s *API) UpdateIP(req *UpdateIPRequest, opts ...scw.RequestOption) (*IP, er
16401642
type CreateIPFailoverRequest struct {
16411643
Zone scw.Zone `json:"-"`
16421644
// OrganizationID: ID of the organization to associate to the IP failover
1643-
OrganizationID string `json:"organization_id"`
1645+
// Precisely one of OrganizationID, ProjectID must be set.
1646+
OrganizationID *string `json:"organization_id,omitempty"`
1647+
// ProjectID: ID of the project to associate to the IP failover
1648+
// Precisely one of OrganizationID, ProjectID must be set.
1649+
ProjectID *string `json:"project_id,omitempty"`
16441650
// Description: description to associate to the IP failover, max 255 characters
16451651
Description string `json:"description"`
16461652
// Tags: tags to associate to the IP failover
@@ -1659,9 +1665,14 @@ type CreateIPFailoverRequest struct {
16591665
func (s *API) CreateIPFailover(req *CreateIPFailoverRequest, opts ...scw.RequestOption) (*IPFailover, error) {
16601666
var err error
16611667

1662-
if req.OrganizationID == "" {
1663-
defaultOrganizationID, _ := s.client.GetDefaultOrganizationID()
1664-
req.OrganizationID = defaultOrganizationID
1668+
defaultProjectID, exist := s.client.GetDefaultProjectID()
1669+
if exist && req.OrganizationID == nil && req.ProjectID == nil {
1670+
req.ProjectID = &defaultProjectID
1671+
}
1672+
1673+
defaultOrganizationID, exist := s.client.GetDefaultOrganizationID()
1674+
if exist && req.OrganizationID == nil && req.ProjectID == nil {
1675+
req.OrganizationID = &defaultOrganizationID
16651676
}
16661677

16671678
if req.Zone == "" {
@@ -1751,6 +1762,8 @@ type ListIPFailoversRequest struct {
17511762
ServerIDs []string `json:"-"`
17521763
// OrganizationID: filter servers by organization ID
17531764
OrganizationID *string `json:"-"`
1765+
// ProjectID: filter servers by project ID
1766+
ProjectID *string `json:"-"`
17541767
}
17551768

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

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

0 commit comments

Comments
 (0)