v14.3.0
This commit is contained in:
63
pkg/sdn/logicalports/exclude_firewall.go
Normal file
63
pkg/sdn/logicalports/exclude_firewall.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||
)
|
||||
|
||||
type LogicalPortsForExcludeFromFirewall struct {
|
||||
// Exclude IP Addresses
|
||||
// Required: true
|
||||
ExcludeIPAddresses bool `url:"exclude_ip_addresses" json:"exclude_ip_addresses" validate:"required"`
|
||||
|
||||
// ID
|
||||
// Required: true
|
||||
ID string `url:"id" json:"id" validate:"required"`
|
||||
|
||||
// Version ID
|
||||
// Required: true
|
||||
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||
}
|
||||
|
||||
// ExcludeFirewallRequest struct to exclude firewall for logical port
|
||||
type ExcludeFirewallRequest struct {
|
||||
// Access Group ID
|
||||
// Required: true
|
||||
AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
|
||||
|
||||
// Logical Ports For Exclude From Firewall
|
||||
// Required: true
|
||||
LogicalPortsForExcludeFromFirewall []LogicalPortsForExcludeFromFirewall `json:"logical_ports_for_exclude_from_firewall" validate:"required,dive"`
|
||||
|
||||
// Exclusion Reason
|
||||
// Required: false
|
||||
ExclusionReason string `url:"exclusion_reason,omitempty" json:"exclusion_reason,omitempty"`
|
||||
}
|
||||
|
||||
// ExcludeFirewall excludes firewall from a logical port
|
||||
func (lp LogicalPorts) ExcludeFirewall(ctx context.Context, req ExcludeFirewallRequest) (*RecordVersion, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/logical_port/exclude_firewall"
|
||||
|
||||
res, err := lp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := RecordVersion{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
Reference in New Issue
Block a user