v1.16.5
This commit is contained in:
51
pkg/cloudbroker/compute/migrate_v2_resolve.go
Normal file
51
pkg/cloudbroker/compute/migrate_v2_resolve.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// MigrateResolveRequest to resolve a migration
|
||||
type MigrateV2ResolveRequest struct {
|
||||
// Workflow job ID
|
||||
// Required: true
|
||||
WorkflowJobID string `url:"workflow_job_id" json:"workflow_job_id" validate:"required"`
|
||||
|
||||
// Take over cleanup
|
||||
// Required: false
|
||||
TakeOverCleanup interface{} `url:"take_over_cleanup,omitempty" json:"take_over_cleanup,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
// MigrateV2Resolve resolves a migration of a compute
|
||||
func (c Compute) MigrateV2Resolve(ctx context.Context, req MigrateV2ResolveRequest) (*MigrateV2ResolveRecord, error) {
|
||||
res, err := c.MigrateV2ResolveRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := MigrateV2ResolveRecord{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// MigrateV2ResolveRaw resolves a migration of a compute and returns an array of bytes
|
||||
func (c Compute) MigrateV2ResolveRaw(ctx context.Context, req MigrateV2ResolveRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/migrate_v2_resolve"
|
||||
|
||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
return res, err
|
||||
}
|
||||
Reference in New Issue
Block a user