Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b666789c7d | |||
| b069c31745 | |||
| 2953ef0a85 | |||
| 50a4d5ade2 | |||
| 1575b75fa6 | |||
| 35fa4af0d6 | |||
| d3e6309ef8 |
38
CHANGELOG.md
38
CHANGELOG.md
@@ -1,32 +1,10 @@
|
|||||||
## Version 1.6.0
|
## Version 1.6.6
|
||||||
|
|
||||||
### Bugfix
|
## Bugfix
|
||||||
- Fix cloudaApi/client and cloudapi/legacy-client, the cyclicity of sending requests has been removed
|
- Fixed model RecordExtNet in cloudbroker/extnet/models for correct work of get request
|
||||||
- Edit description field SSLSkipVerify in cloudapi/config/config and cloudapi/config/legacy-config
|
- Fixed json tags in ItemResourceConsumption model and delete extra model Consumed in cloudbroker/account/models
|
||||||
- Remove tags required fields ExtNetID VINSID Start in model CreateRequest in cloudapi/lb/create
|
- Fixed statelessSepId field type from uint64 to int64 in cloudbroker/compute/models for correct work of list request
|
||||||
- Add tags required fields BindingName BindingAddress BindingPort in model FrontendBindRequest in cloudapi/lb/frontend_bind
|
|
||||||
- Add tags required fields BindingAddress BindingPort in model FrontendBindUpdateRequest in cloudapi/lb/frontend_bind_update
|
|
||||||
|
|
||||||
### Feature
|
## Feature
|
||||||
- Add field UserData in cloudapi/bservice/group_add
|
- 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 fields VinsId, LbSysctlParams, HighlyAvailable, AdditionalSANs, InitConfiguration, ClusterConfiguration, KubeletConfiguration, KubeProxyConfiguration, JoinConfiguration, UserData, ExtNetOnly, OidcCertificate in model request cloudapi/k8s/create
|
- 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
|
||||||
- Add field Externalip in model ItemDetailedInfo in cloudapi/k8s/models
|
|
||||||
- Add fields SysctlParams, HighlyAvailable in model CreateRequest in cloudapi/lb/create
|
|
||||||
- Add fields BackendHAIP, FrontendHAIP, PartK8s, SysctlParams in model RecordLB in cloudapi/lb/models
|
|
||||||
- Add models InfoStack, ItemStack, ListStacks cloudapi/stack/models
|
|
||||||
- Add field Routes and type Route in CreateInAccountRequest and CreateInRGRequest models in cloudapi/vins/create_in_rg and /cloudapi/vins/create_in_account
|
|
||||||
- Add field Enabled in model ItemVNFInterface
|
|
||||||
- Add fields Routes in models RecordNAT, RecordDHCP, RecordGW and add type ListStaticRoutes, ListRoutes, ItemRoutes in cloudapi/vins/models
|
|
||||||
|
|
||||||
- Added new endpoints:
|
|
||||||
- cloudapi/k8s/get_worker_nodes_meta_data
|
|
||||||
- cloudapi/k8s/update_worker_nodes_meta_data
|
|
||||||
- cloudapi/lb/make_highly_available
|
|
||||||
- cloudapi/lb/updateSysctParams
|
|
||||||
- cloudapi/stack/get
|
|
||||||
- cloudapi/stack/list
|
|
||||||
- cloudapi/vins/static_route_list
|
|
||||||
- cloudapi/vins/static_route_access_grant
|
|
||||||
- cloudapi/vins/static_route_access_revoke
|
|
||||||
- cloudapi/vins/static_route_add
|
|
||||||
- cloudapi/vins/static_route_del
|
|
||||||
50
README.md
50
README.md
@@ -527,6 +527,56 @@ func main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Для запросов Get и List реализованы запросы GetRaw и ListRaw, которые возвращают ответ не в виде соответствующей структуры, а в виде массива байт (JSON).
|
||||||
|
Выполнение таких запросов происходит аналогично.
|
||||||
|
|
||||||
|
#### Пример выполнения GetRaw и ListRaw запросов
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
|
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Настройка конфигурации
|
||||||
|
cfg := config.Config{
|
||||||
|
AppID: "<APPID>",
|
||||||
|
AppSecret: "<APPSECRET>",
|
||||||
|
SSOURL: "https://sso.digitalenergy.online",
|
||||||
|
DecortURL: "https://mr4.digitalenergy.online",
|
||||||
|
Retries: 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Создание клиента
|
||||||
|
client := decort.New(cfg)
|
||||||
|
|
||||||
|
// 1. Создание структуры запроса GetRequest на создание аккаунта и выполнение GetRaw запроса с помощью конвейера
|
||||||
|
req1 := account.GetRequest{
|
||||||
|
AccountID: 123,
|
||||||
|
}
|
||||||
|
res1, err := client.CloudAPI().Account().GetRaw(context.Background(), req1)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
fmt.Println(string(res1))
|
||||||
|
|
||||||
|
// 2. Создание структуры запроса ListRequest на получение аккаунтов и выполнение ListRaw запроса с помощью конвейера
|
||||||
|
req2 := account.ListRequest{}
|
||||||
|
res2, err := client.CloudAPI().Account().ListRaw(context.Background(), req2)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
fmt.Println(string(res2))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Фильтрация
|
### Фильтрация
|
||||||
|
|
||||||
Для каждого `ListRequest` в SDK есть группа функций для фильтрации ответа платформы. Для того чтобы произвести фильтрацию по заданным полям, достаточно описать анонимную функцию (предикат) в `.FilterFunc()`, например:
|
Для каждого `ListRequest` в SDK есть группа функций для фильтрации ответа платформы. Для того чтобы произвести фильтрацию по заданным полям, достаточно описать анонимную функцию (предикат) в `.FilterFunc()`, например:
|
||||||
|
|||||||
333
client.go
333
client.go
@@ -15,9 +15,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"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"
|
||||||
"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"
|
||||||
)
|
)
|
||||||
@@ -71,114 +71,253 @@ func (dc *DecortClient) CloudBroker() *cloudbroker.CloudBroker {
|
|||||||
|
|
||||||
// DecortApiCall method for sending requests to the platform
|
// DecortApiCall method for sending requests to the platform
|
||||||
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) {
|
||||||
if k8sCreateReq, ok := params.(k8s.CreateRequest); ok {
|
k8sCaCreateReq, okCa := params.(k8s_ca.CreateRequest)
|
||||||
|
k8sCbCreateReq, okCb := params.(k8s_cb.CreateRequest)
|
||||||
|
|
||||||
|
if okCa {
|
||||||
reqBody := &bytes.Buffer{}
|
reqBody := &bytes.Buffer{}
|
||||||
writer := multipart.NewWriter(reqBody)
|
writer := multipart.NewWriter(reqBody)
|
||||||
if k8sCreateReq.OidcCertificate != "" {
|
if k8sCaCreateReq.OidcCertificate != "" {
|
||||||
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
|
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
|
||||||
_, _ =io.Copy(part, strings.NewReader(k8sCreateReq.OidcCertificate))
|
_, _ = io.Copy(part, strings.NewReader(k8sCaCreateReq.OidcCertificate))
|
||||||
}
|
}
|
||||||
|
|
||||||
_= writer.WriteField("name", k8sCreateReq.Name)
|
_ = writer.WriteField("name", k8sCaCreateReq.Name)
|
||||||
_= writer.WriteField("rgId", strconv.FormatUint(k8sCreateReq.RGID, 10))
|
_ = writer.WriteField("rgId", strconv.FormatUint(k8sCaCreateReq.RGID, 10))
|
||||||
_= writer.WriteField("k8ciId", strconv.FormatUint(k8sCreateReq.K8SCIID, 10))
|
_ = writer.WriteField("k8ciId", strconv.FormatUint(k8sCaCreateReq.K8SCIID, 10))
|
||||||
_= writer.WriteField("workerGroupName", k8sCreateReq.WorkerGroupName)
|
_ = writer.WriteField("workerGroupName", k8sCaCreateReq.WorkerGroupName)
|
||||||
_= writer.WriteField("networkPlugin", k8sCreateReq.NetworkPlugin)
|
_ = writer.WriteField("networkPlugin", k8sCaCreateReq.NetworkPlugin)
|
||||||
|
|
||||||
if k8sCreateReq.MasterSEPID != 0 {
|
if k8sCaCreateReq.MasterSEPID != 0 {
|
||||||
_= writer.WriteField("masterSepId", strconv.FormatUint(k8sCreateReq.MasterSEPID, 10))
|
_ = writer.WriteField("masterSepId", strconv.FormatUint(k8sCaCreateReq.MasterSEPID, 10))
|
||||||
}
|
}
|
||||||
if k8sCreateReq.MasterSEPPool != "" {
|
if k8sCaCreateReq.MasterSEPPool != "" {
|
||||||
_= writer.WriteField("masterSepPool", k8sCreateReq.MasterSEPPool)
|
_ = writer.WriteField("masterSepPool", k8sCaCreateReq.MasterSEPPool)
|
||||||
}
|
}
|
||||||
if k8sCreateReq.WorkerSEPID != 0 {
|
if k8sCaCreateReq.WorkerSEPID != 0 {
|
||||||
_= writer.WriteField("workerSepId", strconv.FormatUint(k8sCreateReq.WorkerSEPID, 10))
|
_ = writer.WriteField("workerSepId", strconv.FormatUint(k8sCaCreateReq.WorkerSEPID, 10))
|
||||||
}
|
}
|
||||||
if k8sCreateReq.WorkerSEPPool != "" {
|
if k8sCaCreateReq.WorkerSEPPool != "" {
|
||||||
_= writer.WriteField("workerSepPool", k8sCreateReq.WorkerSEPPool)
|
_ = writer.WriteField("workerSepPool", k8sCaCreateReq.WorkerSEPPool)
|
||||||
}
|
}
|
||||||
|
|
||||||
if k8sCreateReq.Labels != nil {
|
if k8sCaCreateReq.Labels != nil {
|
||||||
for _, v := range k8sCreateReq.Labels {
|
for _, v := range k8sCaCreateReq.Labels {
|
||||||
_= writer.WriteField("labels", v)
|
_ = writer.WriteField("labels", v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if k8sCreateReq.Taints != nil {
|
if k8sCaCreateReq.Taints != nil {
|
||||||
for _, v := range k8sCreateReq.Taints {
|
for _, v := range k8sCaCreateReq.Taints {
|
||||||
_= writer.WriteField("taints", v)
|
_ = writer.WriteField("taints", v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if k8sCreateReq.Annotations != nil {
|
if k8sCaCreateReq.Annotations != nil {
|
||||||
for _, v := range k8sCreateReq.Annotations {
|
for _, v := range k8sCaCreateReq.Annotations {
|
||||||
_= writer.WriteField("annotations", v)
|
_ = writer.WriteField("annotations", v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if k8sCreateReq.MasterCPU != 0 {
|
if k8sCaCreateReq.MasterCPU != 0 {
|
||||||
_= writer.WriteField("masterCpu", strconv.FormatUint(uint64(k8sCreateReq.MasterCPU), 10))
|
_ = writer.WriteField("masterCpu", strconv.FormatUint(uint64(k8sCaCreateReq.MasterCPU), 10))
|
||||||
}
|
}
|
||||||
if k8sCreateReq.MasterNum != 0 {
|
if k8sCaCreateReq.MasterNum != 0 {
|
||||||
_= writer.WriteField("masterNum", strconv.FormatUint(uint64(k8sCreateReq.MasterNum), 10))
|
_ = writer.WriteField("masterNum", strconv.FormatUint(uint64(k8sCaCreateReq.MasterNum), 10))
|
||||||
}
|
}
|
||||||
if k8sCreateReq.MasterRAM != 0 {
|
if k8sCaCreateReq.MasterRAM != 0 {
|
||||||
_= writer.WriteField("masterRam", strconv.FormatUint(uint64(k8sCreateReq.MasterRAM), 10))
|
_ = writer.WriteField("masterRam", strconv.FormatUint(uint64(k8sCaCreateReq.MasterRAM), 10))
|
||||||
}
|
}
|
||||||
if k8sCreateReq.MasterDisk != 0 {
|
if k8sCaCreateReq.MasterDisk != 0 {
|
||||||
_= writer.WriteField("masterDisk", strconv.FormatUint(uint64(k8sCreateReq.MasterDisk), 10))
|
_ = writer.WriteField("masterDisk", strconv.FormatUint(uint64(k8sCaCreateReq.MasterDisk), 10))
|
||||||
}
|
}
|
||||||
if k8sCreateReq.WorkerCPU != 0 {
|
if k8sCaCreateReq.WorkerCPU != 0 {
|
||||||
_= writer.WriteField("workerCpu", strconv.FormatUint(uint64(k8sCreateReq.WorkerCPU), 10))
|
_ = writer.WriteField("workerCpu", strconv.FormatUint(uint64(k8sCaCreateReq.WorkerCPU), 10))
|
||||||
}
|
}
|
||||||
if k8sCreateReq.WorkerNum != 0 {
|
if k8sCaCreateReq.WorkerNum != 0 {
|
||||||
_= writer.WriteField("workerNum", strconv.FormatUint(uint64(k8sCreateReq.WorkerNum), 10))
|
_ = writer.WriteField("workerNum", strconv.FormatUint(uint64(k8sCaCreateReq.WorkerNum), 10))
|
||||||
}
|
}
|
||||||
if k8sCreateReq.WorkerRAM != 0 {
|
if k8sCaCreateReq.WorkerRAM != 0 {
|
||||||
_= writer.WriteField("workerRam", strconv.FormatUint(uint64(k8sCreateReq.WorkerRAM), 10))
|
_ = writer.WriteField("workerRam", strconv.FormatUint(uint64(k8sCaCreateReq.WorkerRAM), 10))
|
||||||
}
|
}
|
||||||
if k8sCreateReq.WorkerDisk != 0 {
|
if k8sCaCreateReq.WorkerDisk != 0 {
|
||||||
_= writer.WriteField("workerDisk", strconv.FormatUint(uint64(k8sCreateReq.WorkerDisk), 10))
|
_ = writer.WriteField("workerDisk", strconv.FormatUint(uint64(k8sCaCreateReq.WorkerDisk), 10))
|
||||||
}
|
}
|
||||||
if k8sCreateReq.ExtNetID != 0 {
|
if k8sCaCreateReq.ExtNetID != 0 {
|
||||||
_= writer.WriteField("extnetId", strconv.FormatUint(k8sCreateReq.ExtNetID, 10))
|
_ = writer.WriteField("extnetId", strconv.FormatUint(k8sCaCreateReq.ExtNetID, 10))
|
||||||
}
|
}
|
||||||
if k8sCreateReq.VinsId != 0 {
|
if k8sCaCreateReq.VinsId != 0 {
|
||||||
_= writer.WriteField("vinsId", strconv.FormatUint(k8sCreateReq.VinsId, 10))
|
_ = writer.WriteField("vinsId", strconv.FormatUint(k8sCaCreateReq.VinsId, 10))
|
||||||
}
|
}
|
||||||
if !k8sCreateReq.WithLB {
|
if !k8sCaCreateReq.WithLB {
|
||||||
_= writer.WriteField("withLB", strconv.FormatBool(k8sCreateReq.WithLB))
|
_ = writer.WriteField("withLB", strconv.FormatBool(k8sCaCreateReq.WithLB))
|
||||||
}
|
}
|
||||||
|
|
||||||
_= writer.WriteField("highlyAvailable", strconv.FormatBool(k8sCreateReq.HighlyAvailable))
|
_ = writer.WriteField("highlyAvailableLB", strconv.FormatBool(k8sCaCreateReq.HighlyAvailable))
|
||||||
|
|
||||||
if k8sCreateReq.AdditionalSANs != nil {
|
if k8sCaCreateReq.AdditionalSANs != nil {
|
||||||
for _, v := range k8sCreateReq.AdditionalSANs {
|
for _, v := range k8sCaCreateReq.AdditionalSANs {
|
||||||
_= writer.WriteField("additionalSANs", v)
|
_ = writer.WriteField("additionalSANs", v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if k8sCreateReq.InitConfiguration != "" {
|
if k8sCaCreateReq.InitConfiguration != "" {
|
||||||
_= writer.WriteField("initConfiguration", k8sCreateReq.InitConfiguration)
|
_ = writer.WriteField("initConfiguration", k8sCaCreateReq.InitConfiguration)
|
||||||
}
|
}
|
||||||
if k8sCreateReq.ClusterConfiguration != "" {
|
if k8sCaCreateReq.ClusterConfiguration != "" {
|
||||||
_= writer.WriteField("clusterConfiguration", k8sCreateReq.ClusterConfiguration)
|
_ = writer.WriteField("clusterConfiguration", k8sCaCreateReq.ClusterConfiguration)
|
||||||
}
|
}
|
||||||
if k8sCreateReq.KubeletConfiguration != "" {
|
if k8sCaCreateReq.KubeletConfiguration != "" {
|
||||||
_= writer.WriteField("kubeletConfiguration", k8sCreateReq.KubeletConfiguration)
|
_ = writer.WriteField("kubeletConfiguration", k8sCaCreateReq.KubeletConfiguration)
|
||||||
}
|
}
|
||||||
if k8sCreateReq.KubeProxyConfiguration != "" {
|
if k8sCaCreateReq.KubeProxyConfiguration != "" {
|
||||||
_= writer.WriteField("kubeProxyConfiguration", k8sCreateReq.KubeProxyConfiguration)
|
_ = writer.WriteField("kubeProxyConfiguration", k8sCaCreateReq.KubeProxyConfiguration)
|
||||||
}
|
}
|
||||||
if k8sCreateReq.JoinConfiguration != "" {
|
if k8sCaCreateReq.JoinConfiguration != "" {
|
||||||
_= writer.WriteField("joinConfiguration", k8sCreateReq.JoinConfiguration)
|
_ = writer.WriteField("joinConfiguration", k8sCaCreateReq.JoinConfiguration)
|
||||||
}
|
}
|
||||||
if k8sCreateReq.Description != "" {
|
if k8sCaCreateReq.Description != "" {
|
||||||
_= writer.WriteField("desc", k8sCreateReq.Description)
|
_ = writer.WriteField("desc", k8sCaCreateReq.Description)
|
||||||
}
|
}
|
||||||
if k8sCreateReq.UserData != "" {
|
if k8sCaCreateReq.UserData != "" {
|
||||||
_= writer.WriteField("userData", k8sCreateReq.UserData)
|
_ = writer.WriteField("userData", k8sCaCreateReq.UserData)
|
||||||
}
|
}
|
||||||
|
|
||||||
_= writer.WriteField("extnetOnly", strconv.FormatBool(k8sCreateReq.ExtNetOnly))
|
_ = writer.WriteField("extnetOnly", strconv.FormatBool(k8sCaCreateReq.ExtNetOnly))
|
||||||
_= writer.FormDataContentType()
|
_ = writer.FormDataContentType()
|
||||||
|
|
||||||
|
ct := writer.FormDataContentType()
|
||||||
|
|
||||||
|
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)
|
||||||
|
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
|
||||||
|
} else if okCb {
|
||||||
|
reqBody := &bytes.Buffer{}
|
||||||
|
writer := multipart.NewWriter(reqBody)
|
||||||
|
if k8sCbCreateReq.OidcCertificate != "" {
|
||||||
|
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
|
||||||
|
_, _ = io.Copy(part, strings.NewReader(k8sCbCreateReq.OidcCertificate))
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = writer.WriteField("name", k8sCbCreateReq.Name)
|
||||||
|
_ = writer.WriteField("rgId", strconv.FormatUint(k8sCbCreateReq.RGID, 10))
|
||||||
|
_ = writer.WriteField("k8ciId", strconv.FormatUint(k8sCbCreateReq.K8CIID, 10))
|
||||||
|
_ = writer.WriteField("workerGroupName", k8sCbCreateReq.WorkerGroupName)
|
||||||
|
_ = writer.WriteField("networkPlugin", k8sCbCreateReq.NetworkPlugin)
|
||||||
|
|
||||||
|
if k8sCbCreateReq.MasterSEPID != 0 {
|
||||||
|
_ = writer.WriteField("masterSepId", strconv.FormatUint(k8sCbCreateReq.MasterSEPID, 10))
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.MasterSEPPool != "" {
|
||||||
|
_ = writer.WriteField("masterSepPool", k8sCbCreateReq.MasterSEPPool)
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.WorkerSEPID != 0 {
|
||||||
|
_ = writer.WriteField("workerSepId", strconv.FormatUint(k8sCbCreateReq.WorkerSEPID, 10))
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.WorkerSEPPool != "" {
|
||||||
|
_ = writer.WriteField("workerSepPool", k8sCbCreateReq.WorkerSEPPool)
|
||||||
|
}
|
||||||
|
|
||||||
|
if k8sCbCreateReq.Labels != nil {
|
||||||
|
for _, v := range k8sCbCreateReq.Labels {
|
||||||
|
_ = writer.WriteField("labels", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.Taints != nil {
|
||||||
|
for _, v := range k8sCbCreateReq.Taints {
|
||||||
|
_ = writer.WriteField("taints", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.Annotations != nil {
|
||||||
|
for _, v := range k8sCbCreateReq.Annotations {
|
||||||
|
_ = writer.WriteField("annotations", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if k8sCbCreateReq.MasterCPU != 0 {
|
||||||
|
_ = writer.WriteField("masterCpu", strconv.FormatUint(k8sCbCreateReq.MasterCPU, 10))
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.MasterNum != 0 {
|
||||||
|
_ = writer.WriteField("masterNum", strconv.FormatUint(k8sCbCreateReq.MasterNum, 10))
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.MasterRAM != 0 {
|
||||||
|
_ = writer.WriteField("masterRam", strconv.FormatUint(k8sCbCreateReq.MasterRAM, 10))
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.MasterDisk != 0 {
|
||||||
|
_ = writer.WriteField("masterDisk", strconv.FormatUint(k8sCbCreateReq.MasterDisk, 10))
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.WorkerCPU != 0 {
|
||||||
|
_ = writer.WriteField("workerCpu", strconv.FormatUint(k8sCbCreateReq.WorkerCPU, 10))
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.WorkerNum != 0 {
|
||||||
|
_ = writer.WriteField("workerNum", strconv.FormatUint(k8sCbCreateReq.WorkerNum, 10))
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.WorkerRAM != 0 {
|
||||||
|
_ = writer.WriteField("workerRam", strconv.FormatUint(k8sCbCreateReq.WorkerRAM, 10))
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.WorkerDisk != 0 {
|
||||||
|
_ = writer.WriteField("workerDisk", strconv.FormatUint(k8sCbCreateReq.WorkerDisk, 10))
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.ExtNetID != 0 {
|
||||||
|
_ = writer.WriteField("extnetId", strconv.FormatUint(k8sCbCreateReq.ExtNetID, 10))
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.VinsId != 0 {
|
||||||
|
_ = writer.WriteField("vinsId", strconv.FormatUint(k8sCbCreateReq.VinsId, 10))
|
||||||
|
}
|
||||||
|
if !k8sCbCreateReq.WithLB {
|
||||||
|
_ = writer.WriteField("withLB", strconv.FormatBool(k8sCbCreateReq.WithLB))
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = writer.WriteField("highlyAvailableLB", strconv.FormatBool(k8sCbCreateReq.HighlyAvailable))
|
||||||
|
|
||||||
|
if k8sCbCreateReq.AdditionalSANs != nil {
|
||||||
|
for _, v := range k8sCbCreateReq.AdditionalSANs {
|
||||||
|
_ = writer.WriteField("additionalSANs", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.InitConfiguration != "" {
|
||||||
|
_ = writer.WriteField("initConfiguration", k8sCbCreateReq.InitConfiguration)
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.ClusterConfiguration != "" {
|
||||||
|
_ = writer.WriteField("clusterConfiguration", k8sCbCreateReq.ClusterConfiguration)
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.KubeletConfiguration != "" {
|
||||||
|
_ = writer.WriteField("kubeletConfiguration", k8sCbCreateReq.KubeletConfiguration)
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.KubeProxyConfiguration != "" {
|
||||||
|
_ = writer.WriteField("kubeProxyConfiguration", k8sCbCreateReq.KubeProxyConfiguration)
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.JoinConfiguration != "" {
|
||||||
|
_ = writer.WriteField("joinConfiguration", k8sCbCreateReq.JoinConfiguration)
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.Description != "" {
|
||||||
|
_ = writer.WriteField("desc", k8sCbCreateReq.Description)
|
||||||
|
}
|
||||||
|
if k8sCbCreateReq.UserData != "" {
|
||||||
|
_ = writer.WriteField("userData", k8sCbCreateReq.UserData)
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = writer.WriteField("extnetOnly", strconv.FormatBool(k8sCbCreateReq.ExtNetOnly))
|
||||||
|
_ = writer.FormDataContentType()
|
||||||
|
|
||||||
ct := writer.FormDataContentType()
|
ct := writer.FormDataContentType()
|
||||||
|
|
||||||
@@ -281,24 +420,24 @@ func (dc *DecortClient) do(req *http.Request) (*http.Response, error) {
|
|||||||
req.Header.Add("Authorization", "bearer "+dc.cfg.Token)
|
req.Header.Add("Authorization", "bearer "+dc.cfg.Token)
|
||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
|
|
||||||
var resp *http.Response
|
// var resp *http.Response
|
||||||
var err error
|
// var err error
|
||||||
buf, _ := io.ReadAll(req.Body)
|
buf, _ := io.ReadAll(req.Body)
|
||||||
req = req.Clone(req.Context())
|
// req = req.Clone(req.Context())
|
||||||
|
|
||||||
for i := uint64(0); i < dc.cfg.Retries; i++ {
|
// for i := uint64(0); i < dc.cfg.Retries; i++ {
|
||||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||||
resp, err = dc.client.Do(req)
|
resp, err := dc.client.Do(req)
|
||||||
|
|
||||||
// if err == nil {
|
// if err == nil {
|
||||||
if resp.StatusCode == 200 {
|
if resp.StatusCode == 200 {
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
|
||||||
respBytes, _ := io.ReadAll(resp.Body)
|
|
||||||
err = fmt.Errorf("%s", respBytes)
|
|
||||||
resp.Body.Close()
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
respBytes, _ := io.ReadAll(resp.Body)
|
||||||
|
err = fmt.Errorf("%s", respBytes)
|
||||||
|
resp.Body.Close()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||||
}
|
}
|
||||||
@@ -308,24 +447,24 @@ func (dc *DecortClient) domp(req *http.Request, ctype string) (*http.Response, e
|
|||||||
req.Header.Add("Authorization", "bearer "+dc.cfg.Token)
|
req.Header.Add("Authorization", "bearer "+dc.cfg.Token)
|
||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
|
|
||||||
var resp *http.Response
|
// var resp *http.Response
|
||||||
var err error
|
// var err error
|
||||||
buf, _ := io.ReadAll(req.Body)
|
buf, _ := io.ReadAll(req.Body)
|
||||||
req = req.Clone(req.Context())
|
// req = req.Clone(req.Context())
|
||||||
|
|
||||||
for i := uint64(0); i < dc.cfg.Retries; i++ {
|
// for i := uint64(0); i < dc.cfg.Retries; i++ {
|
||||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||||
resp, err = dc.client.Do(req)
|
resp, err := dc.client.Do(req)
|
||||||
|
|
||||||
// if err == nil {
|
// if err == nil {
|
||||||
if resp.StatusCode == 200 {
|
if resp.StatusCode == 200 {
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
|
||||||
respBytes, _ := io.ReadAll(resp.Body)
|
|
||||||
err = fmt.Errorf("%s", respBytes)
|
|
||||||
resp.Body.Close()
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
respBytes, _ := io.ReadAll(resp.Body)
|
||||||
|
err = fmt.Errorf("%s", respBytes)
|
||||||
|
resp.Body.Close()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
176
legacy-client.go
176
legacy-client.go
@@ -7,8 +7,10 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -16,6 +18,7 @@ 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"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -68,6 +71,148 @@ 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 {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = writer.WriteField("authkey", ldc.cfg.Token)
|
||||||
|
|
||||||
|
writer.Close()
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
values, err := query.Values(params)
|
values, err := query.Values(params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -140,10 +285,10 @@ func (ldc *LegacyDecortClient) do(req *http.Request) (*http.Response, error) {
|
|||||||
// var resp *http.Response
|
// var resp *http.Response
|
||||||
// var err error
|
// var err error
|
||||||
buf, _ := io.ReadAll(req.Body)
|
buf, _ := io.ReadAll(req.Body)
|
||||||
req = req.Clone(req.Context())
|
// req = req.Clone(req.Context())
|
||||||
|
|
||||||
// for i := uint64(0); i < ldc.cfg.Retries; i++ {
|
// for i := uint64(0); i < ldc.cfg.Retries; i++ {
|
||||||
req = req.Clone(req.Context())
|
|
||||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||||
resp, err := ldc.client.Do(req)
|
resp, err := ldc.client.Do(req)
|
||||||
|
|
||||||
@@ -159,3 +304,30 @@ 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) {
|
||||||
|
req.Header.Add("Content-Type", ctype)
|
||||||
|
req.Header.Add("Authorization", "bearer "+ldc.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 < ldc.cfg.Retries; i++ {
|
||||||
|
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||||
|
resp, err := ldc.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)
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get information about account
|
// GetRequest struct to get information about account
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID an account
|
// ID an account
|
||||||
// Required: true
|
// Required: true
|
||||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets account details
|
// Get gets account details as a RecordAccount struct
|
||||||
func (a Account) Get(ctx context.Context, req GetRequest) (*RecordAccount, error) {
|
func (a Account) Get(ctx context.Context, req GetRequest) (*RecordAccount, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := a.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/account/get"
|
|
||||||
|
|
||||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -41,3 +32,18 @@ func (a Account) Get(ctx context.Context, req GetRequest) (*RecordAccount, error
|
|||||||
return &info, nil
|
return &info, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets account details as an array of bytes
|
||||||
|
func (a Account) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/account/get"
|
||||||
|
|
||||||
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list of accounts
|
// ListRequest struct to get list of accounts
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -33,11 +33,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list all accounts the user has access to
|
// List gets a list of all accounts the user has access to a ListAccounts struct
|
||||||
func (a Account) List(ctx context.Context, req ListRequest) (*ListAccounts, error) {
|
func (a Account) List(ctx context.Context, req ListRequest) (*ListAccounts, error) {
|
||||||
url := "/cloudapi/account/list"
|
res, err := a.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -51,3 +49,11 @@ func (a Account) List(ctx context.Context, req ListRequest) (*ListAccounts, erro
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets a list of all accounts the user has access to as an array of bytes
|
||||||
|
func (a Account) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudapi/account/list"
|
||||||
|
|
||||||
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ type Resource struct {
|
|||||||
DiskSize float64 `json:"disksize"`
|
DiskSize float64 `json:"disksize"`
|
||||||
|
|
||||||
// Max disk size
|
// Max disk size
|
||||||
DiskSizeMax uint64 `json:"disksizemax"`
|
DiskSizeMax float64 `json:"disksizemax"`
|
||||||
|
|
||||||
// Number of External IPs
|
// Number of External IPs
|
||||||
ExtIPs int64 `json:"extips"`
|
ExtIPs int64 `json:"extips"`
|
||||||
@@ -126,10 +126,10 @@ type RecordResourceConsumption struct {
|
|||||||
// Information about resources
|
// Information about resources
|
||||||
type ItemResourceConsumption struct {
|
type ItemResourceConsumption struct {
|
||||||
// Current information about resources
|
// Current information about resources
|
||||||
Current Resource `json:"Current"`
|
Consumed Resource `json:"consumed"`
|
||||||
|
|
||||||
// Reserved information about resources
|
// Reserved information about resources
|
||||||
Reserved Resource `json:"Reserved"`
|
Reserved Resource `json:"reserved"`
|
||||||
|
|
||||||
// Account ID
|
// Account ID
|
||||||
AccountID uint64 `json:"id"`
|
AccountID uint64 `json:"id"`
|
||||||
|
|||||||
@@ -8,15 +8,32 @@ 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 service
|
// GetRequest struct to get detailed information about service
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of the service to query information
|
// ID of the service to query information
|
||||||
// Required: true
|
// Required: true
|
||||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets detailed specifications for the BasicService.
|
// Get gets detailed specifications for the BasicService as a RecordBasicService struct
|
||||||
func (b BService) Get(ctx context.Context, req GetRequest) (*RecordBasicService, error) {
|
func (b BService) Get(ctx context.Context, req GetRequest) (*RecordBasicService, error) {
|
||||||
|
res, err := b.GetRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := RecordBasicService{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets detailed specifications for the BasicService as an array of bytes
|
||||||
|
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) {
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
@@ -26,17 +43,6 @@ func (b BService) Get(ctx context.Context, req GetRequest) (*RecordBasicService,
|
|||||||
|
|
||||||
url := "/cloudapi/bservice/get"
|
url := "/cloudapi/bservice/get"
|
||||||
|
|
||||||
bsRaw, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
return res, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
info := RecordBasicService{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(bsRaw, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list BasicService instances
|
// ListRequest struct to get list of BasicService instances
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -49,11 +49,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list BasicService instances associated with the specified Resource Group
|
// List gets list of BasicService instances associated with the specified Resource Group as a ListBasicServices struct
|
||||||
func (b BService) List(ctx context.Context, req ListRequest) (*ListBasicServices, error) {
|
func (b BService) List(ctx context.Context, req ListRequest) (*ListBasicServices, error) {
|
||||||
url := "/cloudapi/bservice/list"
|
res, err := b.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -67,3 +65,11 @@ func (b BService) List(ctx context.Context, req ListRequest) (*ListBasicServices
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of BasicService instances associated with the specified Resource Group as an array of bytes
|
||||||
|
func (b BService) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudapi/bservice/list"
|
||||||
|
|
||||||
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request for get information about compute
|
// GetRequest struct to get information about compute
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of compute instance
|
// ID of compute instance
|
||||||
// Required: true
|
// Required: true
|
||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Gets information about compute
|
// Get gets information about compute as a RecordCompute struct
|
||||||
func (c Compute) Get(ctx context.Context, req GetRequest) (*RecordCompute, error) {
|
func (c Compute) Get(ctx context.Context, req GetRequest) (*RecordCompute, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := c.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/get"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +31,18 @@ func (c Compute) Get(ctx context.Context, req GetRequest) (*RecordCompute, error
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about compute as an array of bytes
|
||||||
|
func (c Compute) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/compute/get"
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list available computes
|
// ListRequest struct to get list of available computes
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -64,9 +64,7 @@ type ListRequest struct {
|
|||||||
// List gets list of the available computes.
|
// List gets list of the available computes.
|
||||||
// Filtering based on status is possible
|
// Filtering based on status is possible
|
||||||
func (c Compute) List(ctx context.Context, req ListRequest) (*ListComputes, error) {
|
func (c Compute) List(ctx context.Context, req ListRequest) (*ListComputes, error) {
|
||||||
url := "/cloudapi/compute/list"
|
res, err := c.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -80,3 +78,11 @@ func (c Compute) List(ctx context.Context, req ListRequest) (*ListComputes, erro
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of the available computes.
|
||||||
|
func (c Compute) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudapi/compute/list"
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ type ListPCIDeviceRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
DevID uint64 `url:"devId,omitempty" json:"devId,omitempty"`
|
DevID uint64 `url:"devId,omitempty" json:"devId,omitempty"`
|
||||||
|
|
||||||
// Find by type
|
// Find by name
|
||||||
// Required: false
|
// Required: false
|
||||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||||
|
|
||||||
// Find by status
|
// Find by status
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -8,26 +8,17 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get information about disk
|
// GetRequest struct to get information about disk
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of the disk
|
// ID of the disk
|
||||||
// Required: true
|
// Required: true
|
||||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets disk details
|
// Get gets disk details as a RecordDisk struct
|
||||||
// Notice: the devicename field is the name as it is passed to the kernel (kname in linux) for unattached disks this field has no relevant value
|
// Notice: the devicename field is the name as it is passed to the kernel (kname in linux) for unattached disks this field has no relevant value
|
||||||
func (d Disks) Get(ctx context.Context, req GetRequest) (*RecordDisk, error) {
|
func (d Disks) Get(ctx context.Context, req GetRequest) (*RecordDisk, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := d.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/disks/get"
|
|
||||||
|
|
||||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -41,3 +32,19 @@ func (d Disks) Get(ctx context.Context, req GetRequest) (*RecordDisk, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets disk details as an array of bytes
|
||||||
|
// Notice: the devicename field is the name as it is passed to the kernel (kname in linux) for unattached disks this field has no relevant value
|
||||||
|
func (d Disks) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/get"
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list of disks
|
// ListRequest struct to get list of disks
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by id
|
// Find by id
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -57,11 +57,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list the created disks belonging to an account
|
// List gets list of the created disks belonging to an account as a ListDisks struct
|
||||||
func (d Disks) List(ctx context.Context, req ListRequest) (*ListDisks, error) {
|
func (d Disks) List(ctx context.Context, req ListRequest) (*ListDisks, error) {
|
||||||
url := "/cloudapi/disks/list"
|
res, err := d.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -75,3 +73,11 @@ func (d Disks) List(ctx context.Context, req ListRequest) (*ListDisks, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of the created disks belonging to an account as an array of bytes
|
||||||
|
func (d Disks) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudapi/disks/list"
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ 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 external network
|
// GetRequest struct to get detailed information about external network
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of external network
|
// ID of external network
|
||||||
// Required: true
|
// Required: true
|
||||||
NetID uint64 `url:"net_id" json:"net_id" validate:"required"`
|
NetID uint64 `url:"net_id" json:"net_id" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets detailed information about external network
|
// Get gets detailed information about external network as a RecordExtNet struct
|
||||||
func (e ExtNet) Get(ctx context.Context, req GetRequest) (*RecordExtNet, error) {
|
func (e ExtNet) Get(ctx context.Context, req GetRequest) (*RecordExtNet, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := e.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/extnet/get"
|
|
||||||
|
|
||||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +31,18 @@ func (e ExtNet) Get(ctx context.Context, req GetRequest) (*RecordExtNet, error)
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets detailed information about external network as an array of bytes
|
||||||
|
func (e ExtNet) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/extnet/get"
|
||||||
|
|
||||||
|
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list external network
|
// ListRequest struct to get list of external network
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by account ID
|
// Find by account ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -45,11 +45,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list all available external networks
|
// List gets list of all available external networks as a ListExtNets struct
|
||||||
func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNets, error) {
|
func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNets, error) {
|
||||||
url := "/cloudapi/extnet/list"
|
res, err := e.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -63,3 +61,11 @@ func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNets, error)
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all available external networks as an array of bytes
|
||||||
|
func (e ExtNet) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudapi/extnet/list"
|
||||||
|
|
||||||
|
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get information about FLIPGroup
|
// GetRequest struct to get information about FLIPGroup
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// FLIPGroup ID
|
// FLIPGroup ID
|
||||||
// Required: true
|
// Required: true
|
||||||
FLIPGroupID uint64 `url:"flipgroupId" json:"flipgroupId" validate:"required"`
|
FLIPGroupID uint64 `url:"flipgroupId" json:"flipgroupId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets details of the specified Floating IP group
|
// Get gets details of the specified Floating IP group as a RecordFLIPGroup struct
|
||||||
func (f FLIPGroup) Get(ctx context.Context, req GetRequest) (*RecordFLIPGroup, error) {
|
func (f FLIPGroup) Get(ctx context.Context, req GetRequest) (*RecordFLIPGroup, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := f.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/flipgroup/get"
|
|
||||||
|
|
||||||
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +31,18 @@ func (f FLIPGroup) Get(ctx context.Context, req GetRequest) (*RecordFLIPGroup, e
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets details of the specified Floating IP group as an array of bytes
|
||||||
|
func (f FLIPGroup) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/flipgroup/get"
|
||||||
|
|
||||||
|
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list FLIPGroup available to the current user
|
// ListRequest struct to get list of FLIPGroup available to the current user
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by name
|
// Find by name
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -25,11 +25,11 @@ type ListRequest struct {
|
|||||||
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
|
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
|
||||||
|
|
||||||
// Find by IP
|
// Find by IP
|
||||||
// Reuqired: false
|
// Required: false
|
||||||
ByIP string `url:"byIp,omitempty" json:"byIp,omitempty"`
|
ByIP string `url:"byIp,omitempty" json:"byIp,omitempty"`
|
||||||
|
|
||||||
// Find by resource group ID
|
// Find by resource group ID
|
||||||
// Reuqired: false
|
// Required: false
|
||||||
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||||
|
|
||||||
// Find by id
|
// Find by id
|
||||||
@@ -45,11 +45,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list FLIPGroup managed cluster instances available to the current user
|
// List gets list of FLIPGroup managed cluster instances available to the current user as a ListFLIPGroups struct
|
||||||
func (f FLIPGroup) List(ctx context.Context, req ListRequest) (*ListFLIPGroups, error) {
|
func (f FLIPGroup) List(ctx context.Context, req ListRequest) (*ListFLIPGroups, error) {
|
||||||
url := "/cloudapi/flipgroup/list"
|
res, err := f.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -63,3 +61,11 @@ func (f FLIPGroup) List(ctx context.Context, req ListRequest) (*ListFLIPGroups,
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of FLIPGroup managed cluster instances available to the current user as an array of bytes
|
||||||
|
func (f FLIPGroup) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudapi/flipgroup/list"
|
||||||
|
|
||||||
|
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -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 image
|
// GetRequest struct to get detailed information about image
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of image to get
|
// ID of image to get
|
||||||
// Required: true
|
// Required: true
|
||||||
@@ -20,18 +20,9 @@ type GetRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get gets image by ID.
|
// Get gets image by ID.
|
||||||
// Returns image if user has rights on it
|
// Returns image as a RecordImage struct if user has rights on it
|
||||||
func (i Image) Get(ctx context.Context, req GetRequest) (*RecordImage, error) {
|
func (i Image) Get(ctx context.Context, req GetRequest) (*RecordImage, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := i.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/image/get"
|
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -45,3 +36,19 @@ func (i Image) Get(ctx context.Context, req GetRequest) (*RecordImage, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets image by ID.
|
||||||
|
// Returns image as an array of bytes if user has rights on it
|
||||||
|
func (i Image) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/image/get"
|
||||||
|
|
||||||
|
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list available images
|
// ListRequest struct to get list of available images
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by storage endpoint provider ID
|
// Find by storage endpoint provider ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -65,11 +65,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list available images, optionally filtering by account ID
|
// List gets list of available images as a ListImages struct, optionally filtering by account ID
|
||||||
func (i Image) List(ctx context.Context, req ListRequest) (*ListImages, error) {
|
func (i Image) List(ctx context.Context, req ListRequest) (*ListImages, error) {
|
||||||
url := "/cloudapi/image/list"
|
res, err := i.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -83,3 +81,11 @@ func (i Image) List(ctx context.Context, req ListRequest) (*ListImages, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of available images as an array of bytes
|
||||||
|
func (i Image) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudapi/image/list"
|
||||||
|
|
||||||
|
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get information about K8CI
|
// GetRequest struct to get information about K8CI
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of the K8 catalog item to get
|
// ID of the K8 catalog item to get
|
||||||
// Required: true
|
// Required: true
|
||||||
K8CIID uint64 `url:"k8ciId" json:"k8ciId" validate:"required"`
|
K8CIID uint64 `url:"k8ciId" json:"k8ciId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets details of the specified K8 catalog item
|
// Get gets details of the specified K8 catalog item as a RecordK8CI struct
|
||||||
func (k K8CI) Get(ctx context.Context, req GetRequest) (*RecordK8CI, error) {
|
func (k K8CI) Get(ctx context.Context, req GetRequest) (*RecordK8CI, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := k.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/k8ci/get"
|
|
||||||
|
|
||||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -39,3 +30,18 @@ func (k K8CI) Get(ctx context.Context, req GetRequest) (*RecordK8CI, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets details of the specified K8 catalog item as an array of bytes
|
||||||
|
func (k K8CI) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/k8ci/get"
|
||||||
|
|
||||||
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list information about images
|
// ListRequest struct to get list of information about images
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -45,11 +45,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list all k8ci catalog items available to the current user
|
// List gets list of all k8ci catalog items available to the current user as a ListK8CI struct
|
||||||
func (k K8CI) List(ctx context.Context, req ListRequest) (*ListK8CI, error) {
|
func (k K8CI) List(ctx context.Context, req ListRequest) (*ListK8CI, error) {
|
||||||
url := "/cloudapi/k8ci/list"
|
res, err := k.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -63,3 +61,11 @@ func (k K8CI) List(ctx context.Context, req ListRequest) (*ListK8CI, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all k8ci catalog items available to the current user as an array of bytes
|
||||||
|
func (k K8CI) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudapi/k8ci/list"
|
||||||
|
|
||||||
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -111,11 +111,11 @@ type CreateRequest struct {
|
|||||||
|
|
||||||
// Custom sysctl values for Load Balancer instance. Applied on boot
|
// Custom sysctl values for Load Balancer instance. Applied on boot
|
||||||
// Required: false
|
// Required: false
|
||||||
LbSysctlParams string `url:"-" json:"lbSysctlParams,omitempty" validate:"omitempty,dive"`
|
LbSysctlParams string `url:"lbSysctlParams,omitempty" json:"lbSysctlParams,omitempty"`
|
||||||
|
|
||||||
// Use Highly Available schema for LB deploy
|
// Use Highly Available schema for LB deploy
|
||||||
// Required: false
|
// Required: false
|
||||||
HighlyAvailable bool `url:"highlyAvailable,omitempty" json:"highlyAvailable,omitempty"`
|
HighlyAvailable bool `url:"highlyAvailableLB,omitempty" json:"highlyAvailableLB,omitempty"`
|
||||||
|
|
||||||
// Optional extra Subject Alternative Names (SANs) to use for the API Server serving certificate. Can be both IP addresses and DNS names
|
// Optional extra Subject Alternative Names (SANs) to use for the API Server serving certificate. Can be both IP addresses and DNS names
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ 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 kubernetes cluster
|
// GetRequest struct to get detailed information about kubernetes cluster
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// Kubernetes cluster ID
|
// Kubernetes cluster ID
|
||||||
// Required: true
|
// Required: true
|
||||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets information about Kubernetes cluster
|
// Get gets information about Kubernetes cluster as a RecordK8S struct
|
||||||
func (k8s K8S) Get(ctx context.Context, req GetRequest) (*RecordK8S, error) {
|
func (k8s K8S) Get(ctx context.Context, req GetRequest) (*RecordK8S, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := k8s.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/k8s/get"
|
|
||||||
|
|
||||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +31,18 @@ func (k8s K8S) Get(ctx context.Context, req GetRequest) (*RecordK8S, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about Kubernetes cluster as an array of bytes
|
||||||
|
func (k8s K8S) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/k8s/get"
|
||||||
|
|
||||||
|
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list information K8S
|
// ListRequest struct to get list information K8S
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -53,11 +53,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list all kubernetes clusters the user has access to
|
// List gets list of all kubernetes clusters the user has access to as a ListK8SClusters
|
||||||
func (k8s K8S) List(ctx context.Context, req ListRequest) (*ListK8SClusters, error) {
|
func (k8s K8S) List(ctx context.Context, req ListRequest) (*ListK8SClusters, error) {
|
||||||
url := "/cloudapi/k8s/list"
|
res, err := k8s.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -71,3 +69,11 @@ func (k8s K8S) List(ctx context.Context, req ListRequest) (*ListK8SClusters, err
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all kubernetes clusters the user has access to as an array of bytes
|
||||||
|
func (k8s K8S) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudapi/k8s/list"
|
||||||
|
|
||||||
|
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -32,10 +32,6 @@ type ListDeletedRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
BasicServiceID uint64 `url:"basicServiceId,omitempty" json:"basicServiceId,omitempty"`
|
BasicServiceID uint64 `url:"basicServiceId,omitempty" json:"basicServiceId,omitempty"`
|
||||||
|
|
||||||
// Find by status
|
|
||||||
// Required: false
|
|
||||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
|
||||||
|
|
||||||
// Find by techStatus
|
// Find by techStatus
|
||||||
// Required: false
|
// Required: false
|
||||||
TechStatus string `url:"techStatus,omitempty" json:"techStatus,omitempty"`
|
TechStatus string `url:"techStatus,omitempty" json:"techStatus,omitempty"`
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ type WorkersGroupAddRequest struct {
|
|||||||
// Worker node boot disk size in GB If 0 is specified, size is defined by the OS image size
|
// Worker node boot disk size in GB If 0 is specified, size is defined by the OS image size
|
||||||
// Required: false
|
// Required: false
|
||||||
WorkerDisk uint64 `url:"workerDisk,omitempty" json:"workerDisk,omitempty"`
|
WorkerDisk uint64 `url:"workerDisk,omitempty" json:"workerDisk,omitempty"`
|
||||||
|
|
||||||
|
// Meta data for working group computes, format YAML "user_data": 1111
|
||||||
|
// Required: false
|
||||||
|
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// WorkersGroupAdd adds workers group to Kubernetes cluster
|
// WorkersGroupAdd adds workers group to Kubernetes cluster
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ 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 load balancer
|
// GetRequest struct to get detailed information about load balancer
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of the load balancer to get details for
|
// ID of the load balancer to get details for
|
||||||
// Required: true
|
// Required: true
|
||||||
LBID uint64 `url:"lbId" json:"lbId" validate:"required"`
|
LBID uint64 `url:"lbId" json:"lbId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets detailed information about load balancer
|
// Get gets detailed information about load balancer as a RecordLB struct
|
||||||
func (l LB) Get(ctx context.Context, req GetRequest) (*RecordLB, error) {
|
func (l LB) Get(ctx context.Context, req GetRequest) (*RecordLB, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := l.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/lb/get"
|
|
||||||
|
|
||||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +31,18 @@ func (l LB) Get(ctx context.Context, req GetRequest) (*RecordLB, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets detailed information about load balancer as an array of bytes
|
||||||
|
func (l LB) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/lb/get"
|
||||||
|
|
||||||
|
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list of load balancers
|
// ListRequest struct to get list of load balancers
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -53,11 +53,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list all load balancers
|
// List gets list of all load balancers as a ListLB struct
|
||||||
func (l LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
|
func (l LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
|
||||||
url := "/cloudapi/lb/list"
|
res, err := l.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -71,3 +69,11 @@ func (l LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all load balancers as an array of bytes
|
||||||
|
func (l LB) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudapi/lb/list"
|
||||||
|
|
||||||
|
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ type RecordLB struct {
|
|||||||
HAMode bool `json:"HAmode"`
|
HAMode bool `json:"HAmode"`
|
||||||
|
|
||||||
// Access Control List
|
// Access Control List
|
||||||
ACL []interface{} `json:"acl"`
|
ACL interface{} `json:"acl"`
|
||||||
|
|
||||||
// BackendHAIP
|
// BackendHAIP
|
||||||
BackendHAIP string `json:"backendHAIP"`
|
BackendHAIP string `json:"backendHAIP"`
|
||||||
@@ -78,7 +78,7 @@ type RecordLB struct {
|
|||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
// Sysctl Params
|
// Sysctl Params
|
||||||
SysctlParams []interface{} `json:"sysctlParams"`
|
SysctlParams interface{} `json:"sysctlParams"`
|
||||||
|
|
||||||
// Tech status
|
// Tech status
|
||||||
TechStatus string `json:"techStatus"`
|
TechStatus string `json:"techStatus"`
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list of locations
|
// ListRequest struct to get list of locations
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Page number
|
// Page number
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -33,11 +33,9 @@ type ListRequest struct {
|
|||||||
LocationCode string `url:"locationCode,omitempty" json:"locationCode,omitempty"`
|
LocationCode string `url:"locationCode,omitempty" json:"locationCode,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list all locations
|
// List gets list of all locations as a ListLocations struct
|
||||||
func (l Locations) List(ctx context.Context, req ListRequest) (*ListLocations, error) {
|
func (l Locations) List(ctx context.Context, req ListRequest) (*ListLocations, error) {
|
||||||
url := "/cloudapi/locations/list"
|
res, err := l.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -51,3 +49,11 @@ func (l Locations) List(ctx context.Context, req ListRequest) (*ListLocations, e
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all locations as an array of bytes
|
||||||
|
func (l Locations) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudapi/locations/list"
|
||||||
|
|
||||||
|
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,6 +13,14 @@ type AffinityGroupsListRequest struct {
|
|||||||
// Resource group ID
|
// Resource group ID
|
||||||
// Required: true
|
// Required: true
|
||||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||||
|
|
||||||
|
// Page number
|
||||||
|
// Required: false
|
||||||
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
|
|
||||||
|
// Page size
|
||||||
|
// Required: false
|
||||||
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AffinityGroupsList gets all currently defined affinity groups in this resource group with compute IDs
|
// AffinityGroupsList gets all currently defined affinity groups in this resource group with compute IDs
|
||||||
|
|||||||
@@ -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 resource group
|
// GetRequest struct to get detailed information about resource group
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// Resource group ID
|
// Resource group ID
|
||||||
// Required: true
|
// Required: true
|
||||||
@@ -19,18 +19,9 @@ type GetRequest struct {
|
|||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets current configuration of the resource group
|
// Get gets current configuration of the resource group as a RecordResourceGroup struct
|
||||||
func (r RG) Get(ctx context.Context, req GetRequest) (*RecordResourceGroup, error) {
|
func (r RG) Get(ctx context.Context, req GetRequest) (*RecordResourceGroup, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := r.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/rg/get"
|
|
||||||
|
|
||||||
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -44,3 +35,18 @@ func (r RG) Get(ctx context.Context, req GetRequest) (*RecordResourceGroup, erro
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets current configuration of the resource group as an array of bytes
|
||||||
|
func (r RG) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/rg/get"
|
||||||
|
|
||||||
|
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list of resource groups
|
// ListRequest struct to get list of resource groups
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -53,11 +53,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of all resource groups the user has access to
|
// List gets list of all resource groups the user has access to as a ListResourceGroups struct
|
||||||
func (r RG) List(ctx context.Context, req ListRequest) (*ListResourceGroups, error) {
|
func (r RG) List(ctx context.Context, req ListRequest) (*ListResourceGroups, error) {
|
||||||
url := "/cloudapi/rg/list"
|
res, err := r.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -71,3 +69,11 @@ func (r RG) List(ctx context.Context, req ListRequest) (*ListResourceGroups, err
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all resource groups the user has access to as an array of bytes
|
||||||
|
func (r RG) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudapi/rg/list"
|
||||||
|
|
||||||
|
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -48,10 +48,10 @@ type Resources struct {
|
|||||||
// Detailed information about resource consumption
|
// Detailed information about resource consumption
|
||||||
type ItemResourceConsumption struct {
|
type ItemResourceConsumption struct {
|
||||||
// Consumed information about resources
|
// Consumed information about resources
|
||||||
Consumed Resource `json:"Consumed"`
|
Consumed Resource `json:"consumed"`
|
||||||
|
|
||||||
// Reserved information about resources
|
// Reserved information about resources
|
||||||
Reserved Resource `json:"Reserved"`
|
Reserved Resource `json:"reserved"`
|
||||||
|
|
||||||
// Resource limits
|
// Resource limits
|
||||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||||
@@ -333,7 +333,7 @@ type ListAffinityGroupsComputes []ItemAffinityGroupComputes
|
|||||||
|
|
||||||
type ListAffinityGroups struct {
|
type ListAffinityGroups struct {
|
||||||
// Data
|
// Data
|
||||||
Data map[string][]uint64 `json:"data"`
|
Data []map[string][]uint64 `json:"data"`
|
||||||
|
|
||||||
// Entry count
|
// Entry count
|
||||||
EntryCount uint64 `json:"entryCount"`
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for list the available flavors
|
// ListRequest struct for list of the available flavors
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// ID of the cloudspace
|
// ID of the cloudspace
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -25,11 +25,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list the available flavors, filtering can be based on the user which is doing the request
|
// List gets list of the available flavors as a ListSizes struct, filtering can be based on the user which is doing the request
|
||||||
func (s Sizes) List(ctx context.Context, req ListRequest) (*ListSizes, error) {
|
func (s Sizes) List(ctx context.Context, req ListRequest) (*ListSizes, error) {
|
||||||
url := "/cloudapi/sizes/list"
|
res, err := s.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -43,3 +41,11 @@ func (s Sizes) List(ctx context.Context, req ListRequest) (*ListSizes, error) {
|
|||||||
|
|
||||||
return list, nil
|
return list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of the available flavors as an array of bytes
|
||||||
|
func (s Sizes) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudapi/sizes/list"
|
||||||
|
|
||||||
|
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get info of stack
|
// GetRequest struct to get info of stack
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: true
|
// Required: true
|
||||||
StackId uint64 `url:"stackId" json:"stackId" validate:"required"`
|
StackId uint64 `url:"stackId" json:"stackId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get stack details by ID
|
// Get gets stack details by ID as an InfoStack struct
|
||||||
func (i Stack) Get(ctx context.Context, req GetRequest) (*InfoStack, error) {
|
func (i Stack) Get(ctx context.Context, req GetRequest) (*InfoStack, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := i.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/stack/get"
|
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +31,18 @@ func (i Stack) Get(ctx context.Context, req GetRequest) (*InfoStack, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets stack details by ID as an array of bytes
|
||||||
|
func (i Stack) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/stack/get"
|
||||||
|
|
||||||
|
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list stack
|
// ListRequest struct to get list of stacks
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -33,11 +33,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListStacks gets list stack
|
// List gets list of stacks as a ListStacks struct
|
||||||
func (i Stack) List(ctx context.Context, req ListRequest) (*ListStacks, error) {
|
func (i Stack) List(ctx context.Context, req ListRequest) (*ListStacks, error) {
|
||||||
url := "/cloudapi/stack/list"
|
res, err := i.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -51,3 +49,11 @@ func (i Stack) List(ctx context.Context, req ListRequest) (*ListStacks, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of stacks as an array of bytes
|
||||||
|
func (i Stack) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudapi/stack/list"
|
||||||
|
|
||||||
|
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get infromation about task
|
// GetRequest struct to get information about task
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of audit
|
// ID of audit
|
||||||
// Required: true
|
// Required: true
|
||||||
AuditID string `url:"auditId" json:"auditId" validate:"required"`
|
AuditID string `url:"auditId" json:"auditId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets background API task status and result
|
// Get gets background API task status and result as a RecordAsyncTask struct
|
||||||
func (t Tasks) Get(ctx context.Context, req GetRequest) (*RecordAsyncTask, error) {
|
func (t Tasks) Get(ctx context.Context, req GetRequest) (*RecordAsyncTask, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := t.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/tasks/get"
|
|
||||||
|
|
||||||
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -41,3 +32,18 @@ func (t Tasks) Get(ctx context.Context, req GetRequest) (*RecordAsyncTask, error
|
|||||||
return &info, nil
|
return &info, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets background API task status and result as an array of bytes
|
||||||
|
func (t Tasks) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/tasks/get"
|
||||||
|
|
||||||
|
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list of tasks
|
// ListRequest struct to get list of tasks
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Page number
|
// Page number
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -17,11 +17,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list user API tasks with status PROCESSING
|
// List gets list of user API tasks with status PROCESSING as a ListTasks struct
|
||||||
func (t Tasks) List(ctx context.Context, req ListRequest) (*ListTasks, error) {
|
func (t Tasks) List(ctx context.Context, req ListRequest) (*ListTasks, error) {
|
||||||
url := "/cloudapi/tasks/list"
|
res, err := t.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -35,3 +33,11 @@ func (t Tasks) List(ctx context.Context, req ListRequest) (*ListTasks, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of user API tasks with status PROCESSING as an array of bytes
|
||||||
|
func (t Tasks) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudapi/tasks/list"
|
||||||
|
|
||||||
|
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get information about VINS
|
// GetRequest struct to get information about VINS
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// VINS ID
|
// VINS ID
|
||||||
// Required: true
|
// Required: true
|
||||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets information about VINS by ID
|
// Get gets information about VINS by ID as a RecordVINS struct
|
||||||
func (v VINS) Get(ctx context.Context, req GetRequest) (*RecordVINS, error) {
|
func (v VINS) Get(ctx context.Context, req GetRequest) (*RecordVINS, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := v.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/vins/get"
|
|
||||||
|
|
||||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -39,5 +30,19 @@ func (v VINS) Get(ctx context.Context, req GetRequest) (*RecordVINS, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about VINS by ID as an array of bytes
|
||||||
|
func (v VINS) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/vins/get"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list of VINSes
|
// ListRequest struct to get list of VINSes
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -41,11 +41,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of VINSes available for current user
|
// List gets list of VINSes available for current user as a ListVINS struct
|
||||||
func (v VINS) List(ctx context.Context, req ListRequest) (*ListVINS, error) {
|
func (v VINS) List(ctx context.Context, req ListRequest) (*ListVINS, error) {
|
||||||
url := "/cloudapi/vins/list"
|
res, err := v.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -59,3 +57,11 @@ func (v VINS) List(ctx context.Context, req ListRequest) (*ListVINS, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of VINSes available for current user as an array of bytes
|
||||||
|
func (v VINS) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudapi/vins/list"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,15 +8,32 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get information about account
|
// GetRequest struct to get information about account
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID an account
|
// ID an account
|
||||||
// Required: true
|
// Required: true
|
||||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets information about account
|
// Get gets information about account as a RecordAccount struct
|
||||||
func (a Account) Get(ctx context.Context, req GetRequest) (*RecordAccount, error) {
|
func (a Account) Get(ctx context.Context, req GetRequest) (*RecordAccount, error) {
|
||||||
|
res, err := a.GetRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := RecordAccount{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about account as an array of bytes
|
||||||
|
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) {
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
@@ -26,17 +43,6 @@ func (a Account) Get(ctx context.Context, req GetRequest) (*RecordAccount, error
|
|||||||
|
|
||||||
url := "/cloudbroker/account/get"
|
url := "/cloudbroker/account/get"
|
||||||
|
|
||||||
info := RecordAccount{}
|
|
||||||
|
|
||||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
return res, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list of accounts
|
// ListRequest struct to get list of accounts
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -33,11 +33,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list all accounts the user has access to
|
// List gets list of all accounts the user has access to as a ListAccounts struct
|
||||||
func (a Account) List(ctx context.Context, req ListRequest) (*ListAccounts, error) {
|
func (a Account) List(ctx context.Context, req ListRequest) (*ListAccounts, error) {
|
||||||
url := "/cloudbroker/account/list"
|
res, err := a.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -51,3 +49,11 @@ func (a Account) List(ctx context.Context, req ListRequest) (*ListAccounts, erro
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all accounts the user has access to as an array of bytes
|
||||||
|
func (a Account) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudbroker/account/list"
|
||||||
|
|
||||||
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ type RecordResourceConsumption struct {
|
|||||||
|
|
||||||
type ItemResourceConsumption struct {
|
type ItemResourceConsumption struct {
|
||||||
// Current information about resources
|
// Current information about resources
|
||||||
Current Resource `json:"Current"`
|
Consumed Resource `json:"consumed"`
|
||||||
|
|
||||||
// Reserved information about resources
|
// Reserved information about resources
|
||||||
Reserved Resource `json:"Reserved"`
|
Reserved Resource `json:"reserved"`
|
||||||
|
|
||||||
// ID of account
|
// ID of account
|
||||||
AccountID uint64 `json:"id"`
|
AccountID uint64 `json:"id"`
|
||||||
@@ -54,7 +54,7 @@ type Resource struct {
|
|||||||
DiskSize float64 `json:"disksize"`
|
DiskSize float64 `json:"disksize"`
|
||||||
|
|
||||||
// Disk size max
|
// Disk size max
|
||||||
DiskSizeMax uint64 `json:"disksizemax"`
|
DiskSizeMax float64 `json:"disksizemax"`
|
||||||
|
|
||||||
// Number of External IPs
|
// Number of External IPs
|
||||||
ExtIPs int64 `json:"extips"`
|
ExtIPs int64 `json:"extips"`
|
||||||
@@ -414,33 +414,6 @@ type Computes struct {
|
|||||||
Stopped uint64 `json:"Stopped"`
|
Stopped uint64 `json:"Stopped"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Consumed
|
|
||||||
type Consumed struct {
|
|
||||||
// Number of CPU
|
|
||||||
CPU uint64 `json:"cpu"`
|
|
||||||
|
|
||||||
// Disk size
|
|
||||||
DiskSize float64 `json:"disksize"`
|
|
||||||
|
|
||||||
// Disk size max
|
|
||||||
DiskSizeMax int64 `json:"disksizemax"`
|
|
||||||
|
|
||||||
// External IPs
|
|
||||||
ExtIPs uint64 `json:"extips"`
|
|
||||||
|
|
||||||
// External traffic
|
|
||||||
ExtTraffic uint64 `json:"exttraffic"`
|
|
||||||
|
|
||||||
// Number of GPU
|
|
||||||
GPU uint64 `json:"gpu"`
|
|
||||||
|
|
||||||
// Number of RAM
|
|
||||||
RAM uint64 `json:"ram"`
|
|
||||||
|
|
||||||
// SEPs
|
|
||||||
SEPs map[string]map[string]DiskUsage `json:"seps"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Limits
|
// Limits
|
||||||
type Limits struct {
|
type Limits struct {
|
||||||
// Number of CPU
|
// Number of CPU
|
||||||
@@ -471,7 +444,7 @@ type Limits struct {
|
|||||||
// Resources of resource group
|
// Resources of resource group
|
||||||
type RGResuorces struct {
|
type RGResuorces struct {
|
||||||
// Consumed
|
// Consumed
|
||||||
Consumed Consumed `json:"Consumed"`
|
Consumed Resource `json:"Consumed"`
|
||||||
|
|
||||||
// Limits
|
// Limits
|
||||||
Limits Limits `json:"Limits"`
|
Limits Limits `json:"Limits"`
|
||||||
|
|||||||
@@ -8,15 +8,32 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for getting apiaccess group.
|
// GetRequest struct to get apiaccess group.
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// APIAccess group ID.
|
// APIAccess group ID.
|
||||||
// Required: true
|
// Required: true
|
||||||
APIAccessID uint64 `url:"apiaccessId" json:"apiaccessId" validate:"required"`
|
APIAccessID uint64 `url:"apiaccessId" json:"apiaccessId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets apiaccess group.
|
// Get gets apiaccess group as an ItemAPIAccess struct
|
||||||
func (a APIAccess) Get(ctx context.Context, req GetRequest) (*ItemAPIAccess, error) {
|
func (a APIAccess) Get(ctx context.Context, req GetRequest) (*ItemAPIAccess, error) {
|
||||||
|
res, err := a.GetRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := ItemAPIAccess{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets apiaccess group as an array of bytes
|
||||||
|
func (a APIAccess) 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) {
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
@@ -26,17 +43,6 @@ func (a APIAccess) Get(ctx context.Context, req GetRequest) (*ItemAPIAccess, err
|
|||||||
|
|
||||||
url := "/cloudbroker/apiaccess/get"
|
url := "/cloudbroker/apiaccess/get"
|
||||||
|
|
||||||
info := ItemAPIAccess{}
|
|
||||||
|
|
||||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
return res, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 list of all non deleted apiaccess instances.
|
// ListRequest struct to get list of all non deleted apiaccess instances.
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -43,8 +43,25 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of all non deleted apiaccess instances.
|
// List gets list of all non deleted apiaccess instances as a ListAPIAccess struct
|
||||||
func (a APIAccess) List(ctx context.Context, req ListRequest) (*ListAPIAccess, error) {
|
func (a APIAccess) List(ctx context.Context, req ListRequest) (*ListAPIAccess, error) {
|
||||||
|
res, err := a.ListRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := ListAPIAccess{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all non deleted apiaccess instances as an array of bytes
|
||||||
|
func (a APIAccess) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
@@ -54,17 +71,6 @@ func (a APIAccess) List(ctx context.Context, req ListRequest) (*ListAPIAccess, e
|
|||||||
|
|
||||||
url := "/cloudbroker/apiaccess/list"
|
url := "/cloudbroker/apiaccess/list"
|
||||||
|
|
||||||
info := ListAPIAccess{}
|
|
||||||
|
|
||||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
return res, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request for get information about compute
|
// GetRequest to get information about compute
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of compute instance
|
// ID of compute instance
|
||||||
// Required: true
|
// Required: true
|
||||||
@@ -19,18 +19,9 @@ type GetRequest struct {
|
|||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets information about compute
|
// Get gets information about compute as a RecordCompute struct
|
||||||
func (c Compute) Get(ctx context.Context, req GetRequest) (*RecordCompute, error) {
|
func (c Compute) Get(ctx context.Context, req GetRequest) (*RecordCompute, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := c.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/get"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -44,3 +35,18 @@ func (c Compute) Get(ctx context.Context, req GetRequest) (*RecordCompute, error
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about compute as an array of bytes
|
||||||
|
func (c Compute) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/compute/get"
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list available computes
|
// ListRequest struct to get list of available computes
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -61,12 +61,10 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of the available computes.
|
// List gets list of the available computes as a ListComputes struct.
|
||||||
// Filtering based on status is possible
|
// Filtering based on status is possible
|
||||||
func (c Compute) List(ctx context.Context, req ListRequest) (*ListComputes, error) {
|
func (c Compute) List(ctx context.Context, req ListRequest) (*ListComputes, error) {
|
||||||
url := "/cloudbroker/compute/list"
|
res, err := c.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -80,3 +78,11 @@ func (c Compute) List(ctx context.Context, req ListRequest) (*ListComputes, erro
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of the available computes as an array of bytes
|
||||||
|
func (c Compute) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudbroker/compute/list"
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -672,7 +672,7 @@ type InfoCompute struct {
|
|||||||
StackName string `json:"stackName"`
|
StackName string `json:"stackName"`
|
||||||
|
|
||||||
// Stateless SEP ID
|
// Stateless SEP ID
|
||||||
StatelessSEPID uint64 `json:"statelessSepId"`
|
StatelessSEPID int64 `json:"statelessSepId"`
|
||||||
|
|
||||||
// Stateless SEP Type
|
// Stateless SEP Type
|
||||||
StatelessSEPType string `json:"statelessSepType"`
|
StatelessSEPType string `json:"statelessSepType"`
|
||||||
|
|||||||
@@ -8,26 +8,17 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get information about disk
|
// GetRequest struct to get information about disk
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of the disk
|
// ID of the disk
|
||||||
// Required: true
|
// Required: true
|
||||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets disk details
|
// Get gets disk details as a RecordDisk struct.
|
||||||
// Notice: the devicename field is the name as it is passed to the kernel (kname in linux) for unattached disks this field has no relevant value
|
// Notice: the devicename field is the name as it is passed to the kernel (kname in linux) for unattached disks this field has no relevant value
|
||||||
func (d Disks) Get(ctx context.Context, req GetRequest) (*RecordDisk, error) {
|
func (d Disks) Get(ctx context.Context, req GetRequest) (*RecordDisk, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := d.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/disks/get"
|
|
||||||
|
|
||||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -41,3 +32,19 @@ func (d Disks) Get(ctx context.Context, req GetRequest) (*RecordDisk, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets disk details as an array of bytes.
|
||||||
|
// Notice: the devicename field is the name as it is passed to the kernel (kname in linux) for unattached disks this field has no relevant value
|
||||||
|
func (d Disks) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/disks/get"
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list/list_deleted of disks
|
// ListRequest struct to get list/list_deleted of disks
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by id
|
// Find by id
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -57,11 +57,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list the created disks belonging to an account
|
// List gets list of the created disks belonging to an account as a ListDisks struct
|
||||||
func (d Disks) List(ctx context.Context, req ListRequest) (*ListDisks, error) {
|
func (d Disks) List(ctx context.Context, req ListRequest) (*ListDisks, error) {
|
||||||
url := "/cloudbroker/disks/list"
|
res, err := d.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -75,3 +73,11 @@ func (d Disks) List(ctx context.Context, req ListRequest) (*ListDisks, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of the created disks belonging to an account as an array of bytes
|
||||||
|
func (d Disks) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudbroker/disks/list"
|
||||||
|
|
||||||
|
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get information about external network
|
// GetRequest struct to get information about external network
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of external network
|
// ID of external network
|
||||||
// Required: true
|
// Required: true
|
||||||
NetID uint64 `url:"net_id" json:"net_id" validate:"required"`
|
NetID uint64 `url:"net_id" json:"net_id" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets external network details
|
// Get gets external network details as a RecordExtNet struct
|
||||||
func (e ExtNet) Get(ctx context.Context, req GetRequest) (*RecordExtNet, error) {
|
func (e ExtNet) Get(ctx context.Context, req GetRequest) (*RecordExtNet, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := e.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/extnet/get"
|
|
||||||
|
|
||||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +31,18 @@ func (e ExtNet) Get(ctx context.Context, req GetRequest) (*RecordExtNet, error)
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets external network details as an array of bytes
|
||||||
|
func (e ExtNet) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/extnet/get"
|
||||||
|
|
||||||
|
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list external network
|
// ListRequest struct to get list of external network
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by account ID
|
// Find by account ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -45,11 +45,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list all available external networks
|
// List gets list of all available external networks as a ListExtNet struct
|
||||||
func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNet, error) {
|
func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNet, error) {
|
||||||
url := "/cloudbroker/extnet/list"
|
res, err := e.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -63,3 +61,11 @@ func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNet, error)
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all available external networks as an array of bytes
|
||||||
|
func (e ExtNet) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudbroker/extnet/list"
|
||||||
|
|
||||||
|
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -127,29 +127,86 @@ type ListExtNet struct {
|
|||||||
|
|
||||||
// Detailed information about external network
|
// Detailed information about external network
|
||||||
type RecordExtNet struct {
|
type RecordExtNet struct {
|
||||||
// Main information about external network
|
// CKey
|
||||||
ItemExtNet
|
CKey string `json:"_ckey"`
|
||||||
|
|
||||||
// CheckIps
|
// Meta
|
||||||
|
Meta []interface{} `json:"_meta"`
|
||||||
|
|
||||||
|
// CheckIPs
|
||||||
CheckIPs []string `json:"checkIps"`
|
CheckIPs []string `json:"checkIps"`
|
||||||
|
|
||||||
|
// Default
|
||||||
|
Default bool `json:"default"`
|
||||||
|
|
||||||
|
// Default QOS
|
||||||
|
DefaultQOS QOS `json:"defaultQos"`
|
||||||
|
|
||||||
|
// Description
|
||||||
|
Description string `json:"desc"`
|
||||||
|
|
||||||
// List DNS
|
// List DNS
|
||||||
DNS []string `json:"dns"`
|
DNS []string `json:"dns"`
|
||||||
|
|
||||||
// List excludes
|
// List excludes
|
||||||
Excluded ListReservations `json:"excluded"`
|
Excluded ListReservations `json:"excluded"`
|
||||||
|
|
||||||
|
// Free IPs number
|
||||||
|
FreeIPs uint64 `json:"free_ips"`
|
||||||
|
|
||||||
// Gateway
|
// Gateway
|
||||||
Gateway string `json:"gateway"`
|
Gateway string `json:"gateway"`
|
||||||
|
|
||||||
|
// Grid ID
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
|
// GUID
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
|
// ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// IPCIDR
|
||||||
|
IPCIDR string `json:"ipcidr"`
|
||||||
|
|
||||||
|
// Milestones
|
||||||
|
Milestones uint64 `json:"milestones"`
|
||||||
|
|
||||||
|
// Name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
// Network
|
// Network
|
||||||
Network string `json:"network"`
|
Network string `json:"network"`
|
||||||
|
|
||||||
|
// Network ID
|
||||||
|
NetworkID uint64 `json:"networkId"`
|
||||||
|
|
||||||
|
// OVSBridge
|
||||||
|
OVSBridge string `json:"ovsBridge"`
|
||||||
|
|
||||||
|
// PreReservationsNum
|
||||||
|
PreReservationsNum uint64 `json:"preReservationsNum"`
|
||||||
|
|
||||||
// Prefix
|
// Prefix
|
||||||
Prefix uint64 `json:"prefix"`
|
Prefix uint64 `json:"prefix"`
|
||||||
|
|
||||||
|
// PriVNFDevID
|
||||||
|
PriVNFDevID uint64 `json:"priVnfDevId"`
|
||||||
|
|
||||||
// List reservations
|
// List reservations
|
||||||
Reservations ListReservations `json:"reservations"`
|
Reservations ListReservations `json:"reservations"`
|
||||||
|
|
||||||
|
// List of shared with
|
||||||
|
SharedWith []interface{} `json:"sharedWith"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// VLAN ID
|
||||||
|
VLANID uint64 `json:"vlanId"`
|
||||||
|
|
||||||
|
// VNFs
|
||||||
|
VNFs VNFs `json:"vnfs"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of static routes
|
// List of static routes
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get information about FLIPGroup
|
// GetRequest struct to get information about FLIPGroup
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// FLIPGroup ID
|
// FLIPGroup ID
|
||||||
// Required: true
|
// Required: true
|
||||||
FLIPGroupID uint64 `url:"flipgroupId" json:"flipgroupId" validate:"required"`
|
FLIPGroupID uint64 `url:"flipgroupId" json:"flipgroupId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets details of the specified Floating IP group
|
// Get gets details of the specified Floating IP group as a RecordFLIPGroup struct
|
||||||
func (f FLIPGroup) Get(ctx context.Context, req GetRequest) (*RecordFLIPGroup, error) {
|
func (f FLIPGroup) Get(ctx context.Context, req GetRequest) (*RecordFLIPGroup, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := f.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/flipgroup/get"
|
|
||||||
|
|
||||||
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +31,18 @@ func (f FLIPGroup) Get(ctx context.Context, req GetRequest) (*RecordFLIPGroup, e
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets details of the specified Floating IP group as an array of bytes
|
||||||
|
func (f FLIPGroup) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/flipgroup/get"
|
||||||
|
|
||||||
|
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list FLIPGroup available to the current user
|
// ListRequest struct to get list of FLIPGroup available to the current user
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by name
|
// Find by name
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -25,11 +25,11 @@ type ListRequest struct {
|
|||||||
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
|
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
|
||||||
|
|
||||||
// Find by IP
|
// Find by IP
|
||||||
// Reuqired: false
|
// Required: false
|
||||||
ByIP string `url:"byIp,omitempty" json:"byIp,omitempty"`
|
ByIP string `url:"byIp,omitempty" json:"byIp,omitempty"`
|
||||||
|
|
||||||
// Find by resource group ID
|
// Find by resource group ID
|
||||||
// Reuqired: false
|
// Required: false
|
||||||
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||||
|
|
||||||
// Find by id
|
// Find by id
|
||||||
@@ -45,11 +45,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list FLIPGroup managed cluster instances available to the current user
|
// List gets list of FLIPGroup managed cluster instances available to the current user as a ListFLIPGroups struct
|
||||||
func (f FLIPGroup) List(ctx context.Context, req ListRequest) (*ListFLIPGroups, error) {
|
func (f FLIPGroup) List(ctx context.Context, req ListRequest) (*ListFLIPGroups, error) {
|
||||||
url := "/cloudbroker/flipgroup/list"
|
res, err := f.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -63,3 +61,11 @@ func (f FLIPGroup) List(ctx context.Context, req ListRequest) (*ListFLIPGroups,
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of FLIPGroup managed cluster instances available to the current user as an array of bytes
|
||||||
|
func (f FLIPGroup) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudbroker/flipgroup/list"
|
||||||
|
|
||||||
|
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,6 +9,15 @@ func (lg ListGrids) FilterByID(id uint64) ListGrids {
|
|||||||
return lg.FilterFunc(predicate)
|
return lg.FilterFunc(predicate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FilterByGID returns ListGrids with specified GID.
|
||||||
|
func (lg ListGrids) FilterByGID(gid uint64) ListGrids {
|
||||||
|
predicate := func(rg ItemGridList) bool {
|
||||||
|
return rg.GID == gid
|
||||||
|
}
|
||||||
|
|
||||||
|
return lg.FilterFunc(predicate)
|
||||||
|
}
|
||||||
|
|
||||||
// FilterByName returns ListGrids with specified Name.
|
// FilterByName returns ListGrids with specified Name.
|
||||||
func (lg ListGrids) FilterByName(name string) ListGrids {
|
func (lg ListGrids) FilterByName(name string) ListGrids {
|
||||||
predicate := func(rg ItemGridList) bool {
|
predicate := func(rg ItemGridList) bool {
|
||||||
|
|||||||
@@ -106,6 +106,14 @@ func TestFilterByID(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFilterByGID(t *testing.T) {
|
||||||
|
actual := grids.FilterByGID(777).FindOne()
|
||||||
|
|
||||||
|
if actual.GID != 777 {
|
||||||
|
t.Fatal("expected ID 777, found: ", actual.GID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestFilterByName(t *testing.T) {
|
func TestFilterByName(t *testing.T) {
|
||||||
actual := grids.FilterByName("gamma").FindOne()
|
actual := grids.FilterByName("gamma").FindOne()
|
||||||
|
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get grid details
|
// GetRequest struct to get grid details
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// Grid (platform) ID
|
// Grid (platform) ID
|
||||||
// Required: true
|
// Required: true
|
||||||
GID uint64 `url:"gridId" json:"gridId" validate:"required"`
|
GID uint64 `url:"gridId" json:"gridId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets information about grid by ID
|
// Get gets information about grid by ID as a RecordGrid struct
|
||||||
func (g Grid) Get(ctx context.Context, req GetRequest) (*RecordGrid, error) {
|
func (g Grid) Get(ctx context.Context, req GetRequest) (*RecordGrid, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := g.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/grid/get"
|
|
||||||
|
|
||||||
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +31,18 @@ func (g Grid) Get(ctx context.Context, req GetRequest) (*RecordGrid, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about grid by ID as an array of bytes
|
||||||
|
func (g Grid) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/grid/get"
|
||||||
|
|
||||||
|
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list locations
|
// ListRequest struct to get list of locations
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by id grid
|
// Find by id grid
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -25,11 +25,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list all locations
|
// List gets list of all locations as a ListGrids struct
|
||||||
func (g Grid) List(ctx context.Context, req ListRequest) (*ListGrids, error) {
|
func (g Grid) List(ctx context.Context, req ListRequest) (*ListGrids, error) {
|
||||||
url := "/cloudbroker/grid/list"
|
res, err := g.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -43,3 +41,11 @@ func (g Grid) List(ctx context.Context, req ListRequest) (*ListGrids, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all locations as an array of bytes
|
||||||
|
func (g Grid) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudbroker/grid/list"
|
||||||
|
|
||||||
|
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Reuqest struct for getting details of the specified group.
|
// GetRequest struct to get details of the specified group.
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// Group ID
|
// Group ID
|
||||||
// Required: true
|
// Required: true
|
||||||
GroupID string `url:"groupId" json:"groupId" validate:"required"`
|
GroupID string `url:"groupId" json:"groupId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets details of the specified group.
|
// Get gets details of the specified group as an ItemGroup struct
|
||||||
func (g Group) Get(ctx context.Context, req GetRequest) (*ItemGroup, error) {
|
func (g Group) Get(ctx context.Context, req GetRequest) (*ItemGroup, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := g.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/group/get"
|
|
||||||
|
|
||||||
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +31,18 @@ func (g Group) Get(ctx context.Context, req GetRequest) (*ItemGroup, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets details of the specified group as an array of bytes
|
||||||
|
func (g Group) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/group/get"
|
||||||
|
|
||||||
|
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -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 list of group instances.
|
// ListRequest struct to get list of group instances.
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by id.
|
// Find by id.
|
||||||
// Requires: false
|
// Requires: false
|
||||||
@@ -31,17 +31,9 @@ type ListRequest struct {
|
|||||||
Active bool `url:"active" json:"active" validate:"required"`
|
Active bool `url:"active" json:"active" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List gets list of group instances as a ListGroups struct
|
||||||
func (g Group) List(ctx context.Context, req ListRequest) (*ListGroups, error) {
|
func (g Group) List(ctx context.Context, req ListRequest) (*ListGroups, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := g.ListRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/group/list"
|
|
||||||
|
|
||||||
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -55,3 +47,18 @@ func (g Group) List(ctx context.Context, req ListRequest) (*ListGroups, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of group instances as an array of bytes
|
||||||
|
func (g Group) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/group/list"
|
||||||
|
|
||||||
|
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,15 +8,32 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get image details
|
// GetRequest struct to get image details
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of image
|
// ID of image
|
||||||
// Required: true
|
// Required: true
|
||||||
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get get image details by ID
|
// Get gets image details by ID as a RecordImage struct
|
||||||
func (i Image) Get(ctx context.Context, req GetRequest) (*RecordImage, error) {
|
func (i Image) Get(ctx context.Context, req GetRequest) (*RecordImage, error) {
|
||||||
|
res, err := i.GetRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := RecordImage{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets image details by ID as an array of bytes
|
||||||
|
func (i Image) 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) {
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
@@ -26,17 +43,6 @@ func (i Image) Get(ctx context.Context, req GetRequest) (*RecordImage, error) {
|
|||||||
|
|
||||||
url := "/cloudbroker/image/get"
|
url := "/cloudbroker/image/get"
|
||||||
|
|
||||||
info := RecordImage{}
|
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
return res, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list available images
|
// ListRequest struct to get list of available images
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Filter images by storage endpoint provider ID
|
// Filter images by storage endpoint provider ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -65,11 +65,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of information about images
|
// List gets list of information about images as a ListImages struct
|
||||||
func (i Image) List(ctx context.Context, req ListRequest) (*ListImages, error) {
|
func (i Image) List(ctx context.Context, req ListRequest) (*ListImages, error) {
|
||||||
url := "/cloudbroker/image/list"
|
res, err := i.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -83,3 +81,11 @@ func (i Image) List(ctx context.Context, req ListRequest) (*ListImages, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of information about images as an array of bytes
|
||||||
|
func (i Image) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudbroker/image/list"
|
||||||
|
|
||||||
|
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -176,10 +176,10 @@ type GUID string
|
|||||||
func (r *GUID) UnmarshalJSON(b []byte) error {
|
func (r *GUID) UnmarshalJSON(b []byte) error {
|
||||||
|
|
||||||
if b[0] == '"' {
|
if b[0] == '"' {
|
||||||
*r = GUID(string(b[1:len(b)-1]))
|
*r = GUID(string(b[1 : len(b)-1]))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
*r = GUID(string(b))
|
*r = GUID(string(b))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -190,74 +190,167 @@ type ListHistory []History
|
|||||||
|
|
||||||
// List stacks
|
// List stacks
|
||||||
type ListStacks struct {
|
type ListStacks struct {
|
||||||
Data []struct {
|
// Data
|
||||||
// CKey
|
Data []ItemListStacks `json:"data"`
|
||||||
CKey string `json:"_ckey"`
|
|
||||||
|
|
||||||
// Meta
|
|
||||||
Meta []interface{} `json:"_meta"`
|
|
||||||
|
|
||||||
// API URL
|
|
||||||
APIURL string `json:"apiUrl"`
|
|
||||||
|
|
||||||
// API key
|
|
||||||
APIKey string `json:"apikey"`
|
|
||||||
|
|
||||||
// App ID
|
|
||||||
AppID string `json:"appId"`
|
|
||||||
|
|
||||||
// CPU allocation ratio
|
|
||||||
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
|
||||||
|
|
||||||
// Description
|
|
||||||
Description string `json:"desc"`
|
|
||||||
|
|
||||||
// Descr
|
|
||||||
Descr string `json:"descr"`
|
|
||||||
|
|
||||||
// Drivers
|
|
||||||
Drivers []string `json:"drivers"`
|
|
||||||
|
|
||||||
// Eco
|
|
||||||
Eco interface{} `json:"eco"`
|
|
||||||
|
|
||||||
// Error
|
|
||||||
Error uint64 `json:"error"`
|
|
||||||
|
|
||||||
// Grid ID
|
|
||||||
GID uint64 `json:"gid"`
|
|
||||||
|
|
||||||
// GID
|
|
||||||
GUID uint64 `json:"guid"`
|
|
||||||
|
|
||||||
// ID
|
|
||||||
ID uint64 `json:"id"`
|
|
||||||
|
|
||||||
// List image IDs
|
|
||||||
Images []uint64 `json:"images"`
|
|
||||||
|
|
||||||
// Login
|
|
||||||
Login string `json:"login"`
|
|
||||||
|
|
||||||
// Mem allocation ratio
|
|
||||||
// Required: false
|
|
||||||
MemAllocationRatio float64 `json:"mem_allocation_ratio"`
|
|
||||||
|
|
||||||
// Name
|
|
||||||
Name string `json:"name"`
|
|
||||||
|
|
||||||
// Password
|
|
||||||
Password string `json:"passwd"`
|
|
||||||
|
|
||||||
// Reference ID
|
|
||||||
ReferenceID string `json:"referenceId"`
|
|
||||||
|
|
||||||
// Status
|
|
||||||
Status string `json:"status"`
|
|
||||||
|
|
||||||
// Type
|
|
||||||
Type string `json:"type"`
|
|
||||||
} `json:"data"`
|
|
||||||
|
|
||||||
|
// Entry count
|
||||||
EntryCount uint64 `json:"entryCount"`
|
EntryCount uint64 `json:"entryCount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detailed information about image
|
||||||
|
type ItemListStacks struct {
|
||||||
|
// CKey
|
||||||
|
CKey string `json:"_ckey"`
|
||||||
|
|
||||||
|
// Meta
|
||||||
|
Meta []interface{} `json:"_meta"`
|
||||||
|
|
||||||
|
// API URL
|
||||||
|
APIURL string `json:"apiUrl"`
|
||||||
|
|
||||||
|
// API key
|
||||||
|
APIKey string `json:"apikey"`
|
||||||
|
|
||||||
|
// App ID
|
||||||
|
AppID string `json:"appId"`
|
||||||
|
|
||||||
|
// CPU allocation ratio
|
||||||
|
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||||
|
|
||||||
|
// Description
|
||||||
|
Description string `json:"desc"`
|
||||||
|
|
||||||
|
// Descr
|
||||||
|
Descr string `json:"descr"`
|
||||||
|
|
||||||
|
// Drivers
|
||||||
|
Drivers []string `json:"drivers"`
|
||||||
|
|
||||||
|
// Eco
|
||||||
|
Eco interface{} `json:"eco"`
|
||||||
|
|
||||||
|
// Error
|
||||||
|
Error uint64 `json:"error"`
|
||||||
|
|
||||||
|
// Grid ID
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
|
// GID
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
|
// ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// List image IDs
|
||||||
|
Images []uint64 `json:"images"`
|
||||||
|
|
||||||
|
// Login
|
||||||
|
Login string `json:"login"`
|
||||||
|
|
||||||
|
// Mem allocation ratio
|
||||||
|
MemAllocationRatio float64 `json:"mem_allocation_ratio"`
|
||||||
|
|
||||||
|
// Name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// Packegas
|
||||||
|
Packages Packages `json:"packages"`
|
||||||
|
|
||||||
|
// Password
|
||||||
|
Password string `json:"passwd"`
|
||||||
|
|
||||||
|
// Reference ID
|
||||||
|
ReferenceID string `json:"referenceId"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// Type
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Package
|
||||||
|
type Packages struct {
|
||||||
|
// LibvirtBin
|
||||||
|
LibvirtBin LibvirtBin `json:"libvirt-bin"`
|
||||||
|
|
||||||
|
// LibvirtDaemon
|
||||||
|
LibvirtDaemon LibvirtDaemon `json:"libvirt-daemon"`
|
||||||
|
|
||||||
|
// Lvm2Lockd
|
||||||
|
Lvm2Lockd Lvm2Lockd `json:"lvm2-lockd"`
|
||||||
|
|
||||||
|
// OpenvswitchCommon
|
||||||
|
OpenvswitchCommon OpenvswitchCommon `json:"openvswitch-common"`
|
||||||
|
|
||||||
|
// OpenvswitchSwitch
|
||||||
|
OpenvswitchSwitch OpenvswitchSwitch `json:"openvswitch-switch"`
|
||||||
|
|
||||||
|
// QemuSystemX86
|
||||||
|
QemuSystemX86 QemuSystemX86 `json:"qemu-system-x86"`
|
||||||
|
|
||||||
|
// Sanlock
|
||||||
|
Sanlock Sanlock `json:"sanlock"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LibvirtBin
|
||||||
|
type LibvirtBin struct {
|
||||||
|
// InstalledSize
|
||||||
|
InstalledSize string `json:"installed_size"`
|
||||||
|
|
||||||
|
// Version
|
||||||
|
Ver string `json:"ver"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LibvirtDaemon struct {
|
||||||
|
// InstalledSize
|
||||||
|
InstalledSize string `json:"installed_size"`
|
||||||
|
|
||||||
|
// Version
|
||||||
|
Ver string `json:"ver"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lvm2Lockd
|
||||||
|
type Lvm2Lockd struct {
|
||||||
|
// InstalledSize
|
||||||
|
InstalledSize string `json:"installed_size"`
|
||||||
|
|
||||||
|
// Version
|
||||||
|
Ver string `json:"ver"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenvswitchCommon
|
||||||
|
type OpenvswitchCommon struct {
|
||||||
|
// InstalledSize
|
||||||
|
InstalledSize string `json:"installed_size"`
|
||||||
|
|
||||||
|
// Version
|
||||||
|
Ver string `json:"ver"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenvswitchSwitch
|
||||||
|
type OpenvswitchSwitch struct {
|
||||||
|
// InstalledSize
|
||||||
|
InstalledSize string `json:"installed_size"`
|
||||||
|
|
||||||
|
// Version
|
||||||
|
Ver string `json:"ver"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// QemuSystemX86
|
||||||
|
type QemuSystemX86 struct {
|
||||||
|
// InstalledSize
|
||||||
|
InstalledSize string `json:"installed_size"`
|
||||||
|
|
||||||
|
// Version
|
||||||
|
Ver string `json:"ver"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sanlock
|
||||||
|
type Sanlock struct {
|
||||||
|
// InstalledSize
|
||||||
|
InstalledSize string `json:"installed_size"`
|
||||||
|
|
||||||
|
// Version
|
||||||
|
Ver string `json:"ver"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get information about K8CI
|
// GetRequest struct to get information about K8CI
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of the K8 catalog item to get
|
// ID of the K8 catalog item to get
|
||||||
// Required: true
|
// Required: true
|
||||||
K8CIID uint64 `url:"k8ciId" json:"k8ciId" validate:"required"`
|
K8CIID uint64 `url:"k8ciId" json:"k8ciId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets details of the specified K8 catalog item
|
// Get gets details of the specified K8 catalog item as a RecordK8CI struct
|
||||||
func (k K8CI) Get(ctx context.Context, req GetRequest) (*RecordK8CI, error) {
|
func (k K8CI) Get(ctx context.Context, req GetRequest) (*RecordK8CI, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := k.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/k8ci/get"
|
|
||||||
|
|
||||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +31,18 @@ func (k K8CI) Get(ctx context.Context, req GetRequest) (*RecordK8CI, error) {
|
|||||||
|
|
||||||
return &item, nil
|
return &item, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets details of the specified K8 catalog item as an array of bytes
|
||||||
|
func (k K8CI) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/k8ci/get"
|
||||||
|
|
||||||
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list information about images
|
// ListRequest struct to get list information about images
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -45,11 +45,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list all k8ci catalog items available to the current user
|
// List gets list of all k8ci catalog items available to the current user as a ListK8CI struct
|
||||||
func (k K8CI) List(ctx context.Context, req ListRequest) (*ListK8CI, error) {
|
func (k K8CI) List(ctx context.Context, req ListRequest) (*ListK8CI, error) {
|
||||||
url := "/cloudbroker/k8ci/list"
|
res, err := k.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -63,3 +61,11 @@ func (k K8CI) List(ctx context.Context, req ListRequest) (*ListK8CI, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all k8ci catalog items available to the current user as an array of bytes
|
||||||
|
func (k K8CI) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudbroker/k8ci/list"
|
||||||
|
|
||||||
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ type CreateRequest struct {
|
|||||||
|
|
||||||
// Name for first worker group created with cluster
|
// Name for first worker group created with cluster
|
||||||
// Required: true
|
// Required: true
|
||||||
WorkerGroupName string `url:"workerGroupName" json:"workerGroupName" validate:"required, workerGroupName"`
|
WorkerGroupName string `url:"workerGroupName" json:"workerGroupName" validate:"required,workerGroupName"`
|
||||||
|
|
||||||
// Network plugin
|
// Network plugin
|
||||||
// Must be one of these values: flunnel, weawenet, calico
|
// Must be one of these values: flunnel, weawenet, calico
|
||||||
@@ -113,11 +113,11 @@ type CreateRequest struct {
|
|||||||
|
|
||||||
// Custom sysctl values for Load Balancer instance. Applied on boot
|
// Custom sysctl values for Load Balancer instance. Applied on boot
|
||||||
// Required: false
|
// Required: false
|
||||||
LbSysctlParams string `url:"-" json:"lbSysctlParams,omitempty" validate:"omitempty,dive"`
|
LbSysctlParams string `url:"lbSysctlParams,omitempty" json:"lbSysctlParams,omitempty"`
|
||||||
|
|
||||||
// Use Highly Available schema for LB deploy
|
// Use Highly Available schema for LB deploy
|
||||||
// Required: false
|
// Required: false
|
||||||
HighlyAvailable bool `url:"highlyAvailable,omitempty" json:"highlyAvailable,omitempty"`
|
HighlyAvailable bool `url:"highlyAvailableLB,omitempty" json:"highlyAvailableLB,omitempty"`
|
||||||
|
|
||||||
// Optional extra Subject Alternative Names (SANs) to use for the API Server serving certificate. Can be both IP addresses and DNS names
|
// Optional extra Subject Alternative Names (SANs) to use for the API Server serving certificate. Can be both IP addresses and DNS names
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ 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 kubernetes cluster
|
// GetRequest struct to get detailed information about kubernetes cluster
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// Kubernetes cluster ID
|
// Kubernetes cluster ID
|
||||||
// Required: true
|
// Required: true
|
||||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets information about kubernetes cluster
|
// Get gets information about kubernetes cluster as a RecordK8S struct
|
||||||
func (k K8S) Get(ctx context.Context, req GetRequest) (*RecordK8S, error) {
|
func (k K8S) Get(ctx context.Context, req GetRequest) (*RecordK8S, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := k.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/k8s/get"
|
|
||||||
|
|
||||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +31,18 @@ func (k K8S) Get(ctx context.Context, req GetRequest) (*RecordK8S, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about kubernetes cluster as an array of bytes
|
||||||
|
func (k K8S) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/k8s/get"
|
||||||
|
|
||||||
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list information K8S
|
// ListRequest struct to get list information K8S
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -53,12 +53,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list all kubernetes clusters
|
// List gets list of all kubernetes clusters as a ListK8S struct
|
||||||
func (k K8S) List(ctx context.Context, req ListRequest) (*ListK8S, error) {
|
func (k K8S) List(ctx context.Context, req ListRequest) (*ListK8S, error) {
|
||||||
|
res, err := k.ListRaw(ctx, req)
|
||||||
url := "/cloudbroker/k8s/list"
|
|
||||||
|
|
||||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -72,3 +69,11 @@ func (k K8S) List(ctx context.Context, req ListRequest) (*ListK8S, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all kubernetes clusters as an array of bytes
|
||||||
|
func (k K8S) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudbroker/k8s/list"
|
||||||
|
|
||||||
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ type WorkersGroupAddRequest struct {
|
|||||||
// Worker node boot disk size in GB If 0 is specified, size is defined by the OS image size
|
// Worker node boot disk size in GB If 0 is specified, size is defined by the OS image size
|
||||||
// Required: false
|
// Required: false
|
||||||
WorkerDisk uint64 `url:"workerDisk,omitempty" json:"workerDisk,omitempty"`
|
WorkerDisk uint64 `url:"workerDisk,omitempty" json:"workerDisk,omitempty"`
|
||||||
|
|
||||||
|
// Meta data for working group computes, format YAML "user_data": 1111
|
||||||
|
// Required: false
|
||||||
|
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// WorkersGroupAdd adds workers group to kubernetes cluster
|
// WorkersGroupAdd adds workers group to kubernetes cluster
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ 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 load balancer
|
// GetRequest struct to get detailed information about load balancer
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of the load balancer to get details for
|
// ID of the load balancer to get details for
|
||||||
// Required: true
|
// Required: true
|
||||||
LBID uint64 `url:"lbId" json:"lbId" validate:"required"`
|
LBID uint64 `url:"lbId" json:"lbId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets detailed information about load balancer
|
// Get gets detailed information about load balancer as a RecordLB struct
|
||||||
func (lb LB) Get(ctx context.Context, req GetRequest) (*RecordLB, error) {
|
func (lb LB) Get(ctx context.Context, req GetRequest) (*RecordLB, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := lb.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/lb/get"
|
|
||||||
|
|
||||||
res, err := lb.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +31,18 @@ func (lb LB) Get(ctx context.Context, req GetRequest) (*RecordLB, error) {
|
|||||||
return &info, nil
|
return &info, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets detailed information about load balancer as an array of bytes
|
||||||
|
func (lb LB) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/lb/get"
|
||||||
|
|
||||||
|
res, err := lb.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list of load balancers
|
// ListRequest struct to get list of load balancers
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -53,11 +53,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list all load balancers
|
// List gets list of all load balancers as a ListLB struct
|
||||||
func (lb LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
|
func (lb LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
|
||||||
url := "/cloudbroker/lb/list"
|
res, err := lb.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := lb.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -70,5 +68,12 @@ func (lb LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all load balancers as an array of bytes
|
||||||
|
func (lb LB) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudbroker/lb/list"
|
||||||
|
|
||||||
|
res, err := lb.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ type HighlyAvailableRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make Load Balancer Highly available
|
// Make Load Balancer Highly available
|
||||||
func (l LB) HighlyAvailable(ctx context.Context, req HighlyAvailableRequest) (uint64, error) {
|
func (l LB) HighlyAvailable(ctx context.Context, req HighlyAvailableRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
return 0, validators.ValidationError(validationError)
|
return false, validators.ValidationError(validationError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,12 +28,12 @@ func (l LB) HighlyAvailable(ctx context.Context, req HighlyAvailableRequest) (ui
|
|||||||
|
|
||||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
result, err := strconv.ParseBool(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@@ -154,7 +154,10 @@ type RecordLB struct {
|
|||||||
Meta []interface{} `json:"_meta"`
|
Meta []interface{} `json:"_meta"`
|
||||||
|
|
||||||
// Access Control List
|
// Access Control List
|
||||||
ACL []interface{} `json:"acl"`
|
ACL interface{} `json:"acl"`
|
||||||
|
|
||||||
|
// BackendHAIP
|
||||||
|
BackendHAIP string `json:"backendHAIP"`
|
||||||
|
|
||||||
// List of load balancer backends
|
// List of load balancer backends
|
||||||
Backends ListBackends `json:"backends"`
|
Backends ListBackends `json:"backends"`
|
||||||
@@ -171,6 +174,9 @@ type RecordLB struct {
|
|||||||
// External network ID
|
// External network ID
|
||||||
ExtNetID uint64 `json:"extnetId"`
|
ExtNetID uint64 `json:"extnetId"`
|
||||||
|
|
||||||
|
// FrontendHAIP
|
||||||
|
FrontendHAIP string `json:"frontendHAIP"`
|
||||||
|
|
||||||
// List of load balancer frontends
|
// List of load balancer frontends
|
||||||
Frontends ListFrontends `json:"frontends"`
|
Frontends ListFrontends `json:"frontends"`
|
||||||
|
|
||||||
@@ -208,7 +214,7 @@ type RecordLB struct {
|
|||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
// Sysctl Params
|
// Sysctl Params
|
||||||
SysctlParams []string `json:"sysctlParams"`
|
SysctlParams interface{} `json:"sysctlParams"`
|
||||||
|
|
||||||
// Tech status
|
// Tech status
|
||||||
TechStatus string `json:"techStatus"`
|
TechStatus string `json:"techStatus"`
|
||||||
@@ -223,7 +229,10 @@ type ItemLBList struct {
|
|||||||
HAMode bool `json:"HAmode"`
|
HAMode bool `json:"HAmode"`
|
||||||
|
|
||||||
// Access Control List
|
// Access Control List
|
||||||
ACL []interface{} `json:"acl"`
|
ACL interface{} `json:"acl"`
|
||||||
|
|
||||||
|
// BackendHAIP
|
||||||
|
BackendHAIP string `json:"backendHAIP"`
|
||||||
|
|
||||||
// List of load balancer backends
|
// List of load balancer backends
|
||||||
Backends ListBackends `json:"backends"`
|
Backends ListBackends `json:"backends"`
|
||||||
@@ -252,6 +261,9 @@ type ItemLBList struct {
|
|||||||
// External network ID
|
// External network ID
|
||||||
ExtNetID uint64 `json:"extnetId"`
|
ExtNetID uint64 `json:"extnetId"`
|
||||||
|
|
||||||
|
// FrontendHAIP
|
||||||
|
FrontendHAIP string `json:"frontendHAIP"`
|
||||||
|
|
||||||
// List of load balancer frontends
|
// List of load balancer frontends
|
||||||
Frontends ListFrontends `json:"frontends"`
|
Frontends ListFrontends `json:"frontends"`
|
||||||
|
|
||||||
@@ -286,7 +298,7 @@ type ItemLBList struct {
|
|||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
// Sysctl Params
|
// Sysctl Params
|
||||||
SysctlParams []string `json:"sysctlParams"`
|
SysctlParams interface{} `json:"sysctlParams"`
|
||||||
|
|
||||||
// Tech status
|
// Tech status
|
||||||
TechStatus string `json:"techStatus"`
|
TechStatus string `json:"techStatus"`
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ListRequest struct to get list of pci devices
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by id
|
// Find by id
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -36,11 +37,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list all pci devices
|
// List gets list of all pci devices as a ListPCIDevices struct
|
||||||
func (p PCIDevice) List(ctx context.Context, req ListRequest) (*ListPCIDevices, error) {
|
func (p PCIDevice) List(ctx context.Context, req ListRequest) (*ListPCIDevices, error) {
|
||||||
url := "/cloudbroker/pcidevice/list"
|
res, err := p.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -54,3 +53,11 @@ func (p PCIDevice) List(ctx context.Context, req ListRequest) (*ListPCIDevices,
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all pci devices as an array of bytes
|
||||||
|
func (p PCIDevice) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudbroker/pcidevice/list"
|
||||||
|
|
||||||
|
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -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 resource group
|
// GetRequest struct to get detailed information about resource group
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// Resource group ID
|
// Resource group ID
|
||||||
// Required: true
|
// Required: true
|
||||||
@@ -19,18 +19,9 @@ type GetRequest struct {
|
|||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets current configuration of the resource group
|
// Get gets current configuration of the resource group as a RecordRG struct
|
||||||
func (r RG) Get(ctx context.Context, req GetRequest) (*RecordRG, error) {
|
func (r RG) Get(ctx context.Context, req GetRequest) (*RecordRG, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := r.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/rg/get"
|
|
||||||
|
|
||||||
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -44,3 +35,18 @@ func (r RG) Get(ctx context.Context, req GetRequest) (*RecordRG, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets current configuration of the resource group as an array of bytes
|
||||||
|
func (r RG) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/rg/get"
|
||||||
|
|
||||||
|
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list of resource groups
|
// ListRequest struct to get list of resource groups
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -49,11 +49,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of all resource groups the user has access to
|
// List gets list of all resource groups the user has access to as a ListRG struct
|
||||||
func (r RG) List(ctx context.Context, req ListRequest) (*ListRG, error) {
|
func (r RG) List(ctx context.Context, req ListRequest) (*ListRG, error) {
|
||||||
url := "/cloudbroker/rg/list"
|
res, err := r.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -67,3 +65,11 @@ func (r RG) List(ctx context.Context, req ListRequest) (*ListRG, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all resource groups the user has access to as an array of bytes
|
||||||
|
func (r RG) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudbroker/rg/list"
|
||||||
|
|
||||||
|
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get SEP parameters
|
// GetRequest struct to get SEP parameters
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// Storage endpoint provider ID
|
// Storage endpoint provider ID
|
||||||
// Required: true
|
// Required: true
|
||||||
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
|
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets SEP parameters
|
// Get gets SEP parameters as a RecordSEP struct
|
||||||
func (s SEP) Get(ctx context.Context, req GetRequest) (*RecordSEP, error) {
|
func (s SEP) Get(ctx context.Context, req GetRequest) (*RecordSEP, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := s.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/sep/get"
|
|
||||||
|
|
||||||
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +31,18 @@ func (s SEP) Get(ctx context.Context, req GetRequest) (*RecordSEP, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets SEP parameters as an array of bytes
|
||||||
|
func (s SEP) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/sep/get"
|
||||||
|
|
||||||
|
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list of SEPs
|
// ListRequest struct to get list of SEPs
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -45,11 +45,9 @@ type ListRequest struct {
|
|||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of SEPs
|
// List gets list of SEPs as a ListSEP struct
|
||||||
func (s SEP) List(ctx context.Context, req ListRequest) (*ListSEP, error) {
|
func (s SEP) List(ctx context.Context, req ListRequest) (*ListSEP, error) {
|
||||||
url := "/cloudbroker/sep/list"
|
res, err := s.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -63,3 +61,11 @@ func (s SEP) List(ctx context.Context, req ListRequest) (*ListSEP, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of SEPs as an array of bytes
|
||||||
|
func (s SEP) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudbroker/sep/list"
|
||||||
|
|
||||||
|
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list stack
|
// GetRequest struct to get list of stacks
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: true
|
// Required: true
|
||||||
StackId uint64 `url:"stackId" json:"stackId" validate:"required"`
|
StackId uint64 `url:"stackId" json:"stackId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get stack details by ID
|
// Get gets stack details by ID as an InfoStack struct
|
||||||
func (i Stack) Get(ctx context.Context, req GetRequest) (*InfoStack, error) {
|
func (i Stack) Get(ctx context.Context, req GetRequest) (*InfoStack, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := i.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/stack/get"
|
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +31,18 @@ func (i Stack) Get(ctx context.Context, req GetRequest) (*InfoStack, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets stack details by ID as an array of bytes
|
||||||
|
func (i Stack) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/stack/get"
|
||||||
|
|
||||||
|
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list stack
|
// ListRequest struct to get list of stacks
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -33,11 +33,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListStacks gets list stack
|
// List gets list of stacks as a ListStacks struct
|
||||||
func (i Stack) List(ctx context.Context, req ListRequest) (*ListStacks, error) {
|
func (i Stack) List(ctx context.Context, req ListRequest) (*ListStacks, error) {
|
||||||
url := "/cloudbroker/stack/list"
|
res, err := i.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -51,3 +49,11 @@ func (i Stack) List(ctx context.Context, req ListRequest) (*ListStacks, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of stacks as an array of bytes
|
||||||
|
func (i Stack) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudbroker/stack/list"
|
||||||
|
|
||||||
|
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ type InfoStack struct {
|
|||||||
|
|
||||||
// ID
|
// ID
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
// List image IDs
|
// List image IDs
|
||||||
Images []uint64 `json:"images"`
|
Images []uint64 `json:"images"`
|
||||||
|
|
||||||
@@ -73,7 +74,6 @@ type InfoStack struct {
|
|||||||
|
|
||||||
// List of stacks
|
// List of stacks
|
||||||
type ListStacks struct {
|
type ListStacks struct {
|
||||||
|
|
||||||
//List
|
//List
|
||||||
Data []InfoStack `json:"data"`
|
Data []InfoStack `json:"data"`
|
||||||
|
|
||||||
@@ -83,10 +83,12 @@ type ListStacks struct {
|
|||||||
|
|
||||||
// Package
|
// Package
|
||||||
type Packages struct {
|
type Packages struct {
|
||||||
|
|
||||||
// LibvirtBin
|
// LibvirtBin
|
||||||
LibvirtBin LibvirtBin `json:"libvirt-bin"`
|
LibvirtBin LibvirtBin `json:"libvirt-bin"`
|
||||||
|
|
||||||
|
// LibvirtDaemon
|
||||||
|
LibvirtDaemon LibvirtDaemon `json:"libvirt-daemon"`
|
||||||
|
|
||||||
// Lvm2Lockd
|
// Lvm2Lockd
|
||||||
Lvm2Lockd Lvm2Lockd `json:"lvm2-lockd"`
|
Lvm2Lockd Lvm2Lockd `json:"lvm2-lockd"`
|
||||||
|
|
||||||
@@ -105,7 +107,14 @@ type Packages struct {
|
|||||||
|
|
||||||
// LibvirtBin
|
// LibvirtBin
|
||||||
type LibvirtBin struct {
|
type LibvirtBin struct {
|
||||||
|
// InstalledSize
|
||||||
|
InstalledSize string `json:"installed_size"`
|
||||||
|
|
||||||
|
// Version
|
||||||
|
Ver string `json:"ver"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LibvirtDaemon struct {
|
||||||
// InstalledSize
|
// InstalledSize
|
||||||
InstalledSize string `json:"installed_size"`
|
InstalledSize string `json:"installed_size"`
|
||||||
|
|
||||||
@@ -115,7 +124,6 @@ type LibvirtBin struct {
|
|||||||
|
|
||||||
// Lvm2Lockd
|
// Lvm2Lockd
|
||||||
type Lvm2Lockd struct {
|
type Lvm2Lockd struct {
|
||||||
|
|
||||||
// InstalledSize
|
// InstalledSize
|
||||||
InstalledSize string `json:"installed_size"`
|
InstalledSize string `json:"installed_size"`
|
||||||
|
|
||||||
@@ -125,7 +133,6 @@ type Lvm2Lockd struct {
|
|||||||
|
|
||||||
// OpenvswitchCommon
|
// OpenvswitchCommon
|
||||||
type OpenvswitchCommon struct {
|
type OpenvswitchCommon struct {
|
||||||
|
|
||||||
// InstalledSize
|
// InstalledSize
|
||||||
InstalledSize string `json:"installed_size"`
|
InstalledSize string `json:"installed_size"`
|
||||||
|
|
||||||
@@ -135,7 +142,6 @@ type OpenvswitchCommon struct {
|
|||||||
|
|
||||||
// OpenvswitchSwitch
|
// OpenvswitchSwitch
|
||||||
type OpenvswitchSwitch struct {
|
type OpenvswitchSwitch struct {
|
||||||
|
|
||||||
// InstalledSize
|
// InstalledSize
|
||||||
InstalledSize string `json:"installed_size"`
|
InstalledSize string `json:"installed_size"`
|
||||||
|
|
||||||
@@ -145,7 +151,6 @@ type OpenvswitchSwitch struct {
|
|||||||
|
|
||||||
// QemuSystemX86
|
// QemuSystemX86
|
||||||
type QemuSystemX86 struct {
|
type QemuSystemX86 struct {
|
||||||
|
|
||||||
// InstalledSize
|
// InstalledSize
|
||||||
InstalledSize string `json:"installed_size"`
|
InstalledSize string `json:"installed_size"`
|
||||||
|
|
||||||
@@ -155,7 +160,6 @@ type QemuSystemX86 struct {
|
|||||||
|
|
||||||
// Sanlock
|
// Sanlock
|
||||||
type Sanlock struct {
|
type Sanlock struct {
|
||||||
|
|
||||||
// InstalledSize
|
// InstalledSize
|
||||||
InstalledSize string `json:"installed_size"`
|
InstalledSize string `json:"installed_size"`
|
||||||
|
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get background API task status and result
|
// GetRequest struct to get background API task status and result
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of audit GUID
|
// ID of audit GUID
|
||||||
// Required: true
|
// Required: true
|
||||||
AuditID string `url:"auditId" json:"auditId" validate:"required"`
|
AuditID string `url:"auditId" json:"auditId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets background API task status and result
|
// Get gets background API task status and result as a RecordTask struct
|
||||||
func (t Tasks) Get(ctx context.Context, req GetRequest) (*RecordTask, error) {
|
func (t Tasks) Get(ctx context.Context, req GetRequest) (*RecordTask, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := t.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/tasks/get"
|
|
||||||
|
|
||||||
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +31,18 @@ func (t Tasks) Get(ctx context.Context, req GetRequest) (*RecordTask, error) {
|
|||||||
|
|
||||||
return &item, nil
|
return &item, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets background API task status and result as an array of bytes
|
||||||
|
func (t Tasks) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/tasks/get"
|
||||||
|
|
||||||
|
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list audits
|
// ListRequest struct to get list of audits
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Page number
|
// Page number
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -17,11 +17,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list user API task with status PROCESSING
|
// List gets list of user API task with status PROCESSING as a ListTasks struct
|
||||||
func (t Tasks) List(ctx context.Context, req ListRequest) (*ListTasks, error) {
|
func (t Tasks) List(ctx context.Context, req ListRequest) (*ListTasks, error) {
|
||||||
url := "/cloudbroker/tasks/list"
|
res, err := t.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -35,3 +33,11 @@ func (t Tasks) List(ctx context.Context, req ListRequest) (*ListTasks, error) {
|
|||||||
|
|
||||||
return &item, nil
|
return &item, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of user API task with status PROCESSING as an array of bytes
|
||||||
|
func (t Tasks) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudbroker/tasks/list"
|
||||||
|
|
||||||
|
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,25 +8,16 @@ import (
|
|||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for getting user details.
|
// GetRequest struct to get user details.
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// ID of the user.
|
// ID of the user.
|
||||||
// Required: true
|
// Required: true
|
||||||
UserID string `url:"userId" json:"userId" validate:"required"`
|
UserID string `url:"userId" json:"userId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets user details.
|
// Get gets user details as an ItemUser struct.
|
||||||
func (u User) Get(ctx context.Context, req GetRequest) (*ItemUser, error) {
|
func (u User) Get(ctx context.Context, req GetRequest) (*ItemUser, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := u.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/user/get"
|
|
||||||
|
|
||||||
res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,3 +31,18 @@ func (u User) Get(ctx context.Context, req GetRequest) (*ItemUser, error) {
|
|||||||
|
|
||||||
return &item, nil
|
return &item, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets user details as an array of bytes
|
||||||
|
func (u User) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/user/get"
|
||||||
|
|
||||||
|
res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -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 all non deleted user instances.
|
// ListRequest struct to get all non deleted user instances.
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID.
|
// Find by ID.
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -31,18 +31,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets all non deleted user instances.
|
// List gets all non deleted user instances as a ListUsers struct
|
||||||
func (u User) List(ctx context.Context, req ListRequest) (*ListUsers, error) {
|
func (u User) List(ctx context.Context, req ListRequest) (*ListUsers, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := u.ListRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/user/list"
|
|
||||||
|
|
||||||
res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -56,3 +47,18 @@ func (u User) List(ctx context.Context, req ListRequest) (*ListUsers, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets all non deleted user instances as an array of bytes
|
||||||
|
func (u User) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/user/list"
|
||||||
|
|
||||||
|
res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for getting list of VGPU
|
// ListRequest struct to get list of VGPU
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by id
|
// Find by id
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -49,11 +49,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list all VGPU
|
// List gets list of all VGPU as a ListVGPU struct
|
||||||
func (v VGPU) List(ctx context.Context, req ListRequest) (*ListVGPU, error) {
|
func (v VGPU) List(ctx context.Context, req ListRequest) (*ListVGPU, error) {
|
||||||
url := "/cloudbroker/vgpu/list"
|
res, err := v.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -67,3 +65,11 @@ func (v VGPU) List(ctx context.Context, req ListRequest) (*ListVGPU, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all VGPU as an array of bytes
|
||||||
|
func (v VGPU) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudbroker/vgpu/list"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -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 information about VINS
|
// GetRequest struct to get information about VINS
|
||||||
type GetRequest struct {
|
type GetRequest struct {
|
||||||
// VINS ID
|
// VINS ID
|
||||||
// Required: true
|
// Required: true
|
||||||
@@ -19,18 +19,9 @@ type GetRequest struct {
|
|||||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets information about VINS by ID
|
// Get gets information about VINS by ID as a RecordVINS struct
|
||||||
func (v VINS) Get(ctx context.Context, req GetRequest) (*RecordVINS, error) {
|
func (v VINS) Get(ctx context.Context, req GetRequest) (*RecordVINS, error) {
|
||||||
err := validators.ValidateRequest(req)
|
res, err := v.GetRaw(ctx, req)
|
||||||
if err != nil {
|
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
|
||||||
return nil, validators.ValidationError(validationError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/vins/get"
|
|
||||||
|
|
||||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -44,3 +35,18 @@ func (v VINS) Get(ctx context.Context, req GetRequest) (*RecordVINS, error) {
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRaw gets information about VINS by ID as an array of bytes
|
||||||
|
func (v VINS) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/vins/get"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for get list of VINSes
|
// ListRequest struct to get list of VINSes
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
// Find by ID
|
// Find by ID
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -41,11 +41,9 @@ type ListRequest struct {
|
|||||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List gets list of VINSes
|
// List gets list of VINSes as a ListVINS struct
|
||||||
func (v VINS) List(ctx context.Context, req ListRequest) (*ListVINS, error) {
|
func (v VINS) List(ctx context.Context, req ListRequest) (*ListVINS, error) {
|
||||||
url := "/cloudbroker/vins/list"
|
res, err := v.ListRaw(ctx, req)
|
||||||
|
|
||||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -59,3 +57,11 @@ func (v VINS) List(ctx context.Context, req ListRequest) (*ListVINS, error) {
|
|||||||
|
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of VINSes as an array of bytes
|
||||||
|
func (v VINS) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
url := "/cloudbroker/vins/list"
|
||||||
|
|
||||||
|
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user