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,43 +2,35 @@ package vins
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for delete NAT rule
type NATRuleDelRequest struct {
// VINS ID
// Required: true
VINSID uint64 `url:"vinsId" json:"vinsId"`
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
// ID of the rule to delete.
// Pass -1 to clear all rules at once
// Required: true
RuleID uint64 `url:"ruleId" json:"ruleId"`
RuleID uint64 `url:"ruleId" json:"ruleId" validate:"required"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
func (vrq NATRuleDelRequest) validate() error {
if vrq.VINSID == 0 {
return errors.New("validation-error: field VINSID must be set")
}
if vrq.RuleID == 0 {
return errors.New("validation-error: field RuleID must be set")
}
return nil
}
// NATRuleDel delete NAT (port forwarding) rule on VINS
func (v VINS) NATRuleDel(ctx context.Context, req NATRuleDelRequest) (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 := "/cloudbroker/vins/natRuleDel"