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.
decort-golang-sdk/pkg/cloudbroker/k8s/get.go

47 lines
1.1 KiB

3 years ago
package k8s
import (
"context"
"encoding/json"
"net/http"
3 years ago
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
3 years ago
)
2 years ago
// GetRequest struct to get detailed information about kubernetes cluster
3 years ago
type GetRequest struct {
// Kubernetes cluster ID
// Required: true
3 years ago
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
3 years ago
}
2 years ago
// Get gets information about kubernetes cluster as a RecordK8S struct
3 years ago
func (k K8S) Get(ctx context.Context, req GetRequest) (*RecordK8S, error) {
2 years ago
res, err := k.GetRaw(ctx, req)
3 years ago
if err != nil {
return nil, err
}
info := RecordK8S{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}
2 years ago
// GetRaw gets information about kubernetes cluster as an array of bytes
func (k K8S) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
2 years ago
return nil, validators.ValidationErrors(validators.GetErrors(err))
2 years ago
}
url := "/cloudbroker/k8s/get"
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}