v15.5.0
This commit is contained in:
dayterr
2026-07-10 15:44:33 +03:00
parent 55fe76d12e
commit 0595b5ae39
15 changed files with 571 additions and 100 deletions

View File

@@ -2,8 +2,8 @@ package hypervisors
import (
"context"
"encoding/json"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/constants"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
@@ -17,27 +17,21 @@ type DeleteRequest struct {
}
// Delete a hypervisor
func (hv Hypervisors) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
func (hv Hypervisors) Delete(ctx context.Context, req DeleteRequest) (*RecordVersion, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/sdn/hypervisor/delete"
res, err := hv.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)
info := RecordVersion{}
err = json.Unmarshal(res, &info)
if err != nil {
return false, err
return nil, err
}
if string(res) == "" {
return true, nil
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
return &info, nil
}

View File

@@ -1,5 +1,11 @@
package hypervisors
// Information about a version
type RecordVersion struct {
// Version ID
VersionID uint64 `json:"version_id"`
}
// Main information about hypervisor
type RecordHypervisor struct {
// Created at

View File

@@ -55,34 +55,35 @@ type CreateRequest struct {
// Logical port addresses
// Required: false
LogicalPortAddresses []LogicalPortAddress `url:"logical_port_addresses,omitempty" json:"logical_port_addresses,omitempty" validate:"dive"`
LogicalPortAddresses []LogicalPortAddressRequest `url:"logical_port_addresses,omitempty" json:"logical_port_addresses,omitempty" validate:"dive"`
// Labels
// Required: false
Labels CreateLabels `url:"labels,omitempty" json:"labels,omitempty"`
Labels *CreateLabels `url:"labels,omitempty" json:"labels"`
}
// LogicalPortAddressRequest struct representing logical port address
type LogicalPortAddressRequest struct {
// IP address
// IP address. IPv4 or IPv6 address of the logical port
// If nil (allowed only when IsPrimary is true), the system will automatically generate a valid address
// Required: true
IP string `url:"ip" json:"ip" validate:"required"`
IP interface{} `url:"ip" json:"ip" validate:"omitempty,isString"`
// IP type
// Required: true
IPType string `url:"ip_type" json:"ip_type" validate:"required,oneof=IPv4 IPv6"`
// Is primary. True or False
// Is primary
// Required: true
IsPrimary interface{} `url:"is_primary" json:"is_primary" validate:"required,isBool"`
// Is discovered
// Required: true
IsDiscovered interface{} `url:"is_discovered" json:"is_discovered" 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

View File

@@ -34,6 +34,9 @@ type LogicalPort struct {
// Enabled
Enabled bool `json:"enabled"`
// Exclude firewall information
ExcludeFirewall ExcludeFirewall `json:"exclude_firewall"`
// External network ID
ExternalNetworkID string `json:"external_network_id"`
@@ -162,6 +165,18 @@ type MigrationStatus struct {
VersionID uint64 `json:"version_id"`
}
// ExcludeFirewall information
type ExcludeFirewall struct {
// Exclusion reason
ExclusionReason string `json:"exclusion_reason"`
// Whether logical port addresses are excluded from firewall
LogicalPortAddressesExcluded bool `json:"logical_port_addresses_excluded"`
// Whether logical port is excluded from firewall
LogicalPortExcluded bool `json:"logical_port_excluded"`
}
// Labels information
type Labels struct {
// VM ID

View File

@@ -67,7 +67,7 @@ type UpdateRequest struct {
// Labels
// Required: false
Labels UpdateLabels `url:"labels,omitempty" json:"labels,omitempty"`
Labels *UpdateLabels `url:"labels,omitempty" json:"labels"`
}
// UpdateAddress struct representing update address
@@ -86,7 +86,7 @@ type UpdateAddress struct {
// Is discovered. True or False
// Required: true
IsDiscovered bool `url:"is_discovered" json:"is_discovered" validate:"required"`
IsDiscovered interface{} `url:"is_discovered" json:"is_discovered" validate:"required,isBool"`
// Is primary. True or False
// Required: true
@@ -107,11 +107,11 @@ type AddAddress struct {
// Required: true
IPType string `url:"ip_type" json:"ip_type" validate:"required,oneof=IPv4 IPv6"`
// Is discovered. True or False
// Is discovered
// Required: true
IsDiscovered bool `url:"is_discovered" json:"is_discovered" validate:"required"`
IsDiscovered interface{} `url:"is_discovered" json:"is_discovered" validate:"required,isBool"`
// Is primary. True or False
// Is primary
// Required: true
IsPrimary interface{} `url:"is_primary" json:"is_primary" validate:"required,isBool"`

View File

@@ -182,7 +182,7 @@ type L2ExternalNetwork struct {
}
// Info about an external network port
type ExternalNetworkPort struct {
type ExternalNetworkPorts struct {
// Access group ID
AccessGroupID string `json:"access_group_id"`
@@ -192,9 +192,6 @@ type ExternalNetworkPort struct {
// Bridge network name
BridgeNetworkName string `json:"bridge_network_name"`
// Comment
Comment string `json:"comment"`
// Default gateway for IPv4
DefaultGatewayIPv4 string `json:"default_gateway_ipv4"`
@@ -204,9 +201,6 @@ type ExternalNetworkPort struct {
// Description
Description string `json:"description"`
// Is a logical port enabled
Enabled bool `json:"enabled"`
// Details of external network ports
ExternalNetworkPorts ExternalNetworkPortsField `json:"external_network_ports"`
@@ -216,9 +210,6 @@ type ExternalNetworkPort struct {
// ID of an external network port
ID string `json:"id"`
// IP v4
IPv4 string `json:"ipv4"`
// Status
Status Status `json:"status"`
@@ -239,14 +230,8 @@ type ExternalNetworkPort struct {
// VLAN Tag
VLANTag int `json:"vlan_tag"`
// MAC
MAC string `json:"mac"`
}
// List of external network ports
type ExternalNetworkPorts []ExternalNetworkPort
// Info about a logical port
type LogicalPort struct {
// ID