This commit is contained in:
2024-03-06 17:02:50 +03:00
parent 83bf1fb1fa
commit de9cca4053
49 changed files with 1962 additions and 720 deletions

View File

@@ -0,0 +1,38 @@
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))
for _, p := range lp {
res := make([]uint64, 0, len(lp.Data))
for _, p := range lp.Data {
res = append(res, p.ID)
}
return res

View File

@@ -12,6 +12,14 @@ 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
@@ -75,6 +83,15 @@ 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
@@ -232,7 +249,13 @@ type ItemPFW struct {
}
// List port forwards
type ListPFW []ItemPFW
type ListPFW struct {
// Data
Data []ItemPFW `json:"data"`
// Entry count
EntryCount uint64 `json:"entryCount"`
}
// Main information about rule
type ItemRule struct {
@@ -569,6 +592,9 @@ type InfoCompute struct {
// Boot disk size
BootDiskSize uint64 `json:"bootdiskSize"`
// cd Image Id
CdImageId uint64 `json:"cdImageId"`
// Clone reference
CloneReference uint64 `json:"cloneReference"`
@@ -638,6 +664,9 @@ type InfoCompute struct {
// Name
Name string `json:"name"`
// Need reboot
NeedReboot bool `json:"needReboot"`
// List OS users
OSUsers ListOSUsers `json:"osUsers"`
@@ -732,7 +761,7 @@ type ItemCompute struct {
InfoCompute
// Total disk size
TotalDiskSize uint64 `json:"totalDiskSize"`
TotalDiskSize uint64 `json:"totalDisksSize"`
// 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, erro
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) (ListSnapshots, error) {
func (c Compute) SnapshotList(ctx context.Context, req SnapshotListRequest) (*ListSnapShot, 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) (Lis
return nil, err
}
list := ListSnapshots{}
list := ListSnapShot{}
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) (*RecordACL, error) {
func (c Compute) UserList(ctx context.Context, req UserListRequest) (*ListUsers, 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) (*RecordACL,
return nil, err
}
list := RecordACL{}
list := ListUsers{}
err = json.Unmarshal(res, &list)
if err != nil {