v1.16.0
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// AuditsRequest struct to give list of account audits
|
||||
type AuditsRequest struct {
|
||||
// ID of the account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
}
|
||||
|
||||
// Audits gets audit records for the specified account object
|
||||
func (a Account) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/audits"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListAudits{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteRequest struct to delete account
|
||||
type DeleteRequest struct {
|
||||
// ID of account to delete
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// Whether to completely delete the account
|
||||
// Required: false
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
}
|
||||
|
||||
// Delete completes delete an account from the system Returns true if account is deleted or was already deleted or never existed
|
||||
func (a Account) Delete(ctx context.Context, req DeleteRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/delete"
|
||||
|
||||
result, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(result), nil
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DisableEnableRequest struct to change status of account
|
||||
type DisableEnableRequest struct {
|
||||
// ID of account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
}
|
||||
|
||||
// Disable disables an account
|
||||
func (a Account) Disable(ctx context.Context, req DisableEnableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(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
|
||||
}
|
||||
|
||||
// Enable enables an account
|
||||
func (a Account) Enable(ctx context.Context, req DisableEnableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(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,51 +0,0 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetConsumedCloudUnitsByTypeRequest struct to calculate the currently consumed cloud units of the specified type for all cloudspaces and resource groups in the account
|
||||
type GetConsumedCloudUnitsByTypeRequest struct {
|
||||
// ID an account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// Cloud unit resource type
|
||||
// Required: true
|
||||
CUType string `url:"cutype" json:"cutype" validate:"required,accountCUType"`
|
||||
}
|
||||
|
||||
// GetConsumedCloudUnitsByType calculates the currently consumed cloud units of the specified type for all cloudspaces
|
||||
// and resource groups in the account.
|
||||
// Possible types of cloud units are include:
|
||||
//
|
||||
// - CU_M: returns consumed memory in MB
|
||||
// - CU_C: returns number of virtual cpu cores
|
||||
// - CU_D: returns consumed virtual disk storage in GB
|
||||
// - CU_DM: returns consumed max virtual disk storage in GB
|
||||
// - CU_I: returns number of public IPs
|
||||
// - gpu_units: return number of GPU units
|
||||
func (a Account) GetConsumedCloudUnitsByType(ctx context.Context, req GetConsumedCloudUnitsByTypeRequest) (float64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(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,47 +0,0 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetReservedAccountUnitsRequest struct to calculate the reserved units for all cloudspaces and resource groups in the account
|
||||
type GetReservedAccountUnitsRequest struct {
|
||||
// ID an account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
}
|
||||
|
||||
// GetReservedAccountUnits calculates the reserved units for all cloudspaces and resource groups in the account.
|
||||
// Calculated cloud units are returned in a dict which includes:
|
||||
//
|
||||
// - CU_M: reserved memory in MB
|
||||
// - CU_C: number of cpu cores
|
||||
// - CU_D: reserved vdisk storage in GB
|
||||
// - CU_DM: reserved max vdisk storage in GB
|
||||
// - CU_I: number of public IPs
|
||||
func (a Account) GetReservedAccountUnits(ctx context.Context, req GetReservedAccountUnitsRequest) (*ResourceLimits, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/getReservedAccountUnits"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := ResourceLimits{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
@@ -203,11 +203,56 @@ type ListResourceConsumption struct {
|
||||
|
||||
// Information about computes
|
||||
type Computes struct {
|
||||
// Number of starting computes
|
||||
Starting uint64 `json:"STARTING"`
|
||||
|
||||
// Number of started computes
|
||||
Started uint64 `json:"started"`
|
||||
Started uint64 `json:"STARTED"`
|
||||
|
||||
// Number of stopping computes
|
||||
Stopping uint64 `json:"STOPPING"`
|
||||
|
||||
// Number of stopped computes
|
||||
Stopped uint64 `json:"stopped"`
|
||||
Stopped uint64 `json:"STOPPED"`
|
||||
|
||||
// Number of paused computes
|
||||
Paused uint64 `json:"PAUSED"`
|
||||
|
||||
// Number of pausing computes
|
||||
Pausing uint64 `json:"PAUSING"`
|
||||
|
||||
// Number of merging computes
|
||||
Merge uint64 `json:"MERGE"`
|
||||
|
||||
// Number of migrating computes
|
||||
Migrating uint64 `json:"MIGRATING"`
|
||||
|
||||
// Number of computes migrating in
|
||||
MigratingIn uint64 `json:"MIGRATING_IN"`
|
||||
|
||||
// Number of computes migrating out
|
||||
MigratingOut uint64 `json:"MIGRATING_OUT"`
|
||||
|
||||
// Number of computes in down status
|
||||
Down uint64 `json:"DOWN"`
|
||||
|
||||
// Number of scheduled computes
|
||||
Scheduled uint64 `json:"SCHEDULED"`
|
||||
|
||||
// Number of computes with stopped backup
|
||||
BackupStopped uint64 `json:"BACKUP_STOPPED"`
|
||||
|
||||
// Number of computes with running backup
|
||||
BackupRunning uint64 `json:"BACKUP_RUNNING"`
|
||||
|
||||
// Number of computes creating a snapshot
|
||||
Snapcreate uint64 `json:"SNAPCREATE"`
|
||||
|
||||
// Number of cloning computes
|
||||
Cloning uint64 `json:"CLONING"`
|
||||
|
||||
// Number of computes being rolled back
|
||||
Rollback uint64 `json:"ROLLBACK"`
|
||||
}
|
||||
|
||||
// Information about machines
|
||||
@@ -455,6 +500,9 @@ type ItemVINS struct {
|
||||
// Deleted time
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
// Enable Default Gateway
|
||||
EnableDefaultGateway bool `json:"enable_default_gateway"`
|
||||
|
||||
// External IP
|
||||
ExternalIP string `json:"externalIP"`
|
||||
|
||||
@@ -524,11 +572,56 @@ type ListAudits []ItemAudit
|
||||
|
||||
// Information compute in resource group
|
||||
type RGComputes struct {
|
||||
// Number of starting computes
|
||||
Starting uint64 `json:"STARTING"`
|
||||
|
||||
// Number of started computes
|
||||
Started uint64 `json:"Started"`
|
||||
Started uint64 `json:"STARTED"`
|
||||
|
||||
// Number of stopping computes
|
||||
Stopping uint64 `json:"STOPPING"`
|
||||
|
||||
// Number of stopped computes
|
||||
Stopped uint64 `json:"Stopped"`
|
||||
Stopped uint64 `json:"STOPPED"`
|
||||
|
||||
// Number of paused computes
|
||||
Paused uint64 `json:"PAUSED"`
|
||||
|
||||
// Number of pausing computes
|
||||
Pausing uint64 `json:"PAUSING"`
|
||||
|
||||
// Number of merging computes
|
||||
Merge uint64 `json:"MERGE"`
|
||||
|
||||
// Number of migrating computes
|
||||
Migrating uint64 `json:"MIGRATING"`
|
||||
|
||||
// Number of computes migrating in
|
||||
MigratingIn uint64 `json:"MIGRATING_IN"`
|
||||
|
||||
// Number of computes migrating out
|
||||
MigratingOut uint64 `json:"MIGRATING_OUT"`
|
||||
|
||||
// Number of computes in down status
|
||||
Down uint64 `json:"DOWN"`
|
||||
|
||||
// Number of scheduled computes
|
||||
Scheduled uint64 `json:"SCHEDULED"`
|
||||
|
||||
// Number of computes with stopped backup
|
||||
BackupStopped uint64 `json:"BACKUP_STOPPED"`
|
||||
|
||||
// Number of computes with running backup
|
||||
BackupRunning uint64 `json:"BACKUP_RUNNING"`
|
||||
|
||||
// Number of computes creating a snapshot
|
||||
Snapcreate uint64 `json:"SNAPCREATE"`
|
||||
|
||||
// Number of cloning computes
|
||||
Cloning uint64 `json:"CLONING"`
|
||||
|
||||
// Number of computes being rolled back
|
||||
Rollback uint64 `json:"ROLLBACK"`
|
||||
}
|
||||
|
||||
// Resources of Resource group
|
||||
|
||||
Reference in New Issue
Block a user