This commit is contained in:
2023-10-23 12:40:54 +03:00
parent b069c31745
commit b666789c7d
73 changed files with 1134 additions and 641 deletions

View File

@@ -8,25 +8,16 @@ import (
"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 {
// ID an account
// 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) {
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)
res, err := a.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -41,3 +32,18 @@ func (a Account) Get(ctx context.Context, req GetRequest) (*RecordAccount, error
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
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list of accounts
// ListRequest struct to get list of accounts
type ListRequest struct {
// Find by ID
// Required: false
@@ -33,11 +33,9 @@ type ListRequest struct {
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) {
url := "/cloudapi/account/list"
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := a.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -51,3 +49,11 @@ func (a Account) List(ctx context.Context, req ListRequest) (*ListAccounts, erro
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
}

View File

@@ -8,15 +8,32 @@ import (
"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 {
// ID of the service to query information
// Required: true
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) {
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)
if err != nil {
for _, validationError := range validators.GetErrors(err) {
@@ -26,17 +43,6 @@ func (b BService) Get(ctx context.Context, req GetRequest) (*RecordBasicService,
url := "/cloudapi/bservice/get"
bsRaw, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
info := RecordBasicService{}
err = json.Unmarshal(bsRaw, &info)
if err != nil {
return nil, err
}
return &info, nil
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list BasicService instances
// ListRequest struct to get list of BasicService instances
type ListRequest struct {
// Find by ID
// Required: false
@@ -49,11 +49,9 @@ type ListRequest struct {
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) {
url := "/cloudapi/bservice/list"
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := b.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -67,3 +65,11 @@ func (b BService) List(ctx context.Context, req ListRequest) (*ListBasicServices
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
}

View File

@@ -8,25 +8,16 @@ import (
"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 {
// ID of compute instance
// Required: true
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) {
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)
res, err := c.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -40,3 +31,18 @@ func (c Compute) Get(ctx context.Context, req GetRequest) (*RecordCompute, error
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
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list available computes
// ListRequest struct to get list of available computes
type ListRequest struct {
// Find by ID
// Required: false
@@ -64,9 +64,7 @@ type ListRequest struct {
// List gets list of the available computes.
// Filtering based on status is possible
func (c Compute) List(ctx context.Context, req ListRequest) (*ListComputes, error) {
url := "/cloudapi/compute/list"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -80,3 +78,11 @@ func (c Compute) List(ctx context.Context, req ListRequest) (*ListComputes, erro
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
}

View File

@@ -8,26 +8,17 @@ import (
"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 {
// ID of the disk
// Required: true
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
func (d Disks) Get(ctx context.Context, req GetRequest) (*RecordDisk, 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)
res, err := d.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -41,3 +32,19 @@ func (d Disks) Get(ctx context.Context, req GetRequest) (*RecordDisk, error) {
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
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list of disks
// ListRequest struct to get list of disks
type ListRequest struct {
// Find by id
// Required: false
@@ -57,11 +57,9 @@ type ListRequest struct {
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) {
url := "/cloudapi/disks/list"
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := d.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -75,3 +73,11 @@ func (d Disks) List(ctx context.Context, req ListRequest) (*ListDisks, error) {
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
}

View File

@@ -8,25 +8,16 @@ import (
"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 {
// ID of external network
// Required: true
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) {
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)
res, err := e.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -40,3 +31,18 @@ func (e ExtNet) Get(ctx context.Context, req GetRequest) (*RecordExtNet, error)
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
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list external network
// ListRequest struct to get list of external network
type ListRequest struct {
// Find by account ID
// Required: false
@@ -45,11 +45,9 @@ type ListRequest struct {
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) {
url := "/cloudapi/extnet/list"
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := e.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -63,3 +61,11 @@ func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNets, error)
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
}

View File

@@ -8,25 +8,16 @@ import (
"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 {
// FLIPGroup ID
// Required: true
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) {
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)
res, err := f.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -40,3 +31,18 @@ func (f FLIPGroup) Get(ctx context.Context, req GetRequest) (*RecordFLIPGroup, e
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
}

View File

@@ -6,7 +6,7 @@ import (
"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 {
// Find by name
// Required: false
@@ -25,11 +25,11 @@ type ListRequest struct {
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
// Find by IP
// Reuqired: false
// Required: false
ByIP string `url:"byIp,omitempty" json:"byIp,omitempty"`
// Find by resource group ID
// Reuqired: false
// Required: false
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
// Find by id
@@ -45,11 +45,9 @@ type ListRequest struct {
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) {
url := "/cloudapi/flipgroup/list"
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := f.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -63,3 +61,11 @@ func (f FLIPGroup) List(ctx context.Context, req ListRequest) (*ListFLIPGroups,
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
}

View File

@@ -8,7 +8,7 @@ import (
"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 {
// ID of image to get
// Required: true
@@ -20,18 +20,9 @@ type GetRequest struct {
}
// 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) {
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)
res, err := i.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -45,3 +36,19 @@ func (i Image) Get(ctx context.Context, req GetRequest) (*RecordImage, error) {
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
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list available images
// ListRequest struct to get list of available images
type ListRequest struct {
// Find by storage endpoint provider ID
// Required: false
@@ -65,11 +65,9 @@ type ListRequest struct {
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) {
url := "/cloudapi/image/list"
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := i.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -83,3 +81,11 @@ func (i Image) List(ctx context.Context, req ListRequest) (*ListImages, error) {
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
}

View File

@@ -8,25 +8,16 @@ import (
"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 {
// ID of the K8 catalog item to get
// Required: true
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) {
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)
res, err := k.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -39,3 +30,18 @@ func (k K8CI) Get(ctx context.Context, req GetRequest) (*RecordK8CI, error) {
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
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list information about images
// ListRequest struct to get list of information about images
type ListRequest struct {
// Find by ID
// Required: false
@@ -45,11 +45,9 @@ type ListRequest struct {
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) {
url := "/cloudapi/k8ci/list"
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := k.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -63,3 +61,11 @@ func (k K8CI) List(ctx context.Context, req ListRequest) (*ListK8CI, error) {
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
}

View File

@@ -8,25 +8,16 @@ import (
"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 {
// Kubernetes cluster ID
// Required: true
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) {
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)
res, err := k8s.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -40,3 +31,18 @@ func (k8s K8S) Get(ctx context.Context, req GetRequest) (*RecordK8S, error) {
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
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list information K8S
// ListRequest struct to get list information K8S
type ListRequest struct {
// Find by ID
// Required: false
@@ -53,11 +53,9 @@ type ListRequest struct {
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) {
url := "/cloudapi/k8s/list"
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := k8s.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -71,3 +69,11 @@ func (k8s K8S) List(ctx context.Context, req ListRequest) (*ListK8SClusters, err
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
}

View File

@@ -8,25 +8,16 @@ import (
"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 {
// ID of the load balancer to get details for
// Required: true
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) {
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)
res, err := l.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -40,3 +31,18 @@ func (l LB) Get(ctx context.Context, req GetRequest) (*RecordLB, error) {
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
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list of load balancers
// ListRequest struct to get list of load balancers
type ListRequest struct {
// Find by ID
// Required: false
@@ -53,11 +53,9 @@ type ListRequest struct {
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) {
url := "/cloudapi/lb/list"
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := l.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -71,3 +69,11 @@ func (l LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
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
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list of locations
// ListRequest struct to get list of locations
type ListRequest struct {
// Page number
// Required: false
@@ -33,11 +33,9 @@ type ListRequest struct {
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) {
url := "/cloudapi/locations/list"
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := l.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -51,3 +49,11 @@ func (l Locations) List(ctx context.Context, req ListRequest) (*ListLocations, e
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
}

View File

@@ -8,7 +8,7 @@ import (
"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 {
// Resource group ID
// Required: true
@@ -19,18 +19,9 @@ type GetRequest struct {
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) {
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)
res, err := r.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -44,3 +35,18 @@ func (r RG) Get(ctx context.Context, req GetRequest) (*RecordResourceGroup, erro
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
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list of resource groups
// ListRequest struct to get list of resource groups
type ListRequest struct {
// Find by ID
// Required: false
@@ -53,11 +53,9 @@ type ListRequest struct {
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) {
url := "/cloudapi/rg/list"
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := r.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -71,3 +69,11 @@ func (r RG) List(ctx context.Context, req ListRequest) (*ListResourceGroups, err
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
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for list the available flavors
// ListRequest struct for list of the available flavors
type ListRequest struct {
// ID of the cloudspace
// Required: false
@@ -25,11 +25,9 @@ type ListRequest struct {
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) {
url := "/cloudapi/sizes/list"
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := s.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -43,3 +41,11 @@ func (s Sizes) List(ctx context.Context, req ListRequest) (*ListSizes, error) {
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
}

View File

@@ -8,25 +8,16 @@ import (
"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 {
// Find by ID
// Required: true
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) {
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)
res, err := i.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -40,3 +31,18 @@ func (i Stack) Get(ctx context.Context, req GetRequest) (*InfoStack, error) {
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
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list stack
// ListRequest struct to get list of stacks
type ListRequest struct {
// Find by ID
// Required: false
@@ -33,11 +33,9 @@ type ListRequest struct {
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) {
url := "/cloudapi/stack/list"
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := i.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -51,3 +49,11 @@ func (i Stack) List(ctx context.Context, req ListRequest) (*ListStacks, error) {
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
}

View File

@@ -8,25 +8,16 @@ import (
"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 {
// ID of audit
// Required: true
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) {
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)
res, err := t.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -41,3 +32,18 @@ func (t Tasks) Get(ctx context.Context, req GetRequest) (*RecordAsyncTask, error
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
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list of tasks
// ListRequest struct to get list of tasks
type ListRequest struct {
// Page number
// Required: false
@@ -17,11 +17,9 @@ type ListRequest struct {
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) {
url := "/cloudapi/tasks/list"
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := t.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -35,3 +33,11 @@ func (t Tasks) List(ctx context.Context, req ListRequest) (*ListTasks, error) {
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
}

View File

@@ -8,25 +8,16 @@ import (
"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 {
// VINS ID
// Required: true
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) {
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)
res, err := v.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -39,5 +30,19 @@ func (v VINS) Get(ctx context.Context, req GetRequest) (*RecordVINS, error) {
}
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
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list of VINSes
// ListRequest struct to get list of VINSes
type ListRequest struct {
// Find by ID
// Required: false
@@ -41,11 +41,9 @@ type ListRequest struct {
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) {
url := "/cloudapi/vins/list"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := v.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -59,3 +57,11 @@ func (v VINS) List(ctx context.Context, req ListRequest) (*ListVINS, error) {
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
}