v12.8.0
This commit is contained in:
57
pkg/sdn/routers/gwport/create.go
Normal file
57
pkg/sdn/routers/gwport/create.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package gwport
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// CreateRequest struct to create gateway port
|
||||
type CreateRequest struct {
|
||||
// ID of router
|
||||
// Required: true
|
||||
RouterID string `url:"router_id" json:"router_id" validate:"required"`
|
||||
|
||||
// ID of version
|
||||
// Required: true
|
||||
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||
|
||||
// Detailed description of the external network
|
||||
// Required: true
|
||||
Description string `url:"description" json:"description" validate:"required"`
|
||||
|
||||
// External network port ID
|
||||
// Required: true
|
||||
ExternalNetworkPortID string `url:"external_network_port_id" json:"external_network_port_id" validate:"required"`
|
||||
|
||||
// Whether is enabled
|
||||
// Required: true
|
||||
Enabled bool `url:"snat_enabled" json:"snat_enabled"`
|
||||
}
|
||||
|
||||
// Create creates a gateway port
|
||||
func (i GWPort) Create(ctx context.Context, req CreateRequest) (*GatewayPort, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/router/gateway_port/create"
|
||||
|
||||
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := GatewayPort{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
46
pkg/sdn/routers/gwport/delete.go
Normal file
46
pkg/sdn/routers/gwport/delete.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package gwport
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteRequest struct for delete router
|
||||
type DeleteRequest struct {
|
||||
// ID of router
|
||||
// Required: true
|
||||
RouterID string `url:"router_id" json:"router_id" validate:"required"`
|
||||
|
||||
// ID of gateway port
|
||||
// Required: true
|
||||
GatewayPortID string `url:"gateway_port_id" json:"gateway_port_id" validate:"required"`
|
||||
|
||||
// ID of version
|
||||
// Required: true
|
||||
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||
|
||||
// Force delete
|
||||
// Required: false
|
||||
Force interface{} `url:"force,omitempty" json:"force,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
// Delete delete a router
|
||||
func (e GWPort) Delete(ctx context.Context, req DeleteRequest) error {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/router/gateway_port/delete"
|
||||
|
||||
_, err = e.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
19
pkg/sdn/routers/gwport/gateaway_port.go
Normal file
19
pkg/sdn/routers/gwport/gateaway_port.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package gwport
|
||||
|
||||
// API Actor API for managing SDN routers gateway port
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creating request to routers gateway port
|
||||
type GWPort struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for routers gateway port endpoints
|
||||
func New(client interfaces.Caller) *GWPort {
|
||||
return &GWPort{
|
||||
client,
|
||||
}
|
||||
}
|
||||
51
pkg/sdn/routers/gwport/get.go
Normal file
51
pkg/sdn/routers/gwport/get.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package gwport
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get information about gateway port
|
||||
type GetRequest struct {
|
||||
// Router ID
|
||||
// Required: true
|
||||
RouterID string `url:"router_id" json:"router_id" validate:"required"`
|
||||
|
||||
// Gateway port ID
|
||||
// Required: true
|
||||
GatewayPortID string `url:"gateway_port_id" json:"gateway_port_id" validate:"required"`
|
||||
}
|
||||
|
||||
// Get gets gateway port details as a GatewayPort struct
|
||||
func (a GWPort) Get(ctx context.Context, req GetRequest) (*GatewayPort, error) {
|
||||
res, err := a.GetRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := GatewayPort{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
|
||||
}
|
||||
|
||||
// GetRaw gets gateway port details as an array of bytes
|
||||
func (a GWPort) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/router/gateway_port/get"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
return res, err
|
||||
}
|
||||
47
pkg/sdn/routers/gwport/list.go
Normal file
47
pkg/sdn/routers/gwport/list.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package gwport
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of gateway ports
|
||||
type ListRequest struct {
|
||||
// Router ID
|
||||
// Required: true
|
||||
RouterID string `url:"router_id" json:"router_id" validate:"required"`
|
||||
}
|
||||
|
||||
// List gets gateway port list
|
||||
func (a GWPort) List(ctx context.Context, req ListRequest) (GatewayPortsList, error) {
|
||||
res, err := a.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := []GatewayPort{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return info, nil
|
||||
|
||||
}
|
||||
|
||||
// GetRaw gets gateway port list as an array of bytes
|
||||
func (a GWPort) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/router/gateway_port/list"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
return res, err
|
||||
}
|
||||
481
pkg/sdn/routers/gwport/models.go
Normal file
481
pkg/sdn/routers/gwport/models.go
Normal file
@@ -0,0 +1,481 @@
|
||||
package gwport
|
||||
|
||||
// List of ports
|
||||
type GatewayPortsList []GatewayPort
|
||||
|
||||
// Gateway port information
|
||||
type GatewayPort struct {
|
||||
// Created time
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// External L4 port maximum
|
||||
ExternalL4PortMax int `json:"external_l4_port_max"`
|
||||
|
||||
// External L4 port minimum
|
||||
ExternalL4PortMin int `json:"external_l4_port_min"`
|
||||
|
||||
// External network port
|
||||
ExternalNetworkPort ExternalNetworkPort `json:"external_network_port"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// SNAT enabled flag
|
||||
SNATEnabled bool `json:"snat_enabled"`
|
||||
|
||||
// Status information
|
||||
Status Status `json:"status"`
|
||||
|
||||
// Updated time
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// External network port information
|
||||
type ExternalNetworkPort struct {
|
||||
// Access group ID
|
||||
AccessGroupID string `json:"access_group_id"`
|
||||
|
||||
// Access group name
|
||||
AccessGroupName string `json:"access_group_name"`
|
||||
|
||||
// Comment
|
||||
Comment string `json:"comment"`
|
||||
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
// Enabled flag
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// IPv4 address
|
||||
IPv4 string `json:"ipv4"`
|
||||
|
||||
// IPv6 address
|
||||
IPv6 string `json:"ipv6"`
|
||||
|
||||
// IPv6 configuration
|
||||
IPv6Config IPv6Config `json:"ipv6_config"`
|
||||
|
||||
// MAC address
|
||||
MAC string `json:"mac"`
|
||||
|
||||
// Router gateway port
|
||||
RouterGatewayPort RouterGatewayPort `json:"router_gateway_port"`
|
||||
|
||||
// Floating IP
|
||||
FloatingIP FloatingIP `json:"floating_ip"`
|
||||
}
|
||||
|
||||
// IPv6 configuration information
|
||||
type IPv6Config struct {
|
||||
// Address mode
|
||||
AddressMode string `json:"address_mode"`
|
||||
|
||||
// Enable periodic RA flag
|
||||
EnablePeriodicRA bool `json:"enable_periodic_ra"`
|
||||
|
||||
// Interval RA
|
||||
IntervalRA int `json:"interval_ra"`
|
||||
|
||||
// Router preference
|
||||
RouterPreference string `json:"router_preference"`
|
||||
}
|
||||
|
||||
// Router gateway port information
|
||||
type RouterGatewayPort struct {
|
||||
// Created time
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Router display name
|
||||
RouterDisplayName string `json:"router_display_name"`
|
||||
|
||||
// Router ID
|
||||
RouterID string `json:"router_id"`
|
||||
|
||||
// SNAT enabled flag
|
||||
SNATEnabled bool `json:"snat_enabled"`
|
||||
|
||||
// Updated time
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
// Floating IP information
|
||||
type FloatingIP struct {
|
||||
// Access group ID
|
||||
AccessGroupID string `json:"access_group_id"`
|
||||
|
||||
// Access group name
|
||||
AccessGroupName string `json:"access_group_name"`
|
||||
|
||||
// Created time
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// External network port
|
||||
ExternalNetworkPort string `json:"external_network_port"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Logical port
|
||||
LogicalPort LogicalPort `json:"logical_port"`
|
||||
|
||||
// Router
|
||||
Router string `json:"router"`
|
||||
|
||||
// Updated time
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// Logical port information
|
||||
type LogicalPort struct {
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Access group ID
|
||||
AccessGroupID string `json:"access_group_id"`
|
||||
|
||||
// Access group name
|
||||
AccessGroupName string `json:"access_group_name"`
|
||||
|
||||
// Adapter MAC
|
||||
AdapterMAC string `json:"adapter_mac"`
|
||||
|
||||
// Address detection flag
|
||||
AddressDetection bool `json:"address_detection"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// Created time
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
// Enabled flag
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// External network ID
|
||||
ExternalNetworkID string `json:"external_network_id"`
|
||||
|
||||
// Hypervisor
|
||||
Hypervisor string `json:"hypervisor"`
|
||||
|
||||
// Hypervisor display name
|
||||
HypervisorDisplayName string `json:"hypervisor_display_name"`
|
||||
|
||||
// Live migration target HV
|
||||
LiveMigrationTargetHV string `json:"live_migration_target_hv"`
|
||||
|
||||
// Status information
|
||||
Status Status `json:"status"`
|
||||
|
||||
// Bindings information
|
||||
Bindings Bindings `json:"bindings"`
|
||||
|
||||
// Unique identifier
|
||||
UniqueIdentifier string `json:"unique_identifier"`
|
||||
|
||||
// Updated time
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// Status information
|
||||
type Status struct {
|
||||
// Common status
|
||||
Common string `json:"common"`
|
||||
|
||||
// Hypervisors status list
|
||||
Hypervisors []HypervisorStatus `json:"hypervisors"`
|
||||
}
|
||||
|
||||
// Hypervisor status information
|
||||
type HypervisorStatus struct {
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
// Hypervisor status
|
||||
HypervisorStatus string `json:"hypervisor_status"`
|
||||
|
||||
// Synced at time
|
||||
SyncedAt string `json:"synced_at"`
|
||||
}
|
||||
|
||||
// Bindings information
|
||||
type Bindings struct {
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Segment display name
|
||||
SegmentDisplayName string `json:"segment_display_name"`
|
||||
|
||||
// Segment ID
|
||||
SegmentID string `json:"segment_id"`
|
||||
|
||||
// Port security flag
|
||||
PortSecurity bool `json:"port_security"`
|
||||
|
||||
// Address detection flag
|
||||
AddressDetection bool `json:"address_detection"`
|
||||
|
||||
// Is excluded from firewall flag
|
||||
IsExcludedFromFirewall bool `json:"is_excluded_from_firewall"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
|
||||
// Created time
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Updated time
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Logical port addresses list
|
||||
LogicalPortAddresses []LogicalPortAddress `json:"logical_port_addresses"`
|
||||
}
|
||||
|
||||
// Logical port address information
|
||||
type LogicalPortAddress struct {
|
||||
// IP address
|
||||
IP string `json:"ip"`
|
||||
|
||||
// IP type
|
||||
IPType string `json:"ip_type"`
|
||||
|
||||
// Is discovered flag
|
||||
IsDiscovered bool `json:"is_discovered"`
|
||||
|
||||
// Is primary flag
|
||||
IsPrimary bool `json:"is_primary"`
|
||||
|
||||
// MAC address
|
||||
MAC string `json:"mac"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Logical port ID
|
||||
LogicalPortID string `json:"logical_port_id"`
|
||||
|
||||
// Assigned at time
|
||||
AssignedAt string `json:"assigned_at"`
|
||||
}
|
||||
|
||||
// Policy information
|
||||
type Policy struct {
|
||||
// Action
|
||||
Action string `json:"action"`
|
||||
|
||||
// Created time
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
// Enabled flag
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Match criteria
|
||||
Match map[string]interface{} `json:"match"`
|
||||
|
||||
// Next IPv4 addresses list
|
||||
NextIPv4Address []string `json:"next_ipv4_address"`
|
||||
|
||||
// Next IPv6 addresses list
|
||||
NextIPv6Address []string `json:"next_ipv6_address"`
|
||||
|
||||
// Priority
|
||||
Priority int `json:"priority"`
|
||||
|
||||
// Updated time
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// Port information
|
||||
type Port struct {
|
||||
// Created time
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// Enabled flag
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// IPv4 address
|
||||
IPv4Address string `json:"ipv4_address"`
|
||||
|
||||
// IPv6 address
|
||||
IPv6Address string `json:"ipv6_address"`
|
||||
|
||||
// IPv6 configuration
|
||||
IPv6Config IPv6Config `json:"ipv6_config"`
|
||||
|
||||
// MAC address
|
||||
MAC string `json:"mac"`
|
||||
|
||||
// Segment information
|
||||
Segment Segment `json:"segment"`
|
||||
|
||||
// Segment ID
|
||||
SegmentID string `json:"segment_id"`
|
||||
|
||||
// Status information
|
||||
Status Status `json:"status"`
|
||||
|
||||
// Updated time
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// Segment information
|
||||
type Segment struct {
|
||||
// Access group ID
|
||||
AccessGroupID string `json:"access_group_id"`
|
||||
|
||||
// Access group name
|
||||
AccessGroupName string `json:"access_group_name"`
|
||||
|
||||
// Created time
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// DHCPv4 configuration
|
||||
DHCPv4 DHCPv4 `json:"dhcp_v4"`
|
||||
|
||||
// DHCPv6 configuration
|
||||
DHCPv6 DHCPv6 `json:"dhcp_v6"`
|
||||
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
// Enabled flag
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Logical ports info list
|
||||
LogicalPortsInfo []LogicalPortInfo `json:"logical_ports_info"`
|
||||
|
||||
// Routers info list
|
||||
RoutersInfo []RouterInfo `json:"routers_info"`
|
||||
|
||||
// Status information
|
||||
Status Status `json:"status"`
|
||||
|
||||
// IPv4 subnet
|
||||
SubnetV4 string `json:"subnet_v4"`
|
||||
|
||||
// IPv6 subnet
|
||||
SubnetV6 string `json:"subnet_v6"`
|
||||
|
||||
// Updated time
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// DHCPv4 configuration
|
||||
type DHCPv4 struct {
|
||||
// DNS servers list
|
||||
DNS []string `json:"dns"`
|
||||
|
||||
// Excluded address ranges list
|
||||
ExcludedAddressRanges []string `json:"excluded_address_ranges"`
|
||||
|
||||
// Gateway address
|
||||
Gateway string `json:"gateway"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Lease time
|
||||
LeaseTime int `json:"lease_time"`
|
||||
|
||||
// Server IP
|
||||
ServerIP string `json:"server_ip"`
|
||||
|
||||
// Server MAC
|
||||
ServerMAC string `json:"server_mac"`
|
||||
|
||||
// Enabled flag
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
// DHCPv6 configuration
|
||||
type DHCPv6 struct {
|
||||
// Address prefix
|
||||
AddressPrefix string `json:"address_prefix"`
|
||||
|
||||
// DNS servers list
|
||||
DNS []string `json:"dns"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Lease time
|
||||
LeaseTime int `json:"lease_time"`
|
||||
|
||||
// Server MAC
|
||||
ServerMAC string `json:"server_mac"`
|
||||
|
||||
// Enabled flag
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
// Logical port info
|
||||
type LogicalPortInfo struct {
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
// Router info
|
||||
type RouterInfo struct {
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
}
|
||||
61
pkg/sdn/routers/gwport/update.go
Normal file
61
pkg/sdn/routers/gwport/update.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package gwport
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// UpdateRequest struct to update gateway port
|
||||
type UpdateRequest struct {
|
||||
// ID of router
|
||||
// Required: true
|
||||
RouterID string `url:"router_id" json:"router_id" validate:"required"`
|
||||
|
||||
// ID of gateway port
|
||||
// Required: true
|
||||
GatewayPortID string `url:"gateway_port_id" json:"gateway_port_id" validate:"required"`
|
||||
|
||||
// ID of version
|
||||
// Required: true
|
||||
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||
|
||||
// Detailed description of the external network
|
||||
// Required: true
|
||||
Description string `url:"description" json:"description" validate:"required"`
|
||||
|
||||
// External network port ID
|
||||
// Required: true
|
||||
ExternalNetworkPortID string `url:"external_network_port_id" json:"external_network_port_id" validate:"required"`
|
||||
|
||||
// Whether is enabled
|
||||
// Required: true
|
||||
Enabled bool `url:"snat_enabled" json:"snat_enabled"`
|
||||
}
|
||||
|
||||
// Updated update a gateway port
|
||||
func (i GWPort) Update(ctx context.Context, req UpdateRequest) (*GatewayPort, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/router/gateway_port/update"
|
||||
|
||||
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPut, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := GatewayPort{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
Reference in New Issue
Block a user