Files
dynamix-golang-sdk/pkg/cloudapi/compute/pin_to_stack.go

44 lines
998 B
Go
Raw Normal View History

2025-09-23 14:34:24 +03:00
package compute
import (
"context"
"net/http"
"strconv"
2025-09-27 01:06:15 +03:00
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
2025-09-23 14:34:24 +03:00
)
// 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"`
2025-09-26 18:56:58 +03:00
// Auto start when node restarted
// Required: false
// Default: false
AutoStart bool `url:"autoStart" json:"autoStart"`
2025-09-23 14:34:24 +03:00
}
// PinToStack pin compute to current stack
2025-09-26 18:56:58 +03:00
func (c Compute) PinToStack(ctx context.Context, req PinToStackRequest) (bool, error) {
2025-09-23 14:34:24 +03:00
err := validators.ValidateRequest(req)
if err != nil {
2025-09-26 18:56:58 +03:00
return false, validators.ValidationErrors(validators.GetErrors(err))
2025-09-23 14:34:24 +03:00
}
url := "/cloudapi/compute/pinToStack"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
2025-09-26 18:56:58 +03:00
return false, err
2025-09-23 14:34:24 +03:00
}
2025-09-26 18:56:58 +03:00
result, err := strconv.ParseBool(string(res))
2025-09-23 14:34:24 +03:00
if err != nil {
2025-09-26 18:56:58 +03:00
return false, err
2025-09-23 14:34:24 +03:00
}
return result, nil
}