v1.12.9
This commit is contained in:
50
pkg/sdn/extnet/get.go
Normal file
50
pkg/sdn/extnet/get.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package extnet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get information about external network
|
||||
type GetRequest struct {
|
||||
// ID of external network
|
||||
// Required: false
|
||||
ExtNetID string `url:"external_network_id" json:"external_network_id" validate:"required"`
|
||||
|
||||
// ID of access group
|
||||
// Required: false
|
||||
AccessGroupID string `url:"access_group_id,omitempty" json:"access_group_id,omitempty"`
|
||||
}
|
||||
|
||||
// Get gets external network details as a ExternalNetworkResponse struct
|
||||
func (e ExtNet) Get(ctx context.Context, req GetRequest) (*ExternalNetworkResponse, error) {
|
||||
res, err := e.GetRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := ExternalNetworkResponse{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets external network details as an array of bytes
|
||||
func (e ExtNet) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/external_network/get"
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
return res, err
|
||||
}
|
||||
Reference in New Issue
Block a user