@@ -542,6 +542,8 @@ type Server struct {
542
542
ID string `json:"id"`
543
543
// OrganizationID: organization ID the server is attached to
544
544
OrganizationID string `json:"organization_id"`
545
+ // ProjectID: project ID the server is attached to
546
+ ProjectID string `json:"project_id"`
545
547
// Name: name of the server
546
548
Name string `json:"name"`
547
549
// Description: description of the server
@@ -620,11 +622,13 @@ type ListServersRequest struct {
620
622
Name * string `json:"-"`
621
623
// OrganizationID: filter servers by organization ID
622
624
OrganizationID * string `json:"-"`
625
+ // ProjectID: filter servers by project ID
626
+ ProjectID * string `json:"-"`
623
627
}
624
628
625
- // ListServers: list baremetal servers
629
+ // ListServers: list baremetal servers for organization
626
630
//
627
- // List baremetal servers.
631
+ // List baremetal servers for organization .
628
632
func (s * API ) ListServers (req * ListServersRequest , opts ... scw.RequestOption ) (* ListServersResponse , error ) {
629
633
var err error
630
634
@@ -646,6 +650,7 @@ func (s *API) ListServers(req *ListServersRequest, opts ...scw.RequestOption) (*
646
650
parameter .AddToQuery (query , "status" , req .Status )
647
651
parameter .AddToQuery (query , "name" , req .Name )
648
652
parameter .AddToQuery (query , "organization_id" , req .OrganizationID )
653
+ parameter .AddToQuery (query , "project_id" , req .ProjectID )
649
654
650
655
if fmt .Sprint (req .Zone ) == "" {
651
656
return nil , errors .New ("field Zone cannot be empty in request" )
@@ -731,7 +736,11 @@ type CreateServerRequest struct {
731
736
// OfferID: offer ID of the new server
732
737
OfferID string `json:"offer_id"`
733
738
// OrganizationID: organization ID with which the server will be created
734
- OrganizationID string `json:"organization_id"`
739
+ // Precisely one of OrganizationID, ProjectID must be set.
740
+ OrganizationID * string `json:"organization_id,omitempty"`
741
+ // ProjectID: project ID with which the server will be created
742
+ // Precisely one of OrganizationID, ProjectID must be set.
743
+ ProjectID * string `json:"project_id,omitempty"`
735
744
// Name: name of the server (≠hostname)
736
745
Name string `json:"name"`
737
746
// Description: description associated to the server, max 255 characters
@@ -748,9 +757,14 @@ type CreateServerRequest struct {
748
757
func (s * API ) CreateServer (req * CreateServerRequest , opts ... scw.RequestOption ) (* Server , error ) {
749
758
var err error
750
759
751
- if req .OrganizationID == "" {
752
- defaultOrganizationID , _ := s .client .GetDefaultOrganizationID ()
753
- req .OrganizationID = defaultOrganizationID
760
+ defaultProjectID , exist := s .client .GetDefaultProjectID ()
761
+ if exist && req .OrganizationID == nil && req .ProjectID == nil {
762
+ req .ProjectID = & defaultProjectID
763
+ }
764
+
765
+ defaultOrganizationID , exist := s .client .GetDefaultOrganizationID ()
766
+ if exist && req .OrganizationID == nil && req .ProjectID == nil {
767
+ req .OrganizationID = & defaultOrganizationID
754
768
}
755
769
756
770
if req .Zone == "" {
0 commit comments