You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
package compute
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
)
|
|
|
|
// PinToStackRequest struct to pin compute to stack
|
|
type PinToStackRequest struct {
|
|
// ID of the compute instance
|
|
// Required: true
|
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
|
|
|
// Stack ID to pin to
|
|
// Required: false
|
|
TargetStackID uint64 `url:"targetStackId" json:"targetStackId"`
|
|
|
|
// Try to migrate or not if compute in running states
|
|
// Required: false
|
|
Force bool `url:"force" json:"force"`
|
|
}
|
|
|
|
// PinToStack pins compute to current stack
|
|
func (c Compute) PinToStack(ctx context.Context, req PinToStackRequest) (uint64, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudbroker/compute/pinToStack"
|
|
|
|
res, err := c.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
|
|
}
|