parent
84b64b7d80
commit
7d6cda7119
@ -1 +1,2 @@
|
||||
cmd/
|
||||
cmd/
|
||||
.idea/
|
@ -1,39 +1,33 @@
|
||||
## Version 1.3.0
|
||||
## Version 1.3.1
|
||||
|
||||
### Features
|
||||
|
||||
- Created CloudAPI/CloudBroker filtering, sorting and serialization functions for List requests.
|
||||
- Every handler with present List request has available FilterBy functions. Filtering by ID, Name is common for each handler.
|
||||
- In case user needs to filter response by uncommon field FilterFunc with user-specified predicate is also available.
|
||||
- CloudAPI/CloudBroker computes, disks and lb also have specific Filter methods predefined, to name a few:
|
||||
- computes:
|
||||
- FilterByK8SID, used to filter computes used by specified k8s cluster;
|
||||
- FilterByK8SMasters, FilterByK8SWorkers, used to filter master/workers nodes. Best used after FilterByK8SID call;
|
||||
- FilterByLBID, used to filter computes used by specified load balancer;
|
||||
|
||||
- disks:
|
||||
- FilterByK8SID, used to filter disks attached to computes inside specified k8s cluster;
|
||||
- FilterByLBID, used to filter disks attached to computes inside specified load balancer;
|
||||
|
||||
- lb:
|
||||
- FilterByK8SID, used to filter load balancers used by specified k8s cluster;
|
||||
|
||||
- Reinvented request validation using go-validator. Made easier to manipulate and add on to.
|
||||
- Request/Config validation now uses tags instead of hard-coded validation functions;
|
||||
|
||||
- Added ability to parse client configuration from JSON or YAML formatted files.
|
||||
- Added FilterByGID for cloudapi/locations/list handler response, used to filter locations by specified GID.
|
||||
- Added /cloudbroker/pcidevices endpoints support
|
||||
- /cloudbroker/pcidevices/create
|
||||
- /cloudbroker/pcidevices/delete
|
||||
- /cloudbroker/pcidevices/disable
|
||||
- /cloudbroker/pcidevices/enable
|
||||
- /cloudbroker/pcidevices/list
|
||||
- Added /cloudbroker/vgpu endpoints support
|
||||
- /cloudbroker/vgpu/allocate
|
||||
- /cloudbroker/vgpu/create
|
||||
- /cloudbroker/vgpu/deallocate
|
||||
- /cloudbroker/vgpu/destroy
|
||||
- /cloudbroker/vgpu/list
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Fixed SSO_URL trailing slash possibly breaking authentication process.
|
||||
- Fixed cloudbroker/vins/nat_rule_add request model types.
|
||||
- Fixed cloudbroker/grid DiskSize field type
|
||||
- Fixed TasksResult, InfoResult in cloudbroker/cloudapi/tasks/models JSON unmarshalling.
|
||||
- Fixed cloudbroker/cloudapi/account/update request model types.
|
||||
- Fixed cloudbroker/cloudapi/rg/update request model types.
|
||||
- Fixed cloudapi/account DeactivationTime field type.
|
||||
- Fixed cloudapi/k8s/workersGroupAdd return value type.
|
||||
- Fixed cloudapi/disks/listUnattached return value type.
|
||||
- Added ListDisksUnattached model as a cloudapi/disks/listUnattached handler response with filters.
|
||||
- Fixed cloudapi/extnet Excluded field type.
|
||||
- Fixed cloudapi/rg RecordResourceUsage model.
|
||||
- Fixed cloudapi/compute ItemACL model.
|
||||
|
||||
### Tests
|
||||
|
||||
- Covered CloudAPI/CloudBroker filters with unit tests.
|
||||
|
||||
### Other
|
||||
|
||||
- Updated module to new repository
|
||||
- Covered cloudapi/disks ListDisksUnattached filters with unit tests.
|
||||
|
@ -0,0 +1,8 @@
|
||||
package cloudbroker
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/pcidevice"
|
||||
|
||||
// Accessing the PCI Device method group
|
||||
func (cb *CloudBroker) PCIDevice() *pcidevice.PCIDevice {
|
||||
return pcidevice.New(cb.client)
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package pcidevice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for creating PCI device
|
||||
type CreateRequest struct {
|
||||
// StackID
|
||||
// Required: true
|
||||
StackID uint64 `url:"stackId" json:"stackId" validate:"required"`
|
||||
|
||||
// Resource group ID
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
|
||||
// Name of device
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// PCI address of the device
|
||||
// Must be in format 0000:1f:2b.0
|
||||
// Required: true
|
||||
HWPath string `url:"hwPath" json:"hwPath" validate:"required,hwPath"`
|
||||
|
||||
// Description, just for information
|
||||
// Required: false
|
||||
Description string `url:"description,omitempty" json:"description,omitempty"`
|
||||
}
|
||||
|
||||
// Create creates PCI Device
|
||||
func (p PCIDevice) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return 0, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/pcidevice/create"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package pcidevice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for deleting PCI device
|
||||
type DeleteRequest struct {
|
||||
// PCI device ID
|
||||
// Required: true
|
||||
DeviceID uint64 `url:"deviceId" json:"deviceId" validate:"required"`
|
||||
|
||||
// Force delete
|
||||
// Required: false
|
||||
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
||||
}
|
||||
|
||||
// Delete PCI device
|
||||
func (p PCIDevice) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/pcidevice/delete"
|
||||
|
||||
res, err := p.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
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package pcidevice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for disabling PCI device
|
||||
type DisableRequest struct {
|
||||
// PCI device ID
|
||||
// Required: true
|
||||
DeviceID uint64 `url:"deviceId" json:"deviceId" validate:"required"`
|
||||
|
||||
// Force delete
|
||||
// Required: false
|
||||
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
||||
}
|
||||
|
||||
// Disable PCI device
|
||||
func (p PCIDevice) Disable(ctx context.Context, req DisableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/pcidevice/disable"
|
||||
|
||||
res, err := p.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
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package pcidevice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for enabling PCI device
|
||||
type EnableRequest struct {
|
||||
// PCI device ID
|
||||
// Required: true
|
||||
DeviceID uint64 `url:"deviceId" json:"deviceId" validate:"required"`
|
||||
}
|
||||
|
||||
// Enable PCI device
|
||||
func (p PCIDevice) Enable(ctx context.Context, req EnableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/pcidevice/enable"
|
||||
|
||||
res, err := p.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
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package pcidevice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// List gets list all pci devices
|
||||
func (p PCIDevice) List(ctx context.Context) (ListPCIDevices, error) {
|
||||
url := "/cloudbroker/pcidevice/list"
|
||||
|
||||
res, err := p.client.DecortApiCall(ctx, http.MethodPost, url, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListPCIDevices{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package pcidevice
|
||||
|
||||
// Main information about PCI device
|
||||
type ItemPCIDevice struct {
|
||||
// CKey
|
||||
CKey string `json:"_ckey"`
|
||||
|
||||
// Meta
|
||||
Meta []interface{} `json:"_meta"`
|
||||
|
||||
// Compute ID
|
||||
ComputeID uint64 `json:"computeId"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// HwPath
|
||||
HwPath string `json:"hwPath"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
// Stack ID
|
||||
StackID uint64 `json:"stackId"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// System name
|
||||
SystemName string `json:"systemName"`
|
||||
}
|
||||
|
||||
// List PCI devices
|
||||
type ListPCIDevices []ItemPCIDevice
|
@ -0,0 +1,15 @@
|
||||
package pcidevice
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
|
||||
// Structure for creating request to PCI device
|
||||
type PCIDevice struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for PCI device endpoints
|
||||
func New(client interfaces.Caller) *PCIDevice {
|
||||
return &PCIDevice{
|
||||
client: client,
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package pcidevice
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/serialization"
|
||||
)
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
//
|
||||
// In order to serialize with indent make sure to follow these guidelines:
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (l ListPCIDevices) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(l) == 0 {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(l, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(l)
|
||||
}
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
//
|
||||
// In order to serialize with indent make sure to follow these guidelines:
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (i ItemPCIDevice) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(i, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(i)
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package cloudbroker
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/vgpu"
|
||||
|
||||
// Accessing the VGPU method group
|
||||
func (cb *CloudBroker) VGPU() *vgpu.VGPU {
|
||||
return vgpu.New(cb.client)
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package vgpu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request for allocating VGPU
|
||||
type AllocateRequest struct {
|
||||
// Virtual GPU ID
|
||||
// Required: true
|
||||
VGPUID uint64 `url:"vgpuId" json:"vgpuId" validate:"required"`
|
||||
}
|
||||
|
||||
// Allocate allocates GPU
|
||||
func (v VGPU) Allocate(ctx context.Context, req AllocateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vgpu/allocate"
|
||||
|
||||
res, err := v.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
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package vgpu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for creating VGPU
|
||||
type CreateRequest struct {
|
||||
// ID of pGPU
|
||||
// Required: true
|
||||
PGPUID uint64 `url:"pgpuId" json:"pgpuId" validate:"required"`
|
||||
|
||||
// ID of the target resource group.
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
|
||||
// Virtual profile id
|
||||
// Required: false
|
||||
ProfileID uint64 `url:"profileId,omitempty" json:"profileId,omitempty"`
|
||||
|
||||
// Allocate vgpu after creation
|
||||
// Required: false
|
||||
Allocate bool `url:"allocate,omitempty" json:"allocate,omitempty"`
|
||||
}
|
||||
|
||||
// Create creates VGPU
|
||||
func (v VGPU) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return 0, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vgpu/create"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package vgpu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request for deallocating VGPU
|
||||
type DeallocateRequest struct {
|
||||
// Virtual GPU ID
|
||||
// Required: true
|
||||
VGPUID uint64 `url:"vgpuId" json:"vgpuId" validate:"required"`
|
||||
|
||||
// Force delete (detach from compute)
|
||||
// Required: false
|
||||
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
||||
}
|
||||
|
||||
// Deallocate releases GPU resources
|
||||
func (v VGPU) Deallocate(ctx context.Context, req DeallocateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vgpu/deallocate"
|
||||
|
||||
res, err := v.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
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package vgpu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request for destroying VGPU
|
||||
type DestroyRequest struct {
|
||||
// Virtual GPU ID
|
||||
// Required: true
|
||||
VGPUID uint64 `url:"vgpuId" json:"vgpuId" validate:"required"`
|
||||
|
||||
// Force delete (deallocate and detach from compute)
|
||||
// Required: false
|
||||
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
||||
}
|
||||
|
||||
// Destroy destroys VGPU
|
||||
func (v VGPU) Destroy(ctx context.Context, req DestroyRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vgpu/destroy"
|
||||
|
||||
res, err := v.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
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package vgpu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Request struct for getting list of VGPU
|
||||
type ListRequest struct {
|
||||
// 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 list all VGPU
|
||||
func (v VGPU) List(ctx context.Context, req ListRequest) (ListVGPU, error) {
|
||||
url := "/cloudbroker/vgpu/list"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListVGPU{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package vgpu
|
||||
|
||||
type ItemVGPU struct {
|
||||
// CKey
|
||||
CKey string `json:"_ckey"`
|
||||
|
||||
// Meta
|
||||
Meta []interface{} `json:"_meta"`
|
||||
|
||||
// Account ID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// Deleted time
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
//Grid ID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// VGPU ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Last claimed by
|
||||
LastClaimedBy uint64 `json:"lastClaimedBy"`
|
||||
|
||||
// Last update time
|
||||
LastUpdateTime uint64 `json:"lastUpdateTime"`
|
||||
|
||||
// Mode
|
||||
Mode string `json:"mode"`
|
||||
|
||||
// PCI Slot
|
||||
PCISlot interface{} `json:"pciSlot"`
|
||||
|
||||
// PGPUID
|
||||
PGPUID uint64 `json:"pgpuid"`
|
||||
|
||||
// Profile ID
|
||||
ProfileID interface{} `json:"profileId"`
|
||||
|
||||
// RAM
|
||||
RAM uint64 `json:"ram"`
|
||||
|
||||
// Reference ID
|
||||
ReferenceID interface{} `json:"referenceId"`
|
||||
|
||||
// RGID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// VMID
|
||||
VMID uint64 `json:"vmid"`
|
||||
}
|
||||
|
||||
// List of VGPU
|
||||
type ListVGPU []ItemVGPU
|
@ -0,0 +1,42 @@
|
||||
package vgpu
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/serialization"
|
||||
)
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
//
|
||||
// In order to serialize with indent make sure to follow these guidelines:
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (l ListVGPU) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(l) == 0 {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(l, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(l)
|
||||
}
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
//
|
||||
// In order to serialize with indent make sure to follow these guidelines:
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (i ItemVGPU) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(i, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(i)
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package vgpu
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
|
||||
// Structure for creating request to VGPU
|
||||
type VGPU struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for VGPU endpoints
|
||||
func New(client interfaces.Caller) *VGPU {
|
||||
return &VGPU{
|
||||
client: client,
|
||||
}
|
||||
}
|
Loading…
Reference in new issue