v12.8.0
This commit is contained in:
47
pkg/sdn/adrspools/get.go
Normal file
47
pkg/sdn/adrspools/get.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package adrspools
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get information about address group
|
||||
type GetRequest struct {
|
||||
// ID an address group
|
||||
// Required: true
|
||||
ID string `url:"address_pool_id" json:"address_pool_id" validate:"required"`
|
||||
}
|
||||
|
||||
// Get gets address pool details as a NetworkAddressPool struct
|
||||
func (a AddressPools) Get(ctx context.Context, req GetRequest) (*NetworkAddressPool, error) {
|
||||
res, err := a.GetRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := NetworkAddressPool{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
|
||||
}
|
||||
|
||||
// GetRaw gets address pool details as an array of bytes
|
||||
func (a AddressPools) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/address_pool/get"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
return res, err
|
||||
}
|
||||
Reference in New Issue
Block a user