v1.12.9
This commit is contained in:
51
pkg/sdn/segments/get_status.go
Normal file
51
pkg/sdn/segments/get_status.go
Normal file
@@ -0,0 +1,51 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user