v1.3.0
This commit is contained in:
@@ -3,30 +3,25 @@ package vins
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for get audits
|
||||
type AuditsRequest struct {
|
||||
// ID of the VINS
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||
}
|
||||
|
||||
func (vrq AuditsRequest) validate() error {
|
||||
if vrq.VINSID == 0 {
|
||||
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
// Audits gets audit records for the specified VINS object
|
||||
func (v VINS) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return nil, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/audits"
|
||||
|
||||
@@ -2,20 +2,21 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for create VINS in account
|
||||
type CreateInAccountRequest struct {
|
||||
// VINS name
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name"`
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// ID of account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId"`
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// Grid ID
|
||||
// Required: false
|
||||
@@ -34,22 +35,13 @@ type CreateInAccountRequest struct {
|
||||
PreReservationsNum uint64 `url:"preReservationsNum,omitempty" json:"preReservationsNum,omitempty"`
|
||||
}
|
||||
|
||||
func (vrq CreateInAccountRequest) validate() error {
|
||||
if vrq.Name == "" {
|
||||
return errors.New("validation-error: field Name can not be empty")
|
||||
}
|
||||
if vrq.AccountID == 0 {
|
||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CreateInAccount creates VINS in account level
|
||||
func (v VINS) CreateInAccount(ctx context.Context, req CreateInAccountRequest) (uint64, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return 0, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/createInAccount"
|
||||
|
||||
@@ -2,24 +2,25 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for create VINS in resource group
|
||||
type CreateInRGRequest struct {
|
||||
// VINS name
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name"`
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// Resource group ID
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId"`
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
|
||||
// Private network IP CIDR
|
||||
// Required: false
|
||||
IPCIDR string `url:"ipcidr,omitempty" json:"ipcidr,omitempty"`
|
||||
IPCIDR string `url:"ipcidr,omitempty" json:"ipcidr,omitempty" validate:"required"`
|
||||
|
||||
// External network ID
|
||||
// Required: false
|
||||
@@ -38,22 +39,13 @@ type CreateInRGRequest struct {
|
||||
PreReservationsNum uint `url:"preReservationsNum,omitempty" json:"preReservationsNum,omitempty"`
|
||||
}
|
||||
|
||||
func (vrq CreateInRGRequest) validate() error {
|
||||
if vrq.Name == "" {
|
||||
return errors.New("validation-error: field Name can not be empty")
|
||||
}
|
||||
if vrq.RGID == 0 {
|
||||
return errors.New("validation-error: field RGID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CreateInRG creates VINS in resource group level
|
||||
func (v VINS) CreateInRG(ctx context.Context, req CreateInRGRequest) (uint64, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return 0, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/createInRG"
|
||||
|
||||
@@ -2,16 +2,17 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for delete VINS
|
||||
type DeleteRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
|
||||
// Set to True if you want force delete non-empty VINS.
|
||||
// Primarily, VINS is considered non-empty if it has virtual machines connected to it,
|
||||
@@ -26,19 +27,13 @@ type DeleteRequest struct {
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
}
|
||||
|
||||
func (vrq DeleteRequest) validate() error {
|
||||
if vrq.VINSID == 0 {
|
||||
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete deletes VINS
|
||||
func (v VINS) Delete(ctx context.Context, req DeleteRequest) (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/delete"
|
||||
|
||||
@@ -2,31 +2,26 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for disable/enable VINS
|
||||
type DisableEnableRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||
}
|
||||
|
||||
func (vrq DisableEnableRequest) validate() error {
|
||||
if vrq.VINSID == 0 {
|
||||
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
// Disable disables VINS
|
||||
func (v VINS) Disable(ctx context.Context, req DisableEnableRequest) (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/disable"
|
||||
@@ -47,9 +42,11 @@ func (v VINS) Disable(ctx context.Context, req DisableEnableRequest) (bool, erro
|
||||
|
||||
// Enable enables VINS
|
||||
func (v VINS) Enable(ctx context.Context, req DisableEnableRequest) (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/enable"
|
||||
|
||||
@@ -2,16 +2,17 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for connect external network
|
||||
type ExtNetConnectRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
|
||||
// External network ID
|
||||
// Required: false
|
||||
@@ -22,19 +23,13 @@ type ExtNetConnectRequest struct {
|
||||
IP string `url:"ip,omitempty" json:"ip,omitempty"`
|
||||
}
|
||||
|
||||
func (vrq ExtNetConnectRequest) validate() error {
|
||||
if vrq.VINSID == 0 {
|
||||
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ExtNetConnect connect VINS to external network
|
||||
func (v VINS) ExtNetConnect(ctx context.Context, req ExtNetConnectRequest) (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/extNetConnect"
|
||||
|
||||
@@ -2,31 +2,26 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for disconnect VINS from external network
|
||||
type ExtNetDisconnectRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||
}
|
||||
|
||||
func (vrq ExtNetDisconnectRequest) validate() error {
|
||||
if vrq.VINSID == 0 {
|
||||
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
// ExtNetDisconnect disconnect VINS from external network
|
||||
func (v VINS) ExtNetDisconnect(ctx context.Context, req ExtNetDisconnectRequest) (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/extNetDisconnect"
|
||||
|
||||
@@ -3,30 +3,25 @@ package vins
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for get list VINS external network connections
|
||||
type ExtNetListRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||
}
|
||||
|
||||
func (vrq ExtNetListRequest) validate() error {
|
||||
if vrq.VINSID == 0 {
|
||||
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
// ExtNetList show list of VINS external network connections
|
||||
func (v VINS) ExtNetList(ctx context.Context, req ExtNetListRequest) (ListExtNets, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return nil, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/extNetList"
|
||||
|
||||
@@ -3,30 +3,25 @@ package vins
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for get information about VINS
|
||||
type GetRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||
}
|
||||
|
||||
func (vrq GetRequest) validate() error {
|
||||
if vrq.VINSID == 0 {
|
||||
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
// Get gets information about VINS by ID
|
||||
func (v VINS) Get(ctx context.Context, req GetRequest) (*RecordVINS, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return nil, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/get"
|
||||
|
||||
@@ -3,30 +3,25 @@ package vins
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for DHCP IP
|
||||
type IPListRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||
}
|
||||
|
||||
func (vrq IPListRequest) validate() error {
|
||||
if vrq.VINSID == 0 {
|
||||
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
// IPList show DHCP IP reservations on VINS
|
||||
func (v VINS) IPList(ctx context.Context, req IPListRequest) (ListIPs, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return nil, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/ipList"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -2,7 +2,6 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
@@ -12,7 +11,7 @@ import (
|
||||
type IPReserveRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
|
||||
// Type of the reservation
|
||||
// Should be one of:
|
||||
@@ -20,7 +19,7 @@ type IPReserveRequest struct {
|
||||
// - VIP
|
||||
// - EXCLUDE
|
||||
// Required: true
|
||||
Type string `url:"type" json:"type"`
|
||||
Type string `url:"type" json:"type" validate:"vinsType"`
|
||||
|
||||
// IP address to use. Non-empty string is required for type "EXCLUDE".
|
||||
// Ignored for types "DHCP" and "VIP".
|
||||
@@ -39,26 +38,13 @@ type IPReserveRequest struct {
|
||||
ComputeID uint64 `url:"computeId,omitempty" json:"computeId,omitempty"`
|
||||
}
|
||||
|
||||
func (vrq IPReserveRequest) validate() error {
|
||||
if vrq.VINSID == 0 {
|
||||
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
|
||||
}
|
||||
if vrq.Type == "" {
|
||||
return errors.New("validation-error: field Type can not be empty")
|
||||
}
|
||||
validate := validators.StringInSlice(vrq.Type, []string{"DHCP", "VIP", "EXCLUDED"})
|
||||
if !validate {
|
||||
return errors.New("'type' should be 'DHCP', 'VIP' or 'EXCLUDED'")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// IPReserve creates reservation on ViNS DHCP
|
||||
func (v VINS) IPReserve(ctx context.Context, req IPReserveRequest) (string, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return "", validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/ipReserve"
|
||||
|
||||
@@ -2,28 +2,29 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for create NAT rules
|
||||
type NATRuleAddRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
|
||||
// Internal IP address to apply this rule to
|
||||
// Required: true
|
||||
IntIP string `url:"intIp" json:"intIp"`
|
||||
IntIP string `url:"intIp" json:"intIp" validate:"required"`
|
||||
|
||||
// Internal IP port number to use for this rule
|
||||
// Required: true
|
||||
IntPort uint `url:"intPort" json:"intPort"`
|
||||
IntPort uint `url:"intPort" json:"intPort" validate:"required"`
|
||||
|
||||
// External IP start port to use for this rule
|
||||
// Required: true
|
||||
ExtPortStart uint `url:"extPortStart" json:"extPortStart"`
|
||||
ExtPortStart uint `url:"extPortStart" json:"extPortStart" validate:"required"`
|
||||
|
||||
// External IP end port to use for this rule
|
||||
// Required: false
|
||||
@@ -34,31 +35,16 @@ type NATRuleAddRequest struct {
|
||||
// - "tcp"
|
||||
// - "udp"
|
||||
// Required: false
|
||||
Proto string `url:"proto,omitempty" json:"proto,omitempty"`
|
||||
}
|
||||
|
||||
func (vrq NATRuleAddRequest) validate() error {
|
||||
if vrq.VINSID == 0 {
|
||||
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
|
||||
}
|
||||
if vrq.IntIP == "" {
|
||||
return errors.New("validation-error: field IntIP can not be empty")
|
||||
}
|
||||
if vrq.IntPort == 0 {
|
||||
return errors.New("validation-error: field IntPort can not be empty or equal to 0")
|
||||
}
|
||||
if vrq.ExtPortStart == 0 {
|
||||
return errors.New("validation-error: field ExtPortStart can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
Proto string `url:"proto,omitempty" json:"proto,omitempty" validate:"omitempty,proto"`
|
||||
}
|
||||
|
||||
// NATRuleAdd create NAT (port forwarding) rule on VINS
|
||||
func (v VINS) NATRuleAdd(ctx context.Context, req NATRuleAddRequest) (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/natRuleAdd"
|
||||
|
||||
@@ -2,39 +2,31 @@ 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"`
|
||||
}
|
||||
|
||||
func (vrq NATRuleDelRequest) validate() error {
|
||||
if vrq.VINSID == 0 {
|
||||
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
|
||||
}
|
||||
if vrq.RuleID == 0 {
|
||||
return errors.New("validation-error: field RuleID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
RuleID uint64 `url:"ruleId" json:"ruleId" validate:"required"`
|
||||
}
|
||||
|
||||
// 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 := "/cloudapi/vins/natRuleDel"
|
||||
|
||||
@@ -3,30 +3,25 @@ package vins
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for get list of NAT rules
|
||||
type NATRuleListRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||
}
|
||||
|
||||
func (vrq NATRuleListRequest) validate() error {
|
||||
if vrq.VINSID == 0 {
|
||||
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
// NATRuleList gets list of NAT (port forwarding) rules
|
||||
func (v VINS) NATRuleList(ctx context.Context, req NATRuleListRequest) (ListNATRules, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return nil, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/vins/natRuleList"
|
||||
|
||||
@@ -2,31 +2,26 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for restore
|
||||
type RestoreRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||
}
|
||||
|
||||
func (vrq RestoreRequest) validate() error {
|
||||
if vrq.VINSID == 0 {
|
||||
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
// Restore restores VINS from recycle bin
|
||||
func (v VINS) Restore(ctx context.Context, req RestoreRequest) (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/restore"
|
||||
|
||||
@@ -2,31 +2,26 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for redeploy VNFDevs
|
||||
type VNFDevRedeployRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||
}
|
||||
|
||||
func (vrq VNFDevRedeployRequest) validate() error {
|
||||
if vrq.VINSID == 0 {
|
||||
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
// VNFDevRedeploy redeploy VINS VNFDevs
|
||||
func (v VINS) VNFDevRedeploy(ctx context.Context, req VNFDevRedeployRequest) (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/vnfdevRedeploy"
|
||||
|
||||
@@ -2,31 +2,26 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for reboot VINSes primary VNF device
|
||||
type VNFDevRestartRequest struct {
|
||||
// VINS ID
|
||||
// Required: true
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId"`
|
||||
}
|
||||
|
||||
func (vrq VNFDevRestartRequest) validate() error {
|
||||
if vrq.VINSID == 0 {
|
||||
return errors.New("validation-error: field VINSID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
||||
}
|
||||
|
||||
// VNFDevRestart reboot VINSes primary VNF device
|
||||
func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (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/vnfdevRestart"
|
||||
|
||||
Reference in New Issue
Block a user