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.
decort-golang-sdk/pkg/sdn/adrspools/delete.go

52 lines
1.2 KiB

package adrspools
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// DeleteRequest struct to delete address pool
type DeleteRequest struct {
// Address pool ID
// Required: true
AddressPoolID string `url:"address_pool_id" json:"address_pool_id" validate:"required"`
// Version ID
// Required: true
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
// Force delete
// Required: false
Force interface{} `url:"force,omitempty" json:"force,omitempty" validate:"omitempty,isBool"`
}
// Delete an address pool
func (i AddressPools) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/sdn/address_pool/delete"
res, err := i.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)
if err != nil {
return false, err
}
if string(res) == "" {
return true, nil
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}