gos_tech_1.6.10 v1.6.7
Tim Tkachev 1 year ago
parent b666789c7d
commit 4120cd2b1a

@ -1,10 +1,20 @@
## Version 1.6.6 ## Version 1.6.7
## Bugfix ## Bugfix
- Fixed model RecordExtNet in cloudbroker/extnet/models for correct work of get request - Refactoring client and legacy-client
- Fixed json tags in ItemResourceConsumption model and delete extra model Consumed in cloudbroker/account/models - Delete tag "required" in RecursiveDelete field model DeleteUserRequest in cloudbroker/account/delete_user
- Fixed statelessSepId field type from uint64 to int64 in cloudbroker/compute/models for correct work of list request - Delete tag "omitempty" in RecursiveDelete field model DeleteUserRequest in cloudapi/account/delete_user
- Delete tag "required" in Ratio field model SetCPUAllocationRatioRequest in cloudbroker/account/set_cpu_allocation_ratio
## Feature - Change tag from "requireD" to "required" in K8SID field model WorkerRestartRequest in cloudbroker/k8s/worker_restart
- Added GetRaw and ListRaw methods that give response as an array of bytes for cloudAPI groups: account, compute, k8s, disks, rg, bservice, disks,extnet, flipgroup, image, k8ci, lb, locations(list), sizes(list), stack, tasks, vins - Add tag "required" in UserIDs field model DeleteUsersRequest in cloudbroker/users/delete_users
- Added GetRaw and ListRaw methods that give response as an array of bytes for cloudbroker groups: account, apiaccess, compute, disks, extnet, flipgroup, grid, group, image, k8ci, k8s, lb, rg, sep, stack, tasks, user, vgpu, vins - Change tag "validate" in ComputeID field model SnapshotEvictDiskRequest in cloudbroker/compute/snapshot_evict_disk
- Delete unnecessary validation in ListRaw method in cloudbroker/apiaccess/list
- Delete unnecessary validation in ListDeleted method in cloudbroker/apiaccess/list_deleted
- Delete unnecessary validation in GetAudit method in cloudbroker/user/get_audit
- Delete unnecessary validation in ListRaw method in cloudbroker/user/list
- Delete unnecessary validation in ListTypes method in cloudbroker/disks/list_types
- Delete tag "required" in Active field model ListRequest in cloudbroker/group/list
- Delete unnecessary validation in List method in cloudbroker/group/list
- Change type from "APIsEndpoints" to "APIString" in APIs field in APIsIncludeRequest model in cloudbroker/apiaccess/apis_include
- Change type from "APIsEndpoints" to "APIString" in APIs field in APIsExcludeRequest model in cloudbroker/apiaccess/apis_exclude
- Refactoring multiple errors out put after validation in all cloudapi and cloudbroker groups, in client and legacy-client

@ -557,7 +557,7 @@ func main() {
// Создание клиента // Создание клиента
client := decort.New(cfg) client := decort.New(cfg)
// 1. Создание структуры запроса GetRequest на создание аккаунта и выполнение GetRaw запроса с помощью конвейера // 1. Создание структуры запроса GetRequest на получение информации об аккаунте и выполнение GetRaw запроса с помощью конвейера
req1 := account.GetRequest{ req1 := account.GetRequest{
AccountID: 123, AccountID: 123,
} }
@ -567,7 +567,7 @@ func main() {
} }
fmt.Println(string(res1)) fmt.Println(string(res1))
// 2. Создание структуры запроса ListRequest на получение аккаунтов и выполнение ListRaw запроса с помощью конвейера // 2. Создание структуры запроса ListRequest на получение информации об аккаунтах и выполнение ListRaw запроса с помощью конвейера
req2 := account.ListRequest{} req2 := account.ListRequest{}
res2, err := client.CloudAPI().Account().ListRaw(context.Background(), req2) res2, err := client.CloudAPI().Account().ListRaw(context.Background(), req2)
if err != nil { if err != nil {

@ -14,12 +14,12 @@ import (
"sync" "sync"
"time" "time"
"github.com/google/go-querystring/query"
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
k8s_ca "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s" k8s_ca "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
k8s_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/k8s" k8s_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/k8s"
"github.com/google/go-querystring/query"
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
) )
// HTTP-client for platform // HTTP-client for platform
@ -73,128 +73,31 @@ func (dc *DecortClient) CloudBroker() *cloudbroker.CloudBroker {
func (dc *DecortClient) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) { func (dc *DecortClient) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) {
k8sCaCreateReq, okCa := params.(k8s_ca.CreateRequest) k8sCaCreateReq, okCa := params.(k8s_ca.CreateRequest)
k8sCbCreateReq, okCb := params.(k8s_cb.CreateRequest) k8sCbCreateReq, okCb := params.(k8s_cb.CreateRequest)
var body *bytes.Buffer
var ctype string
if okCa { if okCa {
reqBody := &bytes.Buffer{} body, ctype = createK8sCloudApi(k8sCaCreateReq)
writer := multipart.NewWriter(reqBody) } else if okCb {
if k8sCaCreateReq.OidcCertificate != "" { body, ctype = createK8sCloudBroker(k8sCbCreateReq)
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt") } else {
_, _ = io.Copy(part, strings.NewReader(k8sCaCreateReq.OidcCertificate)) values, err := query.Values(params)
} if err != nil {
return nil, err
_ = writer.WriteField("name", k8sCaCreateReq.Name)
_ = writer.WriteField("rgId", strconv.FormatUint(k8sCaCreateReq.RGID, 10))
_ = writer.WriteField("k8ciId", strconv.FormatUint(k8sCaCreateReq.K8SCIID, 10))
_ = writer.WriteField("workerGroupName", k8sCaCreateReq.WorkerGroupName)
_ = writer.WriteField("networkPlugin", k8sCaCreateReq.NetworkPlugin)
if k8sCaCreateReq.MasterSEPID != 0 {
_ = writer.WriteField("masterSepId", strconv.FormatUint(k8sCaCreateReq.MasterSEPID, 10))
}
if k8sCaCreateReq.MasterSEPPool != "" {
_ = writer.WriteField("masterSepPool", k8sCaCreateReq.MasterSEPPool)
}
if k8sCaCreateReq.WorkerSEPID != 0 {
_ = writer.WriteField("workerSepId", strconv.FormatUint(k8sCaCreateReq.WorkerSEPID, 10))
}
if k8sCaCreateReq.WorkerSEPPool != "" {
_ = writer.WriteField("workerSepPool", k8sCaCreateReq.WorkerSEPPool)
}
if k8sCaCreateReq.Labels != nil {
for _, v := range k8sCaCreateReq.Labels {
_ = writer.WriteField("labels", v)
}
}
if k8sCaCreateReq.Taints != nil {
for _, v := range k8sCaCreateReq.Taints {
_ = writer.WriteField("taints", v)
}
}
if k8sCaCreateReq.Annotations != nil {
for _, v := range k8sCaCreateReq.Annotations {
_ = writer.WriteField("annotations", v)
}
}
if k8sCaCreateReq.MasterCPU != 0 {
_ = writer.WriteField("masterCpu", strconv.FormatUint(uint64(k8sCaCreateReq.MasterCPU), 10))
}
if k8sCaCreateReq.MasterNum != 0 {
_ = writer.WriteField("masterNum", strconv.FormatUint(uint64(k8sCaCreateReq.MasterNum), 10))
}
if k8sCaCreateReq.MasterRAM != 0 {
_ = writer.WriteField("masterRam", strconv.FormatUint(uint64(k8sCaCreateReq.MasterRAM), 10))
}
if k8sCaCreateReq.MasterDisk != 0 {
_ = writer.WriteField("masterDisk", strconv.FormatUint(uint64(k8sCaCreateReq.MasterDisk), 10))
}
if k8sCaCreateReq.WorkerCPU != 0 {
_ = writer.WriteField("workerCpu", strconv.FormatUint(uint64(k8sCaCreateReq.WorkerCPU), 10))
}
if k8sCaCreateReq.WorkerNum != 0 {
_ = writer.WriteField("workerNum", strconv.FormatUint(uint64(k8sCaCreateReq.WorkerNum), 10))
}
if k8sCaCreateReq.WorkerRAM != 0 {
_ = writer.WriteField("workerRam", strconv.FormatUint(uint64(k8sCaCreateReq.WorkerRAM), 10))
}
if k8sCaCreateReq.WorkerDisk != 0 {
_ = writer.WriteField("workerDisk", strconv.FormatUint(uint64(k8sCaCreateReq.WorkerDisk), 10))
}
if k8sCaCreateReq.ExtNetID != 0 {
_ = writer.WriteField("extnetId", strconv.FormatUint(k8sCaCreateReq.ExtNetID, 10))
}
if k8sCaCreateReq.VinsId != 0 {
_ = writer.WriteField("vinsId", strconv.FormatUint(k8sCaCreateReq.VinsId, 10))
}
if !k8sCaCreateReq.WithLB {
_ = writer.WriteField("withLB", strconv.FormatBool(k8sCaCreateReq.WithLB))
}
_ = writer.WriteField("highlyAvailableLB", strconv.FormatBool(k8sCaCreateReq.HighlyAvailable))
if k8sCaCreateReq.AdditionalSANs != nil {
for _, v := range k8sCaCreateReq.AdditionalSANs {
_ = writer.WriteField("additionalSANs", v)
}
}
if k8sCaCreateReq.InitConfiguration != "" {
_ = writer.WriteField("initConfiguration", k8sCaCreateReq.InitConfiguration)
}
if k8sCaCreateReq.ClusterConfiguration != "" {
_ = writer.WriteField("clusterConfiguration", k8sCaCreateReq.ClusterConfiguration)
}
if k8sCaCreateReq.KubeletConfiguration != "" {
_ = writer.WriteField("kubeletConfiguration", k8sCaCreateReq.KubeletConfiguration)
}
if k8sCaCreateReq.KubeProxyConfiguration != "" {
_ = writer.WriteField("kubeProxyConfiguration", k8sCaCreateReq.KubeProxyConfiguration)
}
if k8sCaCreateReq.JoinConfiguration != "" {
_ = writer.WriteField("joinConfiguration", k8sCaCreateReq.JoinConfiguration)
}
if k8sCaCreateReq.Description != "" {
_ = writer.WriteField("desc", k8sCaCreateReq.Description)
} }
if k8sCaCreateReq.UserData != "" { body = bytes.NewBufferString(values.Encode())
_ = writer.WriteField("userData", k8sCaCreateReq.UserData)
} }
_ = writer.WriteField("extnetOnly", strconv.FormatBool(k8sCaCreateReq.ExtNetOnly)) req, err := http.NewRequestWithContext(ctx, method, dc.decortURL+"/restmachine"+url, body)
_ = writer.FormDataContentType()
ct := writer.FormDataContentType()
writer.Close()
req, err := http.NewRequestWithContext(ctx, method, dc.decortURL+"/restmachine"+url, reqBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if err = dc.getToken(ctx); err != nil { if err = dc.getToken(ctx); err != nil {
return nil, err return nil, err
} }
resp, err := dc.domp(req, ct) resp, err := dc.do(req, ctype)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -210,261 +113,298 @@ func (dc *DecortClient) DecortApiCall(ctx context.Context, method, url string, p
} }
return respBytes, nil return respBytes, nil
} else if okCb { }
func (dc *DecortClient) getToken(ctx context.Context) error {
dc.mutex.Lock()
defer dc.mutex.Unlock()
if dc.cfg.Token == "" || time.Now().After(dc.expiryTime) {
body := fmt.Sprintf("grant_type=client_credentials&client_id=%s&client_secret=%s&response_type=id_token", dc.cfg.AppID, dc.cfg.AppSecret)
bodyReader := strings.NewReader(body)
dc.cfg.SSOURL = strings.TrimSuffix(dc.cfg.SSOURL, "/")
req, _ := http.NewRequestWithContext(ctx, "POST", dc.cfg.SSOURL+"/v1/oauth/access_token", bodyReader)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
resp, err := dc.client.Do(req)
if err != nil {
return fmt.Errorf("cannot get token: %w", err)
}
tokenBytes, _ := io.ReadAll(resp.Body)
resp.Body.Close()
if resp.StatusCode != 200 {
return fmt.Errorf("cannot get token: %s", tokenBytes)
}
token := string(tokenBytes)
dc.cfg.Token = token
dc.expiryTime = time.Now().AddDate(0, 0, 1)
}
return nil
}
func (dc *DecortClient) do(req *http.Request, ctype string) (*http.Response, error) {
if ctype != "" {
req.Header.Add("Content-Type", ctype)
} else {
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
}
req.Header.Add("Authorization", "bearer "+dc.cfg.Token)
req.Header.Set("Accept", "application/json")
// var resp *http.Response
// var err error
buf, _ := io.ReadAll(req.Body)
// req = req.Clone(req.Context())
// for i := uint64(0); i < dc.cfg.Retries; i++ {
req.Body = io.NopCloser(bytes.NewBuffer(buf))
resp, err := dc.client.Do(req)
// if err == nil {
if resp.StatusCode == 200 {
return resp, err
}
respBytes, _ := io.ReadAll(resp.Body)
err = fmt.Errorf("%s", respBytes)
resp.Body.Close()
// }
// }
return nil, fmt.Errorf("could not execute request: %w", err)
}
func createK8sCloudApi(req k8s_ca.CreateRequest) (*bytes.Buffer, string) {
reqBody := &bytes.Buffer{} reqBody := &bytes.Buffer{}
writer := multipart.NewWriter(reqBody) writer := multipart.NewWriter(reqBody)
if k8sCbCreateReq.OidcCertificate != "" { if req.OidcCertificate != "" {
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt") part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
_, _ = io.Copy(part, strings.NewReader(k8sCbCreateReq.OidcCertificate)) _, _ = io.Copy(part, strings.NewReader(req.OidcCertificate))
} }
_ = writer.WriteField("name", k8sCbCreateReq.Name) _ = writer.WriteField("name", req.Name)
_ = writer.WriteField("rgId", strconv.FormatUint(k8sCbCreateReq.RGID, 10)) _ = writer.WriteField("rgId", strconv.FormatUint(req.RGID, 10))
_ = writer.WriteField("k8ciId", strconv.FormatUint(k8sCbCreateReq.K8CIID, 10)) _ = writer.WriteField("k8ciId", strconv.FormatUint(req.K8SCIID, 10))
_ = writer.WriteField("workerGroupName", k8sCbCreateReq.WorkerGroupName) _ = writer.WriteField("workerGroupName", req.WorkerGroupName)
_ = writer.WriteField("networkPlugin", k8sCbCreateReq.NetworkPlugin) _ = writer.WriteField("networkPlugin", req.NetworkPlugin)
if k8sCbCreateReq.MasterSEPID != 0 { if req.MasterSEPID != 0 {
_ = writer.WriteField("masterSepId", strconv.FormatUint(k8sCbCreateReq.MasterSEPID, 10)) _ = writer.WriteField("masterSepId", strconv.FormatUint(req.MasterSEPID, 10))
} }
if k8sCbCreateReq.MasterSEPPool != "" { if req.MasterSEPPool != "" {
_ = writer.WriteField("masterSepPool", k8sCbCreateReq.MasterSEPPool) _ = writer.WriteField("masterSepPool", req.MasterSEPPool)
} }
if k8sCbCreateReq.WorkerSEPID != 0 { if req.WorkerSEPID != 0 {
_ = writer.WriteField("workerSepId", strconv.FormatUint(k8sCbCreateReq.WorkerSEPID, 10)) _ = writer.WriteField("workerSepId", strconv.FormatUint(req.WorkerSEPID, 10))
} }
if k8sCbCreateReq.WorkerSEPPool != "" { if req.WorkerSEPPool != "" {
_ = writer.WriteField("workerSepPool", k8sCbCreateReq.WorkerSEPPool) _ = writer.WriteField("workerSepPool", req.WorkerSEPPool)
} }
if k8sCbCreateReq.Labels != nil { if req.Labels != nil {
for _, v := range k8sCbCreateReq.Labels { for _, v := range req.Labels {
_ = writer.WriteField("labels", v) _ = writer.WriteField("labels", v)
} }
} }
if k8sCbCreateReq.Taints != nil { if req.Taints != nil {
for _, v := range k8sCbCreateReq.Taints { for _, v := range req.Taints {
_ = writer.WriteField("taints", v) _ = writer.WriteField("taints", v)
} }
} }
if k8sCbCreateReq.Annotations != nil { if req.Annotations != nil {
for _, v := range k8sCbCreateReq.Annotations { for _, v := range req.Annotations {
_ = writer.WriteField("annotations", v) _ = writer.WriteField("annotations", v)
} }
} }
if k8sCbCreateReq.MasterCPU != 0 { if req.MasterCPU != 0 {
_ = writer.WriteField("masterCpu", strconv.FormatUint(k8sCbCreateReq.MasterCPU, 10)) _ = writer.WriteField("masterCpu", strconv.FormatUint(uint64(req.MasterCPU), 10))
} }
if k8sCbCreateReq.MasterNum != 0 { if req.MasterNum != 0 {
_ = writer.WriteField("masterNum", strconv.FormatUint(k8sCbCreateReq.MasterNum, 10)) _ = writer.WriteField("masterNum", strconv.FormatUint(uint64(req.MasterNum), 10))
} }
if k8sCbCreateReq.MasterRAM != 0 { if req.MasterRAM != 0 {
_ = writer.WriteField("masterRam", strconv.FormatUint(k8sCbCreateReq.MasterRAM, 10)) _ = writer.WriteField("masterRam", strconv.FormatUint(uint64(req.MasterRAM), 10))
} }
if k8sCbCreateReq.MasterDisk != 0 { if req.MasterDisk != 0 {
_ = writer.WriteField("masterDisk", strconv.FormatUint(k8sCbCreateReq.MasterDisk, 10)) _ = writer.WriteField("masterDisk", strconv.FormatUint(uint64(req.MasterDisk), 10))
} }
if k8sCbCreateReq.WorkerCPU != 0 { if req.WorkerCPU != 0 {
_ = writer.WriteField("workerCpu", strconv.FormatUint(k8sCbCreateReq.WorkerCPU, 10)) _ = writer.WriteField("workerCpu", strconv.FormatUint(uint64(req.WorkerCPU), 10))
} }
if k8sCbCreateReq.WorkerNum != 0 { if req.WorkerNum != 0 {
_ = writer.WriteField("workerNum", strconv.FormatUint(k8sCbCreateReq.WorkerNum, 10)) _ = writer.WriteField("workerNum", strconv.FormatUint(uint64(req.WorkerNum), 10))
} }
if k8sCbCreateReq.WorkerRAM != 0 { if req.WorkerRAM != 0 {
_ = writer.WriteField("workerRam", strconv.FormatUint(k8sCbCreateReq.WorkerRAM, 10)) _ = writer.WriteField("workerRam", strconv.FormatUint(uint64(req.WorkerRAM), 10))
} }
if k8sCbCreateReq.WorkerDisk != 0 { if req.WorkerDisk != 0 {
_ = writer.WriteField("workerDisk", strconv.FormatUint(k8sCbCreateReq.WorkerDisk, 10)) _ = writer.WriteField("workerDisk", strconv.FormatUint(uint64(req.WorkerDisk), 10))
} }
if k8sCbCreateReq.ExtNetID != 0 { if req.ExtNetID != 0 {
_ = writer.WriteField("extnetId", strconv.FormatUint(k8sCbCreateReq.ExtNetID, 10)) _ = writer.WriteField("extnetId", strconv.FormatUint(req.ExtNetID, 10))
} }
if k8sCbCreateReq.VinsId != 0 { if req.VinsId != 0 {
_ = writer.WriteField("vinsId", strconv.FormatUint(k8sCbCreateReq.VinsId, 10)) _ = writer.WriteField("vinsId", strconv.FormatUint(req.VinsId, 10))
} }
if !k8sCbCreateReq.WithLB { if !req.WithLB {
_ = writer.WriteField("withLB", strconv.FormatBool(k8sCbCreateReq.WithLB)) _ = writer.WriteField("withLB", strconv.FormatBool(req.WithLB))
} }
_ = writer.WriteField("highlyAvailableLB", strconv.FormatBool(k8sCbCreateReq.HighlyAvailable)) _ = writer.WriteField("highlyAvailableLB", strconv.FormatBool(req.HighlyAvailable))
if k8sCbCreateReq.AdditionalSANs != nil { if req.AdditionalSANs != nil {
for _, v := range k8sCbCreateReq.AdditionalSANs { for _, v := range req.AdditionalSANs {
_ = writer.WriteField("additionalSANs", v) _ = writer.WriteField("additionalSANs", v)
} }
} }
if k8sCbCreateReq.InitConfiguration != "" { if req.InitConfiguration != "" {
_ = writer.WriteField("initConfiguration", k8sCbCreateReq.InitConfiguration) _ = writer.WriteField("initConfiguration", req.InitConfiguration)
} }
if k8sCbCreateReq.ClusterConfiguration != "" { if req.ClusterConfiguration != "" {
_ = writer.WriteField("clusterConfiguration", k8sCbCreateReq.ClusterConfiguration) _ = writer.WriteField("clusterConfiguration", req.ClusterConfiguration)
} }
if k8sCbCreateReq.KubeletConfiguration != "" { if req.KubeletConfiguration != "" {
_ = writer.WriteField("kubeletConfiguration", k8sCbCreateReq.KubeletConfiguration) _ = writer.WriteField("kubeletConfiguration", req.KubeletConfiguration)
} }
if k8sCbCreateReq.KubeProxyConfiguration != "" { if req.KubeProxyConfiguration != "" {
_ = writer.WriteField("kubeProxyConfiguration", k8sCbCreateReq.KubeProxyConfiguration) _ = writer.WriteField("kubeProxyConfiguration", req.KubeProxyConfiguration)
} }
if k8sCbCreateReq.JoinConfiguration != "" { if req.JoinConfiguration != "" {
_ = writer.WriteField("joinConfiguration", k8sCbCreateReq.JoinConfiguration) _ = writer.WriteField("joinConfiguration", req.JoinConfiguration)
} }
if k8sCbCreateReq.Description != "" { if req.Description != "" {
_ = writer.WriteField("desc", k8sCbCreateReq.Description) _ = writer.WriteField("desc", req.Description)
} }
if k8sCbCreateReq.UserData != "" { if req.UserData != "" {
_ = writer.WriteField("userData", k8sCbCreateReq.UserData) _ = writer.WriteField("userData", req.UserData)
} }
_ = writer.WriteField("extnetOnly", strconv.FormatBool(k8sCbCreateReq.ExtNetOnly)) _ = writer.WriteField("extnetOnly", strconv.FormatBool(req.ExtNetOnly))
_ = writer.FormDataContentType()
ct := writer.FormDataContentType() ct := writer.FormDataContentType()
writer.Close() writer.Close()
req, err := http.NewRequestWithContext(ctx, method, dc.decortURL+"/restmachine"+url, reqBody)
if err != nil {
return nil, err
}
if err = dc.getToken(ctx); err != nil {
return nil, err
}
resp, err := dc.domp(req, ct) return reqBody, ct
if err != nil {
return nil, err
} }
defer resp.Body.Close()
respBytes, err := io.ReadAll(resp.Body) func createK8sCloudBroker(req k8s_cb.CreateRequest) (*bytes.Buffer, string) {
if err != nil { reqBody := &bytes.Buffer{}
return nil, err writer := multipart.NewWriter(reqBody)
if req.OidcCertificate != "" {
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
_, _ = io.Copy(part, strings.NewReader(req.OidcCertificate))
} }
if resp.StatusCode != 200 { _ = writer.WriteField("name", req.Name)
return nil, errors.New(string(respBytes)) _ = writer.WriteField("rgId", strconv.FormatUint(req.RGID, 10))
} _ = writer.WriteField("k8ciId", strconv.FormatUint(req.K8CIID, 10))
_ = writer.WriteField("workerGroupName", req.WorkerGroupName)
_ = writer.WriteField("networkPlugin", req.NetworkPlugin)
return respBytes, nil if req.MasterSEPID != 0 {
_ = writer.WriteField("masterSepId", strconv.FormatUint(req.MasterSEPID, 10))
} }
if req.MasterSEPPool != "" {
values, err := query.Values(params) _ = writer.WriteField("masterSepPool", req.MasterSEPPool)
if err != nil {
return nil, err
} }
if req.WorkerSEPID != 0 {
body := strings.NewReader(values.Encode()) _ = writer.WriteField("workerSepId", strconv.FormatUint(req.WorkerSEPID, 10))
req, err := http.NewRequestWithContext(ctx, method, dc.decortURL+"/restmachine"+url, body)
if err != nil {
return nil, err
} }
if req.WorkerSEPPool != "" {
if err = dc.getToken(ctx); err != nil { _ = writer.WriteField("workerSepPool", req.WorkerSEPPool)
return nil, err
} }
resp, err := dc.do(req) if req.Labels != nil {
if err != nil { for _, v := range req.Labels {
return nil, err _ = writer.WriteField("labels", v)
} }
defer resp.Body.Close()
respBytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
} }
if req.Taints != nil {
if resp.StatusCode != 200 { for _, v := range req.Taints {
return nil, errors.New(string(respBytes)) _ = writer.WriteField("taints", v)
} }
return respBytes, nil
} }
if req.Annotations != nil {
func (dc *DecortClient) getToken(ctx context.Context) error { for _, v := range req.Annotations {
dc.mutex.Lock() _ = writer.WriteField("annotations", v)
defer dc.mutex.Unlock()
if dc.cfg.Token == "" || time.Now().After(dc.expiryTime) {
body := fmt.Sprintf("grant_type=client_credentials&client_id=%s&client_secret=%s&response_type=id_token", dc.cfg.AppID, dc.cfg.AppSecret)
bodyReader := strings.NewReader(body)
dc.cfg.SSOURL = strings.TrimSuffix(dc.cfg.SSOURL, "/")
req, _ := http.NewRequestWithContext(ctx, "POST", dc.cfg.SSOURL+"/v1/oauth/access_token", bodyReader)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
resp, err := dc.client.Do(req)
if err != nil {
return fmt.Errorf("cannot get token: %w", err)
} }
tokenBytes, _ := io.ReadAll(resp.Body)
resp.Body.Close()
if resp.StatusCode != 200 {
return fmt.Errorf("cannot get token: %s", tokenBytes)
} }
token := string(tokenBytes) if req.MasterCPU != 0 {
_ = writer.WriteField("masterCpu", strconv.FormatUint(req.MasterCPU, 10))
dc.cfg.Token = token
dc.expiryTime = time.Now().AddDate(0, 0, 1)
} }
if req.MasterNum != 0 {
return nil _ = writer.WriteField("masterNum", strconv.FormatUint(req.MasterNum, 10))
} }
if req.MasterRAM != 0 {
func (dc *DecortClient) do(req *http.Request) (*http.Response, error) { _ = writer.WriteField("masterRam", strconv.FormatUint(req.MasterRAM, 10))
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
req.Header.Add("Authorization", "bearer "+dc.cfg.Token)
req.Header.Set("Accept", "application/json")
// var resp *http.Response
// var err error
buf, _ := io.ReadAll(req.Body)
// req = req.Clone(req.Context())
// for i := uint64(0); i < dc.cfg.Retries; i++ {
req.Body = io.NopCloser(bytes.NewBuffer(buf))
resp, err := dc.client.Do(req)
// if err == nil {
if resp.StatusCode == 200 {
return resp, err
} }
respBytes, _ := io.ReadAll(resp.Body) if req.MasterDisk != 0 {
err = fmt.Errorf("%s", respBytes) _ = writer.WriteField("masterDisk", strconv.FormatUint(req.MasterDisk, 10))
resp.Body.Close() }
// } if req.WorkerCPU != 0 {
// } _ = writer.WriteField("workerCpu", strconv.FormatUint(req.WorkerCPU, 10))
}
return nil, fmt.Errorf("could not execute request: %w", err) if req.WorkerNum != 0 {
_ = writer.WriteField("workerNum", strconv.FormatUint(req.WorkerNum, 10))
}
if req.WorkerRAM != 0 {
_ = writer.WriteField("workerRam", strconv.FormatUint(req.WorkerRAM, 10))
}
if req.WorkerDisk != 0 {
_ = writer.WriteField("workerDisk", strconv.FormatUint(req.WorkerDisk, 10))
}
if req.ExtNetID != 0 {
_ = writer.WriteField("extnetId", strconv.FormatUint(req.ExtNetID, 10))
}
if req.VinsId != 0 {
_ = writer.WriteField("vinsId", strconv.FormatUint(req.VinsId, 10))
}
if !req.WithLB {
_ = writer.WriteField("withLB", strconv.FormatBool(req.WithLB))
} }
func (dc *DecortClient) domp(req *http.Request, ctype string) (*http.Response, error) { _ = writer.WriteField("highlyAvailableLB", strconv.FormatBool(req.HighlyAvailable))
req.Header.Add("Content-Type", ctype)
req.Header.Add("Authorization", "bearer "+dc.cfg.Token)
req.Header.Set("Accept", "application/json")
// var resp *http.Response if req.AdditionalSANs != nil {
// var err error for _, v := range req.AdditionalSANs {
buf, _ := io.ReadAll(req.Body) _ = writer.WriteField("additionalSANs", v)
// req = req.Clone(req.Context()) }
}
if req.InitConfiguration != "" {
_ = writer.WriteField("initConfiguration", req.InitConfiguration)
}
if req.ClusterConfiguration != "" {
_ = writer.WriteField("clusterConfiguration", req.ClusterConfiguration)
}
if req.KubeletConfiguration != "" {
_ = writer.WriteField("kubeletConfiguration", req.KubeletConfiguration)
}
if req.KubeProxyConfiguration != "" {
_ = writer.WriteField("kubeProxyConfiguration", req.KubeProxyConfiguration)
}
if req.JoinConfiguration != "" {
_ = writer.WriteField("joinConfiguration", req.JoinConfiguration)
}
if req.Description != "" {
_ = writer.WriteField("desc", req.Description)
}
if req.UserData != "" {
_ = writer.WriteField("userData", req.UserData)
}
// for i := uint64(0); i < dc.cfg.Retries; i++ { _ = writer.WriteField("extnetOnly", strconv.FormatBool(req.ExtNetOnly))
req.Body = io.NopCloser(bytes.NewBuffer(buf))
resp, err := dc.client.Do(req)
// if err == nil { ct := writer.FormDataContentType()
if resp.StatusCode == 200 {
return resp, err
}
respBytes, _ := io.ReadAll(resp.Body)
err = fmt.Errorf("%s", respBytes)
resp.Body.Close()
// }
// }
return nil, fmt.Errorf("could not execute request: %w", err) writer.Close()
return reqBody, ct
} }

@ -72,9 +72,7 @@ func ParseConfigJSON(path string) (Config, error) {
err = validators.ValidateConfig(config) err = validators.ValidateConfig(config)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return Config{}, validators.ValidationErrors(validators.GetErrors(err))
return Config{}, validators.ValidationError(validationError)
}
} }
return config, nil return config, nil
@ -96,9 +94,7 @@ func ParseConfigYAML(path string) (Config, error) {
err = validators.ValidateConfig(config) err = validators.ValidateConfig(config)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return Config{}, validators.ValidationErrors(validators.GetErrors(err))
return Config{}, validators.ValidationError(validationError)
}
} }
return config, nil return config, nil

@ -66,9 +66,7 @@ func ParseLegacyConfigJSON(path string) (LegacyConfig, error) {
err = validators.ValidateConfig(config) err = validators.ValidateConfig(config)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return LegacyConfig{}, validators.ValidationErrors(validators.GetErrors(err))
return LegacyConfig{}, validators.ValidationError(validationError)
}
} }
return config, nil return config, nil
@ -90,9 +88,7 @@ func ParseLegacyConfigYAML(path string) (LegacyConfig, error) {
err = validators.ValidateConfig(config) err = validators.ValidateConfig(config)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return LegacyConfig{}, validators.ValidationErrors(validators.GetErrors(err))
return LegacyConfig{}, validators.ValidationError(validationError)
}
} }
return config, nil return config, nil

@ -0,0 +1,41 @@
package multierror
func Join(errs ...error) error {
n := 0
for _, err := range errs {
if err != nil {
n++
}
}
if n == 0 {
return nil
}
e := &joinError{
errs: make([]error, 0, n),
}
for _, err := range errs {
if err != nil {
e.errs = append(e.errs, err)
}
}
return e
}
type joinError struct {
errs []error
}
func (e *joinError) Error() string {
var b []byte
for i, err := range e.errs {
if i > 0 {
b = append(b, '\n')
}
b = append(b, err.Error()...)
}
return string(b)
}
func (e *joinError) Unwrap() []error {
return e.errs
}

@ -2,6 +2,7 @@ package validators
import ( import (
"errors" "errors"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/multierror"
"github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10"
) )
@ -20,6 +21,14 @@ func ValidationError(fe validator.FieldError) error {
return errors.New(errorMessage(fe)) return errors.New(errorMessage(fe))
} }
func ValidationErrors(fes []validator.FieldError) error {
errs := make([]error, 0, len(fes))
for _, fe := range fes {
errs = append(errs, ValidationError(fe))
}
return multierror.Join(errs...)
}
//nolint:errorlint //nolint:errorlint
func GetErrors(err error) validator.ValidationErrors { func GetErrors(err error) validator.ValidationErrors {
return err.(validator.ValidationErrors) return err.(validator.ValidationErrors)

@ -18,8 +18,9 @@ import (
"github.com/google/go-querystring/query" "github.com/google/go-querystring/query"
"repository.basistech.ru/BASIS/decort-golang-sdk/config" "repository.basistech.ru/BASIS/decort-golang-sdk/config"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s" k8s_ca "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
k8s_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/k8s"
) )
// Legacy HTTP-client for platform // Legacy HTTP-client for platform
@ -71,165 +72,34 @@ func (ldc *LegacyDecortClient) CloudBroker() *cloudbroker.CloudBroker {
// DecortApiCall method for sending requests to the platform // DecortApiCall method for sending requests to the platform
func (ldc *LegacyDecortClient) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) { func (ldc *LegacyDecortClient) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) {
if k8sCreateReq, ok := params.(k8s.CreateRequest); ok {
reqBody := &bytes.Buffer{}
writer := multipart.NewWriter(reqBody)
if k8sCreateReq.OidcCertificate != "" {
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
_, _ = io.Copy(part, strings.NewReader(k8sCreateReq.OidcCertificate))
}
_ = writer.WriteField("name", k8sCreateReq.Name)
_ = writer.WriteField("rgId", strconv.FormatUint(k8sCreateReq.RGID, 10))
_ = writer.WriteField("k8ciId", strconv.FormatUint(k8sCreateReq.K8SCIID, 10))
_ = writer.WriteField("workerGroupName", k8sCreateReq.WorkerGroupName)
_ = writer.WriteField("networkPlugin", k8sCreateReq.NetworkPlugin)
if k8sCreateReq.MasterSEPID != 0 {
_ = writer.WriteField("masterSepId", strconv.FormatUint(k8sCreateReq.MasterSEPID, 10))
}
if k8sCreateReq.MasterSEPPool != "" {
_ = writer.WriteField("masterSepPool", k8sCreateReq.MasterSEPPool)
}
if k8sCreateReq.WorkerSEPID != 0 {
_ = writer.WriteField("workerSepId", strconv.FormatUint(k8sCreateReq.WorkerSEPID, 10))
}
if k8sCreateReq.WorkerSEPPool != "" {
_ = writer.WriteField("workerSepPool", k8sCreateReq.WorkerSEPPool)
}
if k8sCreateReq.Labels != nil {
for _, v := range k8sCreateReq.Labels {
_ = writer.WriteField("labels", v)
}
}
if k8sCreateReq.Taints != nil {
for _, v := range k8sCreateReq.Taints {
_ = writer.WriteField("taints", v)
}
}
if k8sCreateReq.Annotations != nil {
for _, v := range k8sCreateReq.Annotations {
_ = writer.WriteField("annotations", v)
}
}
if k8sCreateReq.MasterCPU != 0 {
_ = writer.WriteField("masterCpu", strconv.FormatUint(uint64(k8sCreateReq.MasterCPU), 10))
}
if k8sCreateReq.MasterNum != 0 {
_ = writer.WriteField("masterNum", strconv.FormatUint(uint64(k8sCreateReq.MasterNum), 10))
}
if k8sCreateReq.MasterRAM != 0 {
_ = writer.WriteField("masterRam", strconv.FormatUint(uint64(k8sCreateReq.MasterRAM), 10))
}
if k8sCreateReq.MasterDisk != 0 {
_ = writer.WriteField("masterDisk", strconv.FormatUint(uint64(k8sCreateReq.MasterDisk), 10))
}
if k8sCreateReq.WorkerCPU != 0 {
_ = writer.WriteField("workerCpu", strconv.FormatUint(uint64(k8sCreateReq.WorkerCPU), 10))
}
if k8sCreateReq.WorkerNum != 0 {
_ = writer.WriteField("workerNum", strconv.FormatUint(uint64(k8sCreateReq.WorkerNum), 10))
}
if k8sCreateReq.WorkerRAM != 0 {
_ = writer.WriteField("workerRam", strconv.FormatUint(uint64(k8sCreateReq.WorkerRAM), 10))
}
if k8sCreateReq.WorkerDisk != 0 {
_ = writer.WriteField("workerDisk", strconv.FormatUint(uint64(k8sCreateReq.WorkerDisk), 10))
}
if k8sCreateReq.ExtNetID != 0 {
_ = writer.WriteField("extnetId", strconv.FormatUint(k8sCreateReq.ExtNetID, 10))
}
if k8sCreateReq.VinsId != 0 {
_ = writer.WriteField("vinsId", strconv.FormatUint(k8sCreateReq.VinsId, 10))
}
if !k8sCreateReq.WithLB {
_ = writer.WriteField("withLB", strconv.FormatBool(k8sCreateReq.WithLB))
}
_ = writer.WriteField("highlyAvailableLB", strconv.FormatBool(k8sCreateReq.HighlyAvailable))
if k8sCreateReq.AdditionalSANs != nil {
for _, v := range k8sCreateReq.AdditionalSANs {
_ = writer.WriteField("additionalSANs", v)
}
}
if k8sCreateReq.InitConfiguration != "" {
_ = writer.WriteField("initConfiguration", k8sCreateReq.InitConfiguration)
}
if k8sCreateReq.ClusterConfiguration != "" {
_ = writer.WriteField("clusterConfiguration", k8sCreateReq.ClusterConfiguration)
}
if k8sCreateReq.KubeletConfiguration != "" {
_ = writer.WriteField("kubeletConfiguration", k8sCreateReq.KubeletConfiguration)
}
if k8sCreateReq.KubeProxyConfiguration != "" {
_ = writer.WriteField("kubeProxyConfiguration", k8sCreateReq.KubeProxyConfiguration)
}
if k8sCreateReq.JoinConfiguration != "" {
_ = writer.WriteField("joinConfiguration", k8sCreateReq.JoinConfiguration)
}
if k8sCreateReq.Description != "" {
_ = writer.WriteField("desc", k8sCreateReq.Description)
}
if k8sCreateReq.UserData != "" {
_ = writer.WriteField("userData", k8sCreateReq.UserData)
}
_ = writer.WriteField("extnetOnly", strconv.FormatBool(k8sCreateReq.ExtNetOnly))
_ = writer.FormDataContentType()
ct := writer.FormDataContentType()
if err := ldc.getToken(ctx); err != nil { if err := ldc.getToken(ctx); err != nil {
return nil, err return nil, err
} }
_ = writer.WriteField("authkey", ldc.cfg.Token) k8sCaCreateReq, okCa := params.(k8s_ca.CreateRequest)
k8sCbCreateReq, okCb := params.(k8s_cb.CreateRequest)
writer.Close() var body *bytes.Buffer
var ctype string
req, err := http.NewRequestWithContext(ctx, method, ldc.decortURL+"/restmachine"+url, reqBody)
if err != nil {
return nil, err
}
resp, err := ldc.domp(req, ct)
if err != nil {
return nil, err
}
defer resp.Body.Close()
respBytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
if resp.StatusCode != 200 {
return nil, errors.New(string(respBytes))
}
return respBytes, nil
}
if okCa {
body, ctype = createK8sCloudApiLegacy(k8sCaCreateReq, ldc.cfg.Token)
} else if okCb {
body, ctype = createK8sCloudBrokerLegacy(k8sCbCreateReq, ldc.cfg.Token)
} else {
values, err := query.Values(params) values, err := query.Values(params)
if err != nil { if err != nil {
return nil, err return nil, err
} }
body = bytes.NewBufferString(values.Encode() + fmt.Sprintf("&authkey=%s", ldc.cfg.Token))
if err = ldc.getToken(ctx); err != nil {
return nil, err
} }
body := strings.NewReader(values.Encode() + fmt.Sprintf("&authkey=%s", ldc.cfg.Token))
req, err := http.NewRequestWithContext(ctx, method, ldc.decortURL+"/restmachine"+url, body) req, err := http.NewRequestWithContext(ctx, method, ldc.decortURL+"/restmachine"+url, body)
if err != nil { if err != nil {
return nil, err return nil, err
} }
resp, err := ldc.do(req) resp, err := ldc.do(req, ctype)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -278,8 +148,12 @@ func (ldc *LegacyDecortClient) getToken(ctx context.Context) error {
return nil return nil
} }
func (ldc *LegacyDecortClient) do(req *http.Request) (*http.Response, error) { func (ldc *LegacyDecortClient) do(req *http.Request, ctype string) (*http.Response, error) {
if ctype != "" {
req.Header.Add("Content-Type", ctype)
} else {
req.Header.Add("Content-Type", "application/x-www-form-urlencoded") req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
}
req.Header.Set("Accept", "application/json") req.Header.Set("Accept", "application/json")
// var resp *http.Response // var resp *http.Response
@ -305,29 +179,234 @@ func (ldc *LegacyDecortClient) do(req *http.Request) (*http.Response, error) {
return nil, fmt.Errorf("could not execute request: %w", err) return nil, fmt.Errorf("could not execute request: %w", err)
} }
func (ldc *LegacyDecortClient) domp(req *http.Request, ctype string) (*http.Response, error) { func createK8sCloudApiLegacy(req k8s_ca.CreateRequest, token string) (*bytes.Buffer, string) {
req.Header.Add("Content-Type", ctype) reqBody := &bytes.Buffer{}
req.Header.Add("Authorization", "bearer "+ldc.cfg.Token) writer := multipart.NewWriter(reqBody)
req.Header.Set("Accept", "application/json") if req.OidcCertificate != "" {
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
_, _ = io.Copy(part, strings.NewReader(req.OidcCertificate))
}
// var resp *http.Response _ = writer.WriteField("name", req.Name)
// var err error _ = writer.WriteField("rgId", strconv.FormatUint(req.RGID, 10))
buf, _ := io.ReadAll(req.Body) _ = writer.WriteField("k8ciId", strconv.FormatUint(req.K8SCIID, 10))
// req = req.Clone(req.Context()) _ = writer.WriteField("workerGroupName", req.WorkerGroupName)
_ = writer.WriteField("networkPlugin", req.NetworkPlugin)
// for i := uint64(0); i < ldc.cfg.Retries; i++ { if req.MasterSEPID != 0 {
req.Body = io.NopCloser(bytes.NewBuffer(buf)) _ = writer.WriteField("masterSepId", strconv.FormatUint(req.MasterSEPID, 10))
resp, err := ldc.client.Do(req) }
if req.MasterSEPPool != "" {
_ = writer.WriteField("masterSepPool", req.MasterSEPPool)
}
if req.WorkerSEPID != 0 {
_ = writer.WriteField("workerSepId", strconv.FormatUint(req.WorkerSEPID, 10))
}
if req.WorkerSEPPool != "" {
_ = writer.WriteField("workerSepPool", req.WorkerSEPPool)
}
// if err == nil { if req.Labels != nil {
if resp.StatusCode == 200 { for _, v := range req.Labels {
return resp, err _ = writer.WriteField("labels", v)
}
}
if req.Taints != nil {
for _, v := range req.Taints {
_ = writer.WriteField("taints", v)
}
}
if req.Annotations != nil {
for _, v := range req.Annotations {
_ = writer.WriteField("annotations", v)
}
} }
respBytes, _ := io.ReadAll(resp.Body)
err = fmt.Errorf("%s", respBytes)
resp.Body.Close()
// }
// }
return nil, fmt.Errorf("could not execute request: %w", err) if req.MasterCPU != 0 {
_ = writer.WriteField("masterCpu", strconv.FormatUint(uint64(req.MasterCPU), 10))
}
if req.MasterNum != 0 {
_ = writer.WriteField("masterNum", strconv.FormatUint(uint64(req.MasterNum), 10))
}
if req.MasterRAM != 0 {
_ = writer.WriteField("masterRam", strconv.FormatUint(uint64(req.MasterRAM), 10))
}
if req.MasterDisk != 0 {
_ = writer.WriteField("masterDisk", strconv.FormatUint(uint64(req.MasterDisk), 10))
}
if req.WorkerCPU != 0 {
_ = writer.WriteField("workerCpu", strconv.FormatUint(uint64(req.WorkerCPU), 10))
}
if req.WorkerNum != 0 {
_ = writer.WriteField("workerNum", strconv.FormatUint(uint64(req.WorkerNum), 10))
}
if req.WorkerRAM != 0 {
_ = writer.WriteField("workerRam", strconv.FormatUint(uint64(req.WorkerRAM), 10))
}
if req.WorkerDisk != 0 {
_ = writer.WriteField("workerDisk", strconv.FormatUint(uint64(req.WorkerDisk), 10))
}
if req.ExtNetID != 0 {
_ = writer.WriteField("extnetId", strconv.FormatUint(req.ExtNetID, 10))
}
if req.VinsId != 0 {
_ = writer.WriteField("vinsId", strconv.FormatUint(req.VinsId, 10))
}
if !req.WithLB {
_ = writer.WriteField("withLB", strconv.FormatBool(req.WithLB))
}
_ = writer.WriteField("highlyAvailableLB", strconv.FormatBool(req.HighlyAvailable))
if req.AdditionalSANs != nil {
for _, v := range req.AdditionalSANs {
_ = writer.WriteField("additionalSANs", v)
}
}
if req.InitConfiguration != "" {
_ = writer.WriteField("initConfiguration", req.InitConfiguration)
}
if req.ClusterConfiguration != "" {
_ = writer.WriteField("clusterConfiguration", req.ClusterConfiguration)
}
if req.KubeletConfiguration != "" {
_ = writer.WriteField("kubeletConfiguration", req.KubeletConfiguration)
}
if req.KubeProxyConfiguration != "" {
_ = writer.WriteField("kubeProxyConfiguration", req.KubeProxyConfiguration)
}
if req.JoinConfiguration != "" {
_ = writer.WriteField("joinConfiguration", req.JoinConfiguration)
}
if req.Description != "" {
_ = writer.WriteField("desc", req.Description)
}
if req.UserData != "" {
_ = writer.WriteField("userData", req.UserData)
}
_ = writer.WriteField("extnetOnly", strconv.FormatBool(req.ExtNetOnly))
_ = writer.WriteField("authkey", token)
ct := writer.FormDataContentType()
writer.Close()
return reqBody, ct
}
func createK8sCloudBrokerLegacy(req k8s_cb.CreateRequest, token string) (*bytes.Buffer, string) {
reqBody := &bytes.Buffer{}
writer := multipart.NewWriter(reqBody)
if req.OidcCertificate != "" {
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
_, _ = io.Copy(part, strings.NewReader(req.OidcCertificate))
}
_ = writer.WriteField("name", req.Name)
_ = writer.WriteField("rgId", strconv.FormatUint(req.RGID, 10))
_ = writer.WriteField("k8ciId", strconv.FormatUint(req.K8CIID, 10))
_ = writer.WriteField("workerGroupName", req.WorkerGroupName)
_ = writer.WriteField("networkPlugin", req.NetworkPlugin)
if req.MasterSEPID != 0 {
_ = writer.WriteField("masterSepId", strconv.FormatUint(req.MasterSEPID, 10))
}
if req.MasterSEPPool != "" {
_ = writer.WriteField("masterSepPool", req.MasterSEPPool)
}
if req.WorkerSEPID != 0 {
_ = writer.WriteField("workerSepId", strconv.FormatUint(req.WorkerSEPID, 10))
}
if req.WorkerSEPPool != "" {
_ = writer.WriteField("workerSepPool", req.WorkerSEPPool)
}
if req.Labels != nil {
for _, v := range req.Labels {
_ = writer.WriteField("labels", v)
}
}
if req.Taints != nil {
for _, v := range req.Taints {
_ = writer.WriteField("taints", v)
}
}
if req.Annotations != nil {
for _, v := range req.Annotations {
_ = writer.WriteField("annotations", v)
}
}
if req.MasterCPU != 0 {
_ = writer.WriteField("masterCpu", strconv.FormatUint(req.MasterCPU, 10))
}
if req.MasterNum != 0 {
_ = writer.WriteField("masterNum", strconv.FormatUint(req.MasterNum, 10))
}
if req.MasterRAM != 0 {
_ = writer.WriteField("masterRam", strconv.FormatUint(req.MasterRAM, 10))
}
if req.MasterDisk != 0 {
_ = writer.WriteField("masterDisk", strconv.FormatUint(req.MasterDisk, 10))
}
if req.WorkerCPU != 0 {
_ = writer.WriteField("workerCpu", strconv.FormatUint(req.WorkerCPU, 10))
}
if req.WorkerNum != 0 {
_ = writer.WriteField("workerNum", strconv.FormatUint(req.WorkerNum, 10))
}
if req.WorkerRAM != 0 {
_ = writer.WriteField("workerRam", strconv.FormatUint(req.WorkerRAM, 10))
}
if req.WorkerDisk != 0 {
_ = writer.WriteField("workerDisk", strconv.FormatUint(req.WorkerDisk, 10))
}
if req.ExtNetID != 0 {
_ = writer.WriteField("extnetId", strconv.FormatUint(req.ExtNetID, 10))
}
if req.VinsId != 0 {
_ = writer.WriteField("vinsId", strconv.FormatUint(req.VinsId, 10))
}
if !req.WithLB {
_ = writer.WriteField("withLB", strconv.FormatBool(req.WithLB))
}
_ = writer.WriteField("highlyAvailableLB", strconv.FormatBool(req.HighlyAvailable))
if req.AdditionalSANs != nil {
for _, v := range req.AdditionalSANs {
_ = writer.WriteField("additionalSANs", v)
}
}
if req.InitConfiguration != "" {
_ = writer.WriteField("initConfiguration", req.InitConfiguration)
}
if req.ClusterConfiguration != "" {
_ = writer.WriteField("clusterConfiguration", req.ClusterConfiguration)
}
if req.KubeletConfiguration != "" {
_ = writer.WriteField("kubeletConfiguration", req.KubeletConfiguration)
}
if req.KubeProxyConfiguration != "" {
_ = writer.WriteField("kubeProxyConfiguration", req.KubeProxyConfiguration)
}
if req.JoinConfiguration != "" {
_ = writer.WriteField("joinConfiguration", req.JoinConfiguration)
}
if req.Description != "" {
_ = writer.WriteField("desc", req.Description)
}
if req.UserData != "" {
_ = writer.WriteField("userData", req.UserData)
}
_ = writer.WriteField("extnetOnly", strconv.FormatBool(req.ExtNetOnly))
_ = writer.WriteField("authkey", token)
ct := writer.FormDataContentType()
writer.Close()
return reqBody, ct
} }

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for adding permission to access to account for a user // AddUserRequest struct to add permission to access account for a user
type AddUserRequest struct { type AddUserRequest struct {
// ID of account to add to // ID of account to add to
// Required: true // Required: true
@ -30,9 +30,7 @@ type AddUserRequest struct {
func (a Account) AddUser(ctx context.Context, req AddUserRequest) (bool, error) { func (a Account) AddUser(ctx context.Context, req AddUserRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/addUser" url := "/cloudapi/account/addUser"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for give list account audits // AuditsRequest struct to give list of account audits
type AuditsRequest struct { type AuditsRequest struct {
// ID of the account // ID of the account
// Required: true // Required: true
@ -19,9 +19,7 @@ type AuditsRequest struct {
func (a Account) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) { func (a Account) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/audits" url := "/cloudapi/account/audits"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for creating account // CreateRequest struct for creating account
type CreateRequest struct { type CreateRequest struct {
// Display name // Display name
// Required: true // Required: true
@ -56,9 +56,7 @@ type CreateRequest struct {
func (a Account) Create(ctx context.Context, req CreateRequest) (uint64, error) { func (a Account) Create(ctx context.Context, req CreateRequest) (uint64, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return 0, validators.ValidationErrors(validators.GetErrors(err))
return 0, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/create" url := "/cloudapi/account/create"

@ -7,7 +7,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for delete account // DeleteRequest struct to delete account
type DeleteRequest struct { type DeleteRequest struct {
// ID of account to delete // ID of account to delete
// Required: true // Required: true
@ -22,9 +22,7 @@ type DeleteRequest struct {
func (a Account) Delete(ctx context.Context, req DeleteRequest) (bool, error) { func (a Account) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/delete" url := "/cloudapi/account/delete"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for revoke access to account // DeleteUserRequest struct to revoke access to account
type DeleteUserRequest struct { type DeleteUserRequest struct {
// ID of the account // ID of the account
// Required: true // Required: true
@ -20,16 +20,14 @@ type DeleteUserRequest struct {
// Recursively revoke access rights from owned cloudspaces and vmachines // Recursively revoke access rights from owned cloudspaces and vmachines
// Required: false // Required: false
RecursiveDelete bool `url:"recursivedelete,omitempty" json:"recursivedelete,omitempty"` RecursiveDelete bool `url:"recursivedelete" json:"recursivedelete"`
} }
// DeleteUser revokes user access from the account // DeleteUser revokes user access from the account
func (a Account) DeleteUser(ctx context.Context, req DeleteUserRequest) (bool, error) { func (a Account) DeleteUser(ctx context.Context, req DeleteUserRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/deleteUser" url := "/cloudapi/account/deleteUser"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for change status of account // DisableEnableRequest struct to change status of account
type DisableEnableRequest struct { type DisableEnableRequest struct {
// ID of account // ID of account
// Required: true // Required: true
@ -19,9 +19,7 @@ type DisableEnableRequest struct {
func (a Account) Disable(ctx context.Context, req DisableEnableRequest) (bool, error) { func (a Account) Disable(ctx context.Context, req DisableEnableRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/disable" url := "/cloudapi/account/disable"
@ -43,9 +41,7 @@ func (a Account) Disable(ctx context.Context, req DisableEnableRequest) (bool, e
func (a Account) Enable(ctx context.Context, req DisableEnableRequest) (bool, error) { func (a Account) Enable(ctx context.Context, req DisableEnableRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/enable" url := "/cloudapi/account/enable"

@ -37,9 +37,7 @@ func (a Account) Get(ctx context.Context, req GetRequest) (*RecordAccount, error
func (a Account) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) { func (a Account) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/get" url := "/cloudapi/account/get"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for calculate the currently consumed units for all cloudspaces and resource groups in the account // GetConsumedAccountUnitsRequest struct to calculate the currently consumed units for all cloudspaces and resource groups in the account
type GetConsumedAccountUnitsRequest struct { type GetConsumedAccountUnitsRequest struct {
// ID an account // ID an account
// Required: true // Required: true
@ -25,9 +25,7 @@ type GetConsumedAccountUnitsRequest struct {
func (a Account) GetConsumedAccountUnits(ctx context.Context, req GetConsumedAccountUnitsRequest) (*ResourceLimits, error) { func (a Account) GetConsumedAccountUnits(ctx context.Context, req GetConsumedAccountUnitsRequest) (*ResourceLimits, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/getConsumedAccountUnits" url := "/cloudapi/account/getConsumedAccountUnits"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for calculate the currently consumed cloud units of the specified type for all cloudspaces and resource groups in the account // GetConsumedCloudUnitsByTypeRequest struct to calculate the currently consumed cloud units of the specified type for all cloudspaces and resource groups in the account
type GetConsumedCloudUnitsByTypeRequest struct { type GetConsumedCloudUnitsByTypeRequest struct {
// ID an account // ID an account
// Required: true // Required: true
@ -35,9 +35,7 @@ type GetConsumedCloudUnitsByTypeRequest struct {
func (a Account) GetConsumedCloudUnitsByType(ctx context.Context, req GetConsumedCloudUnitsByTypeRequest) (float64, error) { func (a Account) GetConsumedCloudUnitsByType(ctx context.Context, req GetConsumedCloudUnitsByTypeRequest) (float64, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return 0, validators.ValidationErrors(validators.GetErrors(err))
return 0, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/getConsumedCloudUnitsByType" url := "/cloudapi/account/getConsumedCloudUnitsByType"

@ -7,7 +7,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for download the resources tracking files for an account // GetConsumptionRequest struct to download the resources tracking files for an account
type GetConsumptionRequest struct { type GetConsumptionRequest struct {
// ID an account // ID an account
// Required: true // Required: true
@ -26,9 +26,7 @@ type GetConsumptionRequest struct {
func (a Account) GetConsumption(ctx context.Context, req GetConsumptionRequest) (string, error) { func (a Account) GetConsumption(ctx context.Context, req GetConsumptionRequest) (string, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return "", validators.ValidationErrors(validators.GetErrors(err))
return "", validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/getConsumption" url := "/cloudapi/account/getConsumption"
@ -46,9 +44,7 @@ func (a Account) GetConsumption(ctx context.Context, req GetConsumptionRequest)
func (a Account) GetConsumptionGet(ctx context.Context, req GetConsumptionRequest) (string, error) { func (a Account) GetConsumptionGet(ctx context.Context, req GetConsumptionRequest) (string, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return "", validators.ValidationErrors(validators.GetErrors(err))
return "", validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/getConsumption" url := "/cloudapi/account/getConsumption"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for calculate the reserved units for all cloudspaces and resource groups in the account // GetReservedAccountUnitsRequest struct to calculate the reserved units for all cloudspaces and resource groups in the account
type GetReservedAccountUnitsRequest struct { type GetReservedAccountUnitsRequest struct {
// ID an account // ID an account
// Required: true // Required: true
@ -26,9 +26,7 @@ type GetReservedAccountUnitsRequest struct {
func (a Account) GetReservedAccountUnits(ctx context.Context, req GetReservedAccountUnitsRequest) (*ResourceLimits, error) { func (a Account) GetReservedAccountUnits(ctx context.Context, req GetReservedAccountUnitsRequest) (*ResourceLimits, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/getReservedAccountUnits" url := "/cloudapi/account/getReservedAccountUnits"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for getting resource consumption // GetResourceConsumptionRequest struct to get resource consumption
type GetResourceConsumptionRequest struct { type GetResourceConsumptionRequest struct {
// ID an account // ID an account
// Required: true // Required: true
@ -19,9 +19,7 @@ type GetResourceConsumptionRequest struct {
func (a Account) GetResourceConsumption(ctx context.Context, req GetResourceConsumptionRequest) (*RecordResourceConsumption, error) { func (a Account) GetResourceConsumption(ctx context.Context, req GetResourceConsumptionRequest) (*RecordResourceConsumption, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/getResourceConsumption" url := "/cloudapi/account/getResourceConsumption"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for a get list compute instances // ListComputesRequest struct to get a list of compute instances
type ListComputesRequest struct { type ListComputesRequest struct {
// ID an account // ID an account
// Required: true // Required: true
@ -59,9 +59,7 @@ type ListComputesRequest struct {
func (a Account) ListComputes(ctx context.Context, req ListComputesRequest) (*ListComputes, error) { func (a Account) ListComputes(ctx context.Context, req ListComputesRequest) (*ListComputes, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/listComputes" url := "/cloudapi/account/listComputes"

@ -6,7 +6,7 @@ import (
"net/http" "net/http"
) )
// Request struct for get list deleted accounts // ListDeletedRequest struct to get a list of deleted accounts
type ListDeletedRequest struct { type ListDeletedRequest struct {
// Page number // Page number
// Required: false // Required: false
@ -29,7 +29,7 @@ type ListDeletedRequest struct {
ACL string `url:"acl,omitempty" json:"acl,omitempty"` ACL string `url:"acl,omitempty" json:"acl,omitempty"`
} }
// ListDeleted gets list all deleted accounts the user has access to // ListDeleted gets list of all deleted accounts the user has access to
func (a Account) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListAccounts, error) { func (a Account) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListAccounts, error) {
url := "/cloudapi/account/listDeleted" url := "/cloudapi/account/listDeleted"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for get list deleted disks // ListDisksRequest struct to get a list of deleted disks
type ListDisksRequest struct { type ListDisksRequest struct {
// ID an account // ID an account
// Required: true // Required: true
@ -43,9 +43,7 @@ type ListDisksRequest struct {
func (a Account) ListDisks(ctx context.Context, req ListDisksRequest) (*ListDisks, error) { func (a Account) ListDisks(ctx context.Context, req ListDisksRequest) (*ListDisks, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/listDisks" url := "/cloudapi/account/listDisks"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for get list FLIPGroups // ListFLIPGroupsRequest struct to get a list of FLIPGroups
type ListFLIPGroupsRequest struct { type ListFLIPGroupsRequest struct {
// ID of the account // ID of the account
// Required: true // Required: true
@ -51,9 +51,7 @@ type ListFLIPGroupsRequest struct {
func (a Account) ListFLIPGroups(ctx context.Context, req ListFLIPGroupsRequest) (*ListFLIPGroups, error) { func (a Account) ListFLIPGroups(ctx context.Context, req ListFLIPGroupsRequest) (*ListFLIPGroups, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/listFlipGroups" url := "/cloudapi/account/listFlipGroups"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for get list resource groups // ListRGRequest struct to get a list of resource groups
type ListRGRequest struct { type ListRGRequest struct {
// ID an account // ID an account
// Required: true // Required: true
@ -43,13 +43,11 @@ type ListRGRequest struct {
Status string `url:"status,omitempty" json:"status,omitempty"` Status string `url:"status,omitempty" json:"status,omitempty"`
} }
// ListRG gets list all resource groups under specified account, accessible by the user // ListRG gets list of all resource groups under specified account, accessible by the user
func (a Account) ListRG(ctx context.Context, req ListRGRequest) (*ListRG, error) { func (a Account) ListRG(ctx context.Context, req ListRGRequest) (*ListRG, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/listRG" url := "/cloudapi/account/listRG"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for get list templates // ListTemplatesRequest struct to get a list of templates
type ListTemplatesRequest struct { type ListTemplatesRequest struct {
// ID an account // ID an account
// Required: true // Required: true
@ -39,13 +39,11 @@ type ListTemplatesRequest struct {
Size uint64 `url:"size,omitempty" json:"size,omitempty"` Size uint64 `url:"size,omitempty" json:"size,omitempty"`
} }
// ListTemplates gets list templates which can be managed by this account // ListTemplates gets list of templates which can be managed by this account
func (a Account) ListTemplates(ctx context.Context, req ListTemplatesRequest) (*ListTemplates, error) { func (a Account) ListTemplates(ctx context.Context, req ListTemplatesRequest) (*ListTemplates, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/listTemplates" url := "/cloudapi/account/listTemplates"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for get list VINS // ListVINSRequest struct to get a list of VINS
type ListVINSRequest struct { type ListVINSRequest struct {
// ID an account // ID an account
// Required: true // Required: true
@ -39,13 +39,11 @@ type ListVINSRequest struct {
Size uint64 `url:"size,omitempty" json:"size,omitempty"` Size uint64 `url:"size,omitempty" json:"size,omitempty"`
} }
// ListVINS gets list all ViNSes under specified account, accessible by the user // ListVINS gets list of all ViNSes under specified account, accessible by the user
func (a Account) ListVINS(ctx context.Context, req ListVINSRequest) (*ListVINS, error) { func (a Account) ListVINS(ctx context.Context, req ListVINSRequest) (*ListVINS, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/listVins" url := "/cloudapi/account/listVins"

@ -6,7 +6,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for restore a deleted account // RestoreRequest struct to restore a deleted account
type RestoreRequest struct { type RestoreRequest struct {
// ID an account // ID an account
// Required: true // Required: true
@ -17,9 +17,7 @@ type RestoreRequest struct {
func (a Account) Restore(ctx context.Context, req RestoreRequest) (bool, error) { func (a Account) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/restore" url := "/cloudapi/account/restore"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for updaate account // UpdateRequest struct to update account
type UpdateRequest struct { type UpdateRequest struct {
// ID an account // ID an account
// Required: true // Required: true
@ -51,9 +51,7 @@ type UpdateRequest struct {
func (a Account) Update(ctx context.Context, req UpdateRequest) (bool, error) { func (a Account) Update(ctx context.Context, req UpdateRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/update" url := "/cloudapi/account/update"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for update user access rights // UpdateUserRequest struct to update user access rights
type UpdateUserRequest struct { type UpdateUserRequest struct {
// ID of the account // ID of the account
// Required: true // Required: true
@ -30,9 +30,7 @@ type UpdateUserRequest struct {
func (a Account) UpdateUser(ctx context.Context, req UpdateUserRequest) (bool, error) { func (a Account) UpdateUser(ctx context.Context, req UpdateUserRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/account/updateUser" url := "/cloudapi/account/updateUser"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for BasicService // CreateRequest struct for BasicService
type CreateRequest struct { type CreateRequest struct {
// Name of the service // Name of the service
// Required: true // Required: true
@ -31,9 +31,7 @@ type CreateRequest struct {
func (b BService) Create(ctx context.Context, req CreateRequest) (uint64, error) { func (b BService) Create(ctx context.Context, req CreateRequest) (uint64, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return 0, validators.ValidationErrors(validators.GetErrors(err))
return 0, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/create" url := "/cloudapi/bservice/create"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for delete basic service // DeleteRequest struct to delete basic service
type DeleteRequest struct { type DeleteRequest struct {
// ID of the BasicService to be delete // ID of the BasicService to be delete
// Required: true // Required: true
@ -23,9 +23,7 @@ type DeleteRequest struct {
func (b BService) Delete(ctx context.Context, req DeleteRequest) (bool, error) { func (b BService) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/delete" url := "/cloudapi/bservice/delete"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for disable service // DisableRequest struct for disable service
type DisableRequest struct { type DisableRequest struct {
// ID of the service to disable // ID of the service to disable
// Required: true // Required: true
@ -21,9 +21,7 @@ type DisableRequest struct {
func (b BService) Disable(ctx context.Context, req DisableRequest) (bool, error) { func (b BService) Disable(ctx context.Context, req DisableRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/delete" url := "/cloudapi/bservice/delete"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for disable service // EnableRequest struct to disable service
type EnableRequest struct { type EnableRequest struct {
// ID of the service to enable // ID of the service to enable
// Required: true // Required: true
@ -22,9 +22,7 @@ type EnableRequest struct {
func (b BService) Enable(ctx context.Context, req EnableRequest) (bool, error) { func (b BService) Enable(ctx context.Context, req EnableRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/enable" url := "/cloudapi/bservice/enable"

@ -36,9 +36,7 @@ func (b BService) Get(ctx context.Context, req GetRequest) (*RecordBasicService,
func (b BService) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) { func (b BService) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/get" url := "/cloudapi/bservice/get"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for create new compute group within BasicService // GroupAddRequest struct to create new compute group within BasicService
type GroupAddRequest struct { type GroupAddRequest struct {
// ID of the Basic Service to add a group to // ID of the Basic Service to add a group to
// Required: true // Required: true
@ -80,9 +80,7 @@ type GroupAddRequest struct {
func (b BService) GroupAdd(ctx context.Context, req GroupAddRequest) (uint64, error) { func (b BService) GroupAdd(ctx context.Context, req GroupAddRequest) (uint64, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return 0, validators.ValidationErrors(validators.GetErrors(err))
return 0, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/groupAdd" url := "/cloudapi/bservice/groupAdd"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for remove group compute // GroupComputeRemoveRequest struct to remove group compute
type GroupComputeRemoveRequest struct { type GroupComputeRemoveRequest struct {
// ID of the Basic Service // ID of the Basic Service
// Required: true // Required: true
@ -27,9 +27,7 @@ type GroupComputeRemoveRequest struct {
func (b BService) GroupComputeRemove(ctx context.Context, req GroupComputeRemoveRequest) (bool, error) { func (b BService) GroupComputeRemove(ctx context.Context, req GroupComputeRemoveRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/groupComputeRemove" url := "/cloudapi/bservice/groupComputeRemove"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for get detailed information about Compute Group // GroupGetRequest struct to get detailed information about Compute Group
type GroupGetRequest struct { type GroupGetRequest struct {
// ID of the Basic Service of Compute Group // ID of the Basic Service of Compute Group
// Required: true // Required: true
@ -23,9 +23,7 @@ type GroupGetRequest struct {
func (b BService) GroupGet(ctx context.Context, req GroupGetRequest) (*RecordGroup, error) { func (b BService) GroupGet(ctx context.Context, req GroupGetRequest) (*RecordGroup, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/groupGet" url := "/cloudapi/bservice/groupGet"

@ -8,8 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for add parent Compute Group relation emove parent Compute Group // GroupParentAddRequest struct to add parent Compute Group relation to the specified Compute Group
// relation to the specified Compute Group
type GroupParentAddRequest struct { type GroupParentAddRequest struct {
// ID of the Basic Service of Compute Group // ID of the Basic Service of Compute Group
// Required: true // Required: true
@ -28,9 +27,7 @@ type GroupParentAddRequest struct {
func (b BService) GroupParentAdd(ctx context.Context, req GroupParentAddRequest) (bool, error) { func (b BService) GroupParentAdd(ctx context.Context, req GroupParentAddRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/groupParentAdd" url := "/cloudapi/bservice/groupParentAdd"

@ -8,8 +8,8 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for remove parent Compute Group // GroupParentRemoveRequest struct to remove parent Compute Group
// relation to the specified Compute Group // relation from the specified Compute Group
type GroupParentRemoveRequest struct { type GroupParentRemoveRequest struct {
// ID of the Basic Service of Compute Group // ID of the Basic Service of Compute Group
// Required: true // Required: true
@ -29,9 +29,7 @@ type GroupParentRemoveRequest struct {
func (b BService) GroupParentRemove(ctx context.Context, req GroupParentRemoveRequest) (bool, error) { func (b BService) GroupParentRemove(ctx context.Context, req GroupParentRemoveRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/groupParentRemove" url := "/cloudapi/bservice/groupParentRemove"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for destroy the specified Compute Group // GroupRemoveRequest struct for destroy the specified Compute Group
type GroupRemoveRequest struct { type GroupRemoveRequest struct {
// ID of the Basic Service of Compute Group // ID of the Basic Service of Compute Group
// Required: true // Required: true
@ -23,9 +23,7 @@ type GroupRemoveRequest struct {
func (b BService) GroupRemove(ctx context.Context, req GroupRemoveRequest) (bool, error) { func (b BService) GroupRemove(ctx context.Context, req GroupRemoveRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/groupRemove" url := "/cloudapi/bservice/groupRemove"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for resize the group // GroupResizeRequest struct to resize the group
type GroupResizeRequest struct { type GroupResizeRequest struct {
// ID of the Basic Service of Compute Group // ID of the Basic Service of Compute Group
// Required: true // Required: true
@ -34,9 +34,7 @@ type GroupResizeRequest struct {
func (b BService) GroupResize(ctx context.Context, req GroupResizeRequest) (uint64, error) { func (b BService) GroupResize(ctx context.Context, req GroupResizeRequest) (uint64, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return 0, validators.ValidationErrors(validators.GetErrors(err))
return 0, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/groupResize" url := "/cloudapi/bservice/groupResize"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for start the specified Compute Group // GroupStartRequest struct to start the specified Compute Group
type GroupStartRequest struct { type GroupStartRequest struct {
// ID of the Basic Service of Compute Group // ID of the Basic Service of Compute Group
// Required: true // Required: true
@ -23,9 +23,7 @@ type GroupStartRequest struct {
func (b BService) GroupStart(ctx context.Context, req GroupStartRequest) (bool, error) { func (b BService) GroupStart(ctx context.Context, req GroupStartRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/groupStart" url := "/cloudapi/bservice/groupStart"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for stop the specified Compute Group // GroupStopRequest struct to stop the specified Compute Group
type GroupStopRequest struct { type GroupStopRequest struct {
// ID of the Basic Service of Compute Group // ID of the Basic Service of Compute Group
// Required: true // Required: true
@ -27,9 +27,7 @@ type GroupStopRequest struct {
func (b BService) GroupStop(ctx context.Context, req GroupStopRequest) (bool, error) { func (b BService) GroupStop(ctx context.Context, req GroupStopRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/groupStop" url := "/cloudapi/bservice/groupStop"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for update existing Compute group // GroupUpdateRequest struct to update existing Compute group
type GroupUpdateRequest struct { type GroupUpdateRequest struct {
// ID of the Basic Service of Compute Group // ID of the Basic Service of Compute Group
// Required: true // Required: true
@ -47,9 +47,7 @@ type GroupUpdateRequest struct {
func (b BService) GroupUpdate(ctx context.Context, req GroupUpdateRequest) (bool, error) { func (b BService) GroupUpdate(ctx context.Context, req GroupUpdateRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/groupUpdate" url := "/cloudapi/bservice/groupUpdate"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for update External Network settings // GroupUpdateExtNetRequest struct to update External Network settings
type GroupUpdateExtNetRequest struct { type GroupUpdateExtNetRequest struct {
// ID of the Basic Service of Compute Group // ID of the Basic Service of Compute Group
// Required: true // Required: true
@ -27,9 +27,7 @@ type GroupUpdateExtNetRequest struct {
func (b BService) GroupUpdateExtNet(ctx context.Context, req GroupUpdateExtNetRequest) (bool, error) { func (b BService) GroupUpdateExtNet(ctx context.Context, req GroupUpdateExtNetRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/groupUpdateExtnet" url := "/cloudapi/bservice/groupUpdateExtnet"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for update VINS settings // GroupUpdateVINSRequest struct to update VINS settings
type GroupUpdateVINSRequest struct { type GroupUpdateVINSRequest struct {
// ID of the Basic Service of Compute Group // ID of the Basic Service of Compute Group
// Required: true // Required: true
@ -27,9 +27,7 @@ type GroupUpdateVINSRequest struct {
func (b BService) GroupUpdateVINS(ctx context.Context, req GroupUpdateVINSRequest) (bool, error) { func (b BService) GroupUpdateVINS(ctx context.Context, req GroupUpdateVINSRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/groupUpdateVins" url := "/cloudapi/bservice/groupUpdateVins"

@ -6,7 +6,7 @@ import (
"net/http" "net/http"
) )
// Request struct for get list of deleted BasicService instances // ListDeletedRequest struct to get list of deleted BasicService instances
type ListDeletedRequest struct { type ListDeletedRequest struct {
// ID of the account to query for BasicService instances // ID of the account to query for BasicService instances
// Required: false // Required: false
@ -25,7 +25,7 @@ type ListDeletedRequest struct {
Size uint64 `url:"size,omitempty" json:"size,omitempty"` Size uint64 `url:"size,omitempty" json:"size,omitempty"`
} }
// ListDeleted gets list deleted BasicService instances associated with the specified Resource Group // ListDeleted gets list of deleted BasicService instances associated with the specified Resource Group
func (b BService) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListBasicServices, error) { func (b BService) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListBasicServices, error) {
url := "/cloudapi/bservice/listDeleted" url := "/cloudapi/bservice/listDeleted"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for restores BasicService instance // RestoreRequest struct to restore BasicService instance
type RestoreRequest struct { type RestoreRequest struct {
// ID of the BasicService to be restored // ID of the BasicService to be restored
// Required: true // Required: true
@ -19,9 +19,7 @@ type RestoreRequest struct {
func (b BService) Restore(ctx context.Context, req RestoreRequest) (bool, error) { func (b BService) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/restore" url := "/cloudapi/bservice/restore"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for create snapshot // SnapshotCreateRequest struct to create snapshot
type SnapshotCreateRequest struct { type SnapshotCreateRequest struct {
// ID of the Basic Service // ID of the Basic Service
// Required: true // Required: true
@ -23,9 +23,7 @@ type SnapshotCreateRequest struct {
func (b BService) SnapshotCreate(ctx context.Context, req SnapshotCreateRequest) (bool, error) { func (b BService) SnapshotCreate(ctx context.Context, req SnapshotCreateRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/snapshotCreate" url := "/cloudapi/bservice/snapshotCreate"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for delete snapshot // SnapshotDeleteRequest struct to delete snapshot
type SnapshotDeleteRequest struct { type SnapshotDeleteRequest struct {
// ID of the Basic Service // ID of the Basic Service
// Required: true // Required: true
@ -23,9 +23,7 @@ type SnapshotDeleteRequest struct {
func (b BService) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (bool, error) { func (b BService) SnapshotDelete(ctx context.Context, req SnapshotDeleteRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/snapshotDelete" url := "/cloudapi/bservice/snapshotDelete"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for get list existing snapshots // SnapshotListRequest struct to get list of existing snapshots
type SnapshotListRequest struct { type SnapshotListRequest struct {
// ID of the Basic Service // ID of the Basic Service
// Required: true // Required: true
@ -19,9 +19,7 @@ type SnapshotListRequest struct {
func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest) (ListSnapshots, error) { func (b BService) SnapshotList(ctx context.Context, req SnapshotListRequest) (ListSnapshots, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/snapshotList" url := "/cloudapi/bservice/snapshotList"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for rollback snapshot // SnapshotRollbackRequest struct to rollback snapshot
type SnapshotRollbackRequest struct { type SnapshotRollbackRequest struct {
// ID of the Basic Service // ID of the Basic Service
// Required: true // Required: true
@ -23,9 +23,7 @@ type SnapshotRollbackRequest struct {
func (b BService) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest) (bool, error) { func (b BService) SnapshotRollback(ctx context.Context, req SnapshotRollbackRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/snapshotRollback" url := "/cloudapi/bservice/snapshotRollback"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for start service // StartRequest struct to start service
type StartRequest struct { type StartRequest struct {
// ID of the service to start // ID of the service to start
// Required: true // Required: true
@ -21,9 +21,7 @@ type StartRequest struct {
func (b BService) Start(ctx context.Context, req StartRequest) (bool, error) { func (b BService) Start(ctx context.Context, req StartRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/start" url := "/cloudapi/bservice/start"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for stop service // StopRequest struct to stop service
type StopRequest struct { type StopRequest struct {
// ID of the service to stop // ID of the service to stop
// Required: true // Required: true
@ -21,9 +21,7 @@ type StopRequest struct {
func (b BService) Stop(ctx context.Context, req StopRequest) (bool, error) { func (b BService) Stop(ctx context.Context, req StopRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/bservice/stop" url := "/cloudapi/bservice/stop"

@ -7,7 +7,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for check all computes with current affinity label can start // AffinityGroupCheckStartRequest struct to check all computes with current affinity label can start
type AffinityGroupCheckStartRequest struct { type AffinityGroupCheckStartRequest struct {
// ID of the resource group // ID of the resource group
// Required: true // Required: true
@ -22,9 +22,7 @@ type AffinityGroupCheckStartRequest struct {
func (c Compute) AffinityGroupCheckStart(ctx context.Context, req AffinityGroupCheckStartRequest) (string, error) { func (c Compute) AffinityGroupCheckStart(ctx context.Context, req AffinityGroupCheckStartRequest) (string, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return "", validators.ValidationErrors(validators.GetErrors(err))
return "", validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/affinityGroupCheckStart" url := "/cloudapi/compute/affinityGroupCheckStart"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for clear affinity label for compute // AffinityLabelRemoveRequest struct to clear affinity label for compute
type AffinityLabelRemoveRequest struct { type AffinityLabelRemoveRequest struct {
// ID of the compute instance // ID of the compute instance
// Required: true // Required: true
@ -19,9 +19,7 @@ type AffinityLabelRemoveRequest struct {
func (c Compute) AffinityLabelRemove(ctx context.Context, req AffinityLabelRemoveRequest) (bool, error) { func (c Compute) AffinityLabelRemove(ctx context.Context, req AffinityLabelRemoveRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/affinityLabelRemove" url := "/cloudapi/compute/affinityLabelRemove"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for set affinity label for compute // AffinityLabelSetRequest struct to set affinity label for compute
type AffinityLabelSetRequest struct { type AffinityLabelSetRequest struct {
// ID of the compute instance // ID of the compute instance
// Required: true // Required: true
@ -23,9 +23,7 @@ type AffinityLabelSetRequest struct {
func (c Compute) AffinityLabelSet(ctx context.Context, req AffinityLabelSetRequest) (bool, error) { func (c Compute) AffinityLabelSet(ctx context.Context, req AffinityLabelSetRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/affinityLabelSet" url := "/cloudapi/compute/affinityLabelSet"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for get dict of computes // AffinityRelationsRequest struct to get dict of computes
type AffinityRelationsRequest struct { type AffinityRelationsRequest struct {
// ID of the compute instance // ID of the compute instance
// Required: true // Required: true
@ -19,9 +19,7 @@ type AffinityRelationsRequest struct {
func (c Compute) AffinityRelations(ctx context.Context, req AffinityRelationsRequest) (*RecordAffinityRelations, error) { func (c Compute) AffinityRelations(ctx context.Context, req AffinityRelationsRequest) (*RecordAffinityRelations, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/affinityRelations" url := "/cloudapi/compute/affinityRelations"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for add affinity rule // AffinityRuleAddRequest struct to add affinity rule
type AffinityRuleAddRequest struct { type AffinityRuleAddRequest struct {
// ID of the compute instance // ID of the compute instance
// Required: true // Required: true
@ -46,9 +46,7 @@ type AffinityRuleAddRequest struct {
func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest) (bool, error) { func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/affinityRuleAdd" url := "/cloudapi/compute/affinityRuleAdd"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for remove affinity rule // AffinityRuleRemoveRequest struct to remove affinity rule
type AffinityRuleRemoveRequest struct { type AffinityRuleRemoveRequest struct {
// ID of the compute instance // ID of the compute instance
// Required: true // Required: true
@ -46,9 +46,7 @@ type AffinityRuleRemoveRequest struct {
func (c Compute) AffinityRuleRemove(ctx context.Context, req AffinityRuleRemoveRequest) (bool, error) { func (c Compute) AffinityRuleRemove(ctx context.Context, req AffinityRuleRemoveRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/affinityRuleRemove" url := "/cloudapi/compute/affinityRuleRemove"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for clear affinity rules // AffinityRulesClearRequest struct to clear affinity rules
type AffinityRulesClearRequest struct { type AffinityRulesClearRequest struct {
// ID of the compute instance // ID of the compute instance
// Required: true // Required: true
@ -19,9 +19,7 @@ type AffinityRulesClearRequest struct {
func (c Compute) AffinityRulesClear(ctx context.Context, req AffinityRulesClearRequest) (bool, error) { func (c Compute) AffinityRulesClear(ctx context.Context, req AffinityRulesClearRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/affinityRulesClear" url := "/cloudapi/compute/affinityRulesClear"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for add anti affinity rule // AntiAffinityRuleAddRequest struct to add anti affinity rule
type AntiAffinityRuleAddRequest struct { type AntiAffinityRuleAddRequest struct {
// ID of the compute instance // ID of the compute instance
// Required: true // Required: true
@ -46,9 +46,7 @@ type AntiAffinityRuleAddRequest struct {
func (c Compute) AntiAffinityRuleAdd(ctx context.Context, req AntiAffinityRuleAddRequest) (bool, error) { func (c Compute) AntiAffinityRuleAdd(ctx context.Context, req AntiAffinityRuleAddRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/antiAffinityRuleAdd" url := "/cloudapi/compute/antiAffinityRuleAdd"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for remove anti affinity rule // AntiAffinityRuleRemoveRequest struct to remove anti affinity rule
type AntiAffinityRuleRemoveRequest struct { type AntiAffinityRuleRemoveRequest struct {
// ID of the compute instance // ID of the compute instance
// Required: true // Required: true
@ -46,9 +46,7 @@ type AntiAffinityRuleRemoveRequest struct {
func (c Compute) AntiAffinityRuleRemove(ctx context.Context, req AntiAffinityRuleRemoveRequest) (bool, error) { func (c Compute) AntiAffinityRuleRemove(ctx context.Context, req AntiAffinityRuleRemoveRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/antiAffinityRuleRemove" url := "/cloudapi/compute/antiAffinityRuleRemove"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for clear anti affinity rules // AntiAffinityRulesClearRequest struct to clear anti affinity rules
type AntiAffinityRulesClearRequest struct { type AntiAffinityRulesClearRequest struct {
// ID of the compute instance // ID of the compute instance
// Required: true // Required: true
@ -19,9 +19,7 @@ type AntiAffinityRulesClearRequest struct {
func (c Compute) AntiAffinityRulesClear(ctx context.Context, req AntiAffinityRulesClearRequest) (bool, error) { func (c Compute) AntiAffinityRulesClear(ctx context.Context, req AntiAffinityRulesClearRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/antiAffinityRulesClear" url := "/cloudapi/compute/antiAffinityRulesClear"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for attach GPU for compute // AttachGPURequest struct to attach GPU for compute
type AttachGPURequest struct { type AttachGPURequest struct {
// Identifier compute // Identifier compute
// Required: true // Required: true
@ -23,9 +23,7 @@ type AttachGPURequest struct {
func (c Compute) AttachGPU(ctx context.Context, req AttachGPURequest) (uint64, error) { func (c Compute) AttachGPU(ctx context.Context, req AttachGPURequest) (uint64, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return 0, validators.ValidationErrors(validators.GetErrors(err))
return 0, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/attachGpu" url := "/cloudapi/compute/attachGpu"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for atttach PCI device // AttachPCIDeviceRequest struct to attach PCI device
type AttachPCIDeviceRequest struct { type AttachPCIDeviceRequest struct {
// Identifier compute // Identifier compute
// Required: true // Required: true
@ -23,9 +23,7 @@ type AttachPCIDeviceRequest struct {
func (c Compute) AttachPCIDevice(ctx context.Context, req AttachPCIDeviceRequest) (bool, error) { func (c Compute) AttachPCIDevice(ctx context.Context, req AttachPCIDeviceRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/attachPciDevice" url := "/cloudapi/compute/attachPciDevice"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for get audit records // AuditsRequest struct to get audit records
type AuditsRequest struct { type AuditsRequest struct {
// ID of the compute // ID of the compute
// Required: true // Required: true
@ -19,9 +19,7 @@ type AuditsRequest struct {
func (c Compute) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) { func (c Compute) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/audits" url := "/cloudapi/compute/audits"

@ -7,7 +7,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for getting boot order // BootOrderGetRequest struct to get boot order
type BootOrderGetRequest struct { type BootOrderGetRequest struct {
// Compute ID // Compute ID
// Required: true // Required: true
@ -18,9 +18,7 @@ type BootOrderGetRequest struct {
func (c Compute) BootOrderGet(ctx context.Context, req BootOrderGetRequest) ([]string, error) { func (c Compute) BootOrderGet(ctx context.Context, req BootOrderGetRequest) ([]string, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/bootOrderGet" url := "/cloudapi/compute/bootOrderGet"

@ -7,7 +7,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for setting boot order // BootOrderSetRequest struct to set boot order
type BootOrderSetRequest struct { type BootOrderSetRequest struct {
// ID of compute instance // ID of compute instance
// Required: true // Required: true
@ -26,9 +26,7 @@ type BootOrderSetRequest struct {
func (c Compute) BootOrderSet(ctx context.Context, req BootOrderSetRequest) ([]string, error) { func (c Compute) BootOrderSet(ctx context.Context, req BootOrderSetRequest) ([]string, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/bootOrderSet" url := "/cloudapi/compute/bootOrderSet"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for eject CD image // CDEjectRequest struct to eject CD image
type CDEjectRequest struct { type CDEjectRequest struct {
// ID of compute instance // ID of compute instance
// Required: true // Required: true
@ -19,9 +19,7 @@ type CDEjectRequest struct {
func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error) { func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/cdEject" url := "/cloudapi/compute/cdEject"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for insert new CD image // CDInsertRequest struct to insert new CD image
type CDInsertRequest struct { type CDInsertRequest struct {
// ID of compute instance // ID of compute instance
// Required: true // Required: true
@ -23,9 +23,7 @@ type CDInsertRequest struct {
func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error) { func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/cdInsert" url := "/cloudapi/compute/cdInsert"

@ -7,7 +7,7 @@ import (
"strconv" "strconv"
) )
// Request struct for changing link state // ChangeLinkStateRequest struct to change link state
type ChangeLinkStateRequest struct { type ChangeLinkStateRequest struct {
// Compute ID // Compute ID
// Required: true // Required: true
@ -27,9 +27,7 @@ type ChangeLinkStateRequest struct {
func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest) (bool, error) { func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/changeLinkState" url := "/cloudapi/compute/changeLinkState"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for clone compute instance // CloneRequest struct to clone compute instance
type CloneRequest struct { type CloneRequest struct {
// ID of compute instance // ID of compute instance
// Required: true // Required: true
@ -31,9 +31,7 @@ type CloneRequest struct {
func (c Compute) Clone(ctx context.Context, req CloneRequest) (uint64, error) { func (c Compute) Clone(ctx context.Context, req CloneRequest) (uint64, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return 0, validators.ValidationErrors(validators.GetErrors(err))
return 0, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/clone" url := "/cloudapi/compute/clone"

@ -9,7 +9,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for create template // CreateTemplateRequest struct to create template
type CreateTemplateRequest struct { type CreateTemplateRequest struct {
// ID of the compute to create template from // ID of the compute to create template from
// Required: true // Required: true
@ -30,9 +30,7 @@ type wrapperCreateTemplateRequest struct {
func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest) (uint64, error) { func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest) (uint64, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return 0, validators.ValidationErrors(validators.GetErrors(err))
return 0, validators.ValidationError(validationError)
}
} }
reqWrapped := wrapperCreateTemplateRequest{ reqWrapped := wrapperCreateTemplateRequest{
@ -59,9 +57,7 @@ func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest)
func (c Compute) CreateTemplateAsync(ctx context.Context, req CreateTemplateRequest) (string, error) { func (c Compute) CreateTemplateAsync(ctx context.Context, req CreateTemplateRequest) (string, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return "", validators.ValidationErrors(validators.GetErrors(err))
return "", validators.ValidationError(validationError)
}
} }
reqWrapped := wrapperCreateTemplateRequest{ reqWrapped := wrapperCreateTemplateRequest{

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for delete compute // DeleteRequest struct to delete compute
type DeleteRequest struct { type DeleteRequest struct {
// ID of compute instance // ID of compute instance
// Required: true // Required: true
@ -27,9 +27,7 @@ type DeleteRequest struct {
func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) { func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/delete" url := "/cloudapi/compute/delete"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for deleting compute's custome fields // DeleteCustomFieldsRequest struct to delete compute's custom fields
type DeleteCustomFieldsRequest struct { type DeleteCustomFieldsRequest struct {
// ID of the compute // ID of the compute
// Required: true // Required: true
@ -19,9 +19,7 @@ type DeleteCustomFieldsRequest struct {
func (c Compute) DeleteCustomFields(ctx context.Context, req DeleteCustomFieldsRequest) (bool, error) { func (c Compute) DeleteCustomFields(ctx context.Context, req DeleteCustomFieldsRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/deleteCustomFields" url := "/cloudapi/compute/deleteCustomFields"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for detach vgpu for compute // DetachGPURequest struct to detach vgpu for compute
type DetachGPURequest struct { type DetachGPURequest struct {
// Identifier compute // Identifier compute
// Required: true // Required: true
@ -24,9 +24,7 @@ type DetachGPURequest struct {
func (c Compute) DetachGPU(ctx context.Context, req DetachGPURequest) (bool, error) { func (c Compute) DetachGPU(ctx context.Context, req DetachGPURequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/detachGpu" url := "/cloudapi/compute/detachGpu"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for detach PCI device // DetachPCIDeviceRequest struct to detach PCI device
type DetachPCIDeviceRequest struct { type DetachPCIDeviceRequest struct {
// Identifier compute // Identifier compute
// Required: true // Required: true
@ -23,9 +23,7 @@ type DetachPCIDeviceRequest struct {
func (c Compute) DetachPCIDevice(ctx context.Context, req DetachPCIDeviceRequest) (bool, error) { func (c Compute) DetachPCIDevice(ctx context.Context, req DetachPCIDeviceRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/detachPciDevice" url := "/cloudapi/compute/detachPciDevice"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for disable compute // DisableRequest struct to disable compute
type DisableRequest struct { type DisableRequest struct {
// ID of compute instance // ID of compute instance
// Required: true // Required: true
@ -19,9 +19,7 @@ type DisableRequest struct {
func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error) { func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/disable" url := "/cloudapi/compute/disable"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for create and attach disk to compute // DiskAddRequest struct to create and attach disk to compute
type DiskAddRequest struct { type DiskAddRequest struct {
// ID of compute instance // ID of compute instance
// Required: true // Required: true
@ -52,9 +52,7 @@ type DiskAddRequest struct {
func (c Compute) DiskAdd(ctx context.Context, req DiskAddRequest) (uint64, error) { func (c Compute) DiskAdd(ctx context.Context, req DiskAddRequest) (uint64, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return 0, validators.ValidationErrors(validators.GetErrors(err))
return 0, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/diskAdd" url := "/cloudapi/compute/diskAdd"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for attach disk to compute // DiskAttachRequest struct to attach disk to compute
type DiskAttachRequest struct { type DiskAttachRequest struct {
// ID of compute instance // ID of compute instance
// Required: true // Required: true
@ -27,9 +27,7 @@ type DiskAttachRequest struct {
func (c Compute) DiskAttach(ctx context.Context, req DiskAttachRequest) (bool, error) { func (c Compute) DiskAttach(ctx context.Context, req DiskAttachRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/diskAttach" url := "/cloudapi/compute/diskAttach"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for detach and delete disk from compute // DiskDelRequest struct to detach and delete disk from compute
type DiskDelRequest struct { type DiskDelRequest struct {
// ID of compute instance // ID of compute instance
// Required: true // Required: true
@ -27,9 +27,7 @@ type DiskDelRequest struct {
func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error) { func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/diskDel" url := "/cloudapi/compute/diskDel"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for detach disk from compute // DiskDetachRequest struct to detach disk from compute
type DiskDetachRequest struct { type DiskDetachRequest struct {
// ID of compute instance // ID of compute instance
// Required: true // Required: true
@ -23,9 +23,7 @@ type DiskDetachRequest struct {
func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, error) { func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/diskDetach" url := "/cloudapi/compute/diskDetach"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for change QoS of the disk // DiskQOSRequest struct to change QoS of the disk
type DiskQOSRequest struct { type DiskQOSRequest struct {
// ID of compute instance // ID of compute instance
// Required: true // Required: true
@ -27,9 +27,7 @@ type DiskQOSRequest struct {
func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error) { func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/diskQos" url := "/cloudapi/compute/diskQos"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for change disk size // DiskResizeRequest struct to change disk size
type DiskResizeRequest struct { type DiskResizeRequest struct {
// ID of compute instance // ID of compute instance
// Required: true // Required: true
@ -27,9 +27,7 @@ type DiskResizeRequest struct {
func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, error) { func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/diskResize" url := "/cloudapi/compute/diskResize"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for enable compute // EnableRequest struct to enable compute
type EnableRequest struct { type EnableRequest struct {
// ID of compute instance // ID of compute instance
// Required: true // Required: true
@ -19,9 +19,7 @@ type EnableRequest struct {
func (c Compute) Enable(ctx context.Context, req EnableRequest) (bool, error) { func (c Compute) Enable(ctx context.Context, req EnableRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/enable" url := "/cloudapi/compute/enable"

@ -36,9 +36,7 @@ func (c Compute) Get(ctx context.Context, req GetRequest) (*RecordCompute, error
func (c Compute) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) { func (c Compute) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/get" url := "/cloudapi/compute/get"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for get compute audits // GetAuditsRequest struct to get compute audits
type GetAuditsRequest struct { type GetAuditsRequest struct {
// ID of compute instance // ID of compute instance
// Required: true // Required: true
@ -19,9 +19,7 @@ type GetAuditsRequest struct {
func (c Compute) GetAudits(ctx context.Context, req GetAuditsRequest) (ListShortAudits, error) { func (c Compute) GetAudits(ctx context.Context, req GetAuditsRequest) (ListShortAudits, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/getAudits" url := "/cloudapi/compute/getAudits"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for get console URL // GetConsoleURLRequest struct to get console URL
type GetConsoleURLRequest struct { type GetConsoleURLRequest struct {
// ID of compute instance to get console for // ID of compute instance to get console for
// Required: true // Required: true
@ -19,9 +19,7 @@ type GetConsoleURLRequest struct {
func (c Compute) GetConsoleURL(ctx context.Context, req GetConsoleURLRequest) (string, error) { func (c Compute) GetConsoleURL(ctx context.Context, req GetConsoleURLRequest) (string, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return "", validators.ValidationErrors(validators.GetErrors(err))
return "", validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/getConsoleUrl" url := "/cloudapi/compute/getConsoleUrl"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for getting Compute's customFields // GetCustomFieldsRequest struct to get Compute's customFields
type GetCustomFieldsRequest struct { type GetCustomFieldsRequest struct {
// Compute ID // Compute ID
// Required: true // Required: true
@ -19,9 +19,7 @@ type GetCustomFieldsRequest struct {
func (c Compute) GetCustomFields(ctx context.Context, req GetCustomFieldsRequest) (interface{}, error) { func (c Compute) GetCustomFields(ctx context.Context, req GetCustomFieldsRequest) (interface{}, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/getCustomFields" url := "/cloudapi/compute/getCustomFields"

@ -7,7 +7,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for get compute logs // GetLogRequest struct to get compute logs
type GetLogRequest struct { type GetLogRequest struct {
// ID of compute instance to get log for // ID of compute instance to get log for
// Required: true // Required: true
@ -22,9 +22,7 @@ type GetLogRequest struct {
func (c Compute) GetLog(ctx context.Context, req GetLogRequest) (string, error) { func (c Compute) GetLog(ctx context.Context, req GetLogRequest) (string, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return "", validators.ValidationErrors(validators.GetErrors(err))
return "", validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/getLog" url := "/cloudapi/compute/getLog"
@ -41,9 +39,7 @@ func (c Compute) GetLog(ctx context.Context, req GetLogRequest) (string, error)
func (c Compute) GetLogGet(ctx context.Context, req GetLogRequest) (string, error) { func (c Compute) GetLogGet(ctx context.Context, req GetLogRequest) (string, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return "", validators.ValidationErrors(validators.GetErrors(err))
return "", validators.ValidationError(validationError)
}
} }
url := "/cloudapi//compute/getLog" url := "/cloudapi//compute/getLog"

@ -6,7 +6,7 @@ import (
"net/http" "net/http"
) )
// Request struct for get deleted computes list // ListDeletedRequest struct to get deleted computes list
type ListDeletedRequest struct { type ListDeletedRequest struct {
// Find by ID // Find by ID
// Required: false // Required: false

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for get list PCI devices // ListPCIDeviceRequest struct to get list of PCI devices
type ListPCIDeviceRequest struct { type ListPCIDeviceRequest struct {
// Identifier compute // Identifier compute
// Required: true // Required: true
@ -43,9 +43,7 @@ type ListPCIDeviceRequest struct {
func (c Compute) ListPCIDevice(ctx context.Context, req ListPCIDeviceRequest) (*ListPCIDevices, error) { func (c Compute) ListPCIDevice(ctx context.Context, req ListPCIDeviceRequest) (*ListPCIDevices, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/listPciDevice" url := "/cloudapi/compute/listPciDevice"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for get list vGPU // ListVGPURequest struct to get vGPU list
type ListVGPURequest struct { type ListVGPURequest struct {
// Identifier compute // Identifier compute
// Required: true // Required: true
@ -43,9 +43,7 @@ type ListVGPURequest struct {
func (c Compute) ListVGPU(ctx context.Context, req ListVGPURequest) (*ListVGPUs, error) { func (c Compute) ListVGPU(ctx context.Context, req ListVGPURequest) (*ListVGPUs, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/listVGpu" url := "/cloudapi/compute/listVGpu"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for move compute new resource group // MoveToRGRequest struct to move compute to new resource group
type MoveToRGRequest struct { type MoveToRGRequest struct {
// ID of the compute instance to move // ID of the compute instance to move
// Required: true // Required: true
@ -38,9 +38,7 @@ type MoveToRGRequest struct {
func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error) { func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/moveToRg" url := "/cloudapi/compute/moveToRg"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for attach network // NetAttachRequest struct to attach network
type NetAttachRequest struct { type NetAttachRequest struct {
// ID of compute instance // ID of compute instance
// Required: true // Required: true
@ -31,13 +31,11 @@ type NetAttachRequest struct {
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"` IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
} }
// NetAttach attach network to compute and gets info about network // NetAttach attaches network to compute and gets info about network
func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNetAttach, error) { func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNetAttach, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return nil, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/netAttach" url := "/cloudapi/compute/netAttach"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for detach networ to compute // NetDetachRequest struct to detach network from compute
type NetDetachRequest struct { type NetDetachRequest struct {
// ID of compute instance // ID of compute instance
// Required: true // Required: true
@ -23,13 +23,11 @@ type NetDetachRequest struct {
MAC string `url:"mac,omitempty" json:"mac,omitempty"` MAC string `url:"mac,omitempty" json:"mac,omitempty"`
} }
// NetDetach detach network to compute // NetDetach detaches network from compute
func (c Compute) NetDetach(ctx context.Context, req NetDetachRequest) (bool, error) { func (c Compute) NetDetach(ctx context.Context, req NetDetachRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/netDetach" url := "/cloudapi/compute/netDetach"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for pause compute // PauseRequest struct to pause compute
type PauseRequest struct { type PauseRequest struct {
// ID of compute instance // ID of compute instance
// Required: true // Required: true
@ -19,9 +19,7 @@ type PauseRequest struct {
func (c Compute) Pause(ctx context.Context, req PauseRequest) (bool, error) { func (c Compute) Pause(ctx context.Context, req PauseRequest) (bool, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return false, validators.ValidationErrors(validators.GetErrors(err))
return false, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/pause" url := "/cloudapi/compute/pause"

@ -8,7 +8,7 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
// Request struct for add port forward rule // PFWAddRequest struct to add port forward rule
type PFWAddRequest struct { type PFWAddRequest struct {
// ID of compute instance // ID of compute instance
// Required: true // Required: true
@ -37,9 +37,7 @@ type PFWAddRequest struct {
func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error) { func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
for _, validationError := range validators.GetErrors(err) { return 0, validators.ValidationErrors(validators.GetErrors(err))
return 0, validators.ValidationError(validationError)
}
} }
url := "/cloudapi/compute/pfwAdd" url := "/cloudapi/compute/pfwAdd"

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save