Files
decort-golang-sdk/pkg/cloudbroker/compute/cd_insert.go

37 lines
871 B
Go
Raw Normal View History

2022-12-22 17:56:47 +03:00
package compute
import (
"context"
"net/http"
2023-03-24 17:09:30 +03:00
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
2022-12-22 17:56:47 +03:00
)
2023-10-25 17:37:18 +03:00
// CDInsertRequest struct to insert new CD image
2022-12-22 17:56:47 +03:00
type CDInsertRequest struct {
// ID of compute instance
// Required: true
2023-03-24 17:09:30 +03:00
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
2022-12-22 17:56:47 +03:00
// ID of CD-ROM image
// Required: true
2023-03-24 17:09:30 +03:00
CDROMID uint64 `url:"cdromId" json:"cdromId" validate:"required"`
2022-12-22 17:56:47 +03:00
}
2023-10-25 17:37:18 +03:00
// CDInsert inserts new CD image to compute's CD-ROM
2022-12-22 17:56:47 +03:00
func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error) {
2023-03-24 17:09:30 +03:00
err := validators.ValidateRequest(req)
2022-12-22 17:56:47 +03:00
if err != nil {
2023-10-25 17:37:18 +03:00
return false, validators.ValidationErrors(validators.GetErrors(err))
2022-12-22 17:56:47 +03:00
}
url := "/cloudbroker/compute/cdInsert"
_, err = c.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
return true, nil
}