This commit is contained in:
2023-03-24 17:09:30 +03:00
parent 437841c8dd
commit 84b64b7d80
433 changed files with 4246 additions and 6516 deletions

View File

@@ -2,16 +2,17 @@ package vins
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for IP relese
type IPReleaseRequest struct {
// VINS ID
// Required: true
VINSID uint64 `url:"vinsId" json:"vinsId"`
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
// IP address
// Required: false
@@ -22,20 +23,14 @@ type IPReleaseRequest struct {
MAC string `url:"mac,omitempty" json:"mac,omitempty"`
}
func (vrq IPReleaseRequest) validate() error {
if vrq.VINSID == 0 {
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
}
return nil
}
// IPRelese delete IP reservation matched by specified IP & MAC address combination.
// If both IP and MAC address are empty strings, all IP reservations will be deleted.
func (v VINS) IPRelese(ctx context.Context, req IPReleaseRequest) (bool, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return false, err
for _, validationError := range validators.GetErrors(err) {
return false, validators.ValidationError(validationError)
}
}
url := "/cloudapi/vins/ipRelease"