You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
decort-golang-sdk/pkg/sdn/netobjgroups/get.go

48 lines
1.1 KiB

4 days ago
package netobjgroups
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/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
}