Skip to content
Merged
Show file tree
Hide file tree
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
130 changes: 68 additions & 62 deletions api/baremetal/v1alpha1/baremetal_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,80 +348,82 @@ type IP struct {
}

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

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

type RemoteServerAccess struct {
// URL url to access on the server
// URL uRL to access to the server console
URL string `json:"url"`
// Login login for the authentification
// Login the login to use for the remote access authentification
Login string `json:"login"`
// Password password for the authentification
// Password the password to use for the remote access authentification
Password string `json:"password"`
// ExpiresAt after this date, the remote access will be closed
// ExpiresAt the date after which the remote access will be closed
ExpiresAt time.Time `json:"expires_at"`
}

type Server struct {
// ID iD of the server
ID string `json:"id"`
// OrganizationID organization ID linked with the server
// OrganizationID organization ID the server is attached to
OrganizationID string `json:"organization_id"`
// Name name of the server
Name string `json:"name"`
// Description description of the server
Description string `json:"description"`
// UpdatedAt date of last update of the server
// UpdatedAt date of last modification of the server
UpdatedAt time.Time `json:"updated_at"`
// CreatedAt creation date of the server
// CreatedAt date of creation of the server
CreatedAt time.Time `json:"created_at"`
// Status status of the server
//
// Default value: unknown
Status ServerStatus `json:"status"`
// OfferID offer reference of the server
// OfferID offer ID of the server
OfferID string `json:"offer_id"`
// Install object to describe the specifications of installation
// Install information about the last installation of the server
Install *ServerInstall `json:"install"`
// Tags array of customs tags
// Tags array of customs tags attached to the server
Tags []string `json:"tags"`
// IPs array of IPs
// IPs array of IPs attached to the server
IPs []*IP `json:"ips"`
// Domain the server domain
// Domain domain of the server
Domain string `json:"domain"`
// BootType boot type
// BootType boot type of the server
//
// Default value: normal
BootType ServerBootType `json:"boot_type"`
}

type ServerEvent struct {
// ID iD of the server for whom the action will be applied
ID string `json:"id"`

// Action the action that will be applied to the server
Action string `json:"action"`

// UpdatedAt date of last modification of the action
UpdatedAt time.Time `json:"updated_at"`

// CreatedAt date of creation of the action
CreatedAt time.Time `json:"created_at"`
}

type ServerInstall struct {
// OsID iD of the OS
OsID string `json:"os_id"`

// Hostname host defined in the server install
Hostname string `json:"hostname"`

// SSHKeyIDs sSH public key IDs defined in the server install
SSHKeyIDs []string `json:"ssh_key_ids"`
// Status
// Status status of the server install
//
// Default value: unknown
Status ServerInstallStatus `json:"status"`
Expand All @@ -433,21 +435,23 @@ type ListServersRequest struct {
Zone scw.Zone `json:"-"`
// Page page number
Page *int32 `json:"-"`
// PageSize set the maximum list size
// PageSize number of server per page
PageSize *int32 `json:"-"`
// OrderBy order the response
// OrderBy order of the servers
//
// Default value: created_at_asc
OrderBy ListServersRequestOrderBy `json:"-"`
// Tags filter by tags
// Tags filter servers by tags
Tags []string `json:"-"`
// Status filter by status
// Status filter servers by status
Status []string `json:"-"`
// Name filter by name
// Name filter servers by name
Name *string `json:"-"`
}

// ListServers list all your servers.
// ListServers list servers
//
// List all created servers.
func (s *API) ListServers(req *ListServersRequest, opts ...scw.RequestOption) (*ListServersResponse, error) {
var err error

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

type GetServerRequest struct {
Zone scw.Zone `json:"-"`
// ServerID iD of the searched server
// ServerID iD of the server
ServerID string `json:"-"`
}

// GetServer get server details.
// GetServer get server
//
// Get the server associated with the given ID.
func (s *API) GetServer(req *GetServerRequest, opts ...scw.RequestOption) (*Server, error) {
Expand Down Expand Up @@ -550,21 +554,21 @@ func (s *API) GetServer(req *GetServerRequest, opts ...scw.RequestOption) (*Serv

type CreateServerRequest struct {
Zone scw.Zone `json:"-"`
// OfferID iD of the server offer to order
// OfferID offer ID of the new server
OfferID string `json:"offer_id"`
// OrganizationID iD of organization to associate to the server
// OrganizationID organization ID with which the server will be created
OrganizationID string `json:"organization_id"`
// Name name of the server (≠hostname)
Name string `json:"name"`
// Description some description to associate to the server, max 255 characters
// Description description associated to the server, max 255 characters
Description string `json:"description"`
// Tags array of tags to associate to the server
// Tags tags to associate to the server
Tags []string `json:"tags"`
}

// CreateServer create server.
// CreateServer create server
//
// Create server associated with the offer.
// Create a new server. Once the server is created, you probably want to install an OS.
func (s *API) CreateServer(req *CreateServerRequest, opts ...scw.RequestOption) (*Server, error) {
var err error

Expand Down Expand Up @@ -608,13 +612,13 @@ type UpdateServerRequest struct {
ServerID string `json:"-"`
// Name name of the server (≠hostname), not updated if null
Name *string `json:"name"`
// Description some description to associate to the server, max 255 characters, not updated if null
// Description description associated to the server, max 255 characters, not updated if null
Description *string `json:"description"`
// Tags array of tags to associate to the server, not updated if null
// Tags tags associated to the server, not updated if null
Tags *[]string `json:"tags"`
}

// UpdateServer update an existing server.
// UpdateServer update server
//
// Update the server associated with the given ID.
func (s *API) UpdateServer(req *UpdateServerRequest, opts ...scw.RequestOption) (*Server, error) {
Expand Down Expand Up @@ -655,19 +659,19 @@ func (s *API) UpdateServer(req *UpdateServerRequest, opts ...scw.RequestOption)

type InstallServerRequest struct {
Zone scw.Zone `json:"-"`
// ServerID iD of the server to install
// ServerID server ID to install
ServerID string `json:"-"`
// OsID iD of OS to the install on server
// OsID iD of the OS to install on the server
OsID string `json:"os_id"`
// Hostname hostname of the server
Hostname string `json:"hostname"`
// SSHKeyIDs array of ssh key IDs authorized
// SSHKeyIDs sSH key IDs authorized on the server
SSHKeyIDs []string `json:"ssh_key_ids"`
}

// InstallServer install your server.
// InstallServer install server
//
// Install the server associated with the given ID.
// Install an OS on the server associated with the given ID.
func (s *API) InstallServer(req *InstallServerRequest, opts ...scw.RequestOption) (*Server, error) {
var err error

Expand Down Expand Up @@ -710,7 +714,7 @@ type DeleteServerRequest struct {
ServerID string `json:"-"`
}

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

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

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

// StopServer stop an existing server.
// StopServer stop server
//
// Stop the server associated with the given ID.
func (s *API) StopServer(req *StopServerRequest, opts ...scw.RequestOption) (*Server, error) {
Expand Down Expand Up @@ -879,17 +883,17 @@ type ListServerEventsRequest struct {
ServerID string `json:"-"`
// Page page number
Page *int32 `json:"-"`
// PageSize set the maximum list size
// PageSize number of server events per page
PageSize *int32 `json:"-"`
// OrderBy order the response
// OrderBy order of the server events
//
// Default value: created_at_asc
OrderBy ListServerEventsRequestOrderBy `json:"-"`
}

// ListServerEvents list all events server.
// ListServerEvents list server events
//
// List all events server associated with the given ID.
// List events associated to the given server ID.
func (s *API) ListServerEvents(req *ListServerEventsRequest, opts ...scw.RequestOption) (*ListServerEventsResponse, error) {
var err error

Expand Down Expand Up @@ -955,13 +959,15 @@ type CreateRemoteServerAccessRequest struct {
Zone scw.Zone `json:"-"`
// ServerID iD of the server
ServerID string `json:"-"`
// IP the IP which be authorized to connect on the server
// IP the IP authorized to connect to the given server
IP string `json:"ip"`
}

// CreateRemoteServerAccess create remote server access.
// CreateRemoteServerAccess create remote server access
//
// Create remote server access associated with the given ID.
// The remote access is available one hour after the installation of the server.
//
func (s *API) CreateRemoteServerAccess(req *CreateRemoteServerAccessRequest, opts ...scw.RequestOption) (*RemoteServerAccess, error) {
var err error

Expand Down Expand Up @@ -1004,9 +1010,9 @@ type GetRemoteServerAccessRequest struct {
ServerID string `json:"-"`
}

// GetRemoteServerAccess get remote server access.
// GetRemoteServerAccess get remote server access
//
// Get remote server access associated with the given ID.
// Get the remote server access associated with the given ID.
func (s *API) GetRemoteServerAccess(req *GetRemoteServerAccessRequest, opts ...scw.RequestOption) (*RemoteServerAccess, error) {
var err error

Expand Down Expand Up @@ -1044,7 +1050,7 @@ type DeleteRemoteServerAccessRequest struct {
ServerID string `json:"-"`
}

// DeleteRemoteServerAccess delete remote server access.
// DeleteRemoteServerAccess delete remote server access
//
// Delete remote server access associated with the given ID.
func (s *API) DeleteRemoteServerAccess(req *DeleteRemoteServerAccessRequest, opts ...scw.RequestOption) error {
Expand Down Expand Up @@ -1080,15 +1086,15 @@ type UpdateIPRequest struct {
Zone scw.Zone `json:"-"`
// ServerID iD of the server
ServerID string `json:"-"`
// IPID iD of IP to update
// IPID iD of the IP to update
IPID string `json:"-"`
// Reverse new reverse to update
// Reverse new reverse IP to update, not updated if null
Reverse *string `json:"reverse"`
}

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

Expand Down
18 changes: 14 additions & 4 deletions api/test/v1/test_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (enum *ListHumansRequestOrderBy) UnmarshalJSON(data []byte) error {
type Human struct {
ID string `json:"id"`

ProjectID string `json:"project_id"`
OrganizationID string `json:"organization_id"`

CreatedAt time.Time `json:"created_at"`

Expand Down Expand Up @@ -263,13 +263,18 @@ type ListHumansRequest struct {
// Default value: created_at_asc
OrderBy ListHumansRequestOrderBy `json:"-"`

ProjectID *string `json:"-"`
OrganizationID *string `json:"-"`
}

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

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

if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
Expand All @@ -284,7 +289,7 @@ func (s *API) ListHumans(req *ListHumansRequest, opts ...scw.RequestOption) (*Li
parameter.AddToQuery(query, "page", req.Page)
parameter.AddToQuery(query, "page_size", req.PageSize)
parameter.AddToQuery(query, "order_by", req.OrderBy)
parameter.AddToQuery(query, "project_id", req.ProjectID)
parameter.AddToQuery(query, "organization_id", req.OrganizationID)

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

ProjectID string `json:"project_id"`
OrganizationID string `json:"organization_id"`
}

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

if req.OrganizationID == "" {
defaultOrganizationID, _ := s.client.GetDefaultOrganizationID()
req.OrganizationID = defaultOrganizationID
}

if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
Expand Down
Loading