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.
49 lines
1.0 KiB
49 lines
1.0 KiB
package compute
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
|
)
|
|
|
|
// BootOrderSetRequest struct to set boot order
|
|
type BootOrderSetRequest struct {
|
|
// ID of compute instance
|
|
// Required: true
|
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
|
|
|
// List of boot devices
|
|
// Should be one of:
|
|
// - cdrom
|
|
// - network
|
|
// - hd
|
|
// Required: true
|
|
Order []string `url:"order" json:"order" validate:"min=1,computeOrder"`
|
|
}
|
|
|
|
// BootOrderSet sets compute boot order
|
|
func (c Compute) BootOrderSet(ctx context.Context, req BootOrderSetRequest) ([]string, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudapi/compute/bootOrderSet"
|
|
|
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
orders := make([]string, 0)
|
|
|
|
err = json.Unmarshal(res, &orders)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return orders, nil
|
|
}
|