Merge 'dev' into 'main'
This commit is contained in:
@@ -4,18 +4,20 @@ linters:
|
|||||||
- decorder
|
- decorder
|
||||||
- dogsled
|
- dogsled
|
||||||
- errorlint
|
- errorlint
|
||||||
|
- exhaustive
|
||||||
- exportloopref
|
- exportloopref
|
||||||
- gocognit
|
- exhaustive
|
||||||
|
#- gocognit
|
||||||
- goconst
|
- goconst
|
||||||
- gocyclo
|
#- gocyclo
|
||||||
- gosec
|
- gosec
|
||||||
- ifshort
|
|
||||||
- makezero
|
- makezero
|
||||||
- nestif
|
#- nestif
|
||||||
- nilerr
|
- nilerr
|
||||||
- prealloc
|
- prealloc
|
||||||
- unconvert
|
- unconvert
|
||||||
- unparam
|
- unparam
|
||||||
|
- noctx
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
max-same-issues: 0
|
max-same-issues: 0
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
package decortsdk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/rudecs/decort-sdk/pkg/cloudapi/account"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (dc *Client) Account() *account.Account {
|
|
||||||
return account.New(dc)
|
|
||||||
}
|
|
||||||
17
client.go
17
client.go
@@ -7,13 +7,16 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/rudecs/decort-sdk/pkg/cloudapi"
|
||||||
|
"github.com/rudecs/decort-sdk/pkg/cloudbroker"
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
"github.com/rudecs/decort-sdk/config"
|
"github.com/rudecs/decort-sdk/config"
|
||||||
"github.com/rudecs/decort-sdk/internal/client"
|
"github.com/rudecs/decort-sdk/internal/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
decortUrl string
|
decortURL string
|
||||||
client *http.Client
|
client *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,11 +26,19 @@ func New(cfg config.Config) *Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &Client{
|
return &Client{
|
||||||
decortUrl: cfg.DecortURL,
|
decortURL: cfg.DecortURL,
|
||||||
client: client.NewHttpClient(cfg),
|
client: client.NewHttpClient(cfg),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dc *Client) CloudApi() *cloudapi.CloudApi {
|
||||||
|
return cloudapi.New(dc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dc *Client) CloudBroker() *cloudbroker.CloudBroker {
|
||||||
|
return cloudbroker.New(dc)
|
||||||
|
}
|
||||||
|
|
||||||
func (dc *Client) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) {
|
func (dc *Client) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) {
|
||||||
values, err := query.Values(params)
|
values, err := query.Values(params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -35,7 +46,7 @@ func (dc *Client) DecortApiCall(ctx context.Context, method, url string, params
|
|||||||
}
|
}
|
||||||
|
|
||||||
body := strings.NewReader(values.Encode())
|
body := strings.NewReader(values.Encode())
|
||||||
req, err := http.NewRequestWithContext(ctx, method, dc.decortUrl+"/restmachine"+url, body)
|
req, err := http.NewRequestWithContext(ctx, method, dc.decortURL+"/restmachine"+url, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
package decortsdk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/rudecs/decort-sdk/pkg/cloudapi/compute"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (dc *Client) Compute() *compute.Compute {
|
|
||||||
return compute.New(dc)
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package decortsdk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/rudecs/decort-sdk/pkg/cloudapi/computeci"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (dc *Client) ComputeCI() *computeci.ComputeCI {
|
|
||||||
return computeci.New(dc)
|
|
||||||
}
|
|
||||||
9
disks.go
9
disks.go
@@ -1,9 +0,0 @@
|
|||||||
package decortsdk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/rudecs/decort-sdk/pkg/cloudapi/disks"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (dc *Client) Disks() *disks.Disks {
|
|
||||||
return disks.New(dc)
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package decortsdk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/rudecs/decort-sdk/pkg/cloudapi/extnet"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (dc *Client) Extnet() *extnet.Extnet {
|
|
||||||
return extnet.New(dc)
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package decortsdk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/rudecs/decort-sdk/pkg/cloudapi/flipgroup"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (dc *Client) FlipGroup() *flipgroup.FlipGroup {
|
|
||||||
return flipgroup.New(dc)
|
|
||||||
}
|
|
||||||
9
image.go
9
image.go
@@ -1,9 +0,0 @@
|
|||||||
package decortsdk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/rudecs/decort-sdk/pkg/cloudapi/image"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (dc *Client) Image() *image.Image {
|
|
||||||
return image.New(dc)
|
|
||||||
}
|
|
||||||
@@ -10,15 +10,20 @@ import (
|
|||||||
|
|
||||||
func NewHttpClient(cfg config.Config) *http.Client {
|
func NewHttpClient(cfg config.Config) *http.Client {
|
||||||
|
|
||||||
transCfg := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: cfg.SSLSkipVerify}}
|
transCfg := &http.Transport{
|
||||||
|
TLSClientConfig: &tls.Config{
|
||||||
|
//nolint:gosec
|
||||||
|
InsecureSkipVerify: cfg.SSLSkipVerify,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
return &http.Client{
|
return &http.Client{
|
||||||
Transport: &transport{
|
Transport: &transport{
|
||||||
base: transCfg,
|
base: transCfg,
|
||||||
retries: cfg.Retries,
|
retries: cfg.Retries,
|
||||||
clientId: cfg.AppID,
|
clientID: cfg.AppID,
|
||||||
clientSecret: cfg.AppSecret,
|
clientSecret: cfg.AppSecret,
|
||||||
ssoUrl: cfg.SSOURL,
|
SSOURL: cfg.SSOURL,
|
||||||
//TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
//TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -11,24 +11,24 @@ import (
|
|||||||
type transport struct {
|
type transport struct {
|
||||||
base http.RoundTripper
|
base http.RoundTripper
|
||||||
retries uint64
|
retries uint64
|
||||||
clientId string
|
clientID string
|
||||||
clientSecret string
|
clientSecret string
|
||||||
token string
|
token string
|
||||||
ssoUrl string
|
SSOURL string
|
||||||
expiryTime time.Time
|
expiryTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
if t.token == "" || time.Now().After(t.expiryTime) {
|
if t.token == "" || time.Now().After(t.expiryTime) {
|
||||||
body := fmt.Sprintf("grant_type=client_credentials&client_id=%s&client_secret=%s&response_type=id_token", t.clientId, t.clientSecret)
|
body := fmt.Sprintf("grant_type=client_credentials&client_id=%s&client_secret=%s&response_type=id_token", t.clientID, t.clientSecret)
|
||||||
bodyReader := strings.NewReader(body)
|
bodyReader := strings.NewReader(body)
|
||||||
|
|
||||||
req, _ := http.NewRequest("POST", t.ssoUrl+"/v1/oauth/access_token", bodyReader)
|
req, _ := http.NewRequestWithContext(req.Context(), "POST", t.SSOURL+"/v1/oauth/access_token", bodyReader)
|
||||||
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
|
||||||
resp, err := t.base.RoundTrip(req)
|
resp, err := t.base.RoundTrip(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot get token: %v", err)
|
return nil, fmt.Errorf("cannot get token: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenBytes, _ := io.ReadAll(resp.Body)
|
tokenBytes, _ := io.ReadAll(resp.Body)
|
||||||
@@ -63,5 +63,5 @@ func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||||||
//logrus.Errorf("Could not execute request: %v. Retrying %d/%d", err, i+1, t.retries)
|
//logrus.Errorf("Could not execute request: %v. Retrying %d/%d", err, i+1, t.retries)
|
||||||
time.Sleep(time.Second * 5)
|
time.Sleep(time.Second * 5)
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("could not execute request: %v", err)
|
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
9
k8ci.go
9
k8ci.go
@@ -1,9 +0,0 @@
|
|||||||
package decortsdk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/rudecs/decort-sdk/pkg/cloudapi/k8ci"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (dc *Client) K8CI() *k8ci.K8CI {
|
|
||||||
return k8ci.New(dc)
|
|
||||||
}
|
|
||||||
9
k8s.go
9
k8s.go
@@ -1,9 +0,0 @@
|
|||||||
package decortsdk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/rudecs/decort-sdk/pkg/cloudapi/k8s"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (dc *Client) K8S() *k8s.K8S {
|
|
||||||
return k8s.New(dc)
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package decortsdk
|
|
||||||
|
|
||||||
import "github.com/rudecs/decort-sdk/pkg/cloudapi/kvmppc"
|
|
||||||
|
|
||||||
func (dc *Client) KVMPPC() *kvmppc.KVMPPC {
|
|
||||||
return kvmppc.New(dc)
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package decortsdk
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/rudecs/decort-sdk/pkg/cloudapi/kvmx86"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (dc *Client) KVMX86() *kvmx86.KVMX86 {
|
|
||||||
return kvmx86.New(dc)
|
|
||||||
}
|
|
||||||
7
lb.go
7
lb.go
@@ -1,7 +0,0 @@
|
|||||||
package decortsdk
|
|
||||||
|
|
||||||
import "github.com/rudecs/decort-sdk/pkg/cloudapi/lb"
|
|
||||||
|
|
||||||
func (dc *Client) LB() *lb.LB {
|
|
||||||
return lb.New(dc)
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package decortsdk
|
|
||||||
|
|
||||||
import "github.com/rudecs/decort-sdk/pkg/cloudapi/locations"
|
|
||||||
|
|
||||||
func (dc *Client) Locations() *locations.Locations {
|
|
||||||
return locations.New(dc)
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package opts
|
|
||||||
|
|
||||||
type DecortOpts struct {
|
|
||||||
Type string
|
|
||||||
Value string
|
|
||||||
}
|
|
||||||
26
opts/opts.go
26
opts/opts.go
@@ -1,26 +0,0 @@
|
|||||||
package opts
|
|
||||||
|
|
||||||
import "github.com/rudecs/decort-sdk/typed"
|
|
||||||
|
|
||||||
type Opts struct {
|
|
||||||
IsAdmin bool
|
|
||||||
AdminValue string
|
|
||||||
}
|
|
||||||
|
|
||||||
func New(options []DecortOpts) *Opts {
|
|
||||||
if len(options) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
option := &Opts{}
|
|
||||||
|
|
||||||
for _, v := range options {
|
|
||||||
if v.Type == typed.TypeAdmin {
|
|
||||||
option.IsAdmin = true
|
|
||||||
option.AdminValue = v.Value
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return option
|
|
||||||
}
|
|
||||||
9
pkg/cloudapi/account.go
Normal file
9
pkg/cloudapi/account.go
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package cloudapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/rudecs/decort-sdk/pkg/cloudapi/account"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (ca *CloudApi) Account() *account.Account {
|
||||||
|
return account.New(ca.client)
|
||||||
|
}
|
||||||
@@ -3,26 +3,25 @@ package account
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/internal/validators"
|
"github.com/rudecs/decort-sdk/internal/validators"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AddUserRequest struct {
|
type AddUserRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
UserId string `url:"userId"`
|
UserID string `url:"userId"`
|
||||||
AccessType string `url:"accesstype"`
|
AccessType string `url:"accesstype"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq AddUserRequest) Validate() error {
|
func (arq AddUserRequest) Validate() error {
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if arq.UserId == "" {
|
if arq.UserID == "" {
|
||||||
return errors.New("validation-error: field UserId can not be empty")
|
return errors.New("validation-error: field UserID can not be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
if arq.AccessType == "" {
|
if arq.AccessType == "" {
|
||||||
@@ -37,24 +36,15 @@ func (arq AddUserRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) AddUser(ctx context.Context, req AddUserRequest, options ...opts.DecortOpts) (bool, error) {
|
func (a Account) AddUser(ctx context.Context, req AddUserRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/addUser"
|
url := "/cloudapi/account/addUser"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,48 +4,37 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuditsRequest struct {
|
type AuditsRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq AuditsRequest) Validate() error {
|
func (arq AuditsRequest) Validate() error {
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) Audits(ctx context.Context, req AuditsRequest, options ...opts.DecortOpts) (AccountAuditsList, error) {
|
func (a Account) Audits(ctx context.Context, req AuditsRequest) (AccountAuditsList, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/audits"
|
url := "/cloudapi/account/audits"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
auditsRaw, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
auditsRaw, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
audits := AccountAuditsList{}
|
audits := AccountAuditsList{}
|
||||||
|
|
||||||
err = json.Unmarshal([]byte(auditsRaw), &audits)
|
err = json.Unmarshal(auditsRaw, &audits)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,21 @@ package account
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateRequest struct {
|
type CreateRequest struct {
|
||||||
Name string `url:"name"`
|
Name string `url:"name"`
|
||||||
Username string `url:"username"`
|
Username string `url:"username"`
|
||||||
EmailAddress string `url:"emailaddress,omitempty"`
|
EmailAddress string `url:"emailaddress,omitempty"`
|
||||||
MaxMemoryCapacity uint `url:"maxMemoryCapacity,omitempty"`
|
MaxMemoryCapacity uint64 `url:"maxMemoryCapacity,omitempty"`
|
||||||
MaxVDiskCapacity uint `url:"maxVDiskCapacity,omitempty"`
|
MaxVDiskCapacity uint64 `url:"maxVDiskCapacity,omitempty"`
|
||||||
MaxCPUCapacity uint `url:"maxCPUCapacity,omitempty"`
|
MaxCPUCapacity uint64 `url:"maxCPUCapacity,omitempty"`
|
||||||
MaxNetworkPeerTransfer uint `url:"maxNetworkPeerTransfer,omitempty"`
|
MaxNetworkPeerTransfer uint64 `url:"maxNetworkPeerTransfer,omitempty"`
|
||||||
MaxNumPublicIP uint `url:"maxNumPublicIP,omitempty"`
|
MaxNumPublicIP uint64 `url:"maxNumPublicIP,omitempty"`
|
||||||
SendAccessEmails bool `url:"sendAccessEmails,omitempty"`
|
SendAccessEmails bool `url:"sendAccessEmails,omitempty"`
|
||||||
GpuUnits uint `url:"gpu_units,omitempty"`
|
GPUUnits uint64 `url:"gpu_units,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq CreateRequest) Validate() error {
|
func (arq CreateRequest) Validate() error {
|
||||||
@@ -34,24 +32,15 @@ func (arq CreateRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) Create(ctx context.Context, req CreateRequest, options ...opts.DecortOpts) (uint64, error) {
|
func (a Account) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/create"
|
url := "/cloudbroker/account/create"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,50 +3,34 @@ package account
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"strconv"
|
"net/http"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DeleteRequest struct {
|
type DeleteRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
Permanently bool `url:"permanently,omitempty"`
|
Permanently bool `url:"permanently,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq DeleteRequest) Validate() error {
|
func (arq DeleteRequest) Validate() error {
|
||||||
|
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId must be set")
|
return errors.New("validation-error: field AccountID must be set")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) Delete(ctx context.Context, req DeleteRequest, options ...opts.DecortOpts) (bool, error) {
|
func (a Account) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/delete"
|
url := "/cloudapi/account/delete"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
_, err = a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
return true, nil
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,48 +3,37 @@ package account
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DeleteUserRequest struct {
|
type DeleteUserRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
UserId string `url:"userId"`
|
UserID string `url:"userId"`
|
||||||
RecursiveDelete bool `url:"recursivedelete,omitempty"`
|
RecursiveDelete bool `url:"recursivedelete,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq DeleteUserRequest) Validate() error {
|
func (arq DeleteUserRequest) Validate() error {
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if arq.UserId == "" {
|
if arq.UserID == "" {
|
||||||
return errors.New("validation-error: field UserId can not be empty")
|
return errors.New("validation-error: field UserID can not be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) DeleteUser(ctx context.Context, req DeleteUserRequest, options ...opts.DecortOpts) (bool, error) {
|
func (a Account) DeleteUser(ctx context.Context, req DeleteUserRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/deleteUser"
|
url := "/cloudapi/account/deleteUser"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,41 +3,31 @@ package account
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DisabelEnableRequest struct {
|
type DisabelEnableRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq DisabelEnableRequest) Validate() error {
|
func (arq DisabelEnableRequest) Validate() error {
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) Disable(ctx context.Context, req DisabelEnableRequest, options ...opts.DecortOpts) (bool, error) {
|
func (a Account) Disable(ctx context.Context, req DisabelEnableRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/disable"
|
url := "/cloudapi/account/disable"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -50,23 +40,15 @@ func (a Account) Disable(ctx context.Context, req DisabelEnableRequest, options
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) Enable(ctx context.Context, req DisabelEnableRequest, options ...opts.DecortOpts) (bool, error) {
|
func (a Account) Enable(ctx context.Context, req DisabelEnableRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/enable"
|
url := "/cloudapi/account/enable"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,41 +4,30 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq GetRequest) Validate() error {
|
func (arq GetRequest) Validate() error {
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) Get(ctx context.Context, req GetRequest, options ...opts.DecortOpts) (*AccountWithResources, error) {
|
func (a Account) Get(ctx context.Context, req GetRequest) (*AccountWithResources, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/get"
|
url := "/cloudapi/account/get"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,41 +4,30 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetConsumedAccountUnitsRequest struct {
|
type GetConsumedAccountUnitsRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq GetConsumedAccountUnitsRequest) Validate() error {
|
func (arq GetConsumedAccountUnitsRequest) Validate() error {
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) GetConsumedAccountUnits(ctx context.Context, req GetConsumedAccountUnitsRequest, options ...opts.DecortOpts) (*ResourceLimits, error) {
|
func (a Account) GetConsumedAccountUnits(ctx context.Context, req GetConsumedAccountUnitsRequest) (*ResourceLimits, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/getConsumedAccountUnits"
|
url := "/cloudapi/account/getConsumedAccountUnits"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,20 @@ package account
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/internal/validators"
|
"github.com/rudecs/decort-sdk/internal/validators"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetConsumedCloudUnitsByTypeRequest struct {
|
type GetConsumedCloudUnitsByTypeRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
CUType string `url:"cutype"`
|
CUType string `url:"cutype"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq GetConsumedCloudUnitsByTypeRequest) Validate() error {
|
func (arq GetConsumedCloudUnitsByTypeRequest) Validate() error {
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if arq.CUType == "" {
|
if arq.CUType == "" {
|
||||||
@@ -32,24 +31,15 @@ func (arq GetConsumedCloudUnitsByTypeRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) GetConsumedCloudUnitsByType(ctx context.Context, req GetConsumedCloudUnitsByTypeRequest, options ...opts.DecortOpts) (float64, error) {
|
func (a Account) GetConsumedCloudUnitsByType(ctx context.Context, req GetConsumedCloudUnitsByTypeRequest) (float64, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/getConsumedCloudUnitsByType"
|
url := "/cloudapi/account/getConsumedCloudUnitsByType"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,20 +3,18 @@ package account
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetConsumtionRequest struct {
|
type GetConsumtionRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
Start uint64 `url:"start"`
|
Start uint64 `url:"start"`
|
||||||
End uint64 `url:"end"`
|
End uint64 `url:"end"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq GetConsumtionRequest) Validate() error {
|
func (arq GetConsumtionRequest) Validate() error {
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if arq.Start == 0 {
|
if arq.Start == 0 {
|
||||||
@@ -30,24 +28,15 @@ func (arq GetConsumtionRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) GetConsumtion(ctx context.Context, req GetConsumtionRequest, options ...opts.DecortOpts) (string, error) {
|
func (a Account) GetConsumtion(ctx context.Context, req GetConsumtionRequest) (string, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/getConsumtion"
|
url := "/cloudapi/account/getConsumtion"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@@ -56,7 +45,7 @@ func (a Account) GetConsumtion(ctx context.Context, req GetConsumtionRequest, op
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) GetConsumtionGet(ctx context.Context, req GetConsumtionRequest, options ...opts.DecortOpts) (string, error) {
|
func (a Account) GetConsumtionGet(ctx context.Context, req GetConsumtionRequest) (string, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@@ -65,15 +54,8 @@ func (a Account) GetConsumtionGet(ctx context.Context, req GetConsumtionRequest,
|
|||||||
url := "/account/getConsumtion"
|
url := "/account/getConsumtion"
|
||||||
prefix := "/cloudapi"
|
prefix := "/cloudapi"
|
||||||
|
|
||||||
option := opts.New(options)
|
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
url = prefix + url
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.GET, url, req)
|
res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,41 +4,30 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetReservedAccountUnitsRequest struct {
|
type GetReservedAccountUnitsRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq GetReservedAccountUnitsRequest) Validate() error {
|
func (arq GetReservedAccountUnitsRequest) Validate() error {
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) GetReservedAccountUnits(ctx context.Context, req GetReservedAccountUnitsRequest, options ...opts.DecortOpts) (*ResourceLimits, error) {
|
func (a Account) GetReservedAccountUnits(ctx context.Context, req GetReservedAccountUnitsRequest) (*ResourceLimits, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/getReservedAccountUnits"
|
url := "/cloudapi/account/getReservedAccountUnits"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ package account
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
@@ -13,19 +11,10 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size"`
|
Size uint64 `url:"size"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) List(ctx context.Context, req ListRequest, options ...opts.DecortOpts) (AccountCloudApiList, error) {
|
func (a Account) List(ctx context.Context, req ListRequest) (AccountCloudApiList, error) {
|
||||||
url := "/account/list"
|
url := "/cloudapi/account/list"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,41 +4,30 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ListComputesRequest struct {
|
type ListComputesRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq ListComputesRequest) Validate() error {
|
func (arq ListComputesRequest) Validate() error {
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) ListComputes(ctx context.Context, req ListComputesRequest, options ...opts.DecortOpts) (AccountComputesList, error) {
|
func (a Account) ListComputes(ctx context.Context, req ListComputesRequest) (AccountComputesList, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/listComputes"
|
url := "/cloudapi/account/listComputes"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ package account
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ListDeletedRequest struct {
|
type ListDeletedRequest struct {
|
||||||
@@ -13,19 +11,10 @@ type ListDeletedRequest struct {
|
|||||||
Size uint64 `url:"size"`
|
Size uint64 `url:"size"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) ListDeleted(ctx context.Context, req ListDeletedRequest, options ...opts.DecortOpts) (AccountCloudApiList, error) {
|
func (a Account) ListDeleted(ctx context.Context, req ListDeletedRequest) (AccountCloudApiList, error) {
|
||||||
url := "/account/listDeleted"
|
url := "/cloudapi/account/listDeleted"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,41 +4,30 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ListDisksRequest struct {
|
type ListDisksRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq ListDisksRequest) Validate() error {
|
func (arq ListDisksRequest) Validate() error {
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) ListDisks(ctx context.Context, req ListDisksRequest, options ...opts.DecortOpts) (AccountDisksList, error) {
|
func (a Account) ListDisks(ctx context.Context, req ListDisksRequest) (AccountDisksList, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/listDisks"
|
url := "/cloudapi/account/listDisks"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,41 +4,30 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ListFlipGroupsRequest struct {
|
type ListFlipGroupsRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq ListFlipGroupsRequest) Validate() error {
|
func (arq ListFlipGroupsRequest) Validate() error {
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) ListFlipGroups(ctx context.Context, req ListFlipGroupsRequest, options ...opts.DecortOpts) (AccountFlipGroupsList, error) {
|
func (a Account) ListFlipGroups(ctx context.Context, req ListFlipGroupsRequest) (AccountFlipGroupsList, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/listFlipGroups"
|
url := "/cloudapi/account/listFlipGroups"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,41 +4,30 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ListRGRequest struct {
|
type ListRGRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq ListRGRequest) Validate() error {
|
func (arq ListRGRequest) Validate() error {
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) ListRG(ctx context.Context, req ListRGRequest, options ...opts.DecortOpts) (AccountRGList, error) {
|
func (a Account) ListRG(ctx context.Context, req ListRGRequest) (AccountRGList, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/listRG"
|
url := "/cloudapi/account/listRG"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,42 +4,31 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ListTemplatesRequest struct {
|
type ListTemplatesRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
IncludeDeleted bool `url:"includedeleted"`
|
IncludeDeleted bool `url:"includedeleted"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq ListTemplatesRequest) Validate() error {
|
func (arq ListTemplatesRequest) Validate() error {
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) ListTemplates(ctx context.Context, req ListTemplatesRequest, options ...opts.DecortOpts) (AccountTemplatesList, error) {
|
func (a Account) ListTemplates(ctx context.Context, req ListTemplatesRequest) (AccountTemplatesList, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/listTemplates"
|
url := "/cloudapi/account/listTemplates"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,52 +4,41 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ListVinsRequest struct {
|
type ListVINSRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq ListVinsRequest) Validate() error {
|
func (arq ListVINSRequest) Validate() error {
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) ListVins(ctx context.Context, req ListVinsRequest, options ...opts.DecortOpts) (AccountVinsList, error) {
|
func (a Account) ListVINS(ctx context.Context, req ListVINSRequest) (AccountVINSList, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/listVins"
|
url := "/cloudapi/account/listVins"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
accountVinsList := AccountVinsList{}
|
accountVINSList := AccountVINSList{}
|
||||||
|
|
||||||
err = json.Unmarshal(res, &accountVinsList)
|
err = json.Unmarshal(res, &accountVINSList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return accountVinsList, nil
|
return accountVINSList, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package account
|
package account
|
||||||
|
|
||||||
type AccountAclRecord struct {
|
type AccountACLRecord struct {
|
||||||
IsExplicit bool `json:"explicit"`
|
IsExplicit bool `json:"explicit"`
|
||||||
GUID string `json:"guid"`
|
GUID string `json:"guid"`
|
||||||
Rights string `json:"right"`
|
Rights string `json:"right"`
|
||||||
@@ -16,55 +16,55 @@ type ResourceLimits struct {
|
|||||||
CUI float64 `json:"CU_I"`
|
CUI float64 `json:"CU_I"`
|
||||||
CUM float64 `json:"CU_M"`
|
CUM float64 `json:"CU_M"`
|
||||||
CUNP float64 `json:"CU_NP"`
|
CUNP float64 `json:"CU_NP"`
|
||||||
GpuUnits float64 `json:"gpu_units"`
|
GPUUnits float64 `json:"gpu_units"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountRecord struct {
|
type AccountRecord struct {
|
||||||
DCLocation string `json:"DCLocation"`
|
DCLocation string `json:"DCLocation"`
|
||||||
CKey string `jspn:"_ckey"`
|
CKey string `jspn:"_ckey"`
|
||||||
Meta []interface{} `json:"_meta"`
|
Meta []interface{} `json:"_meta"`
|
||||||
Acl []AccountAclRecord `json:"acl"`
|
ACL []AccountACLRecord `json:"acl"`
|
||||||
Company string `json:"company"`
|
Company string `json:"company"`
|
||||||
CompanyUrl string `json:"companyurl"`
|
CompanyURL string `json:"companyurl"`
|
||||||
CreatedBy string `jspn:"createdBy"`
|
CreatedBy string `jspn:"createdBy"`
|
||||||
CreatedTime int `json:"createdTime"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
DeactiovationTime float64 `json:"deactivationTime"`
|
DeactiovationTime float64 `json:"deactivationTime"`
|
||||||
DeletedBy string `json:"deletedBy"`
|
DeletedBy string `json:"deletedBy"`
|
||||||
DeletedTime int `json:"deletedTime"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
DisplayName string `json:"displayname"`
|
DisplayName string `json:"displayname"`
|
||||||
GUID int `json:"guid"`
|
GUID uint64 `json:"guid"`
|
||||||
ID int `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||||
SendAccessEmails bool `json:"sendAccessEmails"`
|
SendAccessEmails bool `json:"sendAccessEmails"`
|
||||||
ServiceAccount bool `json:"serviceAccount"`
|
ServiceAccount bool `json:"serviceAccount"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
UpdatedTime int `json:"updatedTime"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
Version int `json:"version"`
|
Version uint64 `json:"version"`
|
||||||
Vins []int `json:"vins"`
|
VINS []uint64 `json:"vins"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountList []AccountRecord
|
type AccountList []AccountRecord
|
||||||
|
|
||||||
type AccountCloudApi struct {
|
type AccountCloudApi struct {
|
||||||
Acl []AccountAclRecord `json:"acl"`
|
ACL []AccountACLRecord `json:"acl"`
|
||||||
CreatedTime int `json:"createdTime"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
DeletedTime int `json:"deletedTime"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
ID int `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
UpdatedTime int `json:"updatedTime"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountCloudApiList []AccountCloudApi
|
type AccountCloudApiList []AccountCloudApi
|
||||||
|
|
||||||
type Resource struct {
|
type Resource struct {
|
||||||
CPU int `json:"cpu"`
|
CPU int64 `json:"cpu"`
|
||||||
Disksize int `json:"disksize"`
|
DiskSize int64 `json:"disksize"`
|
||||||
Extips int `json:"extips"`
|
ExtIPs int64 `json:"extips"`
|
||||||
Exttraffic int `json:"exttraffic"`
|
ExtTraffic int64 `json:"exttraffic"`
|
||||||
GPU int `json:"gpu"`
|
GPU int64 `json:"gpu"`
|
||||||
RAM int `json:"ram"`
|
RAM int64 `json:"ram"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Resources struct {
|
type Resources struct {
|
||||||
@@ -73,13 +73,13 @@ type Resources struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Computes struct {
|
type Computes struct {
|
||||||
Started int `json:"started"`
|
Started uint64 `json:"started"`
|
||||||
Stopped int `json:"stopped"`
|
Stopped uint64 `json:"stopped"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Machines struct {
|
type Machines struct {
|
||||||
Running int `json:"running"`
|
Running uint64 `json:"running"`
|
||||||
Halted int `json:"halted"`
|
Halted uint64 `json:"halted"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountWithResources struct {
|
type AccountWithResources struct {
|
||||||
@@ -87,71 +87,71 @@ type AccountWithResources struct {
|
|||||||
Resources Resources `json:"Resources"`
|
Resources Resources `json:"Resources"`
|
||||||
Computes Computes `json:"computes"`
|
Computes Computes `json:"computes"`
|
||||||
Machines Machines `json:"machines"`
|
Machines Machines `json:"machines"`
|
||||||
Vinses int `json:"vinses"`
|
VINSes uint64 `json:"vinses"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountCompute struct {
|
type AccountCompute struct {
|
||||||
AccountId int `json:"accountId"`
|
AccountID uint64 `json:"accountId"`
|
||||||
AccountName string `json:"accountName"`
|
AccountName string `json:"accountName"`
|
||||||
CPUs int `json:"cpus"`
|
CPUs uint64 `json:"cpus"`
|
||||||
CreatedBy string `json:"createdBy"`
|
CreatedBy string `json:"createdBy"`
|
||||||
CreatedTime int `json:"createdTime"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
DeletedBy string `json:"deletedBy"`
|
DeletedBy string `json:"deletedBy"`
|
||||||
DeletedTime int `json:"deletedTime"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
ComputeId int `json:"id"`
|
ComputeID uint64 `json:"id"`
|
||||||
ComputeName string `json:"name"`
|
ComputeName string `json:"name"`
|
||||||
RAM int `json:"ram"`
|
RAM uint64 `json:"ram"`
|
||||||
Registered bool `json:"registered"`
|
Registered bool `json:"registered"`
|
||||||
RGId int `json:"rgId"`
|
RGID uint64 `json:"rgId"`
|
||||||
RGName string `json:"rgName"`
|
RGName string `json:"rgName"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
TechStatus string `json:"techStatus"`
|
TechStatus string `json:"techStatus"`
|
||||||
TotalDisksSize int `json:"totalDisksSize"`
|
TotalDisksSize uint64 `json:"totalDisksSize"`
|
||||||
UpdatedBy string `json:"updatedBy"`
|
UpdatedBy string `json:"updatedBy"`
|
||||||
UpdatedTime int `json:"updatedTime"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
UserManaged bool `json:"userManaged"`
|
UserManaged bool `json:"userManaged"`
|
||||||
VinsConnected int `json:"vinsConnected"`
|
VINSConnected uint64 `json:"vinsConnected"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountComputesList []AccountCompute
|
type AccountComputesList []AccountCompute
|
||||||
|
|
||||||
type AccountDisk struct {
|
type AccountDisk struct {
|
||||||
ID int `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Pool string `json:"pool"`
|
Pool string `json:"pool"`
|
||||||
SepId int `json:"sepId"`
|
SepID uint64 `json:"sepId"`
|
||||||
SizeMax int `json:"sizeMax"`
|
SizeMax uint64 `json:"sizeMax"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountDisksList []AccountDisk
|
type AccountDisksList []AccountDisk
|
||||||
|
|
||||||
type AccountVin struct {
|
type AccountVIN struct {
|
||||||
AccountId int `json:"accountId"`
|
AccountID uint64 `json:"accountId"`
|
||||||
AccountName string `json:"accountName"`
|
AccountName string `json:"accountName"`
|
||||||
Computes int `json:"computes"`
|
Computes uint64 `json:"computes"`
|
||||||
CreatedBy string `json:"createdBy"`
|
CreatedBy string `json:"createdBy"`
|
||||||
CreatedTime int `json:"createdTime"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
DeletedBy string `json:"deletedBy"`
|
DeletedBy string `json:"deletedBy"`
|
||||||
DeletedTime int `json:"deletedTime"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
ExternalIP string `json:"externalIP"`
|
ExternalIP string `json:"externalIP"`
|
||||||
ID int `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Network string `json:"network"`
|
Network string `json:"network"`
|
||||||
PriVnfDevId int `json:"priVnfDevId"`
|
PriVnfDevID uint64 `json:"priVnfDevId"`
|
||||||
RGId int `json:"rgId"`
|
RGID uint64 `json:"rgId"`
|
||||||
RGName string `json:"rgName"`
|
RGName string `json:"rgName"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
UpdatedBy string `json:"updatedBy"`
|
UpdatedBy string `json:"updatedBy"`
|
||||||
UpdatedTime int `json:"updatedTime"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountVinsList []AccountVin
|
type AccountVINSList []AccountVIN
|
||||||
|
|
||||||
type AccountAudit struct {
|
type AccountAudit struct {
|
||||||
Call string `json:"call"`
|
Call string `json:"call"`
|
||||||
ResponseTime float64 `json:"responsetime"`
|
ResponseTime float64 `json:"responsetime"`
|
||||||
StatusCode int `json:"statuscode"`
|
StatusCode uint64 `json:"statuscode"`
|
||||||
Timestamp float64 `json:"timestamp"`
|
Timestamp float64 `json:"timestamp"`
|
||||||
User string `json:"user"`
|
User string `json:"user"`
|
||||||
}
|
}
|
||||||
@@ -159,8 +159,8 @@ type AccountAudit struct {
|
|||||||
type AccountAuditsList []AccountAudit
|
type AccountAuditsList []AccountAudit
|
||||||
|
|
||||||
type AccountRGComputes struct {
|
type AccountRGComputes struct {
|
||||||
Started int `json:"Started"`
|
Started uint64 `json:"Started"`
|
||||||
Stopped int `json:"Stopped"`
|
Stopped uint64 `json:"Stopped"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountRGResources struct {
|
type AccountRGResources struct {
|
||||||
@@ -173,28 +173,28 @@ type AccountRG struct {
|
|||||||
Computes AccountRGComputes `json:"Computes"`
|
Computes AccountRGComputes `json:"Computes"`
|
||||||
Resources AccountRGResources `json:"Resources"`
|
Resources AccountRGResources `json:"Resources"`
|
||||||
CreatedBy string `json:"createdBy"`
|
CreatedBy string `json:"createdBy"`
|
||||||
CreatedTime int `json:"createdTime"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
DeletedBy string `json:"deletedBy"`
|
DeletedBy string `json:"deletedBy"`
|
||||||
DeletedTime int `json:"deletedTime"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
RGID int `json:"id"`
|
RGID uint64 `json:"id"`
|
||||||
Milestones int `json:"milestones"`
|
Milestones uint64 `json:"milestones"`
|
||||||
RGName string `json:"name"`
|
RGName string `json:"name"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
UpdatedBy string `json:"updatedBy"`
|
UpdatedBy string `json:"updatedBy"`
|
||||||
UpdatedTime int `json:"updatedTime"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
Vinses int `json:"vinses"`
|
VINSes uint64 `json:"vinses"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountRGList []AccountRG
|
type AccountRGList []AccountRG
|
||||||
|
|
||||||
type AccountTemplate struct {
|
type AccountTemplate struct {
|
||||||
UNCPath string `json:"UNCPath"`
|
UNCPath string `json:"UNCPath"`
|
||||||
AccountId int `json:"accountId"`
|
AccountID uint64 `json:"accountId"`
|
||||||
Description string `json:"desc"`
|
Description string `json:"desc"`
|
||||||
ID int `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Public bool `json:"public"`
|
Public bool `json:"public"`
|
||||||
Size int `json:"size"`
|
Size uint64 `json:"size"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
@@ -203,27 +203,27 @@ type AccountTemplate struct {
|
|||||||
type AccountTemplatesList []AccountTemplate
|
type AccountTemplatesList []AccountTemplate
|
||||||
|
|
||||||
type AccountFlipGroup struct {
|
type AccountFlipGroup struct {
|
||||||
AccountId int `json:"accountId"`
|
AccountID uint64 `json:"accountId"`
|
||||||
ClientType string `json:"clientType"`
|
ClientType string `json:"clientType"`
|
||||||
ConnType string `json:"connType"`
|
ConnType string `json:"connType"`
|
||||||
CreatedBy string `json:"createdBy"`
|
CreatedBy string `json:"createdBy"`
|
||||||
CreatedTime int `json:"createdTime"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
DefaultGW string `json:"defaultGW"`
|
DefaultGW string `json:"defaultGW"`
|
||||||
DeletedBy string `json:"deletedBy"`
|
DeletedBy string `json:"deletedBy"`
|
||||||
DeletedTime int `json:"deletedTime"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
Description string `json:"desc"`
|
Description string `json:"desc"`
|
||||||
GID int `json:"gid"`
|
GID uint64 `json:"gid"`
|
||||||
GUID int `json:"guid"`
|
GUID uint64 `json:"guid"`
|
||||||
ID int `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
IP string `json:"ip"`
|
IP string `json:"ip"`
|
||||||
Milestones int `json:"milestones"`
|
Milestones uint64 `json:"milestones"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
NetID int `json:"netId"`
|
NetID uint64 `json:"netId"`
|
||||||
NetType string `json:"netType"`
|
NetType string `json:"netType"`
|
||||||
NetMask int `json:"netmask"`
|
NetMask uint64 `json:"netmask"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
UpdatedBy string `json:"updatedBy"`
|
UpdatedBy string `json:"updatedBy"`
|
||||||
UpdatedTime int `json:"updatedTime"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountFlipGroupsList []AccountFlipGroup
|
type AccountFlipGroupsList []AccountFlipGroup
|
||||||
|
|||||||
@@ -3,42 +3,31 @@ package account
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type RestoreRequest struct {
|
type RestoreRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq RestoreRequest) Validate() error {
|
func (arq RestoreRequest) Validate() error {
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) Restore(ctx context.Context, req RestoreRequest, options ...opts.DecortOpts) (bool, error) {
|
func (a Account) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/restore"
|
url := "/cloudapi/account/restore"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,50 +3,39 @@ package account
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type UpdateRequest struct {
|
type UpdateRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
Name string `url:"name,omitempty"`
|
Name string `url:"name,omitempty"`
|
||||||
MaxMemoryCapacity uint `url:"maxMemoryCapacity,omitempty"`
|
MaxMemoryCapacity uint64 `url:"maxMemoryCapacity,omitempty"`
|
||||||
MaxVDiskCapacity uint `url:"maxVDiskCapacity,omitempty"`
|
MaxVDiskCapacity uint64 `url:"maxVDiskCapacity,omitempty"`
|
||||||
MaxCPUCapacity uint `url:"maxCPUCapacity,omitempty"`
|
MaxCPUCapacity uint64 `url:"maxCPUCapacity,omitempty"`
|
||||||
MaxNetworkPeerTransfer uint `url:"maxNetworkPeerTransfer,omitempty"`
|
MaxNetworkPeerTransfer uint64 `url:"maxNetworkPeerTransfer,omitempty"`
|
||||||
MaxNumPublicIP uint `url:"maxNumPublicIP,omitempty"`
|
MaxNumPublicIP uint64 `url:"maxNumPublicIP,omitempty"`
|
||||||
SendAccessEmails bool `url:"sendAccessEmails,omitempty"`
|
SendAccessEmails bool `url:"sendAccessEmails,omitempty"`
|
||||||
GpuUnits uint `url:"gpu_units,omitempty"`
|
GPUUnits uint64 `url:"gpu_units,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq UpdateRequest) Validate() error {
|
func (arq UpdateRequest) Validate() error {
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) Update(ctx context.Context, req UpdateRequest, options ...opts.DecortOpts) (bool, error) {
|
func (a Account) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/update"
|
url := "/cloudapi/account/update"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,26 +3,25 @@ package account
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/internal/validators"
|
"github.com/rudecs/decort-sdk/internal/validators"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type UpdateUserRequest struct {
|
type UpdateUserRequest struct {
|
||||||
AccountId uint64 `url:"accountId"`
|
AccountID uint64 `url:"accountId"`
|
||||||
UserId string `url:"userId"`
|
UserID string `url:"userId"`
|
||||||
AccessType string `url:"accesstype"`
|
AccessType string `url:"accesstype"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq UpdateUserRequest) Validate() error {
|
func (arq UpdateUserRequest) Validate() error {
|
||||||
if arq.AccountId == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if arq.UserId == "" {
|
if arq.UserID == "" {
|
||||||
return errors.New("validation-error: field UserId can not be empty")
|
return errors.New("validation-error: field UserID can not be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
if arq.AccessType == "" {
|
if arq.AccessType == "" {
|
||||||
@@ -37,24 +36,15 @@ func (arq UpdateUserRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Account) UpdateUser(ctx context.Context, req UpdateUserRequest, options ...opts.DecortOpts) (bool, error) {
|
func (a Account) UpdateUser(ctx context.Context, req UpdateUserRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/account/updateUser"
|
url := "/cloudapi/account/updateUser"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := a.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateRequest struct {
|
type CreateRequest struct {
|
||||||
@@ -28,13 +26,13 @@ func (bsrq CreateRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) Create(ctx context.Context, req CreateRequest, options ...opts.DecortOpts) (uint64, error) {
|
func (b BService) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/create"
|
url := "/cloudapi/bservice/create"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DeleteRequest struct {
|
type DeleteRequest struct {
|
||||||
@@ -22,13 +20,13 @@ func (bsrq DeleteRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) Delete(ctx context.Context, req DeleteRequest, options ...opts.DecortOpts) (bool, error) {
|
func (b BService) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/delete"
|
url := "/cloudapi/bservice/delete"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DisableRequest struct {
|
type DisableRequest struct {
|
||||||
@@ -21,13 +19,13 @@ func (bsrq DisableRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) Disable(ctx context.Context, req DisableRequest, options ...opts.DecortOpts) (bool, error) {
|
func (b BService) Disable(ctx context.Context, req DisableRequest) (bool, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/delete"
|
url := "/cloudapi/bservice/delete"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type EnableRequest struct {
|
type EnableRequest struct {
|
||||||
@@ -21,13 +19,13 @@ func (bsrq EnableRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) Enable(ctx context.Context, req EnableRequest, options ...opts.DecortOpts) (bool, error) {
|
func (b BService) Enable(ctx context.Context, req EnableRequest) (bool, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/enable"
|
url := "/cloudapi/bservice/enable"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
@@ -21,13 +19,13 @@ func (bsrq GetRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) Get(ctx context.Context, req GetRequest, options ...opts.DecortOpts) (*BasicService, error) {
|
func (b BService) Get(ctx context.Context, req GetRequest) (*BasicService, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/get"
|
url := "/cloudapi/bservice/get"
|
||||||
bsRaw, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
bsRaw, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GroupAddRequest struct {
|
type GroupAddRequest struct {
|
||||||
@@ -20,7 +18,7 @@ type GroupAddRequest struct {
|
|||||||
Driver string `url:"driver"`
|
Driver string `url:"driver"`
|
||||||
Role string `url:"role,omitempty"`
|
Role string `url:"role,omitempty"`
|
||||||
VINSes []uint64 `url:"vinses,omitempty"`
|
VINSes []uint64 `url:"vinses,omitempty"`
|
||||||
Extnets []uint64 `url:"extnets,omitempty"`
|
ExtNets []uint64 `url:"extnets,omitempty"`
|
||||||
TimeoutStart uint64 `url:"timeoutStart"`
|
TimeoutStart uint64 `url:"timeoutStart"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,13 +58,13 @@ func (bsrq GroupAddRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) GroupAdd(ctx context.Context, req GroupAddRequest, options ...opts.DecortOpts) (uint64, error) {
|
func (b BService) GroupAdd(ctx context.Context, req GroupAddRequest) (uint64, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/groupAdd"
|
url := "/cloudapi/bservice/groupAdd"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GroupComputeRemoveRequest struct {
|
type GroupComputeRemoveRequest struct {
|
||||||
@@ -31,13 +29,13 @@ func (bsrq GroupComputeRemoveRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) GroupComputeRemove(ctx context.Context, req GroupComputeRemoveRequest, options ...opts.DecortOpts) (bool, error) {
|
func (b BService) GroupComputeRemove(ctx context.Context, req GroupComputeRemoveRequest) (bool, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/groupComputeRemove"
|
url := "/cloudapi/bservice/groupComputeRemove"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GroupGetRequest struct {
|
type GroupGetRequest struct {
|
||||||
@@ -26,13 +24,13 @@ func (bsrq GroupGetRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) GroupGet(ctx context.Context, req GroupGetRequest, options ...opts.DecortOpts) (*Group, error) {
|
func (b BService) GroupGet(ctx context.Context, req GroupGetRequest) (*Group, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/groupGet"
|
url := "/cloudapi/bservice/groupGet"
|
||||||
groupRaw, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
groupRaw, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GroupParentAddRequest struct {
|
type GroupParentAddRequest struct {
|
||||||
@@ -31,13 +29,13 @@ func (bsrq GroupParentAddRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) GroupParentAdd(ctx context.Context, req GroupParentAddRequest, options ...opts.DecortOpts) (bool, error) {
|
func (b BService) GroupParentAdd(ctx context.Context, req GroupParentAddRequest) (bool, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/groupParentAdd"
|
url := "/cloudapi/bservice/groupParentAdd"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GroupParentRemoveRequest struct {
|
type GroupParentRemoveRequest struct {
|
||||||
@@ -31,13 +29,13 @@ func (bsrq GroupParentRemoveRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) GroupParentRemove(ctx context.Context, req GroupParentRemoveRequest, options ...opts.DecortOpts) (bool, error) {
|
func (b BService) GroupParentRemove(ctx context.Context, req GroupParentRemoveRequest) (bool, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/groupParentRemove"
|
url := "/cloudapi/bservice/groupParentRemove"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GroupRemoveRequest struct {
|
type GroupRemoveRequest struct {
|
||||||
@@ -26,13 +24,13 @@ func (bsrq GroupRemoveRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) GroupRemove(ctx context.Context, req GroupRemoveRequest, options ...opts.DecortOpts) (bool, error) {
|
func (b BService) GroupRemove(ctx context.Context, req GroupRemoveRequest) (bool, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/groupRemove"
|
url := "/cloudapi/bservice/groupRemove"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,10 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/internal/validators"
|
"github.com/rudecs/decort-sdk/internal/validators"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GroupResizeRequest struct {
|
type GroupResizeRequest struct {
|
||||||
@@ -37,13 +36,13 @@ func (bsrq GroupResizeRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) GroupResize(ctx context.Context, req GroupResizeRequest, options ...opts.DecortOpts) (uint64, error) {
|
func (b BService) GroupResize(ctx context.Context, req GroupResizeRequest) (uint64, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/groupResize"
|
url := "/cloudapi/bservice/groupResize"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GroupStartRequest struct {
|
type GroupStartRequest struct {
|
||||||
@@ -26,13 +24,13 @@ func (bsrq GroupStartRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) GroupStart(ctx context.Context, req GroupStartRequest, options ...opts.DecortOpts) (bool, error) {
|
func (b BService) GroupStart(ctx context.Context, req GroupStartRequest) (bool, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/groupStart"
|
url := "/cloudapi/bservice/groupStart"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GroupStopRequest struct {
|
type GroupStopRequest struct {
|
||||||
@@ -27,13 +25,13 @@ func (bsrq GroupStopRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) GroupStop(ctx context.Context, req GroupStopRequest, options ...opts.DecortOpts) (bool, error) {
|
func (b BService) GroupStop(ctx context.Context, req GroupStopRequest) (bool, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/groupStop"
|
url := "/cloudapi/bservice/groupStop"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GroupUpdateRequest struct {
|
type GroupUpdateRequest struct {
|
||||||
@@ -32,13 +30,13 @@ func (bsrq GroupUpdateRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) GroupUpdate(ctx context.Context, req GroupUpdateRequest, options ...opts.DecortOpts) (bool, error) {
|
func (b BService) GroupUpdate(ctx context.Context, req GroupUpdateRequest) (bool, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/groupUpdate"
|
url := "/cloudapi/bservice/groupUpdate"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,19 +3,17 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GroupUpdateExtnetRequest struct {
|
type GroupUpdateExtNetRequest struct {
|
||||||
ServiceID uint64 `url:"serviceId"`
|
ServiceID uint64 `url:"serviceId"`
|
||||||
CompGroupID uint64 `url:"compgroupId"`
|
CompGroupID uint64 `url:"compgroupId"`
|
||||||
Extnets []uint64 `url:"extnets,omitempty"`
|
ExtNets []uint64 `url:"extnets,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bsrq GroupUpdateExtnetRequest) Validate() error {
|
func (bsrq GroupUpdateExtNetRequest) Validate() error {
|
||||||
if bsrq.ServiceID == 0 {
|
if bsrq.ServiceID == 0 {
|
||||||
return errors.New("field ServiceID can not be empty or equal to 0")
|
return errors.New("field ServiceID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
@@ -27,13 +25,13 @@ func (bsrq GroupUpdateExtnetRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) GroupUpdateExtnet(ctx context.Context, req GroupUpdateExtnetRequest, options ...opts.DecortOpts) (bool, error) {
|
func (b BService) GroupUpdateExtNet(ctx context.Context, req GroupUpdateExtNetRequest) (bool, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/groupUpdateExtnet"
|
url := "/cloudapi/bservice/groupUpdateExtnet"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GroupUpdateVINSRequest struct {
|
type GroupUpdateVINSRequest struct {
|
||||||
@@ -27,13 +25,13 @@ func (bsrq GroupUpdateVINSRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) GroupUpdateVINS(ctx context.Context, req GroupUpdateVINSRequest, options ...opts.DecortOpts) (bool, error) {
|
func (b BService) GroupUpdateVINS(ctx context.Context, req GroupUpdateVINSRequest) (bool, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/groupUpdateVins"
|
url := "/cloudapi/bservice/groupUpdateVins"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
@@ -15,9 +13,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty"`
|
Size uint64 `url:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) List(ctx context.Context, req ListRequest, options ...opts.DecortOpts) (BasicServiceList, error) {
|
func (b BService) List(ctx context.Context, req ListRequest) (BasicServiceList, error) {
|
||||||
url := "/cloudapi/bservice/list"
|
url := "/cloudapi/bservice/list"
|
||||||
bsListRaw, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
bsListRaw, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -30,9 +28,9 @@ func (b BService) List(ctx context.Context, req ListRequest, options ...opts.Dec
|
|||||||
return bsList, nil
|
return bsList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) ListDeleted(ctx context.Context, req ListRequest, options ...opts.DecortOpts) (BasicServiceList, error) {
|
func (b BService) ListDeleted(ctx context.Context, req ListRequest) (BasicServiceList, error) {
|
||||||
url := "/cloudapi/bservice/listDeleted"
|
url := "/cloudapi/bservice/listDeleted"
|
||||||
bsListRaw, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
bsListRaw, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ type Group struct {
|
|||||||
DeletedTime uint64 `json:"deletedTime"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
Disk uint64 `json:"disk"`
|
Disk uint64 `json:"disk"`
|
||||||
Driver string `json:"driver"`
|
Driver string `json:"driver"`
|
||||||
Extnets []uint64 `json:"extnets"`
|
ExtNets []uint64 `json:"extnets"`
|
||||||
GID uint64 `json:"gid"`
|
GID uint64 `json:"gid"`
|
||||||
GUID uint64 `json:"guid"`
|
GUID uint64 `json:"guid"`
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type RestoreRequest struct {
|
type RestoreRequest struct {
|
||||||
@@ -21,13 +19,13 @@ func (bsrq RestoreRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) Restore(ctx context.Context, req RestoreRequest, options ...opts.DecortOpts) (bool, error) {
|
func (b BService) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/restore"
|
url := "/cloudapi/bservice/restore"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type SnapshotCreateRequest struct {
|
type SnapshotCreateRequest struct {
|
||||||
@@ -26,13 +24,13 @@ func (bsrq SnapshotCreateRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) SnapshotCreate(ctx context.Context, req SnapshotCreateRequest, options ...opts.DecortOpts) (bool, error) {
|
func (b BService) SnapshotCreate(ctx context.Context, req SnapshotCreateRequest) (bool, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/snapshotCreate"
|
url := "/cloudapi/bservice/snapshotCreate"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type SnapshotDeleteRequest struct {
|
type SnapshotDeleteRequest struct {
|
||||||
@@ -26,13 +24,13 @@ func (bsrq SnapshotDeleteRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest, options ...opts.DecortOpts) (bool, error) {
|
func (b BService) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (bool, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/snapshotDelete"
|
url := "/cloudapi/bservice/snapshotDelete"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type SnapshotListRequest struct {
|
type SnapshotListRequest struct {
|
||||||
@@ -21,13 +19,13 @@ func (bsrq SnapshotListRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest, options ...opts.DecortOpts) ([]Snapshot, error) {
|
func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest) ([]Snapshot, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/snapshotList"
|
url := "/cloudapi/bservice/snapshotList"
|
||||||
snapshotListRaw, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
snapshotListRaw, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type SnapshotRollbackRequest struct {
|
type SnapshotRollbackRequest struct {
|
||||||
@@ -26,13 +24,13 @@ func (bsrq SnapshotRollbackRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest, options ...opts.DecortOpts) (bool, error) {
|
func (b BService) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest) (bool, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/snapshotRollback"
|
url := "/cloudapi/bservice/snapshotRollback"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type StartRequest struct {
|
type StartRequest struct {
|
||||||
@@ -21,13 +19,13 @@ func (bsrq StartRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) Start(ctx context.Context, req StartRequest, options ...opts.DecortOpts) (bool, error) {
|
func (b BService) Start(ctx context.Context, req StartRequest) (bool, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/start"
|
url := "/cloudapi/bservice/start"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package bservice
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type StopRequest struct {
|
type StopRequest struct {
|
||||||
@@ -21,13 +19,13 @@ func (bsrq StopRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BService) Stop(ctx context.Context, req StopRequest, options ...opts.DecortOpts) (bool, error) {
|
func (b BService) Stop(ctx context.Context, req StopRequest) (bool, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/bservice/stop"
|
url := "/cloudapi/bservice/stop"
|
||||||
res, err := b.client.DecortApiCall(ctx, typed.POST, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
15
pkg/cloudapi/cloudapi.go
Normal file
15
pkg/cloudapi/cloudapi.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package cloudapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/rudecs/decort-sdk/interfaces"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CloudApi struct {
|
||||||
|
client interfaces.Caller
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(client interfaces.Caller) *CloudApi {
|
||||||
|
return &CloudApi{
|
||||||
|
client: client,
|
||||||
|
}
|
||||||
|
}
|
||||||
9
pkg/cloudapi/compute.go
Normal file
9
pkg/cloudapi/compute.go
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package cloudapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/rudecs/decort-sdk/pkg/cloudapi/compute"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (ca *CloudApi) Compute() *compute.Compute {
|
||||||
|
return compute.New(ca.client)
|
||||||
|
}
|
||||||
@@ -3,9 +3,7 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AffinityGroupCheckStartRequest struct {
|
type AffinityGroupCheckStartRequest struct {
|
||||||
@@ -24,23 +22,15 @@ func (crq AffinityGroupCheckStartRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) AffinityGroupCheckStart(ctx context.Context, req AffinityGroupCheckStartRequest, options ...opts.DecortOpts) (string, error) {
|
func (c Compute) AffinityGroupCheckStart(ctx context.Context, req AffinityGroupCheckStartRequest) (string, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/affinityGroupCheckStart"
|
url := "/cloudapi/compute/affinityGroupCheckStart"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,41 +3,31 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AffinityLabelRemoveRequest struct {
|
type AffinityLabelRemoveRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq AffinityLabelRemoveRequest) Validate() error {
|
func (crq AffinityLabelRemoveRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) AffinityLabelRemove(ctx context.Context, req AffinityLabelRemoveRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) AffinityLabelRemove(ctx context.Context, req AffinityLabelRemoveRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/affinityLabelRemove"
|
url := "/cloudapi/compute/affinityLabelRemove"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,20 +3,18 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AffinityLabelSetRequest struct {
|
type AffinityLabelSetRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
AffinityLabel string `url:"affinityLabel"`
|
AffinityLabel string `url:"affinityLabel"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq AffinityLabelSetRequest) Validate() error {
|
func (crq AffinityLabelSetRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
if crq.AffinityLabel == "" {
|
if crq.AffinityLabel == "" {
|
||||||
return errors.New("validation-error: field AffinityLabel can not be empty")
|
return errors.New("validation-error: field AffinityLabel can not be empty")
|
||||||
@@ -25,23 +23,15 @@ func (crq AffinityLabelSetRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) AffinityLabelSet(ctx context.Context, req AffinityLabelSetRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) AffinityLabelSet(ctx context.Context, req AffinityLabelSetRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/affinityLabelSet"
|
url := "/cloudapi/compute/affinityLabelSet"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,48 +4,38 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AffinityRelationsRequest struct {
|
type AffinityRelationsRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
AffinityLabel string `url:"affinityLabel"`
|
AffinityLabel string `url:"affinityLabel"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq AffinityRelationsRequest) Validate() error {
|
func (crq AffinityRelationsRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) AffinityRelations(ctx context.Context, req AffinityRelationsRequest, options ...opts.DecortOpts) (*AffinityRelations, error) {
|
func (c Compute) AffinityRelations(ctx context.Context, req AffinityRelationsRequest) (*AffinityRelations, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/affinityRelations"
|
url := "/cloudapi/compute/affinityRelations"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
relations := &AffinityRelations{}
|
relations := &AffinityRelations{}
|
||||||
|
|
||||||
err = json.Unmarshal([]byte(res), relations)
|
err = json.Unmarshal(res, relations)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,14 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/internal/validators"
|
"github.com/rudecs/decort-sdk/internal/validators"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AffinityRuleAddRequest struct {
|
type AffinityRuleAddRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
Topology string `url:"topology"`
|
Topology string `url:"topology"`
|
||||||
Policy string `url:"policy"`
|
Policy string `url:"policy"`
|
||||||
Mode string `url:"mode"`
|
Mode string `url:"mode"`
|
||||||
@@ -20,8 +19,8 @@ type AffinityRuleAddRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (crq AffinityRuleAddRequest) Validate() error {
|
func (crq AffinityRuleAddRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
if crq.Topology == "" {
|
if crq.Topology == "" {
|
||||||
return errors.New("validation-error: field Topology can not be empty")
|
return errors.New("validation-error: field Topology can not be empty")
|
||||||
@@ -61,23 +60,15 @@ func (crq AffinityRuleAddRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/affinityRuleAdd"
|
url := "/cloudapi/compute/affinityRuleAdd"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,14 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/internal/validators"
|
"github.com/rudecs/decort-sdk/internal/validators"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AffinityRuleRemoveRequest struct {
|
type AffinityRuleRemoveRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
Topology string `url:"topology"`
|
Topology string `url:"topology"`
|
||||||
Policy string `url:"policy"`
|
Policy string `url:"policy"`
|
||||||
Mode string `url:"mode"`
|
Mode string `url:"mode"`
|
||||||
@@ -20,8 +19,8 @@ type AffinityRuleRemoveRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (crq AffinityRuleRemoveRequest) Validate() error {
|
func (crq AffinityRuleRemoveRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
if crq.Topology == "" {
|
if crq.Topology == "" {
|
||||||
return errors.New("validation-error: field Topology can not be empty")
|
return errors.New("validation-error: field Topology can not be empty")
|
||||||
@@ -61,23 +60,15 @@ func (crq AffinityRuleRemoveRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) AffinityRuleRemove(ctx context.Context, req AffinityRuleRemoveRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) AffinityRuleRemove(ctx context.Context, req AffinityRuleRemoveRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/affinityRuleRemove"
|
url := "/cloudapi/compute/affinityRuleRemove"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,41 +3,31 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AffinityRulesClearRequest struct {
|
type AffinityRulesClearRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq AffinityRulesClearRequest) Validate() error {
|
func (crq AffinityRulesClearRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) AffinityRulesClear(ctx context.Context, req AffinityRulesClearRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) AffinityRulesClear(ctx context.Context, req AffinityRulesClearRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/affinityRulesClear"
|
url := "/cloudapi/compute/affinityRulesClear"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,14 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/internal/validators"
|
"github.com/rudecs/decort-sdk/internal/validators"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AntiAffinityRuleAddRequest struct {
|
type AntiAffinityRuleAddRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
Topology string `url:"topology"`
|
Topology string `url:"topology"`
|
||||||
Policy string `url:"policy"`
|
Policy string `url:"policy"`
|
||||||
Mode string `url:"mode"`
|
Mode string `url:"mode"`
|
||||||
@@ -20,8 +19,8 @@ type AntiAffinityRuleAddRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (crq AntiAffinityRuleAddRequest) Validate() error {
|
func (crq AntiAffinityRuleAddRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
if crq.Topology == "" {
|
if crq.Topology == "" {
|
||||||
return errors.New("validation-error: field Topology can not be empty")
|
return errors.New("validation-error: field Topology can not be empty")
|
||||||
@@ -61,23 +60,15 @@ func (crq AntiAffinityRuleAddRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) AntiAffinityRuleAdd(ctx context.Context, req AntiAffinityRuleAddRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) AntiAffinityRuleAdd(ctx context.Context, req AntiAffinityRuleAddRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/antiAffinityRuleAdd"
|
url := "/cloudapi/compute/antiAffinityRuleAdd"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,14 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/internal/validators"
|
"github.com/rudecs/decort-sdk/internal/validators"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AntiAffinityRuleRemoveRequest struct {
|
type AntiAffinityRuleRemoveRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
Topology string `url:"topology"`
|
Topology string `url:"topology"`
|
||||||
Policy string `url:"policy"`
|
Policy string `url:"policy"`
|
||||||
Mode string `url:"mode"`
|
Mode string `url:"mode"`
|
||||||
@@ -20,8 +19,8 @@ type AntiAffinityRuleRemoveRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (crq AntiAffinityRuleRemoveRequest) Validate() error {
|
func (crq AntiAffinityRuleRemoveRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
if crq.Topology == "" {
|
if crq.Topology == "" {
|
||||||
return errors.New("validation-error: field Topology can not be empty")
|
return errors.New("validation-error: field Topology can not be empty")
|
||||||
@@ -61,23 +60,15 @@ func (crq AntiAffinityRuleRemoveRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) AntiAffinityRuleRemove(ctx context.Context, req AntiAffinityRuleRemoveRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) AntiAffinityRuleRemove(ctx context.Context, req AntiAffinityRuleRemoveRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/antiAffinityRuleRemove"
|
url := "/cloudapi/compute/antiAffinityRuleRemove"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,41 +3,31 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AntiAffinityRulesClearRequest struct {
|
type AntiAffinityRulesClearRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq AntiAffinityRulesClearRequest) Validate() error {
|
func (crq AntiAffinityRulesClearRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) AntiAffinityRulesClear(ctx context.Context, req AntiAffinityRulesClearRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) AntiAffinityRulesClear(ctx context.Context, req AntiAffinityRulesClearRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/antiAffinityRulesClear"
|
url := "/cloudapi/compute/antiAffinityRulesClear"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,20 +3,18 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AttachGPURequest struct {
|
type AttachGPURequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
VGPUID uint64 `url:"vgpuId"`
|
VGPUID uint64 `url:"vgpuId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq AttachGPURequest) Validate() error {
|
func (crq AttachGPURequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if crq.VGPUID == 0 {
|
if crq.VGPUID == 0 {
|
||||||
@@ -26,30 +24,22 @@ func (crq AttachGPURequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) AttachGPU(ctx context.Context, req AttachGPURequest, options ...opts.DecortOpts) (uint64, error) {
|
func (c Compute) AttachGPU(ctx context.Context, req AttachGPURequest) (uint64, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/attachGpu"
|
url := "/cloudapi/compute/attachGpu"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -3,20 +3,18 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AttachPciDeviceRequest struct {
|
type AttachPciDeviceRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
DeviceID uint64 `url:"deviceId"`
|
DeviceID uint64 `url:"deviceId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq AttachPciDeviceRequest) Validate() error {
|
func (crq AttachPciDeviceRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if crq.DeviceID == 0 {
|
if crq.DeviceID == 0 {
|
||||||
@@ -26,30 +24,22 @@ func (crq AttachPciDeviceRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) AttachPciDevice(ctx context.Context, req AttachPciDeviceRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) AttachPciDevice(ctx context.Context, req AttachPciDeviceRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/attachPciDevice"
|
url := "/cloudapi/compute/attachPciDevice"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
result, err := strconv.ParseBool(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -4,30 +4,28 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuditsRequest struct {
|
type AuditsRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq AuditsRequest) Validate() error {
|
func (crq AuditsRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("field ComputeId can not be empty or equal to 0")
|
return errors.New("field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) Audits(ctx context.Context, req AuditsRequest, options ...opts.DecortOpts) (AuditList, error) {
|
func (c Compute) Audits(ctx context.Context, req AuditsRequest) (AuditList, error) {
|
||||||
if err := req.Validate(); err != nil {
|
if err := req.Validate(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/cloudapi/compute/audits"
|
url := "/cloudapi/compute/audits"
|
||||||
auditListRaw, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
auditListRaw, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,41 +3,31 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type CDEjectRequest struct {
|
type CDEjectRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq CDEjectRequest) Validate() error {
|
func (crq CDEjectRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) CDEject(ctx context.Context, req CDEjectRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/cdEject"
|
url := "/cloudapi/compute/cdEject"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,20 +3,18 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type CDInsertRequest struct {
|
type CDInsertRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
CDROMID uint64 `url:"cdromId"`
|
CDROMID uint64 `url:"cdromId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq CDInsertRequest) Validate() error {
|
func (crq CDInsertRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
if crq.CDROMID == 0 {
|
if crq.CDROMID == 0 {
|
||||||
return errors.New("validation-error: field CDROMID can not be empty or equal to 0")
|
return errors.New("validation-error: field CDROMID can not be empty or equal to 0")
|
||||||
@@ -25,23 +23,15 @@ func (crq CDInsertRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/cdInsert"
|
url := "/cloudapi/compute/cdInsert"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,22 +3,20 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type CloneRequest struct {
|
type CloneRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
Name string `url:"name"`
|
Name string `url:"name"`
|
||||||
SnapshotTimestamp uint64 `url:"snapshotTimestamp"`
|
SnapshotTimestamp uint64 `url:"snapshotTimestamp"`
|
||||||
SnapshotName string `url:"snapshotName"`
|
SnapshotName string `url:"snapshotName"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq CloneRequest) Validate() error {
|
func (crq CloneRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
if crq.Name == "" {
|
if crq.Name == "" {
|
||||||
return errors.New("validation-error: field Name can not be empty or equal to 0")
|
return errors.New("validation-error: field Name can not be empty or equal to 0")
|
||||||
@@ -27,23 +25,15 @@ func (crq CloneRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) Clone(ctx context.Context, req CloneRequest, options ...opts.DecortOpts) (uint64, error) {
|
func (c Compute) Clone(ctx context.Context, req CloneRequest) (uint64, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/clone"
|
url := "/cloudapi/compute/clone"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,22 +3,20 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateTemplateRequest struct {
|
type CreateTemplateRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
Name string `url:"name"`
|
Name string `url:"name"`
|
||||||
Async bool `url:"async"`
|
Async bool `url:"async"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq CreateTemplateRequest) Validate() error {
|
func (crq CreateTemplateRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if crq.Name == "" {
|
if crq.Name == "" {
|
||||||
@@ -28,7 +26,7 @@ func (crq CreateTemplateRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest, options ...opts.DecortOpts) (uint64, error) {
|
func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest) (uint64, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@@ -36,30 +34,22 @@ func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest,
|
|||||||
|
|
||||||
req.Async = false
|
req.Async = false
|
||||||
|
|
||||||
url := "/compute/createTemplate"
|
url := "/cloudapi/compute/createTemplate"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) CreateTemplateAsync(ctx context.Context, req CreateTemplateRequest, options ...opts.DecortOpts) (string, error) {
|
func (c Compute) CreateTemplateAsync(ctx context.Context, req CreateTemplateRequest) (string, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@@ -67,17 +57,9 @@ func (c Compute) CreateTemplateAsync(ctx context.Context, req CreateTemplateRequ
|
|||||||
|
|
||||||
req.Async = true
|
req.Async = true
|
||||||
|
|
||||||
url := "/compute/createTemplate"
|
url := "/cloudapi/compute/createTemplate"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,43 +3,33 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DeleteRequest struct {
|
type DeleteRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
Permanently bool `url:"permanently,omitempty"`
|
Permanently bool `url:"permanently,omitempty"`
|
||||||
DetachDisks bool `url:"detachDisks,omitempty"`
|
DetachDisks bool `url:"detachDisks,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq DeleteRequest) Validate() error {
|
func (crq DeleteRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) Delete(ctx context.Context, req DeleteRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/delete"
|
url := "/cloudapi/compute/delete"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,49 +3,39 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DetachGPURequest struct {
|
type DetachGPURequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
VGPUID int64 `url:"vgpuId,omitempty"`
|
VGPUID int64 `url:"vgpuId,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq DetachGPURequest) Validate() error {
|
func (crq DetachGPURequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) DetachGPU(ctx context.Context, req DetachGPURequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) DetachGPU(ctx context.Context, req DetachGPURequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/detachGpu"
|
url := "/cloudapi/compute/detachGpu"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
result, err := strconv.ParseBool(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -3,20 +3,18 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DetachPciDeviceRequest struct {
|
type DetachPciDeviceRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
DeviceID uint64 `url:"deviceId"`
|
DeviceID uint64 `url:"deviceId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq DetachPciDeviceRequest) Validate() error {
|
func (crq DetachPciDeviceRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if crq.DeviceID == 0 {
|
if crq.DeviceID == 0 {
|
||||||
@@ -26,30 +24,22 @@ func (crq DetachPciDeviceRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) DetachPciDevice(ctx context.Context, req DetachPciDeviceRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) DetachPciDevice(ctx context.Context, req DetachPciDeviceRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/detachPciDevice"
|
url := "/cloudapi/compute/detachPciDevice"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
result, err := strconv.ParseBool(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -3,48 +3,38 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DisableRequest struct {
|
type DisableRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq DisableRequest) Validate() error {
|
func (crq DisableRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) Disable(ctx context.Context, req DisableRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/disable"
|
url := "/cloudapi/compute/disable"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
result, err := strconv.ParseBool(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DiskAddRequest struct {
|
type DiskAddRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
DiskName string `url:"diskName"`
|
DiskName string `url:"diskName"`
|
||||||
Size uint64 `url:"size"`
|
Size uint64 `url:"size"`
|
||||||
DiskType string `url:"diskType,omitempty"`
|
DiskType string `url:"diskType,omitempty"`
|
||||||
@@ -21,8 +19,8 @@ type DiskAddRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (crq DiskAddRequest) Validate() error {
|
func (crq DiskAddRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if crq.Size == 0 {
|
if crq.Size == 0 {
|
||||||
@@ -36,30 +34,22 @@ func (crq DiskAddRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) DiskAdd(ctx context.Context, req DiskAddRequest, options ...opts.DecortOpts) (uint64, error) {
|
func (c Compute) DiskAdd(ctx context.Context, req DiskAddRequest) (uint64, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/diskAdd"
|
url := "/cloudapi/compute/diskAdd"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -3,20 +3,18 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DiskAttachRequest struct {
|
type DiskAttachRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
DiskID uint64 `url:"diskId"`
|
DiskID uint64 `url:"diskId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq DiskAttachRequest) Validate() error {
|
func (crq DiskAttachRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if crq.DiskID == 0 {
|
if crq.DiskID == 0 {
|
||||||
@@ -26,30 +24,22 @@ func (crq DiskAttachRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) DiskAttach(ctx context.Context, req DiskAttachRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) DiskAttach(ctx context.Context, req DiskAttachRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/diskAttach"
|
url := "/cloudapi/compute/diskAttach"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
result, err := strconv.ParseBool(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -3,21 +3,19 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DiskDelRequest struct {
|
type DiskDelRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
DiskID uint64 `url:"diskId"`
|
DiskID uint64 `url:"diskId"`
|
||||||
Permanently bool `url:"permanently"`
|
Permanently bool `url:"permanently"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq DiskDelRequest) Validate() error {
|
func (crq DiskDelRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if crq.DiskID == 0 {
|
if crq.DiskID == 0 {
|
||||||
@@ -27,30 +25,22 @@ func (crq DiskDelRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/diskDel"
|
url := "/cloudapi/compute/diskDel"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
result, err := strconv.ParseBool(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -3,20 +3,18 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DiskDetachRequest struct {
|
type DiskDetachRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
DiskID uint64 `url:"diskId"`
|
DiskID uint64 `url:"diskId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq DiskDetachRequest) Validate() error {
|
func (crq DiskDetachRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if crq.DiskID == 0 {
|
if crq.DiskID == 0 {
|
||||||
@@ -26,30 +24,22 @@ func (crq DiskDetachRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/diskDetach"
|
url := "/cloudapi/compute/diskDetach"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
result, err := strconv.ParseBool(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -3,21 +3,19 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DiskQOSRequest struct {
|
type DiskQOSRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
DiskID uint64 `url:"diskId"`
|
DiskID uint64 `url:"diskId"`
|
||||||
Limits string `url:"limits"`
|
Limits string `url:"limits"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq DiskQOSRequest) Validate() error {
|
func (crq DiskQOSRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if crq.DiskID == 0 {
|
if crq.DiskID == 0 {
|
||||||
@@ -31,30 +29,22 @@ func (crq DiskQOSRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/diskQos"
|
url := "/cloudapi/compute/diskQos"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
result, err := strconv.ParseBool(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -3,21 +3,19 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DiskResizeRequest struct {
|
type DiskResizeRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
DiskID uint64 `url:"diskId"`
|
DiskID uint64 `url:"diskId"`
|
||||||
Size uint64 `url:"size"`
|
Size uint64 `url:"size"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq DiskResizeRequest) Validate() error {
|
func (crq DiskResizeRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if crq.DiskID == 0 {
|
if crq.DiskID == 0 {
|
||||||
@@ -31,30 +29,22 @@ func (crq DiskResizeRequest) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/diskResize"
|
url := "/cloudapi/compute/diskResize"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
result, err := strconv.ParseBool(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -3,48 +3,38 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type EnableRequest struct {
|
type EnableRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq EnableRequest) Validate() error {
|
func (crq EnableRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) Enable(ctx context.Context, req EnableRequest, options ...opts.DecortOpts) (bool, error) {
|
func (c Compute) Enable(ctx context.Context, req EnableRequest) (bool, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/enable"
|
url := "/cloudapi/compute/enable"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
result, err := strconv.ParseBool(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -4,40 +4,30 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"github.com/rudecs/decort-sdk/opts"
|
|
||||||
"github.com/rudecs/decort-sdk/typed"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
ComputeId uint64 `url:"computeId"`
|
ComputeID uint64 `url:"computeId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (crq GetRequest) Validate() error {
|
func (crq GetRequest) Validate() error {
|
||||||
if crq.ComputeId == 0 {
|
if crq.ComputeID == 0 {
|
||||||
return errors.New("validation-error: field ComputeId can not be empty or equal to 0")
|
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Compute) Get(ctx context.Context, req GetRequest, options ...opts.DecortOpts) (*ComputeRecord, error) {
|
func (c Compute) Get(ctx context.Context, req GetRequest) (*ComputeRecord, error) {
|
||||||
err := req.Validate()
|
err := req.Validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "/compute/get"
|
url := "/cloudapi/compute/get"
|
||||||
prefix := "/cloudapi"
|
|
||||||
|
|
||||||
option := opts.New(options)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if option != nil {
|
|
||||||
if option.IsAdmin {
|
|
||||||
prefix = "/" + option.AdminValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = prefix + url
|
|
||||||
res, err := c.client.DecortApiCall(ctx, typed.POST, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user