v1.16.9
v1.16.9
This commit is contained in:
64
pkg/cloudbroker/compute/mass_pin_to_node.go
Normal file
64
pkg/cloudbroker/compute/mass_pin_to_node.go
Normal file
@@ -0,0 +1,64 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type Pin struct {
|
||||
// ID of the compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||
|
||||
// Target node ID. Required for stopped computes.
|
||||
// For started computes it is optional;
|
||||
// if it differs from the current node, allow_migration must be true,
|
||||
// otherwise the compute is reported with migration_not_allowed error.
|
||||
// Required: false
|
||||
NodeID uint64 `url:"node_id,omitempty" json:"node_id,omitempty"`
|
||||
}
|
||||
|
||||
// MassPinToNodeRequest to pin multiple computes to nodes in a single call
|
||||
type MassPinToNodeRequest struct {
|
||||
// Computes to pin, at most 200 items per request
|
||||
// Required: true
|
||||
Pins []Pin `url:"pins" json:"pins" validate:"required,min=1,max=200,dive"`
|
||||
|
||||
// Allow live migration of started computes to the requested node_id
|
||||
// Default: false
|
||||
// Required: false
|
||||
AllowMigration interface{} `url:"allow_migration,omitempty" json:"allow_migration,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Start compute after node exits from MAINTENANCE state
|
||||
// Default: false
|
||||
// Required: false
|
||||
AutoStart interface{} `url:"auto_start,omitempty" json:"auto_start,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
// MassPinToNode pins multiple computes to nodes in a single call
|
||||
func (c Compute) MassPinToNode(ctx context.Context, req MassPinToNodeRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/mass_pin_to_node"
|
||||
|
||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(res, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
Reference in New Issue
Block a user