Compare commits
	
		
			39 Commits 
		
	
	
		
			gos_tech_1
			...
			main
		
	
	| @ -1,62 +0,0 @@ | |||||||
| # Decort SDK |  | ||||||
| 
 |  | ||||||
| Decort SDK is a library, written in GO (Golang) for interact with the **DECORT** API.   |  | ||||||
| The library contents structures and methods for requesting to an user (cloudapi) and admin (cloudbroker) groups of API.   |  | ||||||
| Also the library have structures for responses. |  | ||||||
| 
 |  | ||||||
| ## Contents |  | ||||||
| 
 |  | ||||||
| - [Install](#install) |  | ||||||
| - [API List](#api-list) |  | ||||||
| - [Examples](#examples) |  | ||||||
| - [Examples2](#examples2) |  | ||||||
| 
 |  | ||||||
| ## Install |  | ||||||
| 
 |  | ||||||
| ```bash |  | ||||||
| go get -u repository.basistech.ru/BASIS/decort-golang-sdk |  | ||||||
| ``` |  | ||||||
| 
 |  | ||||||
| ## API List |  | ||||||
| 
 |  | ||||||
| ## Examples |  | ||||||
| 
 |  | ||||||
| ```go |  | ||||||
| package main |  | ||||||
| 
 |  | ||||||
| import ( |  | ||||||
| 	"context" |  | ||||||
| 	"fmt" |  | ||||||
| 	"log" |  | ||||||
| 
 |  | ||||||
| 	"repository.basistech.ru/BASIS/decort-golang-sdk/config" |  | ||||||
| 	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/kvmx86" |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| func main() { |  | ||||||
| 	cfg := config.Config{ |  | ||||||
| 		AppID:     "<APPID>", |  | ||||||
| 		AppSecret: "<APPSECRET>", |  | ||||||
| 		SSOURL:    "https://sso.digitalenergy.online", |  | ||||||
| 		DecortURL: "https://mr4.digitalenergy.online", |  | ||||||
| 		Retries:   5, |  | ||||||
| 	} |  | ||||||
| 	client := decort.New(cfg) |  | ||||||
| 	req := kvmx86.CreateRequest{ |  | ||||||
| 		RGID:    123, |  | ||||||
| 		Name:    "compute", |  | ||||||
| 		CPU:     4, |  | ||||||
| 		RAM:     4096, |  | ||||||
| 		ImageID: 321, |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	res, err := client.KVMX86().Create(context.Background(), req) |  | ||||||
| 	if err != nil { |  | ||||||
| 		log.Fatal(err) |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	fmt.Println(res) |  | ||||||
| } |  | ||||||
| ``` |  | ||||||
| 
 |  | ||||||
| ## Examples2 |  | ||||||
| @ -0,0 +1,106 @@ | |||||||
|  | package decortsdk | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"encoding/json" | ||||||
|  | 	"errors" | ||||||
|  | 	"fmt" | ||||||
|  | 	"net/http" | ||||||
|  | 	"strings" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | type CheckInfo struct { | ||||||
|  | 	Version string `json:"version"` | ||||||
|  | 	Build   uint64 `json:"build"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | const versionURL = "/system/info/version" | ||||||
|  | 
 | ||||||
|  | func (de DecortClient) Check() (*CheckInfo, error) { | ||||||
|  | 	res, err := de.DecortApiCall(context.Background(), http.MethodGet, versionURL, nil) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	info := CheckInfo{} | ||||||
|  | 
 | ||||||
|  | 	err = json.Unmarshal([]byte(strings.Replace(strings.Trim(string(res), `"`), "\\", "", -1)), &info) | ||||||
|  | 	if err != nil { | ||||||
|  | 		var v string | ||||||
|  | 		json.Unmarshal([]byte(res), &v) | ||||||
|  | 		if _, exists := constants.VersionMap[v]; exists { | ||||||
|  | 			info.Version = v | ||||||
|  | 		} else { | ||||||
|  | 			return nil, fmt.Errorf("platform version isn't supported") | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	if v, ok := constants.VersionMap[info.Version]; ok { | ||||||
|  | 		if v == "-" { | ||||||
|  | 			return &info, nil | ||||||
|  | 		} | ||||||
|  | 		return nil, errors.New(fmt.Sprintf("SDK don't support platform version %s, please use %s SDK version", info.Version, v)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return nil, errors.New(fmt.Sprintf("platform version %s isn't supported", info.Version)) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (bvs BVSDecortClient) Check() (*CheckInfo, error) { | ||||||
|  | 	res, err := bvs.DecortApiCall(context.Background(), http.MethodGet, versionURL, nil) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	info := CheckInfo{} | ||||||
|  | 
 | ||||||
|  | 	err = json.Unmarshal([]byte(strings.Replace(strings.Trim(string(res), `"`), "\\", "", -1)), &info) | ||||||
|  | 	if err != nil { | ||||||
|  | 		var v string | ||||||
|  | 		json.Unmarshal([]byte(res), &v) | ||||||
|  | 		if _, exists := constants.VersionMap[v]; exists { | ||||||
|  | 			info.Version = v | ||||||
|  | 		} else { | ||||||
|  | 			return nil, fmt.Errorf("platform version isn't supported") | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	if v, ok := constants.VersionMap[info.Version]; ok { | ||||||
|  | 		if v == "-" { | ||||||
|  | 			return &info, nil | ||||||
|  | 		} | ||||||
|  | 		return nil, errors.New(fmt.Sprintf("SDK don't support platform version %s, please use %s SDK version", info.Version, v)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return nil, errors.New(fmt.Sprintf("platform version %s isn't supported", info.Version)) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (ldc LegacyDecortClient) Check() (*CheckInfo, error) { | ||||||
|  | 	res, err := ldc.DecortApiCall(context.Background(), http.MethodGet, versionURL, nil) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	info := CheckInfo{} | ||||||
|  | 
 | ||||||
|  | 	err = json.Unmarshal([]byte(strings.Replace(strings.Trim(string(res), `"`), "\\", "", -1)), &info) | ||||||
|  | 	if err != nil { | ||||||
|  | 		var v string | ||||||
|  | 		json.Unmarshal([]byte(res), &v) | ||||||
|  | 		if _, exists := constants.VersionMap[v]; exists { | ||||||
|  | 			info.Version = v | ||||||
|  | 		} else { | ||||||
|  | 			return nil, fmt.Errorf("platform version isn't supported") | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	if v, ok := constants.VersionMap[info.Version]; ok { | ||||||
|  | 		if v == "-" { | ||||||
|  | 			return &info, nil | ||||||
|  | 		} | ||||||
|  | 		return nil, errors.New(fmt.Sprintf("SDK don't support platform version %s, please use %s SDK version", info.Version, v)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return nil, errors.New(fmt.Sprintf("platform version %s isn't supported", info.Version)) | ||||||
|  | } | ||||||
| @ -0,0 +1,216 @@ | |||||||
|  | package config | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"encoding/json" | ||||||
|  | 	"os" | ||||||
|  | 	"time" | ||||||
|  | 
 | ||||||
|  | 	"gopkg.in/yaml.v3" | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/serialization" | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | type BVSConfig struct { | ||||||
|  | 	// ServiceAccount username
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	// Example : "osh_mikoev"
 | ||||||
|  | 	Username string `json:"username" yaml:"username" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// ServiceAccount password
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	// Example: "[1o>hYkjnJr)HI78q7t&#%8Lm"
 | ||||||
|  | 	Password string `json:"password" yaml:"password" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// Domain name
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	// Example: "dynamix"
 | ||||||
|  | 	Domain string `json:"domain" yaml:"domain" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// Application (client) identifier for authorization
 | ||||||
|  | 	// in the cloud platform controller in oauth2 mode.
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	// Example: "ewqfrvea7s890avw804389qwguf234h0otfi3w4eiu"
 | ||||||
|  | 	AppID string `json:"appId" yaml:"appId" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// Application (client) secret code for authorization
 | ||||||
|  | 	// in the cloud platform controller in oauth2 mode.
 | ||||||
|  | 	// Example: "frvet09rvesfis0c9erv9fsov0vsdfi09ovds0f"
 | ||||||
|  | 	AppSecret string `json:"appSecret" yaml:"appSecret" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// Platform authentication service address
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	// Example: "https://sso.digitalenergy.online"
 | ||||||
|  | 	SSOURL string `json:"ssoUrl" yaml:"ssoUrl" validate:"url"` | ||||||
|  | 
 | ||||||
|  | 	// The address of the platform on which the actions are planned
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	// Example: "https://mr4.digitalenergy.online"
 | ||||||
|  | 	DecortURL string `json:"decortUrl" yaml:"decortUrl" validate:"url"` | ||||||
|  | 
 | ||||||
|  | 	// JWT platform token
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	// Example: "qwqwdfwv68979we0q9bfv7e9sbvd89798qrwv97ff"
 | ||||||
|  | 	Token Token `json:"token" yaml:"token"` | ||||||
|  | 
 | ||||||
|  | 	// Amount platform request attempts
 | ||||||
|  | 	// Default value: 5
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	Retries uint64 `json:"retries" yaml:"retries"` | ||||||
|  | 
 | ||||||
|  | 	// Skip verify
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	SSLSkipVerify bool `json:"sslSkipVerify" yaml:"sslSkipVerify"` | ||||||
|  | 
 | ||||||
|  | 	// HTTP client timeout, unlimited if left empty
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	Timeout Duration `json:"timeout" yaml:"timeout"` | ||||||
|  | 
 | ||||||
|  | 	// The path of the configuration file entry
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	PathCfg string `json:"path_cfg" yaml:"path_cfg"` | ||||||
|  | 
 | ||||||
|  | 	// The path of the token file entry
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	PathToken string `json:"path_token" yaml:"path_token"` | ||||||
|  | 
 | ||||||
|  | 	// The number of minutes before the expiration of the token, a refresh will be made
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	TimeToRefresh int64 `json:"timeToRefresh" yaml:"timeToRefresh"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | type Token struct { | ||||||
|  | 	// AccessToken is the token that authorizes and authenticates
 | ||||||
|  | 	// the requests.
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	AccessToken string `json:"access_token" yaml:"access_token"` | ||||||
|  | 
 | ||||||
|  | 	// TokenType is the type of token.
 | ||||||
|  | 	// The Type method returns either this or "Bearer", the default.
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	TokenType string `json:"token_type" yaml:"token_type"` | ||||||
|  | 
 | ||||||
|  | 	// RefreshToken is a token that's used by the application
 | ||||||
|  | 	// (as opposed to the user) to refresh the access token
 | ||||||
|  | 	// if it expires.
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	RefreshToken string `json:"refresh_token" yaml:"refresh_token"` | ||||||
|  | 
 | ||||||
|  | 	// Expiry is the optional expiration time of the access token.
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	Expiry time.Time `json:"expiry" yaml:"expiry"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // SetTimeout is used to set HTTP client timeout.
 | ||||||
|  | func (c *BVSConfig) SetTimeout(dur time.Duration) { | ||||||
|  | 	c.Timeout = Duration(dur) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // ParseConfigJSON parses Config from specified JSON-formatted file.
 | ||||||
|  | func ParseConfigBVSJSON(path string) (BVSConfig, error) { | ||||||
|  | 	file, err := os.ReadFile(path) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return BVSConfig{}, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	var config BVSConfig | ||||||
|  | 
 | ||||||
|  | 	err = json.Unmarshal(file, &config) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return BVSConfig{}, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	err = validators.ValidateConfig(config) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return BVSConfig{}, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return config, nil | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // ParseConfigJSON parses Token from specified JSON-formatted file.
 | ||||||
|  | func ParseTokenBVSJSON(path string) (Token, error) { | ||||||
|  | 	file, err := os.ReadFile(path) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return Token{}, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	var token Token | ||||||
|  | 
 | ||||||
|  | 	err = json.Unmarshal(file, &token) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return Token{}, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	err = validators.ValidateConfig(token) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return Token{}, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return token, nil | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // ParseTokenBVSYAML parses Token from specified YAML-formatted file.
 | ||||||
|  | func ParseTokenBVSYAML(path string) (Token, error) { | ||||||
|  | 	file, err := os.ReadFile(path) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return Token{}, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	var token Token | ||||||
|  | 
 | ||||||
|  | 	err = yaml.Unmarshal(file, &token) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return Token{}, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	err = validators.ValidateConfig(token) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return Token{}, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return token, nil | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // ParseConfigYAML parses Config from specified YAML-formatted file.
 | ||||||
|  | func ParseConfigBVSYAML(path string) (BVSConfig, error) { | ||||||
|  | 	file, err := os.ReadFile(path) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return BVSConfig{}, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	var config BVSConfig | ||||||
|  | 
 | ||||||
|  | 	err = yaml.Unmarshal(file, &config) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return BVSConfig{}, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	err = validators.ValidateConfig(config) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return BVSConfig{}, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return config, nil | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (t Token) Serialize(params ...string) (serialization.Serialized, error) { | ||||||
|  | 	if len(params) > 1 { | ||||||
|  | 		prefix := params[0] | ||||||
|  | 		indent := params[1] | ||||||
|  | 
 | ||||||
|  | 		return json.MarshalIndent(t, prefix, indent) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return json.Marshal(t) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (c BVSConfig) Serialize(params ...string) (serialization.Serialized, error) { | ||||||
|  | 	if len(params) > 1 { | ||||||
|  | 		prefix := params[0] | ||||||
|  | 		indent := params[1] | ||||||
|  | 
 | ||||||
|  | 		return json.MarshalIndent(c, prefix, indent) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return json.Marshal(c) | ||||||
|  | } | ||||||
| @ -0,0 +1,8 @@ | |||||||
|  | package config | ||||||
|  | 
 | ||||||
|  | // UniversalConfig combines configurations for different types of clients
 | ||||||
|  | type UniversalConfig struct { | ||||||
|  | 	Decs3oConfig *Config       `json:"decs3oConfig,omitempty" yaml:"decs3oConfig,omitempty"` | ||||||
|  | 	BVSConfig    *BVSConfig    `json:"bvsConfig,omitempty" yaml:"bvsConfig,omitempty"` | ||||||
|  | 	LegacyConfig *LegacyConfig `json:"legacyConfig,omitempty" yaml:"legacyConfig,omitempty"` | ||||||
|  | } | ||||||
| @ -1,19 +1,21 @@ | |||||||
| module repository.basistech.ru/BASIS/decort-golang-sdk | module repository.basistech.ru/BASIS/decort-golang-sdk | ||||||
| 
 | 
 | ||||||
| go 1.20 | go 1.24.0 | ||||||
| 
 | 
 | ||||||
| require ( | require ( | ||||||
| 	github.com/go-playground/validator/v10 v10.11.2 | 	github.com/go-playground/validator/v10 v10.28.0 | ||||||
| 	github.com/google/go-querystring v1.1.0 | 	github.com/google/go-querystring v1.1.0 | ||||||
|  | 	github.com/joho/godotenv v1.5.1 | ||||||
| 	gopkg.in/yaml.v3 v3.0.1 | 	gopkg.in/yaml.v3 v3.0.1 | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| require ( | require ( | ||||||
|  | 	github.com/gabriel-vasile/mimetype v1.4.10 // indirect | ||||||
| 	github.com/go-playground/locales v0.14.1 // indirect | 	github.com/go-playground/locales v0.14.1 // indirect | ||||||
| 	github.com/go-playground/universal-translator v0.18.1 // indirect | 	github.com/go-playground/universal-translator v0.18.1 // indirect | ||||||
| 	github.com/kr/text v0.2.0 // indirect | 	github.com/google/go-cmp v0.5.9 // indirect | ||||||
| 	github.com/leodido/go-urn v1.2.1 // indirect | 	github.com/leodido/go-urn v1.4.0 // indirect | ||||||
| 	golang.org/x/crypto v0.5.0 // indirect | 	golang.org/x/crypto v0.42.0 // indirect | ||||||
| 	golang.org/x/sys v0.4.0 // indirect | 	golang.org/x/sys v0.36.0 // indirect | ||||||
| 	golang.org/x/text v0.6.0 // indirect | 	golang.org/x/text v0.29.0 // indirect | ||||||
| ) | ) | ||||||
|  | |||||||
| @ -0,0 +1,7 @@ | |||||||
|  | package interfaces | ||||||
|  | 
 | ||||||
|  | // Interface to valiate RAM values
 | ||||||
|  | type RequestWithRAM interface { | ||||||
|  | 	// GetRAM returns RAM values
 | ||||||
|  | 	GetRAM() map[string]uint64 | ||||||
|  | } | ||||||
| @ -0,0 +1,36 @@ | |||||||
|  | package constants | ||||||
|  | 
 | ||||||
|  | const ( | ||||||
|  | 	RESTMACHINE = "/restmachine" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | const ( | ||||||
|  | 	MIMEJSON              = "application/json" | ||||||
|  | 	MIMEHTML              = "text/html" | ||||||
|  | 	MIMEXML               = "application/xml" | ||||||
|  | 	MIMEXML2              = "text/xml" | ||||||
|  | 	MIMEPlain             = "text/plain" | ||||||
|  | 	MIMEPOSTForm          = "application/x-www-form-urlencoded" | ||||||
|  | 	MIMEMultipartPOSTForm = "multipart/form-data" | ||||||
|  | 	MIMEPROTOBUF          = "application/x-protobuf" | ||||||
|  | 	MIMEMSGPACK           = "application/x-msgpack" | ||||||
|  | 	MIMEMSGPACK2          = "application/msgpack" | ||||||
|  | 	MIMEYAML              = "application/x-yaml" | ||||||
|  | 	MIMEYAML2             = "application/yaml" | ||||||
|  | 	MIMETOML              = "application/toml" | ||||||
|  | 	MIMESTREAM            = "application/octet-stream" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | var FileName = map[string]string{ | ||||||
|  | 	"OidcCertificate": "ca.crt", | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | var K8sValues = []string{"labels", "taints", "annotations, additionalSANs"} | ||||||
|  | 
 | ||||||
|  | var VersionMap = map[string]string{ | ||||||
|  | 	"4.4.0": "-", | ||||||
|  | 	"4.3.0": "-", | ||||||
|  | 	"4.2.0": "-", | ||||||
|  | 	"4.1.1": "-", | ||||||
|  | 	"4.1.0": "-", | ||||||
|  | } | ||||||
| @ -1,75 +0,0 @@ | |||||||
| package account |  | ||||||
| 
 |  | ||||||
| import ( |  | ||||||
| 	"context" |  | ||||||
| 	"net/http" |  | ||||||
| 	"strconv" |  | ||||||
| 
 |  | ||||||
| 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| // CreateRequest struct for creating account
 |  | ||||||
| type CreateRequest struct { |  | ||||||
| 	// Display name
 |  | ||||||
| 	// Required: true
 |  | ||||||
| 	Name string `url:"name" json:"name" validate:"required"` |  | ||||||
| 
 |  | ||||||
| 	// Name of the account
 |  | ||||||
| 	// Required: true
 |  | ||||||
| 	Username string `url:"username" json:"username" validate:"required"` |  | ||||||
| 
 |  | ||||||
| 	// Email
 |  | ||||||
| 	// Required: false
 |  | ||||||
| 	EmailAddress string `url:"emailaddress,omitempty" json:"emailaddress,omitempty" validate:"omitempty,email"` |  | ||||||
| 
 |  | ||||||
| 	// Max size of memory in MB
 |  | ||||||
| 	// Required: false
 |  | ||||||
| 	MaxMemoryCapacity int64 `url:"maxMemoryCapacity,omitempty" json:"maxMemoryCapacity,omitempty"` |  | ||||||
| 
 |  | ||||||
| 	// Max size of aggregated vdisks in GB
 |  | ||||||
| 	// Required: false
 |  | ||||||
| 	MaxVDiskCapacity int64 `url:"maxVDiskCapacity,omitempty" json:"maxVDiskCapacity,omitempty"` |  | ||||||
| 
 |  | ||||||
| 	// Max number of CPU cores
 |  | ||||||
| 	// Required: false
 |  | ||||||
| 	MaxCPUCapacity int64 `url:"maxCPUCapacity,omitempty" json:"maxCPUCapacity,omitempty"` |  | ||||||
| 
 |  | ||||||
| 	// Max sent/received network transfer peering
 |  | ||||||
| 	// Required: false
 |  | ||||||
| 	MaxNetworkPeerTransfer int64 `url:"maxNetworkPeerTransfer,omitempty" json:"maxNetworkPeerTransfer,omitempty"` |  | ||||||
| 
 |  | ||||||
| 	// Max number of assigned public IPs
 |  | ||||||
| 	// Required: false
 |  | ||||||
| 	MaxNumPublicIP int64 `url:"maxNumPublicIP,omitempty" json:"maxNumPublicIP,omitempty"` |  | ||||||
| 
 |  | ||||||
| 	// If true send emails when a user is granted access to resources
 |  | ||||||
| 	// Required: false
 |  | ||||||
| 	SendAccessEmails bool `url:"sendAccessEmails" json:"sendAccessEmails"` |  | ||||||
| 
 |  | ||||||
| 	// Limit (positive) or disable (0) GPU resources
 |  | ||||||
| 	// Required: false
 |  | ||||||
| 	GPUUnits int64 `url:"gpu_units,omitempty" json:"gpu_units,omitempty"` |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // Create creates account
 |  | ||||||
| // Setting a cloud unit maximum to -1 or empty will not put any restrictions on the resource
 |  | ||||||
| func (a Account) Create(ctx context.Context, req CreateRequest) (uint64, error) { |  | ||||||
| 	err := validators.ValidateRequest(req) |  | ||||||
| 	if err != nil { |  | ||||||
| 		return 0, validators.ValidationErrors(validators.GetErrors(err)) |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	url := "/cloudapi/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,58 +0,0 @@ | |||||||
| package account |  | ||||||
| 
 |  | ||||||
| import ( |  | ||||||
| 	"context" |  | ||||||
| 	"net/http" |  | ||||||
| 
 |  | ||||||
| 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| // GetConsumptionRequest struct to download the resources tracking files for an account
 |  | ||||||
| type GetConsumptionRequest struct { |  | ||||||
| 	// ID an account
 |  | ||||||
| 	// Required: true
 |  | ||||||
| 	AccountID uint64 `url:"accountId" json:"accountId" validate:"required"` |  | ||||||
| 
 |  | ||||||
| 	// Epoch represents the start time
 |  | ||||||
| 	// Required: true
 |  | ||||||
| 	Start uint64 `url:"start" json:"start" validate:"required"` |  | ||||||
| 
 |  | ||||||
| 	// Epoch represents the end time
 |  | ||||||
| 	// Required: true
 |  | ||||||
| 	End uint64 `url:"end" json:"end" validate:"required"` |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // GetConsumption downloads the resources tracking files for an account within a given period
 |  | ||||||
| func (a Account) GetConsumption(ctx context.Context, req GetConsumptionRequest) (string, error) { |  | ||||||
| 	err := validators.ValidateRequest(req) |  | ||||||
| 	if err != nil { |  | ||||||
| 		return "", validators.ValidationErrors(validators.GetErrors(err)) |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	url := "/cloudapi/account/getConsumption" |  | ||||||
| 
 |  | ||||||
| 	res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) |  | ||||||
| 	if err != nil { |  | ||||||
| 		return "", err |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	return string(res), nil |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // GetConsumptionGet downloads the resources tracking files for an account within a given period
 |  | ||||||
| func (a Account) GetConsumptionGet(ctx context.Context, req GetConsumptionRequest) (string, error) { |  | ||||||
| 	err := validators.ValidateRequest(req) |  | ||||||
| 	if err != nil { |  | ||||||
| 		return "", validators.ValidationErrors(validators.GetErrors(err)) |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	url := "/cloudapi/account/getConsumption" |  | ||||||
| 
 |  | ||||||
| 	res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, req) |  | ||||||
| 	if err != nil { |  | ||||||
| 		return "", err |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	return string(res), nil |  | ||||||
| } |  | ||||||
| @ -0,0 +1,10 @@ | |||||||
|  | package cloudapi | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/audit" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // Accessing the Stack method group
 | ||||||
|  | func (ca *CloudAPI) Audit() *audit.Audit { | ||||||
|  | 	return audit.New(ca.client) | ||||||
|  | } | ||||||
| @ -0,0 +1,15 @@ | |||||||
|  | package audit | ||||||
|  | 
 | ||||||
|  | import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces" | ||||||
|  | 
 | ||||||
|  | // Structure for creating request to audit
 | ||||||
|  | type Audit struct { | ||||||
|  | 	client interfaces.Caller | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Builder for audit endpoint
 | ||||||
|  | func New(client interfaces.Caller) *Audit{ | ||||||
|  | 	return &Audit{ | ||||||
|  | 		client: client, | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @ -0,0 +1,81 @@ | |||||||
|  | package audit | ||||||
|  | 
 | ||||||
|  | // FilterByID returns ListAudits with specified ID.
 | ||||||
|  | func (la ListAudits) FilterByID(guid string) ListAudits { | ||||||
|  | 	predicate := func(ia ItemAudit) bool { | ||||||
|  | 		return ia.GUID == guid | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return la.FilterFunc(predicate) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // FilterByCall returns ListAudits with specified call.
 | ||||||
|  | func (la ListAudits) FilterByCall(call string) ListAudits { | ||||||
|  | 	predicate := func(ic ItemAudit) bool { | ||||||
|  | 		return ic.Call == call | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return la.FilterFunc(predicate) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // FilterByCorrelationID returns ListAudits with specified correlation id.
 | ||||||
|  | func (la ListAudits) FilterByCorrelationID(correlationID string) ListAudits { | ||||||
|  | 	predicate := func(ic ItemAudit) bool { | ||||||
|  | 		return ic.CorrelationID == correlationID | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return la.FilterFunc(predicate) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // FilterByRemoteAddr returns ListAudits with specified remote address.
 | ||||||
|  | func (la ListAudits) FilterByRemoteAddr(remoteAddr string) ListAudits { | ||||||
|  | 	predicate := func(ic ItemAudit) bool { | ||||||
|  | 		return ic.RemoteAddr == remoteAddr | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return la.FilterFunc(predicate) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // FilterByUser returns ListAudits with specified user name.
 | ||||||
|  | func (la ListAudits) FilterByUser(user string) ListAudits { | ||||||
|  | 	predicate := func(ic ItemAudit) bool { | ||||||
|  | 		return ic.User == user | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return la.FilterFunc(predicate) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // FilterByStatusCode return ListAudits with specified status code.
 | ||||||
|  | func (la ListAudits) FilterByStatusCode(statusCode uint64) ListAudits { | ||||||
|  | 	predicate := func(ic ItemAudit) bool { | ||||||
|  | 		return ic.StatusCode == statusCode | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return la.FilterFunc(predicate) | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // FilterFunc allows filtering ListAudits based on a user-specified predicate.
 | ||||||
|  | func (la ListAudits) FilterFunc(predicate func(ItemAudit) bool) ListAudits { | ||||||
|  | 	var result ListAudits | ||||||
|  | 
 | ||||||
|  | 	for _, item := range la.Data { | ||||||
|  | 		if predicate(item) { | ||||||
|  | 			result.Data = append(result.Data, item) | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	result.EntryCount = uint64(len(result.Data)) | ||||||
|  | 
 | ||||||
|  | 	return result | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // FindOne returns first found ItemAudit
 | ||||||
|  | // If none was found, returns an empty struct.
 | ||||||
|  | func (la ListAudits) FindOne() ItemAudit { | ||||||
|  | 	if len(la.Data) == 0 { | ||||||
|  | 		return ItemAudit{} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return la.Data[0] | ||||||
|  | } | ||||||
| @ -0,0 +1,115 @@ | |||||||
|  | package audit | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"testing" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | var audits = ListAudits{ | ||||||
|  | 	Data: []ItemAudit{ | ||||||
|  | 		{ | ||||||
|  | 			Args:          "[]", | ||||||
|  | 			Call:          "/restmachine/cloudapi/audit/linkedJobs", | ||||||
|  | 			GUID:          "550e8400-e29b-41d4-a716-446655440001", | ||||||
|  | 			CorrelationID: "550e8400-e29b-41d4-a716-446655440001", | ||||||
|  | 			Kwargs:        `{\"audit_guid\":\"dd8623a1-a887-48c1-a500-c10210d404cf\"}`, | ||||||
|  | 			RemoteAddr:    "192.168.1.100", | ||||||
|  | 			ResponseTime:  1, | ||||||
|  | 			Result:        `[]`, | ||||||
|  | 			StatusCode:    200, | ||||||
|  | 			Timestamp:     1640995200, | ||||||
|  | 			TimestampEnd:  1640995201, | ||||||
|  | 			User:          "test@example.com", | ||||||
|  | 			TTL:           "2025-07-31T14:22:57.028000", | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			Args:          "[]", | ||||||
|  | 			Call:          "/restmachine/cloudapi/audit/test", | ||||||
|  | 			GUID:          "550e8400-e29b-41d4-a716-446655440002", | ||||||
|  | 			CorrelationID: "550e8400-e29b-41d4-a716-446655440002", | ||||||
|  | 			Kwargs:        `{\"audit_guid\":\"dd8623a1-a887-48c1-a500-c10210d404cf\"}`, | ||||||
|  | 			RemoteAddr:    "192.168.1.105", | ||||||
|  | 			ResponseTime:  5, | ||||||
|  | 			Result:        `[]`, | ||||||
|  | 			StatusCode:    400, | ||||||
|  | 			Timestamp:     1640995200, | ||||||
|  | 			TimestampEnd:  1640995201, | ||||||
|  | 			User:          "test2@example.com", | ||||||
|  | 			TTL:           "2025-07-31T14:22:57.028000", | ||||||
|  | 		}, | ||||||
|  | 	}, | ||||||
|  | 	EntryCount: 2, | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func TestFilterByID(t *testing.T) { | ||||||
|  | 	actual := audits.FilterByID("550e8400-e29b-41d4-a716-446655440002").FindOne() | ||||||
|  | 
 | ||||||
|  | 	if actual.GUID != "550e8400-e29b-41d4-a716-446655440002" { | ||||||
|  | 		t.Fatal("expected GUID 550e8400-e29b-41d4-a716-446655440002, found: ", actual.GUID) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	actualEmpty := audits.FilterByID("") | ||||||
|  | 
 | ||||||
|  | 	if len(actualEmpty.Data) != 0 { | ||||||
|  | 		t.Fatal("expected empty, actual: ", len(actualEmpty.Data)) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func TestFilterByCorrelationID(t *testing.T) { | ||||||
|  | 	actual := audits.FilterByCorrelationID("550e8400-e29b-41d4-a716-446655440002").FindOne() | ||||||
|  | 
 | ||||||
|  | 	if actual.CorrelationID != "550e8400-e29b-41d4-a716-446655440002" { | ||||||
|  | 		t.Fatal("expected GUID 550e8400-e29b-41d4-a716-446655440002, found: ", actual.CorrelationID) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	actualEmpty := audits.FilterByCorrelationID("") | ||||||
|  | 
 | ||||||
|  | 	if len(actualEmpty.Data) != 0 { | ||||||
|  | 		t.Fatal("expected empty, actual: ", len(actualEmpty.Data)) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func TestFilterByRemoteAddr(t *testing.T) { | ||||||
|  | 	actual := audits.FilterByRemoteAddr("192.168.1.100").FindOne() | ||||||
|  | 
 | ||||||
|  | 	if actual.RemoteAddr != "192.168.1.100" { | ||||||
|  | 		t.Fatal("expected remote address 192.168.1.100, found: ", actual.RemoteAddr) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	actualEmpty := audits.FilterByRemoteAddr("") | ||||||
|  | 
 | ||||||
|  | 	if len(actualEmpty.Data) != 0 { | ||||||
|  | 		t.Fatal("expected empty, actual: ", len(actualEmpty.Data)) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func TestFilterByUser(t *testing.T) { | ||||||
|  | 	actual := audits.FilterByUser("test@example.com").FindOne() | ||||||
|  | 
 | ||||||
|  | 	if actual.User != "test@example.com" { | ||||||
|  | 		t.Fatal("expected user test@example.com, found: ", actual.RemoteAddr) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	actualEmpty := audits.FilterByUser("") | ||||||
|  | 
 | ||||||
|  | 	if len(actualEmpty.Data) != 0 { | ||||||
|  | 		t.Fatal("expected empty, actual: ", len(actualEmpty.Data)) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func TestFilterByCall(t *testing.T) { | ||||||
|  | 	actual := audits.FilterByCall("/restmachine/cloudapi/audit/test").FindOne() | ||||||
|  | 
 | ||||||
|  | 	if actual.Call != "/restmachine/cloudapi/audit/test" { | ||||||
|  | 		t.Fatal("expected call /restmachine/cloudapi/audit/test, found: ", actual.Call) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func TestFilterByStatusCode(t *testing.T) { | ||||||
|  | 	actual := audits.FilterByStatusCode(200) | ||||||
|  | 
 | ||||||
|  | 	for _, item := range actual.Data { | ||||||
|  | 		if item.StatusCode != 200 { | ||||||
|  | 			t.Fatal("expected 200 status code, found: ", item.StatusCode) | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @ -0,0 +1,46 @@ | |||||||
|  | package audit | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"encoding/json" | ||||||
|  | 	"net/http" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // GetRequest struct to get information about account
 | ||||||
|  | type GetRequest struct { | ||||||
|  | 	// Audit GUID
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	AuditGuid string `url:"audit_guid" json:"audit_guid" validate:"required"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Get gets information about audit as a RecordAudit struct
 | ||||||
|  | func (a Audit) Get(ctx context.Context, req GetRequest) (*RecordAudit, error) { | ||||||
|  | 	res, err := a.GetRaw(ctx, req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	info := RecordAudit{} | ||||||
|  | 
 | ||||||
|  | 	err = json.Unmarshal(res, &info) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return &info, nil | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // GetRaw gets information about audit as an array of bytes
 | ||||||
|  | func (a Audit) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/audit/get" | ||||||
|  | 
 | ||||||
|  | 	res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) | ||||||
|  | 	return res, err | ||||||
|  | } | ||||||
| @ -0,0 +1,124 @@ | |||||||
|  | package audit | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"encoding/json" | ||||||
|  | 	"net/http" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // ListRequest struct to give list of account audits
 | ||||||
|  | type ListRequest struct { | ||||||
|  | 
 | ||||||
|  | 	// Find all audits after point in time (unixtime)
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	TimestampAt uint64 `url:"timestamp_at,omitempty" json:"timestamp_at,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Find all audits before point in time (unixtime)
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	TimestampTo uint64 `url:"timestamp_to,omitempty" json:"timestamp_to,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Find by user (Mongo RegExp supported)
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	User string `url:"user,omitempty" json:"user,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Find by api endpoint (Mongo RegExp supported)
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	Call string `url:"call,omitempty" json:"call,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Find by request id
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	RequestID string `url:"request_id,omitempty" json:"request_id,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Find by HTTP min status code
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	MinStatusCode uint64 `url:"min_status_code,omitempty" json:"min_status_code,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Find by HTTP max status code
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	MaxStatusCode uint64 `url:"max_status_code,omitempty" json:"max_status_code,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Sort by one of supported fields, format +|-(field)
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty" validate:"omitempty,sortBy"` | ||||||
|  | 
 | ||||||
|  | 	// Page number
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	Page uint64 `url:"page,omitempty" json:"page,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Page size
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	Size uint64 `url:"size,omitempty" json:"size,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Find by resource group id
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	RGID uint64 `url:"resgroup_id,omitempty" json:"resgroup_id,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Find by compute id
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	ComputeID uint64 `url:"compute_id,omitempty" json:"compute_id,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Find by account id
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Find by vins id
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	VINSID uint64 `url:"vins_id,omitempty" json:"vins_id,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Find by service id
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	ServiceID uint64 `url:"service_id,omitempty" json:"service_id,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Find by k8s id
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	K8SID uint64 `url:"k8s_id,omitempty" json:"k8s_id,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Find by flipgroup id
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	FLIPGroupID uint64 `url:"flipgroup_id,omitempty" json:"flipgroup_id,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Find by load balancer id
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	LBID uint64 `url:"lb_id,omitempty" json:"lb_id,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Find by sep id
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	SEPID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Exclude audit lines from response
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	ExcludeAuditLines bool `url:"exclude_audit_lines,omitempty" json:"exclude_audit_lines,omitempty"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // List gets audit records for the specified account object
 | ||||||
|  | func (a Audit) List(ctx context.Context, req ListRequest) (*ListAudits, error) { | ||||||
|  | 
 | ||||||
|  | 	res, err := a.ListRaw(ctx, req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	list := ListAudits{} | ||||||
|  | 
 | ||||||
|  | 	err = json.Unmarshal(res, &list) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return &list, nil | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // ListRaw gets list of audit records an array of bytes
 | ||||||
|  | func (a Audit) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) { | ||||||
|  | 
 | ||||||
|  | 	if err := validators.ValidateRequest(req); err != nil { | ||||||
|  | 		return nil, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/audit/list" | ||||||
|  | 
 | ||||||
|  | 	res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req) | ||||||
|  | 	return res, err | ||||||
|  | } | ||||||
| @ -0,0 +1,95 @@ | |||||||
|  | package audit | ||||||
|  | 
 | ||||||
|  | // Main info about audit
 | ||||||
|  | type RecordAudit struct { | ||||||
|  | 
 | ||||||
|  | 	// Arguments
 | ||||||
|  | 	Arguments string `json:"args"` | ||||||
|  | 
 | ||||||
|  | 	// Call
 | ||||||
|  | 	Call string `json:"call"` | ||||||
|  | 
 | ||||||
|  | 	// GUID
 | ||||||
|  | 	GUID string `json:"guid"` | ||||||
|  | 
 | ||||||
|  | 	// Correlation ID
 | ||||||
|  | 	CorrelationID string `json:"correlation_id"` | ||||||
|  | 
 | ||||||
|  | 	// Kwargs
 | ||||||
|  | 	Kwargs string `json:"kwargs"` | ||||||
|  | 
 | ||||||
|  | 	// RemoteAddr
 | ||||||
|  | 	RemoteAddr string `json:"remote_addr"` | ||||||
|  | 
 | ||||||
|  | 	// Response time
 | ||||||
|  | 	ResponseTime float64 `json:"responsetime"` | ||||||
|  | 
 | ||||||
|  | 	// Result
 | ||||||
|  | 	Result string `json:"result"` | ||||||
|  | 
 | ||||||
|  | 	// Status code
 | ||||||
|  | 	StatusCode uint64 `json:"statuscode"` | ||||||
|  | 
 | ||||||
|  | 	// Tags
 | ||||||
|  | 	Tags string `json:"tags"` | ||||||
|  | 
 | ||||||
|  | 	// Timestamp
 | ||||||
|  | 	Timestamp float64 `json:"timestamp"` | ||||||
|  | 
 | ||||||
|  | 	// TimestampEnd
 | ||||||
|  | 	TimestampEnd float64 `json:"timestampEnd"` | ||||||
|  | 
 | ||||||
|  | 	// User
 | ||||||
|  | 	User string `json:"user"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Main info about audit
 | ||||||
|  | type ItemAudit struct { | ||||||
|  | 	// Args
 | ||||||
|  | 	Args string `json:"args"` | ||||||
|  | 
 | ||||||
|  | 	// Call
 | ||||||
|  | 	Call string `json:"call"` | ||||||
|  | 
 | ||||||
|  | 	// GUID
 | ||||||
|  | 	GUID string `json:"guid"` | ||||||
|  | 
 | ||||||
|  | 	// Correlation ID
 | ||||||
|  | 	CorrelationID string `json:"correlation_id"` | ||||||
|  | 
 | ||||||
|  | 	// Kwargs
 | ||||||
|  | 	Kwargs string `json:"kwargs"` | ||||||
|  | 
 | ||||||
|  | 	// RemoteAddr
 | ||||||
|  | 	RemoteAddr string `json:"remote_addr"` | ||||||
|  | 
 | ||||||
|  | 	// Response time
 | ||||||
|  | 	ResponseTime float64 `json:"responsetime"` | ||||||
|  | 
 | ||||||
|  | 	// Result
 | ||||||
|  | 	Result string `json:"result"` | ||||||
|  | 
 | ||||||
|  | 	// Status code
 | ||||||
|  | 	StatusCode uint64 `json:"statuscode"` | ||||||
|  | 
 | ||||||
|  | 	// Timestamp
 | ||||||
|  | 	Timestamp float64 `json:"timestamp"` | ||||||
|  | 
 | ||||||
|  | 	// Timestamp End
 | ||||||
|  | 	TimestampEnd float64 `json:"timestampEnd"` | ||||||
|  | 
 | ||||||
|  | 	// User
 | ||||||
|  | 	User string `json:"user"` | ||||||
|  | 
 | ||||||
|  | 	// TTL
 | ||||||
|  | 	TTL string `json:"_ttl"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // List of audits
 | ||||||
|  | type ListAudits struct { | ||||||
|  | 	// Data
 | ||||||
|  | 	Data []ItemAudit `json:"data"` | ||||||
|  | 
 | ||||||
|  | 	// EntryCount
 | ||||||
|  | 	EntryCount uint64 `json:"entryCount"` | ||||||
|  | } | ||||||
| @ -0,0 +1,42 @@ | |||||||
|  | package bservice | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"net/http" | ||||||
|  | 	"strconv" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // MigrateToZone struct to move basic service to another zone
 | ||||||
|  | type MigrateToZoneRequest struct { | ||||||
|  | 	// ID of the BasicService to move
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// ID of the zone to move
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	ZoneID uint64 `url:"zoneId" json:"zoneId" validate:"required"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // MigrateToZone moves basic service instance to new zone
 | ||||||
|  | func (b BService) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return false, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/bservice/migrateToZone" | ||||||
|  | 
 | ||||||
|  | 	res, err := b.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 | ||||||
|  | } | ||||||
| @ -0,0 +1,42 @@ | |||||||
|  | package compute | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"net/http" | ||||||
|  | 	"strconv" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // AbortSharedSnapshotMergeRequest struct to abort shared snapshots merge
 | ||||||
|  | type AbortSharedSnapshotMergeRequest struct { | ||||||
|  | 	// ID of the compute
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// Label of the snapshot
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	Label string `url:"label" json:"label" validate:"required"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // AbortSharedSnapshotMerge shared snapshots merge abort
 | ||||||
|  | func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSnapshotMergeRequest) (bool, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return false, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/compute/abort_shared_snapshot_merge" | ||||||
|  | 
 | ||||||
|  | 	res, err := c.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 | ||||||
|  | } | ||||||
| @ -0,0 +1,54 @@ | |||||||
|  | package compute | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"net/http" | ||||||
|  | 	"strconv" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // ChangeIPRequest struct to change IP for network
 | ||||||
|  | type ChangeIPRequest struct { | ||||||
|  | 	// ID of compute instance
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// Network type
 | ||||||
|  | 	// 'EXTNET' for connect to external network directly
 | ||||||
|  | 	// 'VINS' for connect to ViNS
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	NetType string `url:"net_type" json:"net_type" validate:"computeNetType"` | ||||||
|  | 
 | ||||||
|  | 	// Network ID for connect to
 | ||||||
|  | 	// For EXTNET - external network ID
 | ||||||
|  | 	// For VINS - VINS ID
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	NetID uint64 `url:"net_id" json:"net_id" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// IP address to which we will change the existing one, it must be from the same subnet
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	IPAddr string `url:"ip_addr" json:"ip_addr" validate:"required"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // ChangeIP change reserved IP for compute instance
 | ||||||
|  | func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return false, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/compute/changeIp" | ||||||
|  | 
 | ||||||
|  | 	res, err := c.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 | ||||||
|  | } | ||||||
| @ -0,0 +1,46 @@ | |||||||
|  | package compute | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"net/http" | ||||||
|  | 	"strconv" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // ChangeMTURequest struct to change MTU for a compute
 | ||||||
|  | type ChangeMTURequest struct { | ||||||
|  | 	// ID of compute instance
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// Interface name or MAC address
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	Interface string `url:"interface" json:"interface" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// Maximum transmission unit
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	MTU uint64 `url:"mtu" json:"mtu" validate:"required" validate:"omitempty,mtu"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // ChangeMTU change MTU for compute instance
 | ||||||
|  | func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return false, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/compute/change_mtu" | ||||||
|  | 
 | ||||||
|  | 	res, err := c.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 | ||||||
|  | } | ||||||
| @ -0,0 +1,50 @@ | |||||||
|  | package compute | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"net/http" | ||||||
|  | 	"strconv" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // ChangeSecGroupsRequest struct to change security groups for compute
 | ||||||
|  | type ChangeSecGroupsRequest struct { | ||||||
|  | 	// Identifier compute
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// Interface name or MAC address
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	Interface string `url:"interface" json:"interface" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// List of security group IDs to assign to this interface
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Flag indicating whether security groups are enabled for this interface
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // ChangeSecGroups changes security groups for compute
 | ||||||
|  | func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest) (bool, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return false, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/compute/change_security_groups" | ||||||
|  | 
 | ||||||
|  | 	res, err := c.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 | ||||||
|  | } | ||||||
| @ -0,0 +1,39 @@ | |||||||
|  | package compute | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"net/http" | ||||||
|  | 	"strconv" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants" | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // CloneAbortRequest struct to abort a compute clone
 | ||||||
|  | type CloneAbortRequest struct { | ||||||
|  | 	// ID of compute instance
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // CloneAbort aborts a compute clone
 | ||||||
|  | func (c Compute) CloneAbort(ctx context.Context, req CloneAbortRequest) (bool, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return false, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/compute/clone_abort" | ||||||
|  | 
 | ||||||
|  | 	res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return false, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	result, err := strconv.ParseBool(string(res)) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return false, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return result, nil | ||||||
|  | } | ||||||
| @ -0,0 +1,40 @@ | |||||||
|  | package compute | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"encoding/json" | ||||||
|  | 	"net/http" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // GetCloneStatusRequest struct to get information about compute clone status
 | ||||||
|  | type GetCloneStatusRequest struct { | ||||||
|  | 	// ID of compute instance
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // GetCloneStatus gets information about compute clone status as a RecordCloneStatus struct
 | ||||||
|  | func (c Compute) GetCloneStatus(ctx context.Context, req GetCloneStatusRequest) ([]RecordCloneStatus, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/compute/clone_status" | ||||||
|  | 
 | ||||||
|  | 	res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	cloneStatus := make([]RecordCloneStatus, 0) | ||||||
|  | 
 | ||||||
|  | 	err = json.Unmarshal(res, &cloneStatus) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return cloneStatus, nil | ||||||
|  | } | ||||||
| @ -0,0 +1,112 @@ | |||||||
|  | package compute | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"net/http" | ||||||
|  | 	"strconv" | ||||||
|  | 	"strings" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // CreateTemplateFromBlankRequest struct to create template from boot disk of current compute
 | ||||||
|  | type CreateTemplateFromBlankRequest struct { | ||||||
|  | 	// ID of the compute to create template from
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// Name of the rescue disk
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	Name string `url:"name" json:"name" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// Boot type of image BIOS or UEFI
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	BootType string `url:"boottype" json:"boottype" validate:"imageBootType"` | ||||||
|  | 
 | ||||||
|  | 	// Image type linux, windows or other
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	ImageType string `url:"imagetype" json:"imagetype" validate:"imageType"` | ||||||
|  | 
 | ||||||
|  | 	// Storage policy id of disk. The rules of the specified storage policy will be used.
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// Username for the image
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	Username string `url:"username,omitempty" json:"username,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Password for the image
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	Password string `url:"password,omitempty" json:"password,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Account ID to make the image exclusive
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Pool for image create
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// Does this machine supports hot resize
 | ||||||
|  | 	// Default: false
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	HotResize bool `url:"hotresize" json:"hotresize"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | type wrapperCreateTemplateFromBlankRequest struct { | ||||||
|  | 	CreateTemplateFromBlankRequest | ||||||
|  | 	AsyncMode bool `url:"asyncMode"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // CreateTemplateFromBlank creates template from boot disk of current compute in sync mode.
 | ||||||
|  | // It returns id of created compute and error.
 | ||||||
|  | func (c Compute) CreateTemplateFromBlank(ctx context.Context, req CreateTemplateFromBlankRequest) (uint64, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return 0, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	reqWrapped := wrapperCreateTemplateFromBlankRequest{ | ||||||
|  | 		CreateTemplateFromBlankRequest: req, | ||||||
|  | 		AsyncMode:                      false, | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/compute/createTemplateFromBlank" | ||||||
|  | 
 | ||||||
|  | 	res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return 0, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	result, err := strconv.ParseUint(string(res), 10, 64) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return 0, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return result, nil | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // CreateTemplateFromBlankAsync creates template from boot disk of current compute in async mode.
 | ||||||
|  | // It returns guid of task and error.
 | ||||||
|  | func (c Compute) CreateTemplateFromBlankAsync(ctx context.Context, req CreateTemplateFromBlankRequest) (string, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return "", validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	reqWrapped := wrapperCreateTemplateFromBlankRequest{ | ||||||
|  | 		CreateTemplateFromBlankRequest: req, | ||||||
|  | 		AsyncMode:                      true, | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/compute/createTemplateFromBlank" | ||||||
|  | 
 | ||||||
|  | 	res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return "", err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	result := strings.ReplaceAll(string(res), "\"", "") | ||||||
|  | 
 | ||||||
|  | 	return result, nil | ||||||
|  | } | ||||||
| @ -0,0 +1,53 @@ | |||||||
|  | package compute | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"net/http" | ||||||
|  | 	"strconv" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // DiskMigrateRequest struct to migrate compute's disk to target disk
 | ||||||
|  | type DiskMigrateRequest struct { | ||||||
|  | 	// ID of compute instance
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// ID source disk
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	DiskID uint64 `url:"diskId" json:"diskId" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// ID target disk
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	TargetDiskID uint64 `url:"targetDiskId" json:"targetDiskId" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// Migration mode. 1 - Data migration and domain update were already completed by third-party software.
 | ||||||
|  | 	// Use this if target disk already connected to compute and you only need to save changes for next reboot.
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	Mode int64 `url:"mode,omitempty" json:"mode,omitempty"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // DiskMigrate - migrate compute's disk to target disk. Source disk will be detached, target disk will be attached to the same PCI slot.
 | ||||||
|  | // (WARNING) Current realisation is limited. No actual data migration will be performed.
 | ||||||
|  | // Use this API if target disk already connected to compute and you only need to save changes for next reboot (mode: 1).
 | ||||||
|  | func (c Compute) DiskMigrate(ctx context.Context, req DiskMigrateRequest) (bool, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return false, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/compute/diskMigrate" | ||||||
|  | 
 | ||||||
|  | 	res, err := c.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 | ||||||
|  | } | ||||||
| @ -0,0 +1,46 @@ | |||||||
|  | package compute | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"net/http" | ||||||
|  | 	"strconv" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // DiskSwitchToReplicationRequest struct to switch disk to it's replication
 | ||||||
|  | type DiskSwitchToReplicationRequest struct { | ||||||
|  | 	// ID of compute instance
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// ID of the disk to switch
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	DiskID uint64 `url:"diskId" json:"diskId" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// Delete replication relationship
 | ||||||
|  | 	// Required: false
 | ||||||
|  | 	StopReplication bool `url:"stopReplication" json:"stopReplication"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // DiskSwitchToReplication switches disk to it's replication
 | ||||||
|  | func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToReplicationRequest) (bool, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return false, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/compute/diskSwitchToReplication" | ||||||
|  | 
 | ||||||
|  | 	res, err := c.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 | ||||||
|  | } | ||||||
| @ -0,0 +1,38 @@ | |||||||
|  | package compute | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"net/http" | ||||||
|  | 	"strconv" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // GuestAgentDisableRequest struct to disable guest agent
 | ||||||
|  | type GuestAgentDisableRequest struct { | ||||||
|  | 	// ID of compute instance
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Disable guest agent at a specific compute
 | ||||||
|  | func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableRequest) (bool, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return false, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/compute/guest_agent_disable" | ||||||
|  | 
 | ||||||
|  | 	res, err := c.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 | ||||||
|  | } | ||||||
| @ -0,0 +1,38 @@ | |||||||
|  | package compute | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"net/http" | ||||||
|  | 	"strconv" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // GuestAgentEnableRequest struct to enable guest agent
 | ||||||
|  | type GuestAgentEnableRequest struct { | ||||||
|  | 	// ID of compute instance
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Enable guest agent at a specific compute
 | ||||||
|  | func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableRequest) (bool, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return false, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/compute/guest_agent_enable" | ||||||
|  | 
 | ||||||
|  | 	res, err := c.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 | ||||||
|  | } | ||||||
| @ -0,0 +1,48 @@ | |||||||
|  | package compute | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"encoding/json" | ||||||
|  | 	"net/http" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // GuestAgentExecuteRequest struct to execute command from user to agent
 | ||||||
|  | type GuestAgentExecuteRequest struct { | ||||||
|  | 	// ID of compute instance
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// Custom command from user to agent
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	Command string `url:"command" json:"command" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// Arguments to command
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	Arguments string `url:"arguments" json:"arguments" validate:"required"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Execute guest agent command
 | ||||||
|  | func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExecuteRequest) (map[string]interface{}, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/compute/guest_agent_execute" | ||||||
|  | 
 | ||||||
|  | 	res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	var result map[string]interface{} | ||||||
|  | 
 | ||||||
|  | 	err = json.Unmarshal(res, &result) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return result, nil | ||||||
|  | } | ||||||
| @ -0,0 +1,40 @@ | |||||||
|  | package compute | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"encoding/json" | ||||||
|  | 	"net/http" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // GuestAgentFeatureGetRequest struct to feature get guest agent
 | ||||||
|  | type GuestAgentFeatureGetRequest struct { | ||||||
|  | 	// ID of compute instance
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // List of features
 | ||||||
|  | func (c Compute) GuestAgentFeatureGet(ctx context.Context, req GuestAgentFeatureGetRequest) ([]string, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/compute/guest_agent_feature_get" | ||||||
|  | 
 | ||||||
|  | 	res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	features := make([]string, 0) | ||||||
|  | 
 | ||||||
|  | 	err = json.Unmarshal(res, &features) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return features, nil | ||||||
|  | } | ||||||
| @ -0,0 +1,38 @@ | |||||||
|  | package compute | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"net/http" | ||||||
|  | 	"strconv" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // GuestAgentFeatureUpdateRequest struct to feature update guest agent
 | ||||||
|  | type GuestAgentFeatureUpdateRequest struct { | ||||||
|  | 	// ID of compute instance
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Feature update guest agent
 | ||||||
|  | func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeatureUpdateRequest) (bool, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return false, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/compute/guest_agent_feature_update" | ||||||
|  | 
 | ||||||
|  | 	res, err := c.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 | ||||||
|  | } | ||||||
| @ -0,0 +1,33 @@ | |||||||
|  | package compute | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"net/http" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // SharedSnapshotMergeStatusRequest struct to get shared snapshot merge status
 | ||||||
|  | type SharedSnapshotMergeStatusRequest struct { | ||||||
|  | 	// ID of compute instance to get log for
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // SharedSnapshotMergeStatus shared snapshots merge status
 | ||||||
|  | // returns a string representing either the current status or the progress percentage
 | ||||||
|  | func (c Compute) SharedSnapshotMergeStatus(ctx context.Context, req SharedSnapshotMergeStatusRequest) (string, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return "", validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/compute/shared_snapshot_merge_status" | ||||||
|  | 
 | ||||||
|  | 	res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return "", err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return string(res), nil | ||||||
|  | } | ||||||
| @ -0,0 +1,42 @@ | |||||||
|  | package disks | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"net/http" | ||||||
|  | 	"strconv" | ||||||
|  | 
 | ||||||
|  | 	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // ChangeDiskStoragePolicyRequest struct to change storage policy for disk
 | ||||||
|  | type ChangeDiskStoragePolicyRequest struct { | ||||||
|  | 	// ID of the disk
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"` | ||||||
|  | 
 | ||||||
|  | 	// ID of the storage policy to which to connect for disk
 | ||||||
|  | 	// Required: true
 | ||||||
|  | 	StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // ChangeDiskStoragePolicy changes storage policy for disk
 | ||||||
|  | func (d Disks) ChangeDiskStoragePolicy(ctx context.Context, req ChangeDiskStoragePolicyRequest) (bool, error) { | ||||||
|  | 	err := validators.ValidateRequest(req) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return false, validators.ValidationErrors(validators.GetErrors(err)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	url := "/cloudapi/disks/change_disk_storage_policy" | ||||||
|  | 
 | ||||||
|  | 	res, err := d.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 | ||||||
|  | } | ||||||
Some files were not shown because too many files have changed in this diff Show More
					Loading…
					
					
				
		Reference in new issue