This commit is contained in:
dayterr
2026-04-17 17:10:10 +03:00
parent cd67633a52
commit 5e5d90e24f
22 changed files with 752 additions and 112 deletions

View File

@@ -2,6 +2,7 @@ package netobjgroups
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/constants"
@@ -26,6 +27,7 @@ type AttachLogicalPortsRequest struct {
// Required: true
PortBindings []PortBindings `url:"port_bindings" json:"port_bindings" validate:"required,dive"`
}
type PortBindings struct {
// ID of a logical port
// Required: true
@@ -37,18 +39,25 @@ type PortBindings struct {
}
// AttachLogicalPorts attaches logical ports to a network object group
func (nog NetworkObjectGroups) AttachLogicalPorts(ctx context.Context, req AttachLogicalPortsRequest) (bool, error) {
func (nog NetworkObjectGroups) AttachLogicalPorts(ctx context.Context, req AttachLogicalPortsRequest) (*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/network_object_group/attach_logical_ports"
_, err = nog.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
res, err := nog.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return false, err
return nil, err
}
return true, nil
info := RecordVersion{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}