v1.14.4
v1.14.4
This commit is contained in:
47
pkg/cloudbroker/image/create_multi_image.go
Normal file
47
pkg/cloudbroker/image/create_multi_image.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// CreateMultiImageRequest struct to create multi image
|
||||
type CreateMultiImageRequest struct {
|
||||
// Name of the multi image
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// IDs of real images
|
||||
// Required: true
|
||||
TargetIDs []uint64 `url:"target_ids" json:"target_ids" validate:"required"`
|
||||
|
||||
// Account ID
|
||||
// Required: false
|
||||
AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"`
|
||||
}
|
||||
|
||||
// CreateMultiImage creates multi image
|
||||
func (i Image) CreateMultiImage(ctx context.Context, req CreateMultiImageRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/image/create_multi_image"
|
||||
|
||||
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -62,6 +62,9 @@ type RecordImage struct {
|
||||
// Link to
|
||||
LinkTo uint64 `json:"linkTo"`
|
||||
|
||||
// Links to
|
||||
LinksTo []uint64 `json:"linksTo"`
|
||||
|
||||
// Milestones
|
||||
Milestones uint64 `json:"milestones"`
|
||||
|
||||
@@ -197,6 +200,9 @@ type ItemImage struct {
|
||||
// Link to
|
||||
LinkTo uint64 `json:"linkTo"`
|
||||
|
||||
// Links to
|
||||
LinksTo []uint64 `json:"linksTo"`
|
||||
|
||||
// Milestones
|
||||
Milestones uint64 `json:"milestones"`
|
||||
|
||||
|
||||
43
pkg/cloudbroker/image/multi_image_add_links.go
Normal file
43
pkg/cloudbroker/image/multi_image_add_links.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// MultiImageAddLinksRequest struct to add links to multi image
|
||||
type MultiImageAddLinksRequest struct {
|
||||
// ID of the multi image
|
||||
// Required: true
|
||||
ImageID uint64 `url:"image_id" json:"image_id" validate:"required"`
|
||||
|
||||
// IDs of real images
|
||||
// Required: true
|
||||
TargetIDs []uint64 `url:"target_ids" json:"target_ids" validate:"required"`
|
||||
}
|
||||
|
||||
// MultiImageAddLinks adds image links to multi image
|
||||
func (i Image) MultiImageAddLinks(ctx context.Context, req MultiImageAddLinksRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/image/multi_image_add_links"
|
||||
|
||||
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
43
pkg/cloudbroker/image/multi_image_del_links.go
Normal file
43
pkg/cloudbroker/image/multi_image_del_links.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// MultiImageDelLinksRequest struct to delete links from multi image
|
||||
type MultiImageDelLinksRequest struct {
|
||||
// ID of the multi image
|
||||
// Required: true
|
||||
ImageID uint64 `url:"image_id" json:"image_id" validate:"required"`
|
||||
|
||||
// IDs of real images
|
||||
// Required: true
|
||||
TargetIDs []uint64 `url:"target_ids" json:"target_ids" validate:"required"`
|
||||
}
|
||||
|
||||
// MultiImageDelLinks removes image links from multi image
|
||||
func (i Image) MultiImageDelLinks(ctx context.Context, req MultiImageDelLinksRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/image/multi_image_del_links"
|
||||
|
||||
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
42
pkg/cloudbroker/image/multi_image_export.go
Normal file
42
pkg/cloudbroker/image/multi_image_export.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// MultiImageExportRequest struct to export multi image to a pool
|
||||
type MultiImageExportRequest struct {
|
||||
// ID of the multi image
|
||||
// Required: true
|
||||
MultiImageID uint64 `url:"multi_image_id" json:"multi_image_id" validate:"required"`
|
||||
|
||||
// Name of the target pool
|
||||
// Required: true
|
||||
PoolName string `url:"pool_name" json:"pool_name" validate:"required"`
|
||||
}
|
||||
|
||||
// MultiImageExport copies a physical image from multi image to the specified pool
|
||||
func (i Image) MultiImageExport(ctx context.Context, req MultiImageExportRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/image/multi_image_export"
|
||||
|
||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user