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.
45 lines
1.1 KiB
45 lines
1.1 KiB
package logicalports
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
)
|
|
|
|
// MigrateCancelRequest struct to cancel migrate
|
|
type MigrateCancelRequest struct {
|
|
// ID of the logical port
|
|
// Required: true
|
|
LogicalPortID string `url:"logical_port_id" json:"logical_port_id" validate:"required"`
|
|
|
|
// ID of the version
|
|
// Required: true
|
|
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
|
}
|
|
|
|
func (i LogicalPorts) CancelMigrate(ctx context.Context, req MigrateCancelRequest) (*MigrationStatus, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/sdn/logical_port/migration_cancel"
|
|
|
|
res, err := i.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
info := MigrationStatus{}
|
|
|
|
err = json.Unmarshal(res, &info)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &info, nil
|
|
}
|