v1.14.7
This commit is contained in:
33
pkg/sdn/version/get.go
Normal file
33
pkg/sdn/version/get.go
Normal file
@@ -0,0 +1,33 @@
|
||||
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
|
||||
}
|
||||
25
pkg/sdn/version/models.go
Normal file
25
pkg/sdn/version/models.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package version
|
||||
|
||||
// Version info of the SDN platform
|
||||
type RecordVersion struct {
|
||||
// Core component version info
|
||||
Core ComponentVersion `json:"core"`
|
||||
|
||||
// Director component version info
|
||||
Director ComponentVersion `json:"director"`
|
||||
}
|
||||
|
||||
// Version info of a single component
|
||||
type ComponentVersion struct {
|
||||
// Branch name
|
||||
Branch string `json:"branch"`
|
||||
|
||||
// Build time
|
||||
BuildTime string `json:"build_time"`
|
||||
|
||||
// Commit hash
|
||||
Commit string `json:"commit"`
|
||||
|
||||
// Version string
|
||||
Version string `json:"version"`
|
||||
}
|
||||
18
pkg/sdn/version/version.go
Normal file
18
pkg/sdn/version/version.go
Normal file
@@ -0,0 +1,18 @@
|
||||
// API Actor API for managing SDN version
|
||||
package version
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creating request to version
|
||||
type Version struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for version endpoints
|
||||
func New(client interfaces.Caller) *Version {
|
||||
return &Version{
|
||||
client,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user