34 lines
610 B
Go
34 lines
610 B
Go
|
|
package version
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"encoding/json"
|
||
|
|
"net/http"
|
||
|
|
)
|
||
|
|
|
||
|
|
// Get gets SDN version info as a RecordVersion struct
|
||
|
|
func (v Version) Get(ctx context.Context) (*RecordVersion, error) {
|
||
|
|
res, err := v.GetRaw(ctx)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
|
||
|
|
info := RecordVersion{}
|
||
|
|
|
||
|
|
err = json.Unmarshal(res, &info)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
|
||
|
|
return &info, nil
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetRaw gets SDN version info as an array of bytes
|
||
|
|
func (v Version) GetRaw(ctx context.Context) ([]byte, error) {
|
||
|
|
|
||
|
|
url := "/sdn/version/get"
|
||
|
|
|
||
|
|
res, err := v.client.DecortApiCall(ctx, http.MethodGet, url, nil)
|
||
|
|
return res, err
|
||
|
|
}
|