This commit is contained in:
dayterr
2026-04-10 16:38:00 +03:00
parent 30e464e4d2
commit 5cdae8520f
16 changed files with 458 additions and 62 deletions

33
pkg/sdn/version/get.go Normal file
View 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
View 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"`
}

View 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,
}
}