This commit is contained in:
2024-03-14 10:17:08 +03:00
parent de9cca4053
commit 55027a1605
50 changed files with 718 additions and 1963 deletions

View File

@@ -1,10 +0,0 @@
package cloudbroker
import (
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/audit"
)
// Accessing the Stack method group
func (cb *CloudBroker) Audit() *audit.Audit {
return audit.New(cb.client)
}

View File

@@ -1,15 +0,0 @@
package audit
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
// Structure for creating request to audit
type Audit struct {
client interfaces.Caller
}
// Builder for audit endpoint
func New(client interfaces.Caller) *Audit {
return &Audit{
client: client,
}
}

View File

@@ -1,46 +0,0 @@
package audit
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// GetRequest struct to get information about account
type GetRequest struct {
// Audit GUID
// Required: true
AuditGuid string `url:"auditGuid" json:"auditGuid" validate:"required"`
}
// Get gets information about audit as a RecordAudit struct
func (a Audit) Get(ctx context.Context, req GetRequest) (*RecordAudit, error) {
res, err := a.GetRaw(ctx, req)
if err != nil {
return nil, err
}
info := RecordAudit{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}
// GetRaw gets information about audit as an array of bytes
func (a Audit) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/audit/get"
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}

View File

@@ -1,46 +0,0 @@
package audit
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// LinkedJobsRequest struct to get information about jobs linked with Audit
type LinkedJobsRequest struct {
// Audit GUID
// Required: true
AuditGuid string `url:"auditGuid" json:"auditGuid" validate:"required"`
}
// LinkedJobs gets information about Linked Jobs as a ListLinkedJobs struct
func (a Audit) LinkedJobs(ctx context.Context, req LinkedJobsRequest) (*ListLinkedJobs, error) {
res, err := a.GetRawLinkedJobs(ctx, req)
if err != nil {
return nil, err
}
info := ListLinkedJobs{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}
// GetRawLinkedJobs gets information about Linked Jobs as an array of bytes
func (a Audit) GetRawLinkedJobs(ctx context.Context, req LinkedJobsRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/audit/linkedJobs"
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}

View File

@@ -1,64 +0,0 @@
package audit
import (
"context"
"encoding/json"
"net/http"
)
// ListRequest struct to give list of account audits
type ListRequest struct {
// Find all audits after point in time (unixtime)
// Required: false
TimestampAt uint64 `url:"timestampAt,omitempty" json:"timestampAt,omitempty"`
// Find all audits before point in time (unixtime)
// Required: false
TimestampTo uint64 `url:"timestampTo,omitempty" json:"timestampTo,omitempty"`
// Find by user (Mongo RegExp supported)
// Required: false
User string `url:"user,omitempty" json:"user,omitempty"`
// Find by api endpoint (Mongo RegExp supported)
// Required: false
Call string `url:"call,omitempty" json:"call,omitempty"`
// Find by HTTP status code
// Required: false
StatusCode uint64 `url:"statusCode,omitempty" json:"statusCode,omitempty"`
// Page number
// Required: false
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
// Page size
// Required: false
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
}
// List gets audit records for the specified account object
func (a Audit) List(ctx context.Context, req ListRequest) (*ListAudits, error) {
res, err := a.ListRaw(ctx, req)
if err != nil {
return nil, err
}
list := ListAudits{}
err = json.Unmarshal(res, &list)
if err != nil {
return nil, err
}
return &list, nil
}
// ListRaw gets list of audit records an array of bytes
func (a Audit) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
url := "/cloudbroker/audit/list"
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}

View File

@@ -1,102 +0,0 @@
package audit
// Main info about audit
type ItemAudit struct {
// Call
Call string `json:"call"`
// GUID
GUID string `json:"guid"`
// Response time
ResponseTime float64 `json:"responsetime"`
// Status code
StatusCode uint64 `json:"statuscode"`
// Timestamp
Timestamp float64 `json:"timestamp"`
// User
User string `json:"user"`
}
// List of audits
type ListAudits struct {
// Data
Data []ItemAudit `json:"data"`
// EntryCount
EntryCount uint64 `json:"entryCount"`
}
// Main info about audit
type RecordAudit struct {
// Apitask
Apitask string `json:"apitask"`
// Arguments
Arguments string `json:"args"`
// Call
Call string `json:"call"`
// GUID
GUID string `json:"guid"`
// Kwargs
Kwargs string `json:"kwargs"`
// RemoteAddr
RemoteAddr string `json:"remote_addr"`
// Response time
ResponseTime float64 `json:"responsetime"`
// Result
Result string `json:"result"`
// Status code
StatusCode uint64 `json:"statuscode"`
// Tags
Tags string `json:"tags"`
// Timestamp
Timestamp float64 `json:"timestamp"`
// TimestampEnd
TimestampEnd float64 `json:"timestampEnd"`
// User
User string `json:"user"`
}
// List of Linked Jobs
type ListLinkedJobs []ItemLinkedJobs
// Main info about Linked Jobs
type ItemLinkedJobs struct {
// CMD
CMD string `json:"cmd"`
// NID
NID uint64 `json:"nid"`
// state
State string `json:"state"`
// TimeCreate
TimeCreate uint64 `json:"timeCreate"`
// TimeStart
TimeStart uint64 `json:"timeStart"`
// TimeStop
TimeStop uint64 `json:"timeStop"`
// Timeout
Timeout uint64 `json:"timeout"`
}

View File

@@ -1,38 +0,0 @@
package compute
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// DeleteCustomFieldsRequest struct to delete compute's custom fields
type DeleteCustomFieldsRequest struct {
// ID of the compute
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
}
// DeleteCustomFields deletes computes custom fields
func (c Compute) DeleteCustomFields(ctx context.Context, req DeleteCustomFieldsRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/compute/deleteCustomFields"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -20,8 +20,8 @@ func (lid ListInfoDisks) IDs() []uint64 {
// IDs gets array of PFWsIDs from ListPFW struct
func (lp ListPFW) IDs() []uint64 {
res := make([]uint64, 0, len(lp.Data))
for _, p := range lp.Data {
res := make([]uint64, 0, len(lp))
for _, p := range lp {
res = append(res, p.ID)
}
return res

View File

@@ -12,14 +12,6 @@ type RecordACL struct {
RGACL ListACL `json:"rgACL"`
}
type ListUsers struct {
// Data
Data RecordACL `json:"data"`
// Entry count
EntryCount uint64 `json:"entryCount"`
}
// ACL information
type ItemACL struct {
// Explicit
@@ -83,15 +75,6 @@ type ItemSnapshot struct {
// List of snapshots
type ListSnapshots []ItemSnapshot
// List of snapshots
type ListSnapShot struct {
// Data
Data []ItemSnapshot `json:"data"`
// Entry count
EntryCount uint64 `json:"entryCount"`
}
// Main information about snapshot usage
type ItemSnapshotUsage struct {
// Count
@@ -249,13 +232,7 @@ type ItemPFW struct {
}
// List port forwards
type ListPFW struct {
// Data
Data []ItemPFW `json:"data"`
// Entry count
EntryCount uint64 `json:"entryCount"`
}
type ListPFW []ItemPFW
// Main information about rule
type ItemRule struct {
@@ -592,9 +569,6 @@ type InfoCompute struct {
// Boot disk size
BootDiskSize uint64 `json:"bootdiskSize"`
// cd Image Id
CdImageId uint64 `json:"cdImageId"`
// Clone reference
CloneReference uint64 `json:"cloneReference"`
@@ -664,9 +638,6 @@ type InfoCompute struct {
// Name
Name string `json:"name"`
// Need reboot
NeedReboot bool `json:"needReboot"`
// List OS users
OSUsers ListOSUsers `json:"osUsers"`
@@ -761,7 +732,7 @@ type ItemCompute struct {
InfoCompute
// Total disk size
TotalDiskSize uint64 `json:"totalDisksSize"`
TotalDiskSize uint64 `json:"totalDiskSize"`
// VINS connected
VINSConnected uint64 `json:"vinsConnected"`

View File

@@ -20,7 +20,7 @@ type PFWListRequest struct {
}
// PFWList gets compute port forwards list
func (c Compute) PFWList(ctx context.Context, req PFWListRequest) (*ListPFW, error) {
func (c Compute) PFWList(ctx context.Context, req PFWListRequest) (ListPFW, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
@@ -40,5 +40,5 @@ func (c Compute) PFWList(ctx context.Context, req PFWListRequest) (*ListPFW, err
return nil, err
}
return &list, nil
return list, nil
}

View File

@@ -16,7 +16,7 @@ type SnapshotListRequest struct {
}
// SnapshotList gets list of compute snapshots
func (c Compute) SnapshotList(ctx context.Context, req SnapshotListRequest) (*ListSnapShot, error) {
func (c Compute) SnapshotList(ctx context.Context, req SnapshotListRequest) (ListSnapshots, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
@@ -29,12 +29,12 @@ func (c Compute) SnapshotList(ctx context.Context, req SnapshotListRequest) (*Li
return nil, err
}
list := ListSnapShot{}
list := ListSnapshots{}
err = json.Unmarshal(res, &list)
if err != nil {
return nil, err
}
return &list, nil
return list, nil
}

View File

@@ -16,7 +16,7 @@ type UserListRequest struct {
}
// UserList gets users list for compute
func (c Compute) UserList(ctx context.Context, req UserListRequest) (*ListUsers, error) {
func (c Compute) UserList(ctx context.Context, req UserListRequest) (*RecordACL, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
@@ -29,7 +29,7 @@ func (c Compute) UserList(ctx context.Context, req UserListRequest) (*ListUsers,
return nil, err
}
list := ListUsers{}
list := RecordACL{}
err = json.Unmarshal(res, &list)
if err != nil {

View File

@@ -2,7 +2,6 @@ package grid
import (
"context"
"fmt"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
@@ -39,7 +38,7 @@ func (g Grid) GetDiagnosisGET(ctx context.Context, req GetDiagnosisRequest) (str
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := fmt.Sprintf("/cloudbroker/grid/getDiagnosis/?gid=%d", req.GID)
url := "/cloudbroker/grid/getDiagnosis"
res, err := g.client.DecortApiCall(ctx, http.MethodGet, url, req)
if err != nil {

View File

@@ -67,9 +67,6 @@ type DiskUsage struct {
// Detailed information about grid
type RecordGrid struct {
// AuthBroker
AuthBroker []interface{} `json:"authBroker"`
// Flag
Flag string `json:"flag"`
@@ -94,9 +91,6 @@ type ItemGridList struct {
// Resource information
Resources Resources `json:"Resources"`
// AuthBroker
AuthBroker []interface{} `json:"authBroker"`
// Flag
Flag string `json:"flag"`

View File

@@ -1,36 +0,0 @@
package k8ci
import (
"context"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// AccessAddRequest struct for adding permission to access to account for a k8ci
type AccessAddRequest struct {
// ID of the K8 catalog item to add access for
// Required: true
K8CIID uint64 `url:"k8ciId" json:"k8ciId" validate:"required"`
// Account ID to add to the sharedWith access list
// Required: true
AccountId uint64 `url:"accountId" json:"accountId" validate:"required"`
}
// Add accountId to sharedWith access list for k8ci.
func (k K8CI) AccessAdd(ctx context.Context, req AccessAddRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/k8ci/accessAdd"
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -1,36 +0,0 @@
package k8ci
import (
"context"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// AccessRemoveRequest struct for removing permission to access to account for a k8ci
type AccessRemoveRequest struct {
// ID of the K8 catalog item to remove access for
// Required: true
K8CIID uint64 `url:"k8ciId" json:"k8ciId" validate:"required"`
// Account ID to be removed from the sharedWith access list
// Required: true
AccountId uint64 `url:"accountId" json:"accountId" validate:"required"`
}
// Remove accountId from sharedWith access list for k8ci.
func (k K8CI) AccessRemove(ctx context.Context, req AccessRemoveRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/k8ci/accessRemove"
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -204,7 +204,7 @@ func (k K8S) Create(ctx context.Context, req CreateRequest) (string, error) {
url := "/cloudbroker/k8s/create"
res, err := k.client.DecortApiCallMP(ctx, http.MethodPost, url, req)
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return "", err
}

View File

@@ -29,10 +29,10 @@ func (l LB) HighlyAvailable(ctx context.Context, req HighlyAvailableRequest) (bo
return false, err
}
result, err := strconv.ParseUint(string(res), 10, 64)
if err != nil || result != req.LBID {
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return true, nil
return result, nil
}

View File

@@ -13,14 +13,6 @@ type AffinityGroupsListRequest struct {
// Resource group ID
// Required: true
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

View File

@@ -53,12 +53,3 @@ func (lpfw ListPFW) IDs() []uint64 {
}
return res
}
// IDs gets array of ComputeIDs from ListAffinityGroupItems struct
func (lag ListAffinityGroupItems) IDs() []uint64 {
res := make([]uint64, 0, len(lag))
for _, ag := range lag {
res = append(res, ag.ID)
}
return res
}

View File

@@ -36,10 +36,6 @@ type ListRequest struct {
// Required: false
Status string `url:"status,omitempty" json:"status,omitempty"`
// Find by status lock
// Required: false
LockStatus string `url:"lockStatus,omitempty" json:"lockStatus,omitempty"`
// Included deleted resource groups
// Required: false
IncludeDeleted bool `url:"includedeleted,omitempty" json:"includedeleted,omitempty"`

View File

@@ -65,10 +65,6 @@ type ItemResourceConsumption struct {
// Reserved information
Reserved Reservation `json:"Reserved"`
// Resource limits
ResourceLimits ResourceLimits `json:"resourceLimits"`
// Resource group ID
RGID uint64 `json:"rgid"`
}
@@ -607,9 +603,6 @@ type ItemLB struct {
// List ACL
ACL ListACL `json:"acl"`
// BackendHAIP
BackendHAIP string `json:"backendHAIP"`
// List backends
Backends ListBackends `json:"backends"`
@@ -634,9 +627,6 @@ type ItemLB struct {
// External network ID
ExtNetID uint64 `json:"extnetId"`
// FrontendHAIP
FrontendHAIP string `json:"frontendHAIP"`
// List of frontends
Frontends ListFrontends `json:"frontends"`
@@ -697,15 +687,8 @@ type ListLB struct {
type ListAffinityGroup struct {
// Data
Data []map[string]ListAffinityGroupItems `json:"data"`
Data map[string][]uint64 `json:"data"`
// Entry count
EntryCount uint64 `json:"entryCount"`
}
type ListAffinityGroupItems []ItemAffinityGroup
type ItemAffinityGroup struct {
ID uint64 `json:"id"`
NodeID uint64 `json:"node_id"`
}

View File

@@ -1,3 +1,4 @@
// Lists all the stack.
package stack
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"

View File

@@ -25,8 +25,7 @@ type CreateInRGRequest struct {
// External network ID
// Required: false
// -1 - not connect to extnet, 0 - auto select, 1+ - extnet ID
ExtNetID int64 `url:"extNetId" json:"extNetId"`
ExtNetID uint64 `url:"extNetId,omitempty" json:"extNetId,omitempty"`
// External IP, related only for extNetId >= 0
// Required: false