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.
49 lines
1.1 KiB
49 lines
1.1 KiB
package segments
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
// GetRequest struct to get information about segment
|
|
type GetRequest struct {
|
|
// ID of segment
|
|
// Required: true
|
|
SegmentID string `url:"segment_id" json:"segment_id" validate:"required"`
|
|
|
|
// ID of access group
|
|
// Required: false
|
|
AccessGroupID string `url:"access_group_id,omitempty" json:"access_group_id,omitempty"`
|
|
}
|
|
|
|
// Get gets segment details as a SegmentResponse struct
|
|
func (s Segments) Get(ctx context.Context, req GetRequest) (*SegmentResponse, error) {
|
|
res, err := s.GetRaw(ctx, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
info := SegmentResponse{}
|
|
|
|
err = json.Unmarshal(res, &info)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &info, nil
|
|
}
|
|
|
|
// GetRaw gets segment details as an array of bytes
|
|
func (s Segments) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
|
|
|
//if err := validators.ValidateRequest(req); err != nil {
|
|
// return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
//}
|
|
|
|
url := "/sdn/segment/get"
|
|
|
|
res, err := s.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
|
return res, err
|
|
}
|