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.
42 lines
1.0 KiB
42 lines
1.0 KiB
|
4 days ago
|
package logicalports
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"net/http"
|
||
|
|
|
||
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||
|
|
)
|
||
|
|
|
||
|
|
// DeleteRequest struct to delete logical port
|
||
|
|
type DeleteRequest struct {
|
||
|
|
// Port ID
|
||
|
|
// Required: true
|
||
|
|
ID string `url:"logical_port_id" json:"logical_port_id" validate:"required"`
|
||
|
|
|
||
|
|
// Version
|
||
|
|
// Required: true
|
||
|
|
Version uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||
|
|
|
||
|
|
// Force delete. True or false
|
||
|
|
// Required: false
|
||
|
|
Force interface{} `url:"force,omitempty" json:"force,omitempty" validate:"omitempty,isBool"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// Delete a logical port
|
||
|
|
func (i LogicalPorts) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||
|
|
err := validators.ValidateRequest(req)
|
||
|
|
if err != nil {
|
||
|
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||
|
|
}
|
||
|
|
|
||
|
|
url := "/sdn/logical_port/delete"
|
||
|
|
|
||
|
|
_, err = i.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)
|
||
|
|
if err != nil {
|
||
|
|
return false, err
|
||
|
|
}
|
||
|
|
|
||
|
|
return true, nil
|
||
|
|
}
|