This commit is contained in:
stSolo
2023-01-23 15:39:41 +03:00
parent ef0dac9b3a
commit 7ddd8c5fbe
39 changed files with 869 additions and 301 deletions

View File

@@ -11,18 +11,12 @@ type ItemDisk struct {
// Account name
AccountName string `json:"accountName"`
// Boot partition
BootPartition uint64 `json:"bootPartition"`
// Computes
Computes map[string]string `json:"computes"`
// Created time
CreatedTime uint64 `json:"createdTime"`
// Compute ID
ComputeID uint64 `json:"computeId"`
// Compute name
ComputeName string `json:"computeName"`
// Deleted time
DeletedTime uint64 `json:"deletedTime"`
@@ -69,11 +63,14 @@ type ItemDisk struct {
ParentID uint64 `json:"parentId"`
// PCI slot
PCISlot uint64 `json:"pciSlot"`
PCISlot int64 `json:"pciSlot"`
// Pool
Pool string `json:"pool"`
// Present to
PresentTo []uint64 `json:"presentTo"`
// Purge time
PurgeTime uint64 `json:"purgeTime"`
@@ -89,12 +86,18 @@ type ItemDisk struct {
// SepType
SepType string `json:"sepType"`
// Shareable
Shareable bool `json:"shareable"`
// SepID
SepID uint64 `json:"sepId"`
// Size max
SizeMax uint64 `json:"sizeMax"`
// Size used
SizeUsed uint64 `json:"sizeUsed"`
// List of snapshots
Snapshots ListSnapshots `json:"snapshots"`
@@ -191,6 +194,9 @@ type RecordDisk struct {
// Account name
AccountName string `json:"accountName"`
// Computes
Computes map[string]string `json:"computes"`
// Created time
CreatedTime uint64 `json:"createdTime"`
@@ -239,6 +245,9 @@ type RecordDisk struct {
// Pool
Pool string `json:"pool"`
// Present to
PresentTo []uint64 `json:"presentTo"`
// Purge time
PurgeTime uint64 `json:"purgeTime"`
@@ -257,6 +266,9 @@ type RecordDisk struct {
// SepID
SepID uint64 `json:"sepId"`
// Shareable
Shareable bool `json:"shareable"`
// Size max
SizeMax uint64 `json:"sizeMax"`

View File

@@ -0,0 +1,45 @@
package disks
import (
"context"
"errors"
"net/http"
"strconv"
)
// Request struct for share data disk
type ShareRequest struct {
// ID of the disk to share
// Required: true
DiskID uint64 `url:"diskId"`
}
func (drq ShareRequest) validate() error {
if drq.DiskID == 0 {
return errors.New("validation-error: field DiskID can not be empty or equal to 0")
}
return nil
}
// Share shares data disk
func (d Disks) Share(ctx context.Context, req ShareRequest) (bool, error) {
err := req.validate()
if err != nil {
return false, err
}
url := "/cloudapi/disks/share"
res, err := d.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

@@ -0,0 +1,45 @@
package disks
import (
"context"
"errors"
"net/http"
"strconv"
)
// Request struct for unshare data disk
type UnshareRequest struct {
// ID of the disk to unshare
// Required: true
DiskID uint64 `url:"diskId"`
}
func (drq UnshareRequest) validate() error {
if drq.DiskID == 0 {
return errors.New("validation-error: field DiskID can not be empty or equal to 0")
}
return nil
}
// Unshare unshares data disk
func (d Disks) Unshare(ctx context.Context, req UnshareRequest) (bool, error) {
err := req.validate()
if err != nil {
return false, err
}
url := "/cloudapi/disks/unshare"
res, err := d.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
}