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.
dynamix-golang-sdk/pkg/cloudbroker/compute/create_template.go

40 lines
1007 B

2 months ago
package compute
import (
"context"
"net/http"
"strings"
1 month ago
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
2 months ago
)
// CreateTemplateRequest struct to create template
type CreateTemplateRequest struct {
// ID of the compute to create template from
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// Name to assign to the template being created
// Required: true
Name string `url:"name" json:"name" validate:"required"`
}
1 month ago
// CreateTemplate create template from compute instance
func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest) (string, error) {
2 months ago
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/compute/createTemplate"
1 month ago
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
2 months ago
if err != nil {
return "", err
}
result := strings.ReplaceAll(string(res), "\"", "")
return result, nil
}