v12.8.0
This commit is contained in:
41
pkg/sdn/netobjgroups/attach_extnet_ports.go
Normal file
41
pkg/sdn/netobjgroups/attach_extnet_ports.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package netobjgroups
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// AttachExtNetPortsRequest struct to attach external network ports to a network object group
|
||||
type AttachExtNetPortsRequest struct {
|
||||
// ID of a network object group
|
||||
// Required: true
|
||||
ObjectGroupID string `url:"object_group_id" json:"object_group_id" validate:"required"`
|
||||
|
||||
// ID of an access group
|
||||
// Required: true
|
||||
AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
|
||||
|
||||
// IDs of external network ports to attach to a network object group
|
||||
// Required: true
|
||||
PortIDs []string `url:"port_ids" json:"port_ids" validate:"required"`
|
||||
}
|
||||
|
||||
// AttachExtNetPorts attaches external network ports to a network object group
|
||||
func (nog NetworkObjectGroups) AttachExtNetPorts(ctx context.Context, req AttachExtNetPortsRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/network_object_group/attach_external_network_ports"
|
||||
|
||||
_, err = nog.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
54
pkg/sdn/netobjgroups/attach_logical_ports.go
Normal file
54
pkg/sdn/netobjgroups/attach_logical_ports.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package netobjgroups
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// AttachLogicalPortsRequest struct to attach logical ports to a network object group
|
||||
type AttachLogicalPortsRequest struct {
|
||||
// ID of a network object group
|
||||
// Required: true
|
||||
ObjectGroupID string `url:"object_group_id" json:"object_group_id" validate:"required"`
|
||||
|
||||
// ID of an access group
|
||||
// Required: true
|
||||
AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
|
||||
|
||||
// Version ID
|
||||
// Required: true
|
||||
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||
|
||||
// Port Bindings
|
||||
// Required: true
|
||||
PortBindings []PortBindings `url:"port_bindings" json:"port_bindings" validate:"required,dive"`
|
||||
}
|
||||
type PortBindings struct {
|
||||
// ID of a logical port
|
||||
// Required: true
|
||||
PortID string `url:"port_id" json:"port_id" validate:"required"`
|
||||
|
||||
// Version of a logical port
|
||||
// Required: true
|
||||
PortVersion int64 `url:"port_version" json:"port_version" validate:"required"`
|
||||
}
|
||||
|
||||
// AttachLogicalPorts attaches logical ports to a network object group
|
||||
func (nog NetworkObjectGroups) AttachLogicalPorts(ctx context.Context, req AttachLogicalPortsRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/network_object_group/attach_logical_ports"
|
||||
|
||||
_, err = nog.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
62
pkg/sdn/netobjgroups/create.go
Normal file
62
pkg/sdn/netobjgroups/create.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package netobjgroups
|
||||
|
||||
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 a network object group
|
||||
type CreateRequest struct {
|
||||
// Access Group ID
|
||||
// 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"`
|
||||
|
||||
// Name
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// Logical ports bindings
|
||||
// Required: false
|
||||
LogicalPortsBindings []LogicalPortsBindings `url:"logical_ports_binding,omitempty" json:"logical_ports_bindings,omitempty" validate:"omitempty,dive"`
|
||||
}
|
||||
type LogicalPortsBindings struct {
|
||||
// Port ID
|
||||
// Required: true
|
||||
PortID string `url:"port_id" json:"port_id" validate:"required"`
|
||||
|
||||
// Port version
|
||||
// Required: true
|
||||
PortVersion int64 `url:"port_version" json:"port_version" validate:"required"`
|
||||
}
|
||||
|
||||
// Create creates a network object group
|
||||
func (nog NetworkObjectGroups) Create(ctx context.Context, req CreateRequest) (*RecordNetObjGroup, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/network_object_group/create"
|
||||
|
||||
res, err := nog.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := RecordNetObjGroup{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
51
pkg/sdn/netobjgroups/delete.go
Normal file
51
pkg/sdn/netobjgroups/delete.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package netobjgroups
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteRequest to delete a network object group
|
||||
type DeleteRequest struct {
|
||||
// ID of a network object group
|
||||
// Required: true
|
||||
ObjectGroupID string `url:"object_group_id" json:"object_group_id" validate:"required"`
|
||||
|
||||
// Version ID
|
||||
// Required: true
|
||||
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||
|
||||
// Force delete
|
||||
// Required: false
|
||||
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
||||
}
|
||||
|
||||
// Delete a network object group
|
||||
func (nog NetworkObjectGroups) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/network_object_group/delete"
|
||||
|
||||
res, err := nog.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if string(res) == "" {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
49
pkg/sdn/netobjgroups/detach_external_network_ports.go
Normal file
49
pkg/sdn/netobjgroups/detach_external_network_ports.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package netobjgroups
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
// DetachExtNetPortsRequest struct to detach an external network port from a network object group
|
||||
type DetachExtNetPortsRequest struct {
|
||||
// ID of a network object group
|
||||
// Required: true
|
||||
ObjectGroupID string `url:"object_group_id" json:"object_group_id" validate:"required"`
|
||||
|
||||
// ID of an access group
|
||||
// Required: true
|
||||
AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
|
||||
|
||||
// ID of an external network port to detach from a network object group
|
||||
// Required: true
|
||||
ExternalNetworkPortID string `url:"external_network_port_id" json:"external_network_port_id" validate:"required"`
|
||||
}
|
||||
|
||||
// DetachExtNetlPorts detaches external network ports from a network object group
|
||||
func (nog NetworkObjectGroups) DetachExtNetPorts(ctx context.Context, req DetachExtNetPortsRequest) (*RecordVersion, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/network_object_group/detach_external_network_ports"
|
||||
|
||||
res, err := nog.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
|
||||
}
|
||||
57
pkg/sdn/netobjgroups/detach_logical_ports.go
Normal file
57
pkg/sdn/netobjgroups/detach_logical_ports.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package netobjgroups
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
// DetachLogicalPortsRequest struct to detach an logical port from a network object group
|
||||
type DetachLogicalPortsRequest struct {
|
||||
// ID of a network object group
|
||||
// Required: true
|
||||
ObjectGroupID string `url:"object_group_id" json:"object_group_id" validate:"required"`
|
||||
|
||||
// ID of an access group
|
||||
// Required: true
|
||||
AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
|
||||
|
||||
// Version ID
|
||||
// Required: true
|
||||
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||
|
||||
// ID of a logical port
|
||||
// Required: true
|
||||
LogicalPortID string `url:"logical_port_id" json:"logical_port_id" validate:"required"`
|
||||
|
||||
// Version of a logical port
|
||||
// Required: true
|
||||
LogicalPortVersion uint64 `url:"logical_port_version" json:"logical_port_version" validate:"required"`
|
||||
}
|
||||
|
||||
// DetachLogicalPorts detaches logical ports from a network object group
|
||||
func (nog NetworkObjectGroups) DetachLogicalPorts(ctx context.Context, req DetachLogicalPortsRequest) (*RecordVersion, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/network_object_group/detach_logical_ports"
|
||||
|
||||
res, err := nog.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
|
||||
}
|
||||
42
pkg/sdn/netobjgroups/filter.go
Normal file
42
pkg/sdn/netobjgroups/filter.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package netobjgroups
|
||||
|
||||
// FilterByID returns NetObjGroupList with specified ID.
|
||||
func (nog NetObjGroupList) FilterByID(id string) NetObjGroupList {
|
||||
predicate := func(netobj RecordNetObjGroup) bool {
|
||||
return netobj.ID == id
|
||||
}
|
||||
|
||||
return nog.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByName returns NetObjGroupList with specified Name.
|
||||
func (nog NetObjGroupList) FilterByName(name string) NetObjGroupList {
|
||||
predicate := func(netobj RecordNetObjGroup) bool {
|
||||
return netobj.Name == name
|
||||
}
|
||||
|
||||
return nog.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering NetObjGroupList based on a user-specified predicate.
|
||||
func (nog NetObjGroupList) FilterFunc(predicate func(group RecordNetObjGroup) bool) NetObjGroupList {
|
||||
var result NetObjGroupList
|
||||
|
||||
for _, acc := range nog.Objects {
|
||||
if predicate(acc) {
|
||||
result.Objects = append(result.Objects, acc)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FindOne returns first element.
|
||||
// If none was found, returns an empty struct.
|
||||
func (nog NetObjGroupList) FindOne() RecordNetObjGroup {
|
||||
if len(nog.Objects) == 0 {
|
||||
return RecordNetObjGroup{}
|
||||
}
|
||||
|
||||
return nog.Objects[0]
|
||||
}
|
||||
111
pkg/sdn/netobjgroups/filter_test.go
Normal file
111
pkg/sdn/netobjgroups/filter_test.go
Normal file
@@ -0,0 +1,111 @@
|
||||
package netobjgroups
|
||||
|
||||
import "testing"
|
||||
|
||||
var testNetObjGroups = NetObjGroupList{
|
||||
Objects: []RecordNetObjGroup{
|
||||
{
|
||||
AccessGroupID: "d85d4a08-3216-4240-a8bd-191cd9cc3bf3",
|
||||
AccessGroupName: "Test1",
|
||||
CreatedAt: "2025-09-04T13:18:14.412118Z",
|
||||
Description: "test descr",
|
||||
ID: "0b16493b-0a38-4c90-80a0-c19f898f593d",
|
||||
Name: "Test1",
|
||||
UpdatedAt: "2025-10-28T07:28:15.450717Z",
|
||||
VersionID: 1761636495441,
|
||||
Counters: Counter{
|
||||
LogicalPortsCount: 1,
|
||||
SecurityPoliciesCount: 2,
|
||||
SecurityRulesCount: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
AccessGroupID: "d85d4a08-3216-4240-a8bd-191cd9cc3bf3",
|
||||
AccessGroupName: "Test2",
|
||||
CreatedAt: "2025-09-04T13:18:14.412118Z",
|
||||
Description: "another descr",
|
||||
ID: "0b16493b-0a38-4c90-80a0-c19f898f593e",
|
||||
Name: "Test2",
|
||||
UpdatedAt: "2025-10-28T07:28:15.450717Z",
|
||||
VersionID: 1761636495442,
|
||||
Counters: Counter{
|
||||
LogicalPortsCount: 1,
|
||||
SecurityPoliciesCount: 2,
|
||||
SecurityRulesCount: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
AccessGroupID: "d85d4a08-3216-4240-a8bd-191cd9cc3bf3",
|
||||
AccessGroupName: "Test3",
|
||||
CreatedAt: "2025-09-04T13:18:14.412118Z",
|
||||
Description: "another descr",
|
||||
ID: "0b16493b-0a38-4c90-80a0-c19f898f593f",
|
||||
Name: "Test3",
|
||||
UpdatedAt: "2025-10-28T07:28:15.450717Z",
|
||||
VersionID: 1761636495443,
|
||||
Counters: Counter{
|
||||
LogicalPortsCount: 1,
|
||||
SecurityPoliciesCount: 2,
|
||||
SecurityRulesCount: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func TestFilterByID(t *testing.T) {
|
||||
actual := testNetObjGroups.FilterByID("0b16493b-0a38-4c90-80a0-c19f898f593d").FindOne()
|
||||
|
||||
if actual.ID != "0b16493b-0a38-4c90-80a0-c19f898f593d" {
|
||||
t.Fatal("actual:", actual.ID, "> expected: 0b16493b-0a38-4c90-80a0-c19f898f593d")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByName(t *testing.T) {
|
||||
actual := testNetObjGroups.FilterByName("Test1").FindOne()
|
||||
|
||||
if actual.Name != "Test1" {
|
||||
t.Fatal("actual:", actual.Name, ">> expected: Test1")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterFunc(t *testing.T) {
|
||||
actual := testNetObjGroups.FilterFunc(func(rnog RecordNetObjGroup) bool {
|
||||
return rnog.Description == "test descr"
|
||||
})
|
||||
|
||||
if len(actual.Objects) != 1 || actual.Objects[0].ID != "0b16493b-0a38-4c90-80a0-c19f898f593d" {
|
||||
t.Fatal("Expected 1 policy with description 'Second policy', found:", len(actual.Objects))
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindOneWithResults(t *testing.T) {
|
||||
result := testNetObjGroups.FilterByID("0b16493b-0a38-4c90-80a0-c19f898f593d").FindOne()
|
||||
if result.ID != "0b16493b-0a38-4c90-80a0-c19f898f593d" {
|
||||
t.Fatal("Expected 0b16493b-0a38-4c90-80a0-c19f898f593d, got:", result.ID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindOneEmpty(t *testing.T) {
|
||||
emptyList := NetObjGroupList{}
|
||||
result := emptyList.FindOne()
|
||||
|
||||
if result.ID != "" || result.Name != "" {
|
||||
t.Fatal("Expected empty NetObjGroup, got:", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByIDNotFound(t *testing.T) {
|
||||
actual := testNetObjGroups.FilterByID("0b16493b-0a38-4c90-80a0-c19f898f593n")
|
||||
|
||||
if len(actual.Objects) != 0 {
|
||||
t.Fatal("Expected 0 policies, found:", len(actual.Objects))
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByDisplayNameNotFound(t *testing.T) {
|
||||
actual := testNetObjGroups.FilterByName("Nonexistent Policy")
|
||||
|
||||
if len(actual.Objects) != 0 {
|
||||
t.Fatal("Expected 0 policies, found:", len(actual.Objects))
|
||||
}
|
||||
}
|
||||
47
pkg/sdn/netobjgroups/get.go
Normal file
47
pkg/sdn/netobjgroups/get.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package netobjgroups
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get info about a network object group
|
||||
type GetRequest struct {
|
||||
// ID of a network object group
|
||||
// Required: true
|
||||
NetObjGroupID string `url:"object_group_id" json:"object_group_id" validate:"required"`
|
||||
}
|
||||
|
||||
// Get gets network object group details as a NetworkObjectGroups struct
|
||||
func (nog NetworkObjectGroups) Get(ctx context.Context, req GetRequest) (*RecordNetObjGroup, error) {
|
||||
res, err := nog.GetRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := RecordNetObjGroup{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
|
||||
}
|
||||
|
||||
// GetRaw gets network object group details as an array of bytes
|
||||
func (nog NetworkObjectGroups) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/network_object_group/get"
|
||||
|
||||
res, err := nog.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
return res, err
|
||||
}
|
||||
84
pkg/sdn/netobjgroups/list.go
Normal file
84
pkg/sdn/netobjgroups/list.go
Normal file
@@ -0,0 +1,84 @@
|
||||
package netobjgroups
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get a list of network object groups
|
||||
type ListRequest struct {
|
||||
// Filter by name
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Filter by access group ID
|
||||
// Required: false
|
||||
AccessGroupID string `url:"access_group_id,omitempty" json:"access_group_id,omitempty"`
|
||||
|
||||
// Updated at lower bound (greater than or equal to)
|
||||
// Required: false
|
||||
UpdatedFrom string `url:"updated_from,omitempty" json:"updated_from,omitempty"`
|
||||
|
||||
// Updated at upper bound (less than)
|
||||
// Required: false
|
||||
UpdatedTo string `url:"updated_to,omitempty" json:"updated_to,omitempty"`
|
||||
|
||||
// Created at lower bound (greater than or equal to)
|
||||
// Required: false
|
||||
CreatedFrom string `url:"created_from,omitempty" json:"created_from,omitempty"`
|
||||
|
||||
// Created at upper bound (less than)
|
||||
// Required: false
|
||||
CreatedTo string `url:"created_to,omitempty" json:"created_to,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 (name, created_at, updated_at)
|
||||
// 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 address pools
|
||||
func (nog NetworkObjectGroups) List(ctx context.Context, req ListRequest) (*NetObjGroupList, error) {
|
||||
res, err := nog.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
objects := []RecordNetObjGroup{}
|
||||
|
||||
err = json.Unmarshal(res, &objects)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := NetObjGroupList{Objects: objects}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
// ListRaw gets a list of all address pools as an array of bytes
|
||||
func (nog NetworkObjectGroups) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/network_object_group/list"
|
||||
|
||||
res, err := nog.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
return res, err
|
||||
}
|
||||
702
pkg/sdn/netobjgroups/models.go
Normal file
702
pkg/sdn/netobjgroups/models.go
Normal file
@@ -0,0 +1,702 @@
|
||||
package netobjgroups
|
||||
|
||||
// Information about a version
|
||||
type RecordVersion struct {
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// List of network object groups
|
||||
type NetObjGroupList struct {
|
||||
Objects []RecordNetObjGroup
|
||||
}
|
||||
|
||||
// Main info about a network object group
|
||||
type RecordNetObjGroup struct {
|
||||
// Access group ID
|
||||
AccessGroupID string `json:"access_group_id"`
|
||||
|
||||
// Access group name
|
||||
AccessGroupName string `json:"access_group_name"`
|
||||
|
||||
// Counters
|
||||
Counters Counter `json:"counters"`
|
||||
|
||||
// Created at
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Updated at
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// External network ports attached to a network object group
|
||||
ExternalNetworkPorts ExternalNetworkPorts `json:"external_network_ports"`
|
||||
|
||||
// ID of a network object group
|
||||
ID string `json:"id"`
|
||||
|
||||
// Logical ports attached to a network object group
|
||||
LogicalPorts LogicalPorts `json:"logical_ports"`
|
||||
|
||||
// Name of a network object group
|
||||
Name string `json:"name"`
|
||||
|
||||
// Security policies of a network object group
|
||||
SecurityPolicies SecurityPolicies `json:"security_policies"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// Info about counters
|
||||
type Counter struct {
|
||||
// Amount of logical ports
|
||||
LogicalPortsCount uint64 `json:"logical_ports_count"`
|
||||
|
||||
// Amount of security policies
|
||||
SecurityPoliciesCount uint64 `json:"security_policies_count"`
|
||||
|
||||
// Amount of security rules
|
||||
SecurityRulesCount uint64 `json:"security_rules_count"`
|
||||
}
|
||||
|
||||
// List of counters
|
||||
type Counters []Counter
|
||||
|
||||
// Info about an external network port
|
||||
type ExternalNetworkPort struct {
|
||||
// Bridge network name
|
||||
BridgeNetworkName string `json:"bridge_network_name"`
|
||||
|
||||
// Default gateaway for IPv4
|
||||
DefaultGateawayIPv4 string `json:"default_gateaway_ipv4"`
|
||||
|
||||
// Default gateaway for IPv6
|
||||
DefaultGateawayIPv6 string `json:"default_gateaway_ipv6"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// Details of external network ports
|
||||
ExternalNetworkPorts ExternalNetworkPortsField `json:"external_network_ports"`
|
||||
|
||||
// Hypervisors
|
||||
Hypervisors []string `json:"hypervisors"`
|
||||
|
||||
// ID of an external network port
|
||||
ID string `json:"id"`
|
||||
|
||||
// Status
|
||||
Status Status `json:"status"`
|
||||
|
||||
// Version ID
|
||||
VersionID string `json:"version_id"`
|
||||
|
||||
// Subnet for V4
|
||||
SubnetV4 string `json:"subnet_v4"`
|
||||
|
||||
// Subnet for V6
|
||||
SubnetV6 string `json:"subnet_v6"`
|
||||
|
||||
// Created at
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Updated at
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// VLAN Tag
|
||||
VLANTag string `json:"vlan_tag"`
|
||||
}
|
||||
|
||||
// List of external network ports
|
||||
type ExternalNetworkPorts []ExternalNetworkPort
|
||||
|
||||
// Info about a 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"`
|
||||
|
||||
// Is address detected
|
||||
AddressDetection bool `json:"address_detection"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// Created at
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
// Is a logical port 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"`
|
||||
|
||||
// Live migration target HV
|
||||
LiveMigrationTargetHV string `json:"live_migration_target_hv"`
|
||||
|
||||
// Status
|
||||
Status Status `json:"status"`
|
||||
|
||||
// Bindings
|
||||
Bindings Bindings `json:"bindings"`
|
||||
|
||||
// Unique identifier
|
||||
UniqueIdentifier string `json:"unique_identifier"`
|
||||
|
||||
// Updated at
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// List a logical ports
|
||||
type LogicalPorts []LogicalPort
|
||||
|
||||
// Info about a security policy
|
||||
type SecurityPolicy struct {
|
||||
// Access group ID
|
||||
AccessGroupID string `json:"access_group_id"`
|
||||
|
||||
// Access group name
|
||||
AccessGroupName string `json:"access_group_name"`
|
||||
|
||||
// Applied to net object group ID
|
||||
AppliedToNetObjectGroupID string `json:"applied_to_net_object_group_id"`
|
||||
|
||||
// Created at
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
// Is a security policy enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// End priority
|
||||
EndPriority uint64 `json:"end_priority"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Security rules
|
||||
SecurityRules SecurityRules `json:"security_rules"`
|
||||
|
||||
// Start priority
|
||||
StartPriority uint64 `json:"start_priority"`
|
||||
|
||||
// Status
|
||||
Status Status `json:"status"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
|
||||
// Updated at
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
// List of security policies
|
||||
type SecurityPolicies []SecurityPolicy
|
||||
|
||||
// Details of external network ports field
|
||||
type ExternalNetworkPortField struct {
|
||||
// Access group ID
|
||||
AccessGroupID string `json:"access_group_id"`
|
||||
|
||||
// Access group name
|
||||
AccessGroupName string `json:"access_group_name"`
|
||||
|
||||
Comment string `json:"comment"`
|
||||
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
// Is a security policy enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// IP v4
|
||||
IPv4 string `json:"ipv4"`
|
||||
|
||||
// IP v6
|
||||
IPv6 string `json:"ipv6"`
|
||||
|
||||
// Config for IP v6
|
||||
IPv6Config IPv6Config `json:"ipv6_config"`
|
||||
|
||||
// MAC
|
||||
MAC string `json:"mac"`
|
||||
|
||||
// Info about a router gateaway port
|
||||
RouterGateawayPort RouterGateawayPort `json:"router_gateaway_port"`
|
||||
|
||||
// Info about a floating IP
|
||||
FloatingIP FloatingIP `json:"floating_ip"`
|
||||
}
|
||||
|
||||
// List of external network ports fields
|
||||
type ExternalNetworkPortsField []ExternalNetworkPortField
|
||||
|
||||
// Info about a status
|
||||
type Status struct {
|
||||
// Common
|
||||
Common string `json:"common"`
|
||||
|
||||
// Info about hypervisors
|
||||
Hypervisors HypervisorsInfo `json:"hypervisors"`
|
||||
}
|
||||
|
||||
// Config for IP v6
|
||||
type IPv6Config struct {
|
||||
// Address mode
|
||||
AddressMode string `json:"address_mode"`
|
||||
|
||||
// Is periodic RA enabled
|
||||
EnablePeriodicRA bool `json:"enable_periodic_ra"`
|
||||
|
||||
// Interval RA
|
||||
IntervalRA uint64 `json:"interval_ra"`
|
||||
|
||||
// Router preference
|
||||
RouterPreference string `json:"router_preference"`
|
||||
}
|
||||
|
||||
// Info about a router gateaway port
|
||||
type RouterGateawayPort struct {
|
||||
// Created at
|
||||
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"`
|
||||
|
||||
// Is SNAT enabled
|
||||
SNATEnabled bool `json:"snat_enabled"`
|
||||
|
||||
// Updated at
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
// Info about a floating IP
|
||||
type FloatingIP struct {
|
||||
// Access group ID
|
||||
AccessGroupID string `json:"access_group_id"`
|
||||
|
||||
// Access group name
|
||||
AccessGroupName string `json:"access_group_name"`
|
||||
|
||||
// Created at
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// External network port in floating IP
|
||||
ExternalNetworkPort ExternalNetworkPortFieldInFloatingIP `json:"external_network_port"`
|
||||
|
||||
// Logical port
|
||||
LogicalPort LogicalPort `json:"logical_port"`
|
||||
|
||||
// Router
|
||||
Router Router `json:"router"`
|
||||
|
||||
// Updated at
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// TODO later
|
||||
type ExternalNetworkPortFieldInFloatingIP struct{}
|
||||
|
||||
// Info about a router
|
||||
type Router struct {
|
||||
// Access group ID
|
||||
AccessGroupID string `json:"access_group_id"`
|
||||
|
||||
// Access group name
|
||||
AccessGroupName string `json:"access_group_name"`
|
||||
|
||||
// Created at
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
// Is a security policy enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// Gateaway ports
|
||||
GateawayPorts GateawayPorts `json:"gateaway_ports"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Policies
|
||||
Policies Policies `json:"policies"`
|
||||
|
||||
// Port
|
||||
Port Ports `json:"ports"`
|
||||
|
||||
// Status
|
||||
Status Status `json:"status"`
|
||||
|
||||
// Updated at
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// Info about bindings
|
||||
type Bindings struct {
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Segment display name
|
||||
SegmentDisplayName string `json:"segment_display_name"`
|
||||
|
||||
// Segment ID
|
||||
SegmentID string `json:"segment_id"`
|
||||
|
||||
// Is a port secured
|
||||
PortSecurity bool `json:"port_security"`
|
||||
|
||||
// Is an address detected
|
||||
AddressDetection bool `json:"address_detection"`
|
||||
|
||||
// Is excluded from firewall
|
||||
IsExcludedFromFirewall bool `json:"is_excluded_from_firewall"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
|
||||
// Created at
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Updated at
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Logical port addresses
|
||||
LogicalPortAddresses LogicalPortAddresses `json:"logical_port_addresses"`
|
||||
}
|
||||
|
||||
// Info about a gateaway port
|
||||
type GateawayPort struct {
|
||||
// Created at
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// Max external L4 port
|
||||
ExternalL4PortMax uint64 `json:"external_l4_port_max"`
|
||||
|
||||
// Min external L4 port
|
||||
ExternalL4PortMin uint64 `json:"external_l4_port_min"`
|
||||
|
||||
// External network port in floating IP
|
||||
ExternalNetworkPortFieldInFloatingIP ExternalNetworkPortFieldInFloatingIP `json:"external_network_port"` // to check
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Is SNAT enabled
|
||||
SNATEnabled bool `json:"snat_enabled"`
|
||||
|
||||
// Status
|
||||
Status Status `json:"status"`
|
||||
|
||||
// Updated at
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// List of gateaway ports
|
||||
type GateawayPorts []GateawayPort
|
||||
|
||||
// Info about a policy
|
||||
type Policy struct {
|
||||
// Action
|
||||
Action string `json:"action"`
|
||||
|
||||
// Created at
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
// Is a security policy enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Match
|
||||
Match string `json:"match"`
|
||||
|
||||
// List of next IP v4 addresses
|
||||
NextIPv4Address []string `json:"next_ipv4_address"`
|
||||
|
||||
// List of next IP v6 addresses
|
||||
NextIPv6Address []string `json:"next_ipv6_address"`
|
||||
|
||||
// Priority
|
||||
Priority int `json:"priority"`
|
||||
|
||||
// Updated at
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// List of policies
|
||||
type Policies []Policy
|
||||
|
||||
// Info about a port
|
||||
type Port struct {
|
||||
// Created at
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// Is a security policy enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// IPv4 address
|
||||
IPv4Address string `json:"ipv4_address"`
|
||||
|
||||
// IPv6 address
|
||||
IPv6Address string `json:"ipv6_address"`
|
||||
|
||||
// Config for IPv6
|
||||
IPv6Config IPv6Config `json:"ipv6_config"`
|
||||
|
||||
// MAC
|
||||
MAC string `json:"mac"`
|
||||
|
||||
// Segment
|
||||
Segment Segment `json:"segment"`
|
||||
|
||||
// Segment ID
|
||||
SegmentID string `json:"segment_id"`
|
||||
|
||||
// Status
|
||||
Status Status `json:"status"`
|
||||
|
||||
// Updated at
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// VersionID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// List of ports
|
||||
type Ports []Port
|
||||
|
||||
// Info about a segment
|
||||
type Segment struct {
|
||||
// Access group ID
|
||||
AccessGroupID string `json:"access_group_id"`
|
||||
|
||||
// Access group name
|
||||
AccessGroupName string `json:"access_group_name"`
|
||||
|
||||
// Created at
|
||||
CreatedAt string `json:"created_at"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
DHCPv4 DHCPv4 `json:"dhcp_v4"`
|
||||
DHCPv6 DHCPv6 `json:"dhcp_v6"`
|
||||
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
// Is a security policy enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Info about logical ports
|
||||
LogicalPortsInfo LogicalPortsInfo `json:"logical_ports_info"`
|
||||
|
||||
// Info about routers
|
||||
RoutersInfo RoutersInfo `json:"routers_info"`
|
||||
|
||||
// Status
|
||||
Status Status `json:"status"`
|
||||
|
||||
// Subnet v4
|
||||
SubnetV4 string `json:"subnet_v4"`
|
||||
|
||||
// Subnet v6
|
||||
SubnetV6 string `json:"subnet_v6"`
|
||||
|
||||
// Updated at
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
||||
// Version ID
|
||||
VersionID uint64 `json:"version_id"`
|
||||
}
|
||||
|
||||
// Info about DHCP v4
|
||||
type DHCPv4 struct {
|
||||
// List of DNS
|
||||
DNS []string `json:"dns"`
|
||||
|
||||
// List of excluded address ranges
|
||||
ExcludedAddressRanges []string `json:"excluded_address_ranges"`
|
||||
|
||||
// Gateaway
|
||||
Gateaway string `json:"gateaway"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Lease time
|
||||
LeaseTime uint64 `json:"lease_time"`
|
||||
|
||||
// Server IP
|
||||
ServerIP string `json:"server_ip"`
|
||||
|
||||
// is there a server MAC
|
||||
ServerMAC bool `json:"server_mac"`
|
||||
|
||||
// Is a security policy enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
// Info about DHCP v6
|
||||
type DHCPv6 struct {
|
||||
// Address prefix
|
||||
AddressPrefix string `json:"address_prefix"`
|
||||
|
||||
// List of DNS
|
||||
DNS []string `json:"dns"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Lease time
|
||||
LeaseTime uint64 `json:"lease_time"`
|
||||
|
||||
// Server MAC
|
||||
ServerMAC string `json:"server_mac"`
|
||||
|
||||
// Is a security policy enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
// Info about logical ports
|
||||
type LogicalPortsInfo struct {
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
// Info about routers
|
||||
type RoutersInfo struct {
|
||||
// Display name
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
// Info about a hypervisor
|
||||
type HypervisorInfo 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
|
||||
SyncedAt string `json:"synced_at"`
|
||||
}
|
||||
|
||||
// List of hypervisors info
|
||||
type HypervisorsInfo []HypervisorInfo
|
||||
|
||||
type LogicalPortAddress struct {
|
||||
// IP
|
||||
IP string `json:"ip"`
|
||||
|
||||
// IP Type
|
||||
IPType string `json:"ip_type"`
|
||||
|
||||
// Is logical port address discovered
|
||||
IsDiscovered bool `json:"is_discovered"`
|
||||
|
||||
// Is logical port address primary
|
||||
IsPrimary bool `json:"is_primary"`
|
||||
|
||||
// MAC
|
||||
MAC string `json:"mac"`
|
||||
|
||||
// ID
|
||||
ID string `json:"id"`
|
||||
|
||||
// Logical port ID
|
||||
LogicalPortID string `json:"logical_port_id"`
|
||||
|
||||
// Assigned at
|
||||
AssignedAt string `json:"assigned_at"`
|
||||
}
|
||||
|
||||
// List of logical port addresses
|
||||
type LogicalPortAddresses []LogicalPortAddress
|
||||
|
||||
// TODO
|
||||
type SecurityRule struct{}
|
||||
|
||||
type SecurityRules []SecurityRule
|
||||
18
pkg/sdn/netobjgroups/network_object_groups.go
Normal file
18
pkg/sdn/netobjgroups/network_object_groups.go
Normal file
@@ -0,0 +1,18 @@
|
||||
// API Actor API for managing SDN network object groups
|
||||
package netobjgroups
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creating request to network object groups
|
||||
type NetworkObjectGroups struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for external network object groups
|
||||
func New(client interfaces.Caller) *NetworkObjectGroups {
|
||||
return &NetworkObjectGroups{
|
||||
client,
|
||||
}
|
||||
}
|
||||
57
pkg/sdn/netobjgroups/update.go
Normal file
57
pkg/sdn/netobjgroups/update.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package netobjgroups
|
||||
|
||||
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 a network object group
|
||||
type UpdateRequest struct {
|
||||
// ID of the object group
|
||||
// Required: true
|
||||
ObjectGroupID string `url:"object_group_id" json:"object_group_id" validate:"required"`
|
||||
|
||||
// ID of the version
|
||||
// Required: true
|
||||
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||||
|
||||
// Access Group ID
|
||||
// Required: true
|
||||
AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
|
||||
|
||||
// Description of the network object group
|
||||
// Required: true
|
||||
Description string `url:"description" json:"description" validate:"required"`
|
||||
|
||||
// Name of the network object group
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
}
|
||||
|
||||
// Update updates a network object group
|
||||
func (nog NetworkObjectGroups) Update(ctx context.Context, req UpdateRequest) (*RecordNetObjGroup, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/network_object_group/update"
|
||||
|
||||
res, err := nog.client.DecortApiCallCtype(ctx, http.MethodPut, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := RecordNetObjGroup{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
Reference in New Issue
Block a user