This commit is contained in:
stSolo
2022-12-22 17:56:47 +03:00
parent 8712561853
commit d4b1ab7133
672 changed files with 28509 additions and 4419 deletions

View File

@@ -6,24 +6,40 @@ import (
"net/http"
)
// Request struct for list the available flavors
type ListRequest struct {
// ID of the cloudspace
// Required: false
CloudspaceID uint64 `url:"cloudspaceId,omitempty"`
Location string `url:"location,omitempty"`
Page uint64 `url:"page,omitempty"`
Size uint64 `url:"size,omitempty"`
// Location code for the sizes
// Required: false
Location string `url:"location,omitempty"`
// Page number
// Required: false
Page uint64 `url:"page,omitempty"`
// Page size
// Required: false
Size uint64 `url:"size,omitempty"`
}
func (s Sizes) List(ctx context.Context, req ListRequest) (SizesList, error) {
// List gets list the available flavors, filtering can be based on the user which is doing the request
func (s Sizes) List(ctx context.Context, req ListRequest) (ListSizes, error) {
url := "/cloudapi/sizes/list"
sizesListRaw, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
sizesList := SizesList{}
if err := json.Unmarshal(sizesListRaw, &sizesList); err != nil {
list := ListSizes{}
err = json.Unmarshal(res, &list)
if err != nil {
return nil, err
}
return sizesList, nil
return list, nil
}

View File

@@ -1,12 +1,25 @@
package sizes
type Size struct {
Description string `json:"desc"`
Disks []uint64 `json:"disks"`
ID uint64 `json:"id"`
Memory uint64 `json:"memory"`
Name string `json:"name"`
VCPUs uint64 `json:"vcpus"`
// Main onformation about configured available flavors
type ItemSize struct {
// Description
Description string `json:"desc"`
// List of disk IDs
Disks []uint64 `json:"disks"`
// ID
ID uint64 `json:"id"`
// Memory
Memory uint64 `json:"memory"`
// Name
Name string `json:"name"`
// VCPUs
VCPUs uint64 `json:"vcpus"`
}
type SizesList []Size
// List of configured available flavors
type ListSizes []ItemSize

View File

@@ -1,13 +1,17 @@
// Lists all the configured flavors available.
// A flavor is a combination of amount of compute capacity(CU) and disk capacity(GB).
package sizes
import (
"github.com/rudecs/decort-sdk/interfaces"
)
// Structure for creatig request to sizes
type Sizes struct {
client interfaces.Caller
}
// Builder for sizes endpoints
func New(client interfaces.Caller) *Sizes {
return &Sizes{
client,