Compare commits
22 Commits
gos_tech_1
...
main
Author | SHA1 | Date |
---|---|---|
|
cbce7f434f | 5 days ago |
|
e04dc42d2b | 2 months ago |
|
88eb9e8898 | 2 months ago |
|
9ec34c6bfc | 3 months ago |
|
80491ed643 | 3 months ago |
|
f1e0f7abb6 | 6 months ago |
|
8eeef825c0 | 8 months ago |
|
9a7a7b6f36 | 8 months ago |
|
3393934456 | 9 months ago |
|
e7c968797b | 10 months ago |
|
bc264c4d90 | 11 months ago |
|
d137c7507a | 11 months ago |
|
55027a1605 | 11 months ago |
|
de9cca4053 | 11 months ago |
|
83bf1fb1fa | 11 months ago |
|
16cad7a3e7 | 1 year ago |
|
96273d2a12 | 1 year ago |
|
d4065938ac | 1 year ago |
|
cd741b7f11 | 1 year ago |
|
a85ad3acd5 | 1 year ago |
|
823dfb49bc | 1 year ago |
|
e6440bc4a3 | 1 year ago |
@ -1,5 +1,40 @@
|
|||||||
## Version 1.6.14
|
## Version 1.10.1
|
||||||
|
|
||||||
|
### Добавлено
|
||||||
|
|
||||||
|
#### compute
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BGOS-268 | Вычисляемое поле `PreferredCPU` в моделях `RecordCompute, ItemCompute, InfoCompute` в cloudapi/compute и cloudbroker/compute |
|
||||||
|
| BGOS-268 | Опциональное поле `PreferredCPU` в структурах `ResizeRequest, UpdateRequest` в cloudapi/compute и cloudbroker/compute |
|
||||||
|
|
||||||
|
#### kvmx86
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BGOS-268 | Опциональное поле `PreferredCPU` в структурах `CreateRequest, CreateBlankRequest` в cloudapi/kvmx86 и cloudbroker/kvmx86 |
|
||||||
|
|
||||||
|
#### node
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BGOS-270 | Вычисляемые поля `DPDK, UEFIFirmwareFile` в модели `ItemNode` в cloudbroker/node |
|
||||||
|
| BGOS-271 | Вычисляемые поля `DPDK, NetworkMode, ToActive, ToInstalling, ToMaintenance, ToRestricted` в моделях `RecordNode` в cloudbroker/node |
|
||||||
|
|
||||||
|
#### sep
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BGOS-273 | Вычисляемое поле `MultipathNum` в модели `RecordSEP` cloudbroker/sep |
|
||||||
|
|
||||||
|
#### vins
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BGOS-265 | Вычисляемое поле `AccoundID` в модели `ItemReservation` в cloudbroker/vins |
|
||||||
|
|
||||||
|
### Удалено
|
||||||
|
|
||||||
|
#### sep
|
||||||
|
| Идентификатор<br>задачи | Описание |
|
||||||
|
| --- | --- |
|
||||||
|
| BGOS-272 | Вычисляемые поля `_ckey,_meta` в модели `RecordSEP` в cloudbroker/sep |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Bugfix
|
|
||||||
- Delete tag required from DeleteRequest field Permanently in cloudapi/k8s
|
|
||||||
- Delete tag omitempty from DeleteDisksRequest and DisksDeleteRequest field Permanently in cloudapi/disks and cloudbroker/disks
|
|
@ -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,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"`
|
||||||
|
}
|
@ -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,14 @@
|
|||||||
|
package constants
|
||||||
|
|
||||||
|
const (
|
||||||
|
RESTMACHINE = "/restmachine"
|
||||||
|
|
||||||
|
// RAM_DIVISIBILITY sets divisibility of RAM value
|
||||||
|
RAM_DIVISIBILITY uint64 = 128
|
||||||
|
)
|
||||||
|
|
||||||
|
var FileName = map[string]string{
|
||||||
|
"OidcCertificate": "ca.crt",
|
||||||
|
}
|
||||||
|
|
||||||
|
var K8sValues = []string{"labels", "taints", "annotations, additionalSANs"}
|
@ -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,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:"auditGuid" json:"auditGuid" 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,41 @@
|
|||||||
|
package audit
|
||||||
|
|
||||||
|
// Main info about audit
|
||||||
|
type RecordAudit struct {
|
||||||
|
|
||||||
|
// Arguments
|
||||||
|
Arguments string `json:"args"`
|
||||||
|
|
||||||
|
// Call
|
||||||
|
Call string `json:"call"`
|
||||||
|
|
||||||
|
// GUID
|
||||||
|
GUID string `json:"guid"`
|
||||||
|
|
||||||
|
// 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"`
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BootDiskSetRequest struct to set boot disk for compute
|
||||||
|
type BootDiskSetRequest struct {
|
||||||
|
// ID of compute instance
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// ID of the disk to set as boot
|
||||||
|
// Required: true
|
||||||
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// BootDiskSet sets boot disk for compute
|
||||||
|
func (c Compute) BootDiskSet(ctx context.Context, req BootDiskSetRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/compute/bootDiskSet"
|
||||||
|
|
||||||
|
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:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Network type
|
||||||
|
// 'EXTNET' for connect to external network directly
|
||||||
|
// 'VINS' for connect to ViNS
|
||||||
|
// Required: true
|
||||||
|
NetType string `url:"netType" json:"netType" validate:"computeNetType"`
|
||||||
|
|
||||||
|
// Network ID for connect to
|
||||||
|
// For EXTNET - external network ID
|
||||||
|
// For VINS - VINS ID
|
||||||
|
// Required: true
|
||||||
|
NetID uint64 `url:"netId" json:"netId" validate:"required"`
|
||||||
|
|
||||||
|
// IP address to which we will change the existing one, it must be from the same subnet
|
||||||
|
// Required: true
|
||||||
|
IPAddr string `url:"ipAddr" json:"ipAddr" 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,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"`
|
||||||
|
|
||||||
|
// 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"`
|
||||||
|
|
||||||
|
// SEP ID
|
||||||
|
// Required: false
|
||||||
|
SepID uint64 `url:"sepId,omitempty" json:"sepId,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,126 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FromPlatformDiskRequest struct to create template from platform disk
|
||||||
|
type FromPlatformDiskRequest struct {
|
||||||
|
// ID of the disk
|
||||||
|
// Required: true
|
||||||
|
DiskID uint64 `url:"diskId" json:"diskId" 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"`
|
||||||
|
|
||||||
|
// Binary architecture of this image
|
||||||
|
// Should be:
|
||||||
|
// - X86_64
|
||||||
|
// Required: true
|
||||||
|
Architecture string `url:"architecture" json:"architecture" validate:"imageArchitecture"`
|
||||||
|
|
||||||
|
// 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"`
|
||||||
|
|
||||||
|
// SEP ID
|
||||||
|
// Required: false
|
||||||
|
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||||
|
|
||||||
|
// Pool for image create
|
||||||
|
// Required: false
|
||||||
|
PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"`
|
||||||
|
|
||||||
|
// List of types of compute suitable for image
|
||||||
|
// Example: [ "KVM_X86" ]
|
||||||
|
// Required: true
|
||||||
|
Drivers []string `url:"drivers" json:"drivers" validate:"required"`
|
||||||
|
|
||||||
|
// Does this machine supports hot resize
|
||||||
|
// Required: false
|
||||||
|
HotResize bool `url:"hotresize" json:"hotresize"`
|
||||||
|
|
||||||
|
// Bootable image
|
||||||
|
// Required: true
|
||||||
|
Bootable bool `url:"bootable" json:"bootable"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type wrapperFromPlatformDiskRequest struct {
|
||||||
|
FromPlatformDiskRequest
|
||||||
|
AsyncMode bool `url:"asyncMode"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromPlatformDisk creates template from platform disk in sync mode.
|
||||||
|
// It returns id of created disk and error.
|
||||||
|
func (d Disks) FromPlatformDisk(ctx context.Context, req FromPlatformDiskRequest) (uint64, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/fromPlatformDisk"
|
||||||
|
|
||||||
|
reqWrapped := wrapperFromPlatformDiskRequest{
|
||||||
|
FromPlatformDiskRequest: req,
|
||||||
|
AsyncMode: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := d.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
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromPlatformDiskAsync creates template from platform disk in async mode.
|
||||||
|
// It returns guid of task and error.
|
||||||
|
func (d Disks) FromPlatformDiskAsync(ctx context.Context, req FromPlatformDiskRequest) (string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/fromPlatformDisk"
|
||||||
|
|
||||||
|
reqWrapped := wrapperFromPlatformDiskRequest{
|
||||||
|
FromPlatformDiskRequest: req,
|
||||||
|
AsyncMode: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := strings.ReplaceAll(string(res), "\"", "")
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ReplicateRequest struct to create an empty disk in chosen SEP and pool combination.
|
||||||
|
type ReplicateRequest struct {
|
||||||
|
// Id of the disk to replicate. This disk will become master in replication
|
||||||
|
// Required: true
|
||||||
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
|
|
||||||
|
// Name of replica disk to create
|
||||||
|
// Required: true
|
||||||
|
Name string `url:"name" json:"name" validate:"required"`
|
||||||
|
|
||||||
|
// ID of SEP to create slave disk
|
||||||
|
// Required: true
|
||||||
|
SepID uint64 `url:"sepId" json:"sepId" validate:"required"`
|
||||||
|
|
||||||
|
// Pool name to create slave disk in
|
||||||
|
// Required: true
|
||||||
|
PoolName string `url:"poolName" json:"poolName" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create an empty disk in chosen SEP and pool combination.
|
||||||
|
// Starts replication between chosen disk and newly created disk
|
||||||
|
// Note: only TATLIN type SEP are supported for replications between
|
||||||
|
func (d Disks) Replicate(ctx context.Context, req ReplicateRequest) (uint64, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/replicate"
|
||||||
|
|
||||||
|
res, err := d.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
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ReplicationResume struct to resume suspended replication
|
||||||
|
type ReplicationResumeRequest struct {
|
||||||
|
// Id of the disk
|
||||||
|
// Required: true
|
||||||
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReplicationResume resume suspended replication
|
||||||
|
func (d Disks) ReplicationResume(ctx context.Context, req ReplicationResumeRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/replicationResume"
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ReplicationReverseRequest struct to change role between disks replications
|
||||||
|
type ReplicationReverseRequest struct {
|
||||||
|
// Id of the disk
|
||||||
|
// Required: true
|
||||||
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReplicationReverse change role between disks replications
|
||||||
|
func (d Disks) ReplicationReverse(ctx context.Context, req ReplicationReverseRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/replicationReverse"
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ReplicationStartRequest struct to starts replication between two chosen disks
|
||||||
|
type ReplicationStartRequest struct {
|
||||||
|
// Id of the disk to replicate. Primary disk in replication
|
||||||
|
// Required: true
|
||||||
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
|
|
||||||
|
// ID of target disk. Secondary disk in replication
|
||||||
|
// Required: true
|
||||||
|
TargetDiskID uint64 `url:"targetDiskId" json:"targetDiskId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReplicationStart starts replication between two chosen disks. It's required for both disks to have same size to avoid replication conflicts
|
||||||
|
// Note: Source disk's SEP and target SEP supported only of TATLIN type.
|
||||||
|
func (d Disks) ReplicationStart(ctx context.Context, req ReplicationStartRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/replicationStart"
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ReplicationStatusRequest struct to get replication status
|
||||||
|
type ReplicationStatusRequest struct {
|
||||||
|
// Id of the disk
|
||||||
|
// Required: true
|
||||||
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReplicationStatus get replication status
|
||||||
|
func (d Disks) ReplicationStatus(ctx context.Context, req ReplicationStatusRequest) (string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/replicationStatus"
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(res), nil
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ReplicationStopRequest struct to remove replication between disks completely
|
||||||
|
type ReplicationStopRequest struct {
|
||||||
|
// Id of the disk
|
||||||
|
// Required: true
|
||||||
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReplicationStop remove replication between disks completely
|
||||||
|
func (d Disks) ReplicationStop(ctx context.Context, req ReplicationStopRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/replicationStop"
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ReplicationSuspendRequest struct to pause replication with possibility to resume from pause moment
|
||||||
|
type ReplicationSuspendRequest struct {
|
||||||
|
// Id of the disk
|
||||||
|
// Required: true
|
||||||
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReplicationSuspend pause replication with possibility to resume from pause moment
|
||||||
|
func (d Disks) ReplicationSuspend(ctx context.Context, req ReplicationSuspendRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/replicationSuspend"
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package cloudapi
|
||||||
|
|
||||||
|
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/dpdknet"
|
||||||
|
|
||||||
|
// Accessing the DPDKNet method group
|
||||||
|
func (ca *CloudAPI) DPDKNet() *dpdknet.DPDKNet {
|
||||||
|
return dpdknet.New(ca.client)
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package dpdknet
|
||||||
|
|
||||||
|
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||||
|
|
||||||
|
// Structure for creating request to DPDK network
|
||||||
|
type DPDKNet struct {
|
||||||
|
client interfaces.Caller
|
||||||
|
}
|
||||||
|
|
||||||
|
// Builder for dpdk endpoints
|
||||||
|
func New(client interfaces.Caller) *DPDKNet {
|
||||||
|
return &DPDKNet{
|
||||||
|
client,
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package dpdknet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetRequest struct to get information about DPDK network
|
||||||
|
type GetRequest struct {
|
||||||
|
// ID of the DPDK network
|
||||||
|
// Required: true
|
||||||
|
DPDKID uint64 `url:"dpdkId" json:"dpdkId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get DPDK network details as a RecordDPDKNet struct
|
||||||
|
func (d DPDKNet) Get(ctx context.Context, req GetRequest) (*RecordDPDKNet, error) {
|
||||||
|
res, err := d.GetRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := RecordDPDKNet{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets DPDK network details as an array of bytes
|
||||||
|
func (d DPDKNet) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/dpdknet/get"
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
package dpdknet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListRequest struct to get list of DPDK networks
|
||||||
|
type ListRequest struct {
|
||||||
|
// Find by id
|
||||||
|
// Required: false
|
||||||
|
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||||
|
|
||||||
|
// Find by gid
|
||||||
|
// Required: false
|
||||||
|
GID uint64 `url:"gid,omitempty" json:"gid,omitempty"`
|
||||||
|
|
||||||
|
// Find by name
|
||||||
|
// Required: false
|
||||||
|
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||||
|
|
||||||
|
// Find by description
|
||||||
|
// Required: false
|
||||||
|
Description string `url:"description,omitempty" json:"description,omitempty"`
|
||||||
|
|
||||||
|
// Find by status
|
||||||
|
// Required: false
|
||||||
|
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||||
|
|
||||||
|
// Find by computeIDs
|
||||||
|
// Required: false
|
||||||
|
ComputeIDs []uint64 `url:"computeIds,omitempty" json:"computeIds,omitempty"`
|
||||||
|
|
||||||
|
// Sort by one of supported fields, format +|-(field)
|
||||||
|
// Required: false
|
||||||
|
SortBy string `url:"sortBy,omitempty" json:"sortBy,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"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// List gets list of the created DPDK networks belonging to an account as a ListDPDKNet struct
|
||||||
|
func (d DPDKNet) List(ctx context.Context, req ListRequest) (*ListDPDKNet, error) {
|
||||||
|
|
||||||
|
res, err := d.ListRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := ListDPDKNet{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &list, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of the created DPDK networks belonging to an account as an array of bytes
|
||||||
|
func (d DPDKNet) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
|
||||||
|
if err := validators.ValidateRequest(req); err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/dpdknet/list"
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
package dpdknet
|
||||||
|
|
||||||
|
// Detailed information about DPDK network
|
||||||
|
type RecordDPDKNet struct {
|
||||||
|
// List of accounts with access
|
||||||
|
AccountAccess []uint64 `json:"accountAccess"`
|
||||||
|
|
||||||
|
// Created time
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
|
// Updated time
|
||||||
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
|
// Description
|
||||||
|
Description string `json:"description"`
|
||||||
|
|
||||||
|
// Grid ID
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
|
// Guid ID
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
|
// ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// Name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// List of resource groups with access
|
||||||
|
RGAccess []uint64 `json:"rgAccess"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// OVS bridge
|
||||||
|
OVSBridge string `json:"ovsBridge"`
|
||||||
|
|
||||||
|
// Vlan ID
|
||||||
|
VlanID uint64 `json:"vlanId"`
|
||||||
|
|
||||||
|
// Compute IDs
|
||||||
|
ComputeIDs []uint64 `json:"computeIds"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListDPDKNet struct {
|
||||||
|
// Data
|
||||||
|
Data []ItemDPDKNet `json:"data"`
|
||||||
|
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ItemDPDKNet struct {
|
||||||
|
// List of accounts with access
|
||||||
|
AccountAccess []uint64 `json:"accountAccess"`
|
||||||
|
|
||||||
|
// Created time
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
|
// Updated time
|
||||||
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
|
// Description
|
||||||
|
Description string `json:"description"`
|
||||||
|
|
||||||
|
// Grid ID
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
|
// Guid ID
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
|
// ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// Name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// List of resource groups with access
|
||||||
|
RGAccess []uint64 `json:"rgAccess"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// OVS bridge
|
||||||
|
OVSBridge string `json:"ovsBridge"`
|
||||||
|
|
||||||
|
// Vlan ID
|
||||||
|
VlanID uint64 `json:"vlanId"`
|
||||||
|
|
||||||
|
// Compute IDs
|
||||||
|
ComputeIDs []uint64 `json:"computeIds"`
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package extnet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetRequest struct to get information about reserved address or address poll
|
||||||
|
type GetReservedIP struct {
|
||||||
|
// AccountID of the account whose reservation information we want to receive
|
||||||
|
// Required: true
|
||||||
|
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||||
|
|
||||||
|
// Field for specifying the ID of extnet whose reservation information we want to receive
|
||||||
|
// Required: false
|
||||||
|
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetReservedIP gets information about reserved address or address poll as a slice of RecordReservedIP struct
|
||||||
|
func (e ExtNet) GetReservedIP(ctx context.Context, req GetReservedIP) ([]RecordReservedIP, error) {
|
||||||
|
res, err := e.GetReservedIPRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
reservedIP := make([]RecordReservedIP, 0)
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &reservedIP)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return reservedIP, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets detailed information about external network as an array of bytes
|
||||||
|
func (e ExtNet) GetReservedIPRaw(ctx context.Context, req GetReservedIP) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/extnet/getReservedIp"
|
||||||
|
|
||||||
|
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue