git test
This commit is contained in:
@@ -1,110 +0,0 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||||
)
|
||||
|
||||
// Label struct
|
||||
type CreateLabels struct {
|
||||
VMID string `url:"vm_id,omitempty" json:"vm_id,omitempty"`
|
||||
VMName string `url:"vm_name,omitempty" json:"vm_name,omitempty"`
|
||||
}
|
||||
|
||||
// CreateRequest struct to create logical port
|
||||
type CreateRequest struct {
|
||||
// ID of the access group
|
||||
// Required: true
|
||||
AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
|
||||
|
||||
// Description
|
||||
// Required: true
|
||||
Description string `url:"description" json:"description" validate:"required"`
|
||||
|
||||
// Display name
|
||||
// Required: true
|
||||
DisplayName string `url:"display_name" json:"display_name" validate:"required"`
|
||||
|
||||
// Enabled. True or False
|
||||
// Required: true
|
||||
Enabled interface{} `url:"enabled" json:"enabled" validate:"required,isBool"`
|
||||
|
||||
// Hypervisor
|
||||
// Required: true
|
||||
Hypervisor string `url:"hypervisor" json:"hypervisor" validate:"required"`
|
||||
|
||||
// Port security. True or False
|
||||
// Required: true
|
||||
PortSecurity interface{} `url:"port_security" json:"port_security" validate:"required,isBool"`
|
||||
|
||||
// Segment ID
|
||||
// Required: true
|
||||
SegmentID string `url:"segment_id" json:"segment_id" validate:"required"`
|
||||
|
||||
// Adapter MAC
|
||||
// Required: false
|
||||
AdapterMAC string `url:"adapter_mac,omitempty" json:"adapter_mac,omitempty"`
|
||||
|
||||
// Unique identifier
|
||||
// Required: false
|
||||
UniqueIdentifier string `url:"unique_identifier,omitempty" json:"unique_identifier,omitempty"`
|
||||
|
||||
// Logical port addresses
|
||||
// Required: false
|
||||
LogicalPortAddresses []LogicalPortAddress `url:"logical_port_addresses,omitempty" json:"logical_port_addresses,omitempty" validate:"dive"`
|
||||
|
||||
// Labels
|
||||
// Required: false
|
||||
Labels CreateLabels `url:"labels,omitempty" json:"labels,omitempty"`
|
||||
}
|
||||
|
||||
// LogicalPortAddressRequest struct representing logical port address
|
||||
type LogicalPortAddressRequest struct {
|
||||
// IP address
|
||||
// Required: true
|
||||
IP string `url:"ip" json:"ip" validate:"required"`
|
||||
|
||||
// IP type
|
||||
// Required: true
|
||||
IPType string `url:"ip_type" json:"ip_type" validate:"required,oneof=IPv4 IPv6"`
|
||||
|
||||
// Is primary. True or False
|
||||
// Required: true
|
||||
IsPrimary interface{} `url:"is_primary" json:"is_primary" validate:"required,isBool"`
|
||||
|
||||
// MAC address
|
||||
// Required: false
|
||||
MAC string `url:"mac,omitempty" json:"mac,omitempty"`
|
||||
|
||||
// Is discovered. True or False
|
||||
// Required: true
|
||||
IsDiscovered bool `url:"is_discovered" json:"is_discovered" validate:"required"`
|
||||
}
|
||||
|
||||
// Create creates a logical port
|
||||
func (l LogicalPorts) Create(ctx context.Context, req CreateRequest) (*LogicalPort, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/logical_port/create"
|
||||
|
||||
res, err := l.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := LogicalPort{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||||
)
|
||||
|
||||
type CreateBatchLogicalPortAddress struct {
|
||||
// IP
|
||||
// Required: true
|
||||
IP string `url:"ip" json:"ip" validate:"required"`
|
||||
|
||||
// IP Type
|
||||
// Required: true
|
||||
IPType string `url:"ip_type" json:"ip_type" validate:"required"`
|
||||
|
||||
// Is Discovered
|
||||
// Required: true
|
||||
IsDiscovered bool `url:"is_discovered" json:"is_discovered" validate:"required"`
|
||||
|
||||
// Is Primary
|
||||
// Required: true
|
||||
IsPrimary bool `url:"is_primary" json:"is_primary" validate:"required"`
|
||||
|
||||
// MAC
|
||||
// Required: false
|
||||
MAC string `url:"mac,omitempty" json:"mac,omitempty"`
|
||||
}
|
||||
|
||||
type CreateBatchBindings struct {
|
||||
// Address Detection
|
||||
// Required: true
|
||||
AddressDetection bool `url:"address_detection" json:"address_detection" validate:"required"`
|
||||
|
||||
// Logical Port Address
|
||||
// Required: true
|
||||
LogicalPortAddresses []CreateBatchLogicalPortAddress `url:"logical_port_addresses" json:"logical_port_addresses" validate:"required,dive"`
|
||||
|
||||
// Port Security
|
||||
// Required: true
|
||||
PortSecurity bool `url:"port_security" json:"port_security" validate:"required"`
|
||||
|
||||
// Segment ID
|
||||
// Required: true
|
||||
SegmentID string `url:"segment_id" json:"segment_id" validate:"required"`
|
||||
}
|
||||
|
||||
type CreateBatchLabels struct {
|
||||
// VM ID
|
||||
// Required: false
|
||||
VMID string `url:"vm_id,omitempty" json:"vm_id,omitempty"`
|
||||
|
||||
// VM Name
|
||||
// Required: false
|
||||
VMName string `url:"vm_name,omitempty" json:"vm_name,omitempty"`
|
||||
}
|
||||
|
||||
type NetObjectGroups struct {
|
||||
// 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"`
|
||||
}
|
||||
|
||||
type Ports struct {
|
||||
// Adapter MAC
|
||||
// Required: false
|
||||
AdapterMAC string `url:"adapter_mac,omitempty" json:"adapter_mac,omitempty"`
|
||||
|
||||
// Bindings
|
||||
// Required: true
|
||||
Bindings CreateBatchBindings `url:"bindings" json:"bindings" validate:"required"`
|
||||
|
||||
// Description
|
||||
// Required: true
|
||||
Description string `url:"description" json:"description" validate:"required"`
|
||||
|
||||
// Display Name
|
||||
// Required: true
|
||||
DisplayName string `url:"display_name" json:"display_name" validate:"required"`
|
||||
|
||||
// Enabled
|
||||
// Required: true
|
||||
Enabled bool `url:"enabled" json:"enabled" validate:"required"`
|
||||
|
||||
// Hypervisor
|
||||
// Required: true
|
||||
Hypervisor string `url:"hypervisor" json:"hypervisor" validate:"required"`
|
||||
|
||||
// Net Object Groups
|
||||
// Required: false
|
||||
NetObjectGroups []NetObjectGroups `json:"net_object_groups" validate:"required,dive"`
|
||||
|
||||
// Labels
|
||||
// Required: false
|
||||
Labels []CreateBatchLabels `url:"labels,omitempty" json:"labels,omitempty" validate:"required,dive"`
|
||||
|
||||
// Unique Identifier
|
||||
// Required: false
|
||||
UniqueIdentifier string `url:"unique_identifier,omitempty" json:"unique_identifier,omitempty"`
|
||||
}
|
||||
|
||||
// CreateBatchRequest struct to create a batch of logical ports
|
||||
type CreateBatchRequest struct {
|
||||
// Access Group ID
|
||||
// Required: true
|
||||
AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
|
||||
|
||||
// Ports
|
||||
// Required: true
|
||||
Ports []Ports `json:"ports" validate:"required,dive"`
|
||||
}
|
||||
|
||||
// CreateBatch creates a batch of logical ports
|
||||
func (lp LogicalPorts) CreateBatch(ctx context.Context, req CreateBatchRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
url := "/sdn/logical_port/create_batch"
|
||||
|
||||
_, err = lp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteRequest struct to delete logical port
|
||||
type DeleteRequest struct {
|
||||
// Port ID
|
||||
// Required: true
|
||||
ID string `url:"logical_port_id" json:"logical_port_id" validate:"required"`
|
||||
|
||||
// Version
|
||||
// Required: true
|
||||
Version uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||
|
||||
// Force delete. True or false
|
||||
// Required: false
|
||||
Force interface{} `url:"force,omitempty" json:"force,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
// Delete a logical port
|
||||
func (i LogicalPorts) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/logical_port/delete"
|
||||
|
||||
_, err = i.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||||
)
|
||||
|
||||
type PortsInfo struct {
|
||||
// Force
|
||||
// Required: true
|
||||
Force bool `url:"force" json:"force" 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"`
|
||||
}
|
||||
|
||||
// DeleteBatchRequest struct to delete a batch of logical ports
|
||||
type DeleteBatchRequest struct {
|
||||
// Access Group ID
|
||||
// Required: true
|
||||
AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
|
||||
|
||||
// Ports Info
|
||||
// Required: true
|
||||
PortsInfo []PortsInfo `json:"ports_info" validate:"required,dive"`
|
||||
}
|
||||
|
||||
// DeleteBatch deletes a batch of logical ports
|
||||
func (lp LogicalPorts) DeleteBatch(ctx context.Context, req DeleteBatchRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
url := "/sdn/logical_port/delete_batch"
|
||||
|
||||
_, err = lp.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/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
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package logicalports
|
||||
|
||||
// FilterByID returns LogicalPortsList with specified ID.
|
||||
func (agl LogicalPortsList) FilterByID(id string) LogicalPortsList {
|
||||
predicate := func(ia LogicalPort) bool {
|
||||
return ia.ID == id
|
||||
}
|
||||
|
||||
return agl.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByName returns LogicalPortsList with specified Name.
|
||||
func (agl LogicalPortsList) FilterByName(name string) LogicalPortsList {
|
||||
predicate := func(ia LogicalPort) bool {
|
||||
return ia.DisplayName == name
|
||||
}
|
||||
|
||||
return agl.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering LogicalPortsList based on a user-specified predicate.
|
||||
func (agl LogicalPortsList) FilterFunc(predicate func(LogicalPort) bool) LogicalPortsList {
|
||||
var result LogicalPortsList
|
||||
|
||||
for _, acc := range agl.Ports {
|
||||
if predicate(acc) {
|
||||
result.Ports = append(result.Ports, acc)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FindOne returns first element.
|
||||
// If none was found, returns an empty struct.
|
||||
func (agl LogicalPortsList) FindOne() LogicalPort {
|
||||
if len(agl.Ports) == 0 {
|
||||
return LogicalPort{}
|
||||
}
|
||||
|
||||
return agl.Ports[0]
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get information about logical port
|
||||
type GetRequest struct {
|
||||
// ID a logical port
|
||||
// Required: true
|
||||
ID string `url:"logical_port_id" json:"logical_port_id" validate:"required"`
|
||||
}
|
||||
|
||||
// Get gets logical port details as a LogicalPort struct
|
||||
func (a LogicalPorts) Get(ctx context.Context, req GetRequest) (*LogicalPort, error) {
|
||||
res, err := a.GetRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := LogicalPort{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
|
||||
}
|
||||
|
||||
// GetRaw gets logical port details as an array of bytes
|
||||
func (a LogicalPorts) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/logical_port/get"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
return res, err
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||||
)
|
||||
|
||||
// GetByUniqueIdentifierRequest struct to get information about logical port
|
||||
type GetByUniqueIdentifierRequest struct {
|
||||
// ID a logical port
|
||||
// Required: true
|
||||
ID string `url:"unique_identifier" json:"unique_identifier" validate:"required"`
|
||||
}
|
||||
|
||||
// GetByUniqueIdentifier gets logical port details as a LogicalPort struct
|
||||
func (a LogicalPorts) GetByUniqueIdentifier(ctx context.Context, req GetByUniqueIdentifierRequest) (*LogicalPort, error) {
|
||||
res, err := a.GetByUniqueIdentifierRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := LogicalPort{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
|
||||
}
|
||||
|
||||
// GetByUniqueIdentifier gets logical port details as an array of bytes
|
||||
func (a LogicalPorts) GetByUniqueIdentifierRaw(ctx context.Context, req GetByUniqueIdentifierRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/logical_port/get_by_unique_identifier"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
return res, err
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package logicalports
|
||||
|
||||
// IDs gets array of IDs from LogicalPortList struct
|
||||
func (pl LogicalPortsList) IDs() []string {
|
||||
res := make([]string, 0, len(pl.Ports))
|
||||
for _, c := range pl.Ports {
|
||||
res = append(res, c.ID)
|
||||
}
|
||||
return res
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get a list of logical ports
|
||||
type ListRequest struct {
|
||||
// Find by access group ID
|
||||
// Required: false
|
||||
AccessGroupID string `url:"access_group_id,omitempty" json:"access_group_id,omitempty"`
|
||||
|
||||
// Find by segment ID
|
||||
// Required: false
|
||||
SegmentID string `url:"segment_id,omitempty" json:"segment_id,omitempty"`
|
||||
|
||||
// Find by segment display name
|
||||
// Required: false
|
||||
SegmentDisplayName string `url:"segment_display_name,omitempty" json:"segment_display_name,omitempty"`
|
||||
|
||||
// Find by external network ID
|
||||
// Required: false
|
||||
ExternalNetworkID string `url:"external_network_id,omitempty" json:"external_network_id,omitempty"`
|
||||
|
||||
// Find by unique identifier
|
||||
// Required: false
|
||||
UniqueIdentifier string `url:"unique_identifier,omitempty" json:"unique_identifier,omitempty"`
|
||||
|
||||
// Find by display name
|
||||
// Required: false
|
||||
DisplayName string `url:"display_name,omitempty" json:"display_name,omitempty"`
|
||||
|
||||
// Find by adapter MAC address
|
||||
// Required: false
|
||||
AdapterMAC string `url:"adapter_mac,omitempty" json:"adapter_mac,omitempty"`
|
||||
|
||||
// Find by hypervisor
|
||||
// Required: false
|
||||
Hypervisor string `url:"hypervisor,omitempty" json:"hypervisor,omitempty"`
|
||||
|
||||
// Find by hypervisor display name
|
||||
// Required: false
|
||||
HypervisorDisplayName string `url:"hypervisor_display_name,omitempty" json:"hypervisor_display_name,omitempty"`
|
||||
|
||||
// Find by live migration target hypervisor
|
||||
// Required: false
|
||||
LiveMigrationTargetHv string `url:"live_migration_target_hv,omitempty" json:"live_migration_target_hv,omitempty"`
|
||||
|
||||
// Find by port security status, true or false
|
||||
// Required: false
|
||||
PortSecurity interface{} `url:"port_security,omitempty" json:"port_security,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Find by address detection status, true or false
|
||||
// Required: false
|
||||
AddressDetection interface{} `url:"address_detection,omitempty" json:"address_detection,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Find by enabled status, true or false
|
||||
// Required: false
|
||||
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Creation date lower bound (inclusive)
|
||||
// Required: false
|
||||
CreatedFrom string `url:"created_from,omitempty" json:"created_from,omitempty"`
|
||||
|
||||
// Creation date upper bound (inclusive)
|
||||
// Required: false
|
||||
CreatedTo string `url:"created_to,omitempty" json:"created_to,omitempty"`
|
||||
|
||||
// Filter by operation status
|
||||
// Required: false
|
||||
OperationStatus string `url:"operation_status,omitempty" json:"operation_status,omitempty"`
|
||||
|
||||
// Filter by hypervisor status
|
||||
// Required: false
|
||||
HypervisorStatus string `url:"hypervisor_status,omitempty" json:"hypervisor_status,omitempty"`
|
||||
|
||||
// Page number for pagination
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Number of results per page
|
||||
// Required: false
|
||||
PerPage uint64 `url:"per_page,omitempty" json:"per_page,omitempty"`
|
||||
|
||||
// Field to sort by (display_name, created_at, updated_at, deleted_at, segment_id, hypervisor, port_security, segment_display_name, primary_address, hypervisor_display_name)
|
||||
// Required: false
|
||||
SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"`
|
||||
|
||||
// Sort order (asc/desc)
|
||||
// Required: false
|
||||
SortOrder string `url:"sort_order,omitempty" json:"sort_order,omitempty"`
|
||||
}
|
||||
|
||||
// List of logical ports
|
||||
func (i LogicalPorts) List(ctx context.Context, req ListRequest) (*LogicalPortsList, error) {
|
||||
res, err := i.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
groups := []LogicalPort{}
|
||||
|
||||
err = json.Unmarshal(res, &groups)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := LogicalPortsList{Ports: groups}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
// ListRaw gets a list of all logical portts as an array of bytes
|
||||
func (a LogicalPorts) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/logical_port/list"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
return res, err
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
// API Actor API for managing SDN logical ports
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creating request to logical ports
|
||||
type LogicalPorts struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for logical ports endpoints
|
||||
func New(client interfaces.Caller) *LogicalPorts {
|
||||
return &LogicalPorts{
|
||||
client,
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||||
)
|
||||
|
||||
// MigrateCancelRequest struct to cancel migrate
|
||||
type MigrateCancelRequest struct {
|
||||
// ID of the logical port
|
||||
// Required: true
|
||||
LogicalPortID string `url:"logical_port_id" json:"logical_port_id" validate:"required"`
|
||||
|
||||
// ID of the version
|
||||
// Required: true
|
||||
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||
}
|
||||
|
||||
func (i LogicalPorts) CancelMigrate(ctx context.Context, req MigrateCancelRequest) (*MigrationStatus, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/logical_port/migration_cancel"
|
||||
|
||||
res, err := i.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := MigrationStatus{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||||
)
|
||||
|
||||
// MigrateStartRequest struct to start migrate
|
||||
type MigrateStartRequest struct {
|
||||
// ID of the logical port
|
||||
// Required: true
|
||||
LogicalPortID string `url:"logical_port_id" json:"logical_port_id" validate:"required"`
|
||||
|
||||
// ID of the version
|
||||
// Required: true
|
||||
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||
|
||||
// Hypervisor
|
||||
// Required: true
|
||||
TargetHypervisor string `url:"target_hypervisor" json:"target_hypervisor" validate:"required"`
|
||||
}
|
||||
|
||||
func (i LogicalPorts) StartMigrate(ctx context.Context, req MigrateStartRequest) (*MigrationStatus, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/logical_port/migration_start"
|
||||
|
||||
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := MigrationStatus{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
@@ -1,178 +0,0 @@
|
||||
package logicalports
|
||||
|
||||
// LogicalPortsList represents a list of logical ports
|
||||
type LogicalPortsList struct {
|
||||
Ports []LogicalPort `json:"ports"`
|
||||
}
|
||||
|
||||
// Main information about logical port
|
||||
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
|
||||
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
|
||||
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"`
|
||||
|
||||
// Labels
|
||||
Labels Labels `json:"labels"`
|
||||
|
||||
// Live migration target hypervisor
|
||||
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 {
|
||||
|
||||
// Operation status
|
||||
OperationStatus string `json:"operation_status"`
|
||||
|
||||
// Hypervisors status
|
||||
Hypervisors []HypervisorStatus `json:"hypervisors"`
|
||||
|
||||
// Hypervisor status
|
||||
HypervisorStatus string `json:"hypervisor_status"`
|
||||
}
|
||||
|
||||
// HypervisorStatus information
|
||||
type HypervisorStatus struct {
|
||||
// Operation status
|
||||
OperationStatus string `json:"operation_status"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
// Hypervisor status
|
||||
HypervisorStatus string `json:"hypervisor_status"`
|
||||
|
||||
// Synced 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
|
||||
PortSecurity bool `json:"port_security"`
|
||||
|
||||
// Address detection
|
||||
AddressDetection bool `json:"address_detection"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
|
||||
// Created time
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Updated time
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Logical port addresses
|
||||
LogicalPortAddresses []LogicalPortAddress `json:"logical_port_addresses"`
|
||||
}
|
||||
|
||||
// LogicalPortAddress information
|
||||
type LogicalPortAddress struct {
|
||||
// IP address
|
||||
IP string `json:"ip"`
|
||||
|
||||
// IP type
|
||||
IPType string `json:"ip_type"`
|
||||
|
||||
// Is discovered
|
||||
IsDiscovered bool `json:"is_discovered"`
|
||||
|
||||
// Is primary
|
||||
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 time
|
||||
AssignedAt string `json:"assigned_at"`
|
||||
}
|
||||
|
||||
// Migration status information
|
||||
type MigrationStatus struct {
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// Labels information
|
||||
type Labels struct {
|
||||
// VM ID
|
||||
VMID string `json:"vm_id"`
|
||||
|
||||
// VM name
|
||||
VMName string `json:"vm_name"`
|
||||
}
|
||||
|
||||
// Information about a version
|
||||
type RecordVersion struct {
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/serialization"
|
||||
)
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
//
|
||||
// In order to serialize with indent make sure to follow these guidelines:
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (la LogicalPortsList) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(la.Ports) == 0 {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(la, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(la)
|
||||
}
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
//
|
||||
// In order to serialize with indent make sure to follow these guidelines:
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (ia LogicalPort) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(ia, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(ia)
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||||
)
|
||||
|
||||
type LogicalPortsForUnexcludeFromFirewall struct {
|
||||
// Exclude IP Addresses
|
||||
// Required: true
|
||||
ID string `url:"id" json:"id" validate:"required"`
|
||||
|
||||
// Version ID
|
||||
// Required: true
|
||||
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||
}
|
||||
|
||||
// UnexcludeFirewallRequest struct to unexclude firewall for logical port
|
||||
type UnexcludeFirewallRequest struct {
|
||||
// Access Group ID
|
||||
// Required: true
|
||||
AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
|
||||
|
||||
// Logical Ports For Unexclude From Firewall
|
||||
// Required: true
|
||||
LogicalPortsForUnexcludeFromFirewall []LogicalPortsForUnexcludeFromFirewall `json:"logical_ports_for_unexclude_from_firewall" validate:"required,dive"`
|
||||
}
|
||||
|
||||
// UnexcludeFirewallRequest struct to unexclude firewall for logical port
|
||||
func (lp LogicalPorts) UnexcludeFirewall(ctx context.Context, req UnexcludeFirewallRequest) (*RecordVersion, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/logical_port/unexclude_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
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||||
)
|
||||
|
||||
// Label struct
|
||||
type UpdateLabels struct {
|
||||
VMID string `url:"vm_id,omitempty" json:"vm_id,omitempty"`
|
||||
VMName string `url:"vm_name,omitempty" json:"vm_name,omitempty"`
|
||||
}
|
||||
|
||||
// UpdateRequest struct to update logical port
|
||||
type UpdateRequest struct {
|
||||
// ID of the logical port
|
||||
// Required: true
|
||||
LogicalPortID string `url:"logical_port_id" json:"logical_port_id" validate:"required"`
|
||||
|
||||
// ID of the version
|
||||
// Required: true
|
||||
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||
|
||||
// Adapter MAC
|
||||
// Required: true
|
||||
AdapterMAC string `url:"adapter_mac" json:"adapter_mac" validate:"required"`
|
||||
|
||||
// Description
|
||||
// Required: true
|
||||
Description string `url:"description" json:"description" validate:"required"`
|
||||
|
||||
// Display name
|
||||
// Required: true
|
||||
DisplayName string `url:"display_name" json:"display_name" validate:"required"`
|
||||
|
||||
// Enabled. True or False
|
||||
// Required: true
|
||||
Enabled interface{} `url:"enabled" json:"enabled" validate:"required,isBool"`
|
||||
|
||||
// Remove addresses
|
||||
// Required: false
|
||||
RemoveAddresses []string `url:"remove_addresses,omitempty" json:"remove_addresses,omitempty"`
|
||||
|
||||
// Hypervisor
|
||||
// Required: true
|
||||
Hypervisor string `url:"hypervisor" json:"hypervisor" validate:"required"`
|
||||
|
||||
// Port security. True or False
|
||||
// Required: true
|
||||
PortSecurity interface{} `url:"port_security" json:"port_security" validate:"required,isBool"`
|
||||
|
||||
// Segment ID
|
||||
// Required: true
|
||||
SegmentID string `url:"segment_id" json:"segment_id" validate:"required"`
|
||||
|
||||
// Update addresses
|
||||
// Required: false
|
||||
UpdateAddresses []UpdateAddress `url:"update_addresses,omitempty" json:"update_addresses,omitempty" validate:"dive"`
|
||||
|
||||
// Add addresses
|
||||
// Required: false
|
||||
AddAddresses []AddAddress `url:"add_addresses,omitempty" json:"add_addresses,omitempty" validate:"dive"`
|
||||
|
||||
// Labels
|
||||
// Required: false
|
||||
Labels UpdateLabels `url:"labels,omitempty" json:"labels,omitempty"`
|
||||
}
|
||||
|
||||
// UpdateAddress struct representing update address
|
||||
type UpdateAddress struct {
|
||||
// ID of the address
|
||||
// Required: true
|
||||
ID string `url:"id" json:"id" validate:"required"`
|
||||
|
||||
// IP address
|
||||
// Required: true
|
||||
IP string `url:"ip" json:"ip" validate:"required"`
|
||||
|
||||
// IP type
|
||||
// Required: true
|
||||
IPType string `url:"ip_type" json:"ip_type" validate:"required,oneof=IPv4 IPv6"`
|
||||
|
||||
// Is discovered. True or False
|
||||
// Required: true
|
||||
IsDiscovered bool `url:"is_discovered" json:"is_discovered" validate:"required"`
|
||||
|
||||
// Is primary. True or False
|
||||
// Required: true
|
||||
IsPrimary interface{} `url:"is_primary" json:"is_primary" validate:"required,isBool"`
|
||||
|
||||
// MAC address
|
||||
// Required: true
|
||||
MAC string `url:"mac" json:"mac" validate:"required"`
|
||||
}
|
||||
|
||||
// AddAddress struct representing add address
|
||||
type AddAddress struct {
|
||||
// IP address
|
||||
// Required: true
|
||||
IP string `url:"ip" json:"ip" validate:"required"`
|
||||
|
||||
// IP type
|
||||
// Required: true
|
||||
IPType string `url:"ip_type" json:"ip_type" validate:"required,oneof=IPv4 IPv6"`
|
||||
|
||||
// Is discovered. True or False
|
||||
// Required: true
|
||||
IsDiscovered bool `url:"is_discovered" json:"is_discovered" validate:"required"`
|
||||
|
||||
// Is primary. True or False
|
||||
// Required: true
|
||||
IsPrimary interface{} `url:"is_primary" json:"is_primary" validate:"required,isBool"`
|
||||
|
||||
// MAC address
|
||||
// Required: true
|
||||
MAC string `url:"mac" json:"mac" validate:"required"`
|
||||
}
|
||||
|
||||
// Update updates a logical port
|
||||
func (i LogicalPorts) Update(ctx context.Context, req UpdateRequest) (*LogicalPort, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/logical_port/update"
|
||||
|
||||
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPut, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := LogicalPort{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
Reference in New Issue
Block a user