This commit is contained in:
stSolo
2022-12-22 17:56:47 +03:00
parent 8712561853
commit d4b1ab7133
672 changed files with 28509 additions and 4419 deletions

View File

@@ -0,0 +1,57 @@
package vins
import (
"context"
"errors"
"net/http"
"strconv"
)
// Request struct for delete NAT rule
type NATRuleDelRequest struct {
// VINS ID
// Required: true
VINSID uint64 `url:"vinsId"`
// ID of the rule to delete.
// Pass -1 to clear all rules at once
// Required: true
RuleID uint64 `url:"ruleId"`
// Reason for action
// Required: false
Reason string `url:"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()
if err != nil {
return false, err
}
url := "/cloudbroker/vins/natRuleDel"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}