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.
52 lines
1.2 KiB
52 lines
1.2 KiB
|
4 days ago
|
package segments
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"encoding/json"
|
||
|
|
"net/http"
|
||
|
|
|
||
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||
|
|
)
|
||
|
|
|
||
|
|
// GetStatusRequest struct to get information about segment status
|
||
|
|
type GetStatusRequest struct {
|
||
|
|
// ID of segment
|
||
|
|
// Required: true
|
||
|
|
SegmentID string `url:"segment_id" json:"segment_id" validate:"required"`
|
||
|
|
|
||
|
|
// ID of version
|
||
|
|
// Required: false
|
||
|
|
VersionID uint64 `url:"version_id,omitempty" json:"version_id,omitempty"`
|
||
|
|
|
||
|
|
// Get detailed status or not
|
||
|
|
// Required: false
|
||
|
|
Detailed interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetStatus gets segment status
|
||
|
|
func (s Segments) GetStatus(ctx context.Context, req GetStatusRequest) (string, error) {
|
||
|
|
type temp struct {
|
||
|
|
Status string `json:"status"`
|
||
|
|
}
|
||
|
|
|
||
|
|
err := validators.ValidateRequest(req)
|
||
|
|
if err != nil {
|
||
|
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||
|
|
}
|
||
|
|
|
||
|
|
url := "/sdn/segment/get_status"
|
||
|
|
|
||
|
|
res, err := s.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||
|
|
if err != nil {
|
||
|
|
return "", err
|
||
|
|
}
|
||
|
|
|
||
|
|
info := temp{}
|
||
|
|
err = json.Unmarshal(res, &info)
|
||
|
|
if err != nil {
|
||
|
|
return "", err
|
||
|
|
}
|
||
|
|
|
||
|
|
return info.Status, nil
|
||
|
|
}
|