Skip to content

Commit 250a123

Browse files
fix: e2e tests project (#195)
* doc: update baremetal doc * fix: rename projectID to orgID
1 parent 5ff34b0 commit 250a123

File tree

3 files changed

+87
-71
lines changed

3 files changed

+87
-71
lines changed

api/baremetal/v1alpha1/baremetal_sdk.go

Lines changed: 68 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -348,80 +348,82 @@ type IP struct {
348348
}
349349

350350
type ListServerEventsResponse struct {
351-
// TotalCount total count of matching events (total_count≠page_size, it is the global count)
351+
// TotalCount total count of matching events
352352
TotalCount uint32 `json:"total_count"`
353-
// Event array of events, which match with the parameters
353+
// Event server events that match filters
354354
Event []*ServerEvent `json:"event"`
355355
}
356356

357357
type ListServersResponse struct {
358-
// TotalCount total count of matching items (total_count≠page_size, it is the global count)
358+
// TotalCount total count of matching servers
359359
TotalCount uint32 `json:"total_count"`
360-
// Servers listing of servers
360+
// Servers servers that match filters
361361
Servers []*Server `json:"servers"`
362362
}
363363

364364
type RemoteServerAccess struct {
365-
// URL url to access on the server
365+
// URL uRL to access to the server console
366366
URL string `json:"url"`
367-
// Login login for the authentification
367+
// Login the login to use for the remote access authentification
368368
Login string `json:"login"`
369-
// Password password for the authentification
369+
// Password the password to use for the remote access authentification
370370
Password string `json:"password"`
371-
// ExpiresAt after this date, the remote access will be closed
371+
// ExpiresAt the date after which the remote access will be closed
372372
ExpiresAt time.Time `json:"expires_at"`
373373
}
374374

375375
type Server struct {
376376
// ID iD of the server
377377
ID string `json:"id"`
378-
// OrganizationID organization ID linked with the server
378+
// OrganizationID organization ID the server is attached to
379379
OrganizationID string `json:"organization_id"`
380380
// Name name of the server
381381
Name string `json:"name"`
382382
// Description description of the server
383383
Description string `json:"description"`
384-
// UpdatedAt date of last update of the server
384+
// UpdatedAt date of last modification of the server
385385
UpdatedAt time.Time `json:"updated_at"`
386-
// CreatedAt creation date of the server
386+
// CreatedAt date of creation of the server
387387
CreatedAt time.Time `json:"created_at"`
388388
// Status status of the server
389389
//
390390
// Default value: unknown
391391
Status ServerStatus `json:"status"`
392-
// OfferID offer reference of the server
392+
// OfferID offer ID of the server
393393
OfferID string `json:"offer_id"`
394-
// Install object to describe the specifications of installation
394+
// Install information about the last installation of the server
395395
Install *ServerInstall `json:"install"`
396-
// Tags array of customs tags
396+
// Tags array of customs tags attached to the server
397397
Tags []string `json:"tags"`
398-
// IPs array of IPs
398+
// IPs array of IPs attached to the server
399399
IPs []*IP `json:"ips"`
400-
// Domain the server domain
400+
// Domain domain of the server
401401
Domain string `json:"domain"`
402-
// BootType boot type
402+
// BootType boot type of the server
403403
//
404404
// Default value: normal
405405
BootType ServerBootType `json:"boot_type"`
406406
}
407407

408408
type ServerEvent struct {
409+
// ID iD of the server for whom the action will be applied
409410
ID string `json:"id"`
410-
411+
// Action the action that will be applied to the server
411412
Action string `json:"action"`
412-
413+
// UpdatedAt date of last modification of the action
413414
UpdatedAt time.Time `json:"updated_at"`
414-
415+
// CreatedAt date of creation of the action
415416
CreatedAt time.Time `json:"created_at"`
416417
}
417418

418419
type ServerInstall struct {
420+
// OsID iD of the OS
419421
OsID string `json:"os_id"`
420-
422+
// Hostname host defined in the server install
421423
Hostname string `json:"hostname"`
422-
424+
// SSHKeyIDs sSH public key IDs defined in the server install
423425
SSHKeyIDs []string `json:"ssh_key_ids"`
424-
// Status
426+
// Status status of the server install
425427
//
426428
// Default value: unknown
427429
Status ServerInstallStatus `json:"status"`
@@ -433,21 +435,23 @@ type ListServersRequest struct {
433435
Zone scw.Zone `json:"-"`
434436
// Page page number
435437
Page *int32 `json:"-"`
436-
// PageSize set the maximum list size
438+
// PageSize number of server per page
437439
PageSize *int32 `json:"-"`
438-
// OrderBy order the response
440+
// OrderBy order of the servers
439441
//
440442
// Default value: created_at_asc
441443
OrderBy ListServersRequestOrderBy `json:"-"`
442-
// Tags filter by tags
444+
// Tags filter servers by tags
443445
Tags []string `json:"-"`
444-
// Status filter by status
446+
// Status filter servers by status
445447
Status []string `json:"-"`
446-
// Name filter by name
448+
// Name filter servers by name
447449
Name *string `json:"-"`
448450
}
449451

450-
// ListServers list all your servers.
452+
// ListServers list servers
453+
//
454+
// List all created servers.
451455
func (s *API) ListServers(req *ListServersRequest, opts ...scw.RequestOption) (*ListServersResponse, error) {
452456
var err error
453457

@@ -510,11 +514,11 @@ func (r *ListServersResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkErro
510514

511515
type GetServerRequest struct {
512516
Zone scw.Zone `json:"-"`
513-
// ServerID iD of the searched server
517+
// ServerID iD of the server
514518
ServerID string `json:"-"`
515519
}
516520

517-
// GetServer get server details.
521+
// GetServer get server
518522
//
519523
// Get the server associated with the given ID.
520524
func (s *API) GetServer(req *GetServerRequest, opts ...scw.RequestOption) (*Server, error) {
@@ -550,21 +554,21 @@ func (s *API) GetServer(req *GetServerRequest, opts ...scw.RequestOption) (*Serv
550554

551555
type CreateServerRequest struct {
552556
Zone scw.Zone `json:"-"`
553-
// OfferID iD of the server offer to order
557+
// OfferID offer ID of the new server
554558
OfferID string `json:"offer_id"`
555-
// OrganizationID iD of organization to associate to the server
559+
// OrganizationID organization ID with which the server will be created
556560
OrganizationID string `json:"organization_id"`
557561
// Name name of the server (≠hostname)
558562
Name string `json:"name"`
559-
// Description some description to associate to the server, max 255 characters
563+
// Description description associated to the server, max 255 characters
560564
Description string `json:"description"`
561-
// Tags array of tags to associate to the server
565+
// Tags tags to associate to the server
562566
Tags []string `json:"tags"`
563567
}
564568

565-
// CreateServer create server.
569+
// CreateServer create server
566570
//
567-
// Create server associated with the offer.
571+
// Create a new server. Once the server is created, you probably want to install an OS.
568572
func (s *API) CreateServer(req *CreateServerRequest, opts ...scw.RequestOption) (*Server, error) {
569573
var err error
570574

@@ -608,13 +612,13 @@ type UpdateServerRequest struct {
608612
ServerID string `json:"-"`
609613
// Name name of the server (≠hostname), not updated if null
610614
Name *string `json:"name"`
611-
// Description some description to associate to the server, max 255 characters, not updated if null
615+
// Description description associated to the server, max 255 characters, not updated if null
612616
Description *string `json:"description"`
613-
// Tags array of tags to associate to the server, not updated if null
617+
// Tags tags associated to the server, not updated if null
614618
Tags *[]string `json:"tags"`
615619
}
616620

617-
// UpdateServer update an existing server.
621+
// UpdateServer update server
618622
//
619623
// Update the server associated with the given ID.
620624
func (s *API) UpdateServer(req *UpdateServerRequest, opts ...scw.RequestOption) (*Server, error) {
@@ -655,19 +659,19 @@ func (s *API) UpdateServer(req *UpdateServerRequest, opts ...scw.RequestOption)
655659

656660
type InstallServerRequest struct {
657661
Zone scw.Zone `json:"-"`
658-
// ServerID iD of the server to install
662+
// ServerID server ID to install
659663
ServerID string `json:"-"`
660-
// OsID iD of OS to the install on server
664+
// OsID iD of the OS to install on the server
661665
OsID string `json:"os_id"`
662666
// Hostname hostname of the server
663667
Hostname string `json:"hostname"`
664-
// SSHKeyIDs array of ssh key IDs authorized
668+
// SSHKeyIDs sSH key IDs authorized on the server
665669
SSHKeyIDs []string `json:"ssh_key_ids"`
666670
}
667671

668-
// InstallServer install your server.
672+
// InstallServer install server
669673
//
670-
// Install the server associated with the given ID.
674+
// Install an OS on the server associated with the given ID.
671675
func (s *API) InstallServer(req *InstallServerRequest, opts ...scw.RequestOption) (*Server, error) {
672676
var err error
673677

@@ -710,7 +714,7 @@ type DeleteServerRequest struct {
710714
ServerID string `json:"-"`
711715
}
712716

713-
// DeleteServer delete an existing server.
717+
// DeleteServer delete server
714718
//
715719
// Delete the server associated with the given ID.
716720
func (s *API) DeleteServer(req *DeleteServerRequest, opts ...scw.RequestOption) (*Server, error) {
@@ -754,7 +758,7 @@ type RebootServerRequest struct {
754758
BootType RebootServerRequestBootType `json:"boot_type"`
755759
}
756760

757-
// RebootServer reboot an existing server.
761+
// RebootServer reboot server
758762
//
759763
// Reboot the server associated with the given ID, use boot param to reboot in rescue.
760764
func (s *API) RebootServer(req *RebootServerRequest, opts ...scw.RequestOption) (*Server, error) {
@@ -799,7 +803,7 @@ type StartServerRequest struct {
799803
ServerID string `json:"-"`
800804
}
801805

802-
// StartServer start an existing server.
806+
// StartServer start server
803807
//
804808
// Start the server associated with the given ID.
805809
func (s *API) StartServer(req *StartServerRequest, opts ...scw.RequestOption) (*Server, error) {
@@ -839,7 +843,7 @@ type StopServerRequest struct {
839843
ServerID string `json:"-"`
840844
}
841845

842-
// StopServer stop an existing server.
846+
// StopServer stop server
843847
//
844848
// Stop the server associated with the given ID.
845849
func (s *API) StopServer(req *StopServerRequest, opts ...scw.RequestOption) (*Server, error) {
@@ -879,17 +883,17 @@ type ListServerEventsRequest struct {
879883
ServerID string `json:"-"`
880884
// Page page number
881885
Page *int32 `json:"-"`
882-
// PageSize set the maximum list size
886+
// PageSize number of server events per page
883887
PageSize *int32 `json:"-"`
884-
// OrderBy order the response
888+
// OrderBy order of the server events
885889
//
886890
// Default value: created_at_asc
887891
OrderBy ListServerEventsRequestOrderBy `json:"-"`
888892
}
889893

890-
// ListServerEvents list all events server.
894+
// ListServerEvents list server events
891895
//
892-
// List all events server associated with the given ID.
896+
// List events associated to the given server ID.
893897
func (s *API) ListServerEvents(req *ListServerEventsRequest, opts ...scw.RequestOption) (*ListServerEventsResponse, error) {
894898
var err error
895899

@@ -955,13 +959,15 @@ type CreateRemoteServerAccessRequest struct {
955959
Zone scw.Zone `json:"-"`
956960
// ServerID iD of the server
957961
ServerID string `json:"-"`
958-
// IP the IP which be authorized to connect on the server
962+
// IP the IP authorized to connect to the given server
959963
IP string `json:"ip"`
960964
}
961965

962-
// CreateRemoteServerAccess create remote server access.
966+
// CreateRemoteServerAccess create remote server access
963967
//
964968
// Create remote server access associated with the given ID.
969+
// The remote access is available one hour after the installation of the server.
970+
//
965971
func (s *API) CreateRemoteServerAccess(req *CreateRemoteServerAccessRequest, opts ...scw.RequestOption) (*RemoteServerAccess, error) {
966972
var err error
967973

@@ -1004,9 +1010,9 @@ type GetRemoteServerAccessRequest struct {
10041010
ServerID string `json:"-"`
10051011
}
10061012

1007-
// GetRemoteServerAccess get remote server access.
1013+
// GetRemoteServerAccess get remote server access
10081014
//
1009-
// Get remote server access associated with the given ID.
1015+
// Get the remote server access associated with the given ID.
10101016
func (s *API) GetRemoteServerAccess(req *GetRemoteServerAccessRequest, opts ...scw.RequestOption) (*RemoteServerAccess, error) {
10111017
var err error
10121018

@@ -1044,7 +1050,7 @@ type DeleteRemoteServerAccessRequest struct {
10441050
ServerID string `json:"-"`
10451051
}
10461052

1047-
// DeleteRemoteServerAccess delete remote server access.
1053+
// DeleteRemoteServerAccess delete remote server access
10481054
//
10491055
// Delete remote server access associated with the given ID.
10501056
func (s *API) DeleteRemoteServerAccess(req *DeleteRemoteServerAccessRequest, opts ...scw.RequestOption) error {
@@ -1080,15 +1086,15 @@ type UpdateIPRequest struct {
10801086
Zone scw.Zone `json:"-"`
10811087
// ServerID iD of the server
10821088
ServerID string `json:"-"`
1083-
// IPID iD of IP to update
1089+
// IPID iD of the IP to update
10841090
IPID string `json:"-"`
1085-
// Reverse new reverse to update
1091+
// Reverse new reverse IP to update, not updated if null
10861092
Reverse *string `json:"reverse"`
10871093
}
10881094

1089-
// UpdateIP update your IP.
1095+
// UpdateIP update IP
10901096
//
1091-
// Configure your ip associated with the given serverID and ipID, set your custom reverse.
1097+
// Configure ip associated with the given server ID and ipID. You can use this method to set a reverse dns for an IP.
10921098
func (s *API) UpdateIP(req *UpdateIPRequest, opts ...scw.RequestOption) (*IP, error) {
10931099
var err error
10941100

api/test/v1/test_sdk.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func (enum *ListHumansRequestOrderBy) UnmarshalJSON(data []byte) error {
171171
type Human struct {
172172
ID string `json:"id"`
173173

174-
ProjectID string `json:"project_id"`
174+
OrganizationID string `json:"organization_id"`
175175

176176
CreatedAt time.Time `json:"created_at"`
177177

@@ -263,13 +263,18 @@ type ListHumansRequest struct {
263263
// Default value: created_at_asc
264264
OrderBy ListHumansRequestOrderBy `json:"-"`
265265

266-
ProjectID *string `json:"-"`
266+
OrganizationID *string `json:"-"`
267267
}
268268

269269
// ListHumans list all your humans
270270
func (s *API) ListHumans(req *ListHumansRequest, opts ...scw.RequestOption) (*ListHumansResponse, error) {
271271
var err error
272272

273+
defaultOrganizationID, exist := s.client.GetDefaultOrganizationID()
274+
if (req.OrganizationID == nil || *req.OrganizationID == "") && exist {
275+
req.OrganizationID = &defaultOrganizationID
276+
}
277+
273278
if req.Region == "" {
274279
defaultRegion, _ := s.client.GetDefaultRegion()
275280
req.Region = defaultRegion
@@ -284,7 +289,7 @@ func (s *API) ListHumans(req *ListHumansRequest, opts ...scw.RequestOption) (*Li
284289
parameter.AddToQuery(query, "page", req.Page)
285290
parameter.AddToQuery(query, "page_size", req.PageSize)
286291
parameter.AddToQuery(query, "order_by", req.OrderBy)
287-
parameter.AddToQuery(query, "project_id", req.ProjectID)
292+
parameter.AddToQuery(query, "organization_id", req.OrganizationID)
288293

289294
if fmt.Sprint(req.Region) == "" {
290295
return nil, errors.New("field Region cannot be empty in request")
@@ -386,13 +391,18 @@ type CreateHumanRequest struct {
386391
// Default value: unknown
387392
EyesColor EyeColors `json:"eyes_color"`
388393

389-
ProjectID string `json:"project_id"`
394+
OrganizationID string `json:"organization_id"`
390395
}
391396

392397
// CreateHuman create a new human
393398
func (s *API) CreateHuman(req *CreateHumanRequest, opts ...scw.RequestOption) (*Human, error) {
394399
var err error
395400

401+
if req.OrganizationID == "" {
402+
defaultOrganizationID, _ := s.client.GetDefaultOrganizationID()
403+
req.OrganizationID = defaultOrganizationID
404+
}
405+
396406
if req.Region == "" {
397407
defaultRegion, _ := s.client.GetDefaultRegion()
398408
req.Region = defaultRegion

0 commit comments

Comments
 (0)