v15.0.0
This commit is contained in:
46
pkg/cloudbroker/node/get_network_info.go
Normal file
46
pkg/cloudbroker/node/get_network_info.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||||
)
|
||||
|
||||
// GetNetworkInfoRequest struct to get network information of a node
|
||||
type GetNetworkInfoRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
|
||||
}
|
||||
|
||||
// GetNetworkInfo gets network information of a node as a RecordNodeNetworkInfo struct
|
||||
func (n Node) GetNetworkInfo(ctx context.Context, req GetNetworkInfoRequest) (*RecordNodeNetworkInfo, error) {
|
||||
res, err := n.GetNetworkInfoRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := RecordNodeNetworkInfo{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetNetworkInfoRaw gets network information of a node as an array of bytes
|
||||
func (n Node) GetNetworkInfoRaw(ctx context.Context, req GetNetworkInfoRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/node/get_network_info"
|
||||
|
||||
res, err := n.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
return res, err
|
||||
}
|
||||
Reference in New Issue
Block a user