Merge 'dev' into 'main'
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"github.com/rudecs/decort-sdk/interfaces"
|
||||
)
|
||||
|
||||
type Account struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
func New(client interfaces.Caller) *Account {
|
||||
return &Account{
|
||||
client,
|
||||
}
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"github.com/rudecs/decort-sdk/interfaces"
|
||||
)
|
||||
|
||||
type Account struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
func New(client interfaces.Caller) *Account {
|
||||
return &Account{
|
||||
client,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,68 +1,58 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/internal/validators"
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type AddUserRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
UserId string `url:"userId"`
|
||||
AccessType string `url:"accesstype"`
|
||||
}
|
||||
|
||||
func (arq AddUserRequest) Validate() error {
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if arq.UserId == "" {
|
||||
return errors.New("validation-error: field UserId can not be empty")
|
||||
}
|
||||
|
||||
if arq.AccessType == "" {
|
||||
return errors.New("validation-error: field AccessType can not be empty")
|
||||
}
|
||||
|
||||
isValid := validators.StringInSlice(arq.AccessType, []string{"R", "RCX", "ARCXDU"})
|
||||
if !isValid {
|
||||
return errors.New("validation-error: field AccessType can be only R, RCX or ARCXDU")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) AddUser(ctx context.Context, req AddUserRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/account/addUser"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type AddUserRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
UserID string `url:"userId"`
|
||||
AccessType string `url:"accesstype"`
|
||||
}
|
||||
|
||||
func (arq AddUserRequest) Validate() error {
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if arq.UserID == "" {
|
||||
return errors.New("validation-error: field UserID can not be empty")
|
||||
}
|
||||
|
||||
if arq.AccessType == "" {
|
||||
return errors.New("validation-error: field AccessType can not be empty")
|
||||
}
|
||||
|
||||
isValid := validators.StringInSlice(arq.AccessType, []string{"R", "RCX", "ARCXDU"})
|
||||
if !isValid {
|
||||
return errors.New("validation-error: field AccessType can be only R, RCX or ARCXDU")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) AddUser(ctx context.Context, req AddUserRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/addUser"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,54 +1,43 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type AuditsRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq AuditsRequest) Validate() error {
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) Audits(ctx context.Context, req AuditsRequest, options ...opts.DecortOpts) (AccountAuditsList, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/account/audits"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
audits := AccountAuditsList{}
|
||||
|
||||
err = json.Unmarshal([]byte(auditsRaw), &audits)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return audits, nil
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type AuditsRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq AuditsRequest) Validate() error {
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) Audits(ctx context.Context, req AuditsRequest) (AccountAuditsList, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/audits"
|
||||
|
||||
auditsRaw, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
audits := AccountAuditsList{}
|
||||
|
||||
err = json.Unmarshal(auditsRaw, &audits)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return audits, nil
|
||||
}
|
||||
|
||||
@@ -1,65 +1,54 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type CreateRequest struct {
|
||||
Name string `url:"name"`
|
||||
Username string `url:"username"`
|
||||
EmailAddress string `url:"emailaddress,omitempty"`
|
||||
MaxMemoryCapacity uint `url:"maxMemoryCapacity,omitempty"`
|
||||
MaxVDiskCapacity uint `url:"maxVDiskCapacity,omitempty"`
|
||||
MaxCPUCapacity uint `url:"maxCPUCapacity,omitempty"`
|
||||
MaxNetworkPeerTransfer uint `url:"maxNetworkPeerTransfer,omitempty"`
|
||||
MaxNumPublicIP uint `url:"maxNumPublicIP,omitempty"`
|
||||
SendAccessEmails bool `url:"sendAccessEmails,omitempty"`
|
||||
GpuUnits uint `url:"gpu_units,omitempty"`
|
||||
}
|
||||
|
||||
func (arq CreateRequest) Validate() error {
|
||||
if arq.Name == "" {
|
||||
return errors.New("validation-error: field Name can not be empty")
|
||||
}
|
||||
|
||||
if arq.Username == "" {
|
||||
return errors.New("validation-error: field Username can not be empty")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) Create(ctx context.Context, req CreateRequest, options ...opts.DecortOpts) (uint64, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
url := "/account/create"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type CreateRequest struct {
|
||||
Name string `url:"name"`
|
||||
Username string `url:"username"`
|
||||
EmailAddress string `url:"emailaddress,omitempty"`
|
||||
MaxMemoryCapacity uint64 `url:"maxMemoryCapacity,omitempty"`
|
||||
MaxVDiskCapacity uint64 `url:"maxVDiskCapacity,omitempty"`
|
||||
MaxCPUCapacity uint64 `url:"maxCPUCapacity,omitempty"`
|
||||
MaxNetworkPeerTransfer uint64 `url:"maxNetworkPeerTransfer,omitempty"`
|
||||
MaxNumPublicIP uint64 `url:"maxNumPublicIP,omitempty"`
|
||||
SendAccessEmails bool `url:"sendAccessEmails,omitempty"`
|
||||
GPUUnits uint64 `url:"gpu_units,omitempty"`
|
||||
}
|
||||
|
||||
func (arq CreateRequest) Validate() error {
|
||||
if arq.Name == "" {
|
||||
return errors.New("validation-error: field Name can not be empty")
|
||||
}
|
||||
|
||||
if arq.Username == "" {
|
||||
return errors.New("validation-error: field Username can not be empty")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/create"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,52 +1,36 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type DeleteRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
Permanently bool `url:"permanently,omitempty"`
|
||||
}
|
||||
|
||||
func (arq DeleteRequest) Validate() error {
|
||||
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId must be set")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) Delete(ctx context.Context, req DeleteRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/account/delete"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
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 {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type DeleteRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
Permanently bool `url:"permanently,omitempty"`
|
||||
}
|
||||
|
||||
func (arq DeleteRequest) Validate() error {
|
||||
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID must be set")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/delete"
|
||||
|
||||
_, err = a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@@ -1,58 +1,47 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type DeleteUserRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
UserId string `url:"userId"`
|
||||
RecursiveDelete bool `url:"recursivedelete,omitempty"`
|
||||
}
|
||||
|
||||
func (arq DeleteUserRequest) Validate() error {
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if arq.UserId == "" {
|
||||
return errors.New("validation-error: field UserId can not be empty")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) DeleteUser(ctx context.Context, req DeleteUserRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/account/deleteUser"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type DeleteUserRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
UserID string `url:"userId"`
|
||||
RecursiveDelete bool `url:"recursivedelete,omitempty"`
|
||||
}
|
||||
|
||||
func (arq DeleteUserRequest) Validate() error {
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if arq.UserID == "" {
|
||||
return errors.New("validation-error: field UserID can not be empty")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) DeleteUser(ctx context.Context, req DeleteUserRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/deleteUser"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,80 +1,62 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type DisabelEnableRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq DisabelEnableRequest) Validate() error {
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) Disable(ctx context.Context, req DisabelEnableRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/account/disable"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
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 {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (a Account) Enable(ctx context.Context, req DisabelEnableRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/account/enable"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
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 {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type DisabelEnableRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq DisabelEnableRequest) Validate() error {
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) Disable(ctx context.Context, req DisabelEnableRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/disable"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (a Account) Enable(ctx context.Context, req DisabelEnableRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/enable"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,55 +1,44 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type GetRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq GetRequest) Validate() error {
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) Get(ctx context.Context, req GetRequest, options ...opts.DecortOpts) (*AccountWithResources, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/account/get"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
account := &AccountWithResources{}
|
||||
|
||||
err = json.Unmarshal(res, &account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return account, nil
|
||||
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq GetRequest) Validate() error {
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) Get(ctx context.Context, req GetRequest) (*AccountWithResources, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/get"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
account := &AccountWithResources{}
|
||||
|
||||
err = json.Unmarshal(res, &account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return account, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -1,55 +1,44 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type GetConsumedAccountUnitsRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq GetConsumedAccountUnitsRequest) Validate() error {
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) GetConsumedAccountUnits(ctx context.Context, req GetConsumedAccountUnitsRequest, options ...opts.DecortOpts) (*ResourceLimits, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/account/getConsumedAccountUnits"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rl := &ResourceLimits{}
|
||||
|
||||
err = json.Unmarshal(res, &rl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rl, nil
|
||||
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetConsumedAccountUnitsRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq GetConsumedAccountUnitsRequest) Validate() error {
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) GetConsumedAccountUnits(ctx context.Context, req GetConsumedAccountUnitsRequest) (*ResourceLimits, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/getConsumedAccountUnits"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rl := &ResourceLimits{}
|
||||
|
||||
err = json.Unmarshal(res, &rl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rl, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -1,64 +1,54 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/internal/validators"
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type GetConsumedCloudUnitsByTypeRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
CUType string `url:"cutype"`
|
||||
}
|
||||
|
||||
func (arq GetConsumedCloudUnitsByTypeRequest) Validate() error {
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if arq.CUType == "" {
|
||||
return errors.New("validation-error: field CUType can not be empty")
|
||||
}
|
||||
|
||||
isValid := validators.StringInSlice(arq.CUType, []string{"CU_M", "CU_C", "CU_D", "CU_S", "CU_A", "CU_NO", "CU_I", "CU_NP"})
|
||||
if !isValid {
|
||||
return errors.New("validation-error: field AccessType can be only CU_M, CU_C, CU_D, CU_S, CU_A, CU_NO, CU_I or CU_NP")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) GetConsumedCloudUnitsByType(ctx context.Context, req GetConsumedCloudUnitsByTypeRequest, options ...opts.DecortOpts) (float64, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
url := "/account/getConsumedCloudUnitsByType"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseFloat(string(res), 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type GetConsumedCloudUnitsByTypeRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
CUType string `url:"cutype"`
|
||||
}
|
||||
|
||||
func (arq GetConsumedCloudUnitsByTypeRequest) Validate() error {
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if arq.CUType == "" {
|
||||
return errors.New("validation-error: field CUType can not be empty")
|
||||
}
|
||||
|
||||
isValid := validators.StringInSlice(arq.CUType, []string{"CU_M", "CU_C", "CU_D", "CU_S", "CU_A", "CU_NO", "CU_I", "CU_NP"})
|
||||
if !isValid {
|
||||
return errors.New("validation-error: field AccessType can be only CU_M, CU_C, CU_D, CU_S, CU_A, CU_NO, CU_I or CU_NP")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) GetConsumedCloudUnitsByType(ctx context.Context, req GetConsumedCloudUnitsByTypeRequest) (float64, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/getConsumedCloudUnitsByType"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseFloat(string(res), 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -1,83 +1,65 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type GetConsumtionRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
Start uint64 `url:"start"`
|
||||
End uint64 `url:"end"`
|
||||
}
|
||||
|
||||
func (arq GetConsumtionRequest) Validate() error {
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if arq.Start == 0 {
|
||||
return errors.New("validation-error: field Start can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if arq.End == 0 {
|
||||
return errors.New("validation-error: field End can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) GetConsumtion(ctx context.Context, req GetConsumtionRequest, options ...opts.DecortOpts) (string, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
url := "/account/getConsumtion"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
|
||||
}
|
||||
|
||||
func (a Account) GetConsumtionGet(ctx context.Context, req GetConsumtionRequest, options ...opts.DecortOpts) (string, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
url := "/account/getConsumtion"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
if option != nil {
|
||||
if option.IsAdmin {
|
||||
prefix = "/" + option.AdminValue
|
||||
}
|
||||
}
|
||||
url = prefix + url
|
||||
res, err := a.client.DecortApiCall(ctx, typed.GET, url, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetConsumtionRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
Start uint64 `url:"start"`
|
||||
End uint64 `url:"end"`
|
||||
}
|
||||
|
||||
func (arq GetConsumtionRequest) Validate() error {
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if arq.Start == 0 {
|
||||
return errors.New("validation-error: field Start can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if arq.End == 0 {
|
||||
return errors.New("validation-error: field End can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) GetConsumtion(ctx context.Context, req GetConsumtionRequest) (string, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/getConsumtion"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
|
||||
}
|
||||
|
||||
func (a Account) GetConsumtionGet(ctx context.Context, req GetConsumtionRequest) (string, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
url := "/account/getConsumtion"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
url = prefix + url
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
|
||||
}
|
||||
|
||||
@@ -1,55 +1,44 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type GetReservedAccountUnitsRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq GetReservedAccountUnitsRequest) Validate() error {
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) GetReservedAccountUnits(ctx context.Context, req GetReservedAccountUnitsRequest, options ...opts.DecortOpts) (*ResourceLimits, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/account/getReservedAccountUnits"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rl := &ResourceLimits{}
|
||||
|
||||
err = json.Unmarshal(res, &rl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rl, nil
|
||||
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GetReservedAccountUnitsRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq GetReservedAccountUnitsRequest) Validate() error {
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) GetReservedAccountUnits(ctx context.Context, req GetReservedAccountUnitsRequest) (*ResourceLimits, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/getReservedAccountUnits"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rl := &ResourceLimits{}
|
||||
|
||||
err = json.Unmarshal(res, &rl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rl, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -1,42 +1,31 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type ListRequest struct {
|
||||
Page uint64 `url:"page"`
|
||||
Size uint64 `url:"size"`
|
||||
}
|
||||
|
||||
func (a Account) List(ctx context.Context, req ListRequest, options ...opts.DecortOpts) (AccountCloudApiList, error) {
|
||||
url := "/account/list"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accountList := AccountCloudApiList{}
|
||||
|
||||
err = json.Unmarshal(res, &accountList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountList, nil
|
||||
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ListRequest struct {
|
||||
Page uint64 `url:"page"`
|
||||
Size uint64 `url:"size"`
|
||||
}
|
||||
|
||||
func (a Account) List(ctx context.Context, req ListRequest) (AccountCloudApiList, error) {
|
||||
url := "/cloudapi/account/list"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accountList := AccountCloudApiList{}
|
||||
|
||||
err = json.Unmarshal(res, &accountList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountList, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -1,55 +1,44 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type ListComputesRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq ListComputesRequest) Validate() error {
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) ListComputes(ctx context.Context, req ListComputesRequest, options ...opts.DecortOpts) (AccountComputesList, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/account/listComputes"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accountComputesList := AccountComputesList{}
|
||||
|
||||
err = json.Unmarshal(res, &accountComputesList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountComputesList, nil
|
||||
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ListComputesRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq ListComputesRequest) Validate() error {
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) ListComputes(ctx context.Context, req ListComputesRequest) (AccountComputesList, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/listComputes"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accountComputesList := AccountComputesList{}
|
||||
|
||||
err = json.Unmarshal(res, &accountComputesList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountComputesList, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -1,42 +1,31 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type ListDeletedRequest struct {
|
||||
Page uint64 `url:"page"`
|
||||
Size uint64 `url:"size"`
|
||||
}
|
||||
|
||||
func (a Account) ListDeleted(ctx context.Context, req ListDeletedRequest, options ...opts.DecortOpts) (AccountCloudApiList, error) {
|
||||
url := "/account/listDeleted"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accountList := AccountCloudApiList{}
|
||||
|
||||
err = json.Unmarshal(res, &accountList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountList, nil
|
||||
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ListDeletedRequest struct {
|
||||
Page uint64 `url:"page"`
|
||||
Size uint64 `url:"size"`
|
||||
}
|
||||
|
||||
func (a Account) ListDeleted(ctx context.Context, req ListDeletedRequest) (AccountCloudApiList, error) {
|
||||
url := "/cloudapi/account/listDeleted"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accountList := AccountCloudApiList{}
|
||||
|
||||
err = json.Unmarshal(res, &accountList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountList, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -1,55 +1,44 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type ListDisksRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq ListDisksRequest) Validate() error {
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) ListDisks(ctx context.Context, req ListDisksRequest, options ...opts.DecortOpts) (AccountDisksList, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/account/listDisks"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accountDisksList := AccountDisksList{}
|
||||
|
||||
err = json.Unmarshal(res, &accountDisksList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountDisksList, nil
|
||||
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ListDisksRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq ListDisksRequest) Validate() error {
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) ListDisks(ctx context.Context, req ListDisksRequest) (AccountDisksList, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/listDisks"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accountDisksList := AccountDisksList{}
|
||||
|
||||
err = json.Unmarshal(res, &accountDisksList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountDisksList, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -1,55 +1,44 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type ListFlipGroupsRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq ListFlipGroupsRequest) Validate() error {
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) ListFlipGroups(ctx context.Context, req ListFlipGroupsRequest, options ...opts.DecortOpts) (AccountFlipGroupsList, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/account/listFlipGroups"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accountFlipGroupsList := AccountFlipGroupsList{}
|
||||
|
||||
err = json.Unmarshal(res, &accountFlipGroupsList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountFlipGroupsList, nil
|
||||
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ListFlipGroupsRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq ListFlipGroupsRequest) Validate() error {
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) ListFlipGroups(ctx context.Context, req ListFlipGroupsRequest) (AccountFlipGroupsList, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/listFlipGroups"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accountFlipGroupsList := AccountFlipGroupsList{}
|
||||
|
||||
err = json.Unmarshal(res, &accountFlipGroupsList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountFlipGroupsList, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -1,55 +1,44 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type ListRGRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq ListRGRequest) Validate() error {
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) ListRG(ctx context.Context, req ListRGRequest, options ...opts.DecortOpts) (AccountRGList, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/account/listRG"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accountRGList := AccountRGList{}
|
||||
|
||||
err = json.Unmarshal(res, &accountRGList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountRGList, nil
|
||||
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ListRGRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq ListRGRequest) Validate() error {
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) ListRG(ctx context.Context, req ListRGRequest) (AccountRGList, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/listRG"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accountRGList := AccountRGList{}
|
||||
|
||||
err = json.Unmarshal(res, &accountRGList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountRGList, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -1,56 +1,45 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type ListTemplatesRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
IncludeDeleted bool `url:"includedeleted"`
|
||||
}
|
||||
|
||||
func (arq ListTemplatesRequest) Validate() error {
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) ListTemplates(ctx context.Context, req ListTemplatesRequest, options ...opts.DecortOpts) (AccountTemplatesList, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/account/listTemplates"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accountTemplatesList := AccountTemplatesList{}
|
||||
|
||||
err = json.Unmarshal(res, &accountTemplatesList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountTemplatesList, nil
|
||||
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ListTemplatesRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
IncludeDeleted bool `url:"includedeleted"`
|
||||
}
|
||||
|
||||
func (arq ListTemplatesRequest) Validate() error {
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) ListTemplates(ctx context.Context, req ListTemplatesRequest) (AccountTemplatesList, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/listTemplates"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accountTemplatesList := AccountTemplatesList{}
|
||||
|
||||
err = json.Unmarshal(res, &accountTemplatesList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountTemplatesList, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -1,55 +1,44 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type ListVinsRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq ListVinsRequest) Validate() error {
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) ListVins(ctx context.Context, req ListVinsRequest, options ...opts.DecortOpts) (AccountVinsList, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/account/listVins"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accountVinsList := AccountVinsList{}
|
||||
|
||||
err = json.Unmarshal(res, &accountVinsList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountVinsList, nil
|
||||
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ListVINSRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq ListVINSRequest) Validate() error {
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) ListVINS(ctx context.Context, req ListVINSRequest) (AccountVINSList, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/listVins"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accountVINSList := AccountVINSList{}
|
||||
|
||||
err = json.Unmarshal(res, &accountVINSList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountVINSList, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -1,229 +1,229 @@
|
||||
package account
|
||||
|
||||
type AccountAclRecord struct {
|
||||
IsExplicit bool `json:"explicit"`
|
||||
GUID string `json:"guid"`
|
||||
Rights string `json:"right"`
|
||||
Status string `json:"status"`
|
||||
Type string `json:"type"`
|
||||
UgroupID string `json:"userGroupId"`
|
||||
CanBeDeleted bool `json:"canBeDeleted"`
|
||||
}
|
||||
|
||||
type ResourceLimits struct {
|
||||
CUC float64 `json:"CU_C"`
|
||||
CUD float64 `json:"CU_D"`
|
||||
CUI float64 `json:"CU_I"`
|
||||
CUM float64 `json:"CU_M"`
|
||||
CUNP float64 `json:"CU_NP"`
|
||||
GpuUnits float64 `json:"gpu_units"`
|
||||
}
|
||||
|
||||
type AccountRecord struct {
|
||||
DCLocation string `json:"DCLocation"`
|
||||
CKey string `jspn:"_ckey"`
|
||||
Meta []interface{} `json:"_meta"`
|
||||
Acl []AccountAclRecord `json:"acl"`
|
||||
Company string `json:"company"`
|
||||
CompanyUrl string `json:"companyurl"`
|
||||
CreatedBy string `jspn:"createdBy"`
|
||||
CreatedTime int `json:"createdTime"`
|
||||
DeactiovationTime float64 `json:"deactivationTime"`
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
DeletedTime int `json:"deletedTime"`
|
||||
DisplayName string `json:"displayname"`
|
||||
GUID int `json:"guid"`
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||
SendAccessEmails bool `json:"sendAccessEmails"`
|
||||
ServiceAccount bool `json:"serviceAccount"`
|
||||
Status string `json:"status"`
|
||||
UpdatedTime int `json:"updatedTime"`
|
||||
Version int `json:"version"`
|
||||
Vins []int `json:"vins"`
|
||||
}
|
||||
|
||||
type AccountList []AccountRecord
|
||||
|
||||
type AccountCloudApi struct {
|
||||
Acl []AccountAclRecord `json:"acl"`
|
||||
CreatedTime int `json:"createdTime"`
|
||||
DeletedTime int `json:"deletedTime"`
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
UpdatedTime int `json:"updatedTime"`
|
||||
}
|
||||
|
||||
type AccountCloudApiList []AccountCloudApi
|
||||
|
||||
type Resource struct {
|
||||
CPU int `json:"cpu"`
|
||||
Disksize int `json:"disksize"`
|
||||
Extips int `json:"extips"`
|
||||
Exttraffic int `json:"exttraffic"`
|
||||
GPU int `json:"gpu"`
|
||||
RAM int `json:"ram"`
|
||||
}
|
||||
|
||||
type Resources struct {
|
||||
Current Resource `json:"Current"`
|
||||
Reserved Resource `json:"Reserved"`
|
||||
}
|
||||
|
||||
type Computes struct {
|
||||
Started int `json:"started"`
|
||||
Stopped int `json:"stopped"`
|
||||
}
|
||||
|
||||
type Machines struct {
|
||||
Running int `json:"running"`
|
||||
Halted int `json:"halted"`
|
||||
}
|
||||
|
||||
type AccountWithResources struct {
|
||||
Account
|
||||
Resources Resources `json:"Resources"`
|
||||
Computes Computes `json:"computes"`
|
||||
Machines Machines `json:"machines"`
|
||||
Vinses int `json:"vinses"`
|
||||
}
|
||||
|
||||
type AccountCompute struct {
|
||||
AccountId int `json:"accountId"`
|
||||
AccountName string `json:"accountName"`
|
||||
CPUs int `json:"cpus"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
CreatedTime int `json:"createdTime"`
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
DeletedTime int `json:"deletedTime"`
|
||||
ComputeId int `json:"id"`
|
||||
ComputeName string `json:"name"`
|
||||
RAM int `json:"ram"`
|
||||
Registered bool `json:"registered"`
|
||||
RGId int `json:"rgId"`
|
||||
RGName string `json:"rgName"`
|
||||
Status string `json:"status"`
|
||||
TechStatus string `json:"techStatus"`
|
||||
TotalDisksSize int `json:"totalDisksSize"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
UpdatedTime int `json:"updatedTime"`
|
||||
UserManaged bool `json:"userManaged"`
|
||||
VinsConnected int `json:"vinsConnected"`
|
||||
}
|
||||
|
||||
type AccountComputesList []AccountCompute
|
||||
|
||||
type AccountDisk struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Pool string `json:"pool"`
|
||||
SepId int `json:"sepId"`
|
||||
SizeMax int `json:"sizeMax"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type AccountDisksList []AccountDisk
|
||||
|
||||
type AccountVin struct {
|
||||
AccountId int `json:"accountId"`
|
||||
AccountName string `json:"accountName"`
|
||||
Computes int `json:"computes"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
CreatedTime int `json:"createdTime"`
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
DeletedTime int `json:"deletedTime"`
|
||||
ExternalIP string `json:"externalIP"`
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Network string `json:"network"`
|
||||
PriVnfDevId int `json:"priVnfDevId"`
|
||||
RGId int `json:"rgId"`
|
||||
RGName string `json:"rgName"`
|
||||
Status string `json:"status"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
UpdatedTime int `json:"updatedTime"`
|
||||
}
|
||||
|
||||
type AccountVinsList []AccountVin
|
||||
|
||||
type AccountAudit struct {
|
||||
Call string `json:"call"`
|
||||
ResponseTime float64 `json:"responsetime"`
|
||||
StatusCode int `json:"statuscode"`
|
||||
Timestamp float64 `json:"timestamp"`
|
||||
User string `json:"user"`
|
||||
}
|
||||
|
||||
type AccountAuditsList []AccountAudit
|
||||
|
||||
type AccountRGComputes struct {
|
||||
Started int `json:"Started"`
|
||||
Stopped int `json:"Stopped"`
|
||||
}
|
||||
|
||||
type AccountRGResources struct {
|
||||
Consumed Resource `json:"Consumed"`
|
||||
Limits Resource `json:"Limits"`
|
||||
Reserved Resource `json:"Reserved"`
|
||||
}
|
||||
|
||||
type AccountRG struct {
|
||||
Computes AccountRGComputes `json:"Computes"`
|
||||
Resources AccountRGResources `json:"Resources"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
CreatedTime int `json:"createdTime"`
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
DeletedTime int `json:"deletedTime"`
|
||||
RGID int `json:"id"`
|
||||
Milestones int `json:"milestones"`
|
||||
RGName string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
UpdatedTime int `json:"updatedTime"`
|
||||
Vinses int `json:"vinses"`
|
||||
}
|
||||
|
||||
type AccountRGList []AccountRG
|
||||
|
||||
type AccountTemplate struct {
|
||||
UNCPath string `json:"UNCPath"`
|
||||
AccountId int `json:"accountId"`
|
||||
Description string `json:"desc"`
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Public bool `json:"public"`
|
||||
Size int `json:"size"`
|
||||
Status string `json:"status"`
|
||||
Type string `json:"type"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type AccountTemplatesList []AccountTemplate
|
||||
|
||||
type AccountFlipGroup struct {
|
||||
AccountId int `json:"accountId"`
|
||||
ClientType string `json:"clientType"`
|
||||
ConnType string `json:"connType"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
CreatedTime int `json:"createdTime"`
|
||||
DefaultGW string `json:"defaultGW"`
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
DeletedTime int `json:"deletedTime"`
|
||||
Description string `json:"desc"`
|
||||
GID int `json:"gid"`
|
||||
GUID int `json:"guid"`
|
||||
ID int `json:"id"`
|
||||
IP string `json:"ip"`
|
||||
Milestones int `json:"milestones"`
|
||||
Name string `json:"name"`
|
||||
NetID int `json:"netId"`
|
||||
NetType string `json:"netType"`
|
||||
NetMask int `json:"netmask"`
|
||||
Status string `json:"status"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
UpdatedTime int `json:"updatedTime"`
|
||||
}
|
||||
|
||||
type AccountFlipGroupsList []AccountFlipGroup
|
||||
package account
|
||||
|
||||
type AccountACLRecord struct {
|
||||
IsExplicit bool `json:"explicit"`
|
||||
GUID string `json:"guid"`
|
||||
Rights string `json:"right"`
|
||||
Status string `json:"status"`
|
||||
Type string `json:"type"`
|
||||
UgroupID string `json:"userGroupId"`
|
||||
CanBeDeleted bool `json:"canBeDeleted"`
|
||||
}
|
||||
|
||||
type ResourceLimits struct {
|
||||
CUC float64 `json:"CU_C"`
|
||||
CUD float64 `json:"CU_D"`
|
||||
CUI float64 `json:"CU_I"`
|
||||
CUM float64 `json:"CU_M"`
|
||||
CUNP float64 `json:"CU_NP"`
|
||||
GPUUnits float64 `json:"gpu_units"`
|
||||
}
|
||||
|
||||
type AccountRecord struct {
|
||||
DCLocation string `json:"DCLocation"`
|
||||
CKey string `jspn:"_ckey"`
|
||||
Meta []interface{} `json:"_meta"`
|
||||
ACL []AccountACLRecord `json:"acl"`
|
||||
Company string `json:"company"`
|
||||
CompanyURL string `json:"companyurl"`
|
||||
CreatedBy string `jspn:"createdBy"`
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
DeactiovationTime float64 `json:"deactivationTime"`
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
DisplayName string `json:"displayname"`
|
||||
GUID uint64 `json:"guid"`
|
||||
ID uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||
SendAccessEmails bool `json:"sendAccessEmails"`
|
||||
ServiceAccount bool `json:"serviceAccount"`
|
||||
Status string `json:"status"`
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
Version uint64 `json:"version"`
|
||||
VINS []uint64 `json:"vins"`
|
||||
}
|
||||
|
||||
type AccountList []AccountRecord
|
||||
|
||||
type AccountCloudApi struct {
|
||||
ACL []AccountACLRecord `json:"acl"`
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
ID uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
}
|
||||
|
||||
type AccountCloudApiList []AccountCloudApi
|
||||
|
||||
type Resource struct {
|
||||
CPU int64 `json:"cpu"`
|
||||
DiskSize int64 `json:"disksize"`
|
||||
ExtIPs int64 `json:"extips"`
|
||||
ExtTraffic int64 `json:"exttraffic"`
|
||||
GPU int64 `json:"gpu"`
|
||||
RAM int64 `json:"ram"`
|
||||
}
|
||||
|
||||
type Resources struct {
|
||||
Current Resource `json:"Current"`
|
||||
Reserved Resource `json:"Reserved"`
|
||||
}
|
||||
|
||||
type Computes struct {
|
||||
Started uint64 `json:"started"`
|
||||
Stopped uint64 `json:"stopped"`
|
||||
}
|
||||
|
||||
type Machines struct {
|
||||
Running uint64 `json:"running"`
|
||||
Halted uint64 `json:"halted"`
|
||||
}
|
||||
|
||||
type AccountWithResources struct {
|
||||
Account
|
||||
Resources Resources `json:"Resources"`
|
||||
Computes Computes `json:"computes"`
|
||||
Machines Machines `json:"machines"`
|
||||
VINSes uint64 `json:"vinses"`
|
||||
}
|
||||
|
||||
type AccountCompute struct {
|
||||
AccountID uint64 `json:"accountId"`
|
||||
AccountName string `json:"accountName"`
|
||||
CPUs uint64 `json:"cpus"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
ComputeID uint64 `json:"id"`
|
||||
ComputeName string `json:"name"`
|
||||
RAM uint64 `json:"ram"`
|
||||
Registered bool `json:"registered"`
|
||||
RGID uint64 `json:"rgId"`
|
||||
RGName string `json:"rgName"`
|
||||
Status string `json:"status"`
|
||||
TechStatus string `json:"techStatus"`
|
||||
TotalDisksSize uint64 `json:"totalDisksSize"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
UserManaged bool `json:"userManaged"`
|
||||
VINSConnected uint64 `json:"vinsConnected"`
|
||||
}
|
||||
|
||||
type AccountComputesList []AccountCompute
|
||||
|
||||
type AccountDisk struct {
|
||||
ID uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Pool string `json:"pool"`
|
||||
SepID uint64 `json:"sepId"`
|
||||
SizeMax uint64 `json:"sizeMax"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type AccountDisksList []AccountDisk
|
||||
|
||||
type AccountVIN struct {
|
||||
AccountID uint64 `json:"accountId"`
|
||||
AccountName string `json:"accountName"`
|
||||
Computes uint64 `json:"computes"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
ExternalIP string `json:"externalIP"`
|
||||
ID uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Network string `json:"network"`
|
||||
PriVnfDevID uint64 `json:"priVnfDevId"`
|
||||
RGID uint64 `json:"rgId"`
|
||||
RGName string `json:"rgName"`
|
||||
Status string `json:"status"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
}
|
||||
|
||||
type AccountVINSList []AccountVIN
|
||||
|
||||
type AccountAudit struct {
|
||||
Call string `json:"call"`
|
||||
ResponseTime float64 `json:"responsetime"`
|
||||
StatusCode uint64 `json:"statuscode"`
|
||||
Timestamp float64 `json:"timestamp"`
|
||||
User string `json:"user"`
|
||||
}
|
||||
|
||||
type AccountAuditsList []AccountAudit
|
||||
|
||||
type AccountRGComputes struct {
|
||||
Started uint64 `json:"Started"`
|
||||
Stopped uint64 `json:"Stopped"`
|
||||
}
|
||||
|
||||
type AccountRGResources struct {
|
||||
Consumed Resource `json:"Consumed"`
|
||||
Limits Resource `json:"Limits"`
|
||||
Reserved Resource `json:"Reserved"`
|
||||
}
|
||||
|
||||
type AccountRG struct {
|
||||
Computes AccountRGComputes `json:"Computes"`
|
||||
Resources AccountRGResources `json:"Resources"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
RGID uint64 `json:"id"`
|
||||
Milestones uint64 `json:"milestones"`
|
||||
RGName string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
VINSes uint64 `json:"vinses"`
|
||||
}
|
||||
|
||||
type AccountRGList []AccountRG
|
||||
|
||||
type AccountTemplate struct {
|
||||
UNCPath string `json:"UNCPath"`
|
||||
AccountID uint64 `json:"accountId"`
|
||||
Description string `json:"desc"`
|
||||
ID uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Public bool `json:"public"`
|
||||
Size uint64 `json:"size"`
|
||||
Status string `json:"status"`
|
||||
Type string `json:"type"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type AccountTemplatesList []AccountTemplate
|
||||
|
||||
type AccountFlipGroup struct {
|
||||
AccountID uint64 `json:"accountId"`
|
||||
ClientType string `json:"clientType"`
|
||||
ConnType string `json:"connType"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
DefaultGW string `json:"defaultGW"`
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
Description string `json:"desc"`
|
||||
GID uint64 `json:"gid"`
|
||||
GUID uint64 `json:"guid"`
|
||||
ID uint64 `json:"id"`
|
||||
IP string `json:"ip"`
|
||||
Milestones uint64 `json:"milestones"`
|
||||
Name string `json:"name"`
|
||||
NetID uint64 `json:"netId"`
|
||||
NetType string `json:"netType"`
|
||||
NetMask uint64 `json:"netmask"`
|
||||
Status string `json:"status"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
}
|
||||
|
||||
type AccountFlipGroupsList []AccountFlipGroup
|
||||
|
||||
@@ -1,53 +1,42 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type RestoreRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq RestoreRequest) Validate() error {
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) Restore(ctx context.Context, req RestoreRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/account/restore"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type RestoreRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
}
|
||||
|
||||
func (arq RestoreRequest) Validate() error {
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/restore"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -1,60 +1,49 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type UpdateRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
Name string `url:"name,omitempty"`
|
||||
MaxMemoryCapacity uint `url:"maxMemoryCapacity,omitempty"`
|
||||
MaxVDiskCapacity uint `url:"maxVDiskCapacity,omitempty"`
|
||||
MaxCPUCapacity uint `url:"maxCPUCapacity,omitempty"`
|
||||
MaxNetworkPeerTransfer uint `url:"maxNetworkPeerTransfer,omitempty"`
|
||||
MaxNumPublicIP uint `url:"maxNumPublicIP,omitempty"`
|
||||
SendAccessEmails bool `url:"sendAccessEmails,omitempty"`
|
||||
GpuUnits uint `url:"gpu_units,omitempty"`
|
||||
}
|
||||
|
||||
func (arq UpdateRequest) Validate() error {
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) Update(ctx context.Context, req UpdateRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/account/update"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type UpdateRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
Name string `url:"name,omitempty"`
|
||||
MaxMemoryCapacity uint64 `url:"maxMemoryCapacity,omitempty"`
|
||||
MaxVDiskCapacity uint64 `url:"maxVDiskCapacity,omitempty"`
|
||||
MaxCPUCapacity uint64 `url:"maxCPUCapacity,omitempty"`
|
||||
MaxNetworkPeerTransfer uint64 `url:"maxNetworkPeerTransfer,omitempty"`
|
||||
MaxNumPublicIP uint64 `url:"maxNumPublicIP,omitempty"`
|
||||
SendAccessEmails bool `url:"sendAccessEmails,omitempty"`
|
||||
GPUUnits uint64 `url:"gpu_units,omitempty"`
|
||||
}
|
||||
|
||||
func (arq UpdateRequest) Validate() error {
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/update"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,68 +1,58 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/internal/validators"
|
||||
"github.com/rudecs/decort-sdk/opts"
|
||||
"github.com/rudecs/decort-sdk/typed"
|
||||
)
|
||||
|
||||
type UpdateUserRequest struct {
|
||||
AccountId uint64 `url:"accountId"`
|
||||
UserId string `url:"userId"`
|
||||
AccessType string `url:"accesstype"`
|
||||
}
|
||||
|
||||
func (arq UpdateUserRequest) Validate() error {
|
||||
if arq.AccountId == 0 {
|
||||
return errors.New("validation-error: field AccountId can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if arq.UserId == "" {
|
||||
return errors.New("validation-error: field UserId can not be empty")
|
||||
}
|
||||
|
||||
if arq.AccessType == "" {
|
||||
return errors.New("validation-error: field AccessType can not be empty")
|
||||
}
|
||||
|
||||
isValid := validators.StringInSlice(arq.AccessType, []string{"R", "RCX", "ARCXDU"})
|
||||
if !isValid {
|
||||
return errors.New("validation-error: field AccessType can be only R, RCX or ARCXDU")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) UpdateUser(ctx context.Context, req UpdateUserRequest, options ...opts.DecortOpts) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/account/updateUser"
|
||||
prefix := "/cloudapi"
|
||||
|
||||
option := opts.New(options)
|
||||
|
||||
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 {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type UpdateUserRequest struct {
|
||||
AccountID uint64 `url:"accountId"`
|
||||
UserID string `url:"userId"`
|
||||
AccessType string `url:"accesstype"`
|
||||
}
|
||||
|
||||
func (arq UpdateUserRequest) Validate() error {
|
||||
if arq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if arq.UserID == "" {
|
||||
return errors.New("validation-error: field UserID can not be empty")
|
||||
}
|
||||
|
||||
if arq.AccessType == "" {
|
||||
return errors.New("validation-error: field AccessType can not be empty")
|
||||
}
|
||||
|
||||
isValid := validators.StringInSlice(arq.AccessType, []string{"R", "RCX", "ARCXDU"})
|
||||
if !isValid {
|
||||
return errors.New("validation-error: field AccessType can be only R, RCX or ARCXDU")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a Account) UpdateUser(ctx context.Context, req UpdateUserRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/updateUser"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user