v1.0.4
This commit is contained in:
1 parent
98b54b8ef9
commit
d340d1b2ad
16 files changed
+875
-60
No files matched your search
@@ -25,7 +25,9 @@ type GetPropertyResult struct {
|
||||
DynamixAuthType []DynamixAuthType `json:"dynamixAuthType,omitempty"`
|
||||
EnableProvideDNS bool `json:"enableProvideDNS,omitempty"`
|
||||
EnableProvideGPU bool `json:"enableProvideGPU,omitempty"`
|
||||
EnableProvideOIDC []OIDCStatus `json:"enableProvideOIDC,omitempty"`
|
||||
FullMarketplace bool `json:"fullMarketplace,omitempty"`
|
||||
NodeLimits NodeLimits `json:"nodeLimits,omitempty"`
|
||||
}
|
||||
|
||||
type GetPropertyResultWithError struct {
|
||||
@@ -35,6 +37,27 @@ type GetPropertyResultWithError struct {
|
||||
Result GetPropertyResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type NodeLimit struct {
|
||||
MaxCPUCount int64 `json:"maxCPUCount,omitempty"`
|
||||
MaxCount int64 `json:"maxCount,omitempty"`
|
||||
MaxDiskSize int64 `json:"maxDiskSize,omitempty"`
|
||||
MaxMemorySize int64 `json:"maxMemorySize,omitempty"`
|
||||
MinCPUCount int64 `json:"minCPUCount,omitempty"`
|
||||
MinDiskSize int64 `json:"minDiskSize,omitempty"`
|
||||
MinMemorySize int64 `json:"minMemorySize,omitempty"`
|
||||
}
|
||||
|
||||
type NodeLimits struct {
|
||||
LoadBalancer NodeLimit `json:"loadBalancer,omitempty"`
|
||||
Master NodeLimit `json:"master,omitempty"`
|
||||
Worker NodeLimit `json:"worker,omitempty"`
|
||||
}
|
||||
|
||||
type OIDCStatus struct {
|
||||
Enabled bool `json:"enabled,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type OSBuild struct {
|
||||
Images []DynamixImage `json:"images,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
@@ -0,0 +1,300 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_seaweedfs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeSeaweedfsService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// check whether installed in cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// check cluster pods liveness
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get SeaweedFS cluster status
|
||||
func (a *DeSeaweedfsService) Describe(ctx context.Context, req DescribeRequest) (DescribeSeaweedfsResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeSeaweedfsResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/seaweedfs/describe"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkInstallation", req.CheckInstallation, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkLiveness", req.CheckLiveness, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DescribeSeaweedfsResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type InstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// images apps repository ID
|
||||
AppsRepositoryID int64 `json:"appsRepositoryId" form:"appsRepositoryId"`
|
||||
// charts repository ID
|
||||
ChartsRepositoryID int64 `json:"chartsRepositoryId" form:"chartsRepositoryId"`
|
||||
// worker group name
|
||||
WorkerGroupName string `json:"workerGroupName" form:"workerGroupName"`
|
||||
// master replicas, 1 or 3 - raft requires odd (default 3)
|
||||
MasterReplicas int64 `json:"masterReplicas" form:"masterReplicas"`
|
||||
// volume server replicas, 1-7, must cover replication copies (default 3)
|
||||
VolumeReplicas int64 `json:"volumeReplicas" form:"volumeReplicas"`
|
||||
// volume storage size in GiB per volume-server replica, 10-16384 (default 50); Total storage = volumeReplicas x volumeStorageGb
|
||||
VolumeStorageGb int64 `json:"volumeStorageGb" form:"volumeStorageGb"`
|
||||
// max size in MB of a single seaweedfs volume file, 1024-30720 (default 10240); a volume is placed on a disk only if it fits entirely, so the disk must hold a whole number of volumes - with the default 50Gi volumeStorage a 10240 limit gives 5 volumes per disk. Smaller value means smaller volumes and more even distribution across volume servers but more volume files; larger value means larger volumes and fewer of them. SeaweedFS refuses limits above 30720 (30GB)
|
||||
VolumeSizeLimitMB int64 `json:"volumeSizeLimitMB" form:"volumeSizeLimitMB"`
|
||||
// replication placement XYZ, digits 0-2, e.g. 001 for a second copy (default 000)
|
||||
Replication string `json:"replication" form:"replication"`
|
||||
}
|
||||
|
||||
// Install SeaweedFS cluster in cluster via Seaweed CR
|
||||
func (a *DeSeaweedfsService) Install(ctx context.Context, req InstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/seaweedfs/install"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "appsRepositoryId", req.AppsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "chartsRepositoryId", req.ChartsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "workerGroupName", req.WorkerGroupName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "masterReplicas", req.MasterReplicas, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "volumeReplicas", req.VolumeReplicas, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "volumeStorageGb", req.VolumeStorageGb, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "volumeSizeLimitMB", req.VolumeSizeLimitMB, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "replication", req.Replication, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type UninstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// delete even if not registered
|
||||
CleanAlways bool `json:"cleanAlways" form:"cleanAlways"`
|
||||
// ignore dns server errors
|
||||
IgnoreDNSError bool `json:"ignoreDnsError" form:"ignoreDnsError"`
|
||||
}
|
||||
|
||||
// Uninstall SeaweedFS cluster from cluster
|
||||
func (a *DeSeaweedfsService) Uninstall(ctx context.Context, req UninstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/seaweedfs/uninstall"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cleanAlways", req.CleanAlways, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "ignoreDnsError", req.IgnoreDNSError, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_seaweedfs
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeSeaweedfs *DeSeaweedfsService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeSeaweedfs = (*DeSeaweedfsService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_seaweedfs
|
||||
|
||||
type DescribeSeaweedfsResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry SeaweedfsRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeSeaweedfsResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeSeaweedfsResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type SeaweedfsRecord struct {
|
||||
Addresses map[string]string `json:"addresses,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
S3AccessKey string `json:"s3AccessKey,omitempty"`
|
||||
S3Endpoint string `json:"s3Endpoint,omitempty"`
|
||||
S3SecretKey string `json:"s3SecretKey,omitempty"`
|
||||
StorageClass string `json:"storageClass,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_seaweedfs
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/BASIS/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,331 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_valkey
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeValkeyService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether valkey is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s valkey pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get valkey by id
|
||||
func (a *DeValkeyService) Describe(ctx context.Context, req DescribeRequest) (DescribeValkeyResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeValkeyResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/valkey/describe"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkInstallation", req.CheckInstallation, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkLiveness", req.CheckLiveness, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DescribeValkeyResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type InstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// password for a valkey user
|
||||
//
|
||||
// Required.
|
||||
Password string `json:"password" form:"password"`
|
||||
// hostname for valkey
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// storage type
|
||||
//
|
||||
// Allowed values:
|
||||
// - "longhorn"
|
||||
// - "glusterfs"
|
||||
// - ""
|
||||
StorageClass string `json:"storageClass" form:"storageClass"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// images apps repository ID. If the ID is zero or the value is empty, the default images apps repository will be used.
|
||||
AppsRepositoryID int64 `json:"appsRepositoryId" form:"appsRepositoryId"`
|
||||
// charts repository ID. If the ID is zero or the value is empty, the default charts repository will be used.
|
||||
ChartsRepositoryID int64 `json:"chartsRepositoryId" form:"chartsRepositoryId"`
|
||||
// worker group name
|
||||
WorkerGroupName string `json:"workerGroupName" form:"workerGroupName"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
}
|
||||
|
||||
// Install valkey in cluster
|
||||
func (a *DeValkeyService) Install(ctx context.Context, req InstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Password) {
|
||||
missingRequiredParams = append(missingRequiredParams, "password")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
if !utils.IsZeroValue(req.StorageClass) {
|
||||
storageClassValue := req.StorageClass
|
||||
storageClassAllowedValues := []string{
|
||||
"longhorn",
|
||||
"glusterfs",
|
||||
"",
|
||||
}
|
||||
storageClassValid := false
|
||||
for _, allowed := range storageClassAllowedValues {
|
||||
if storageClassValue == allowed {
|
||||
storageClassValid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !storageClassValid {
|
||||
return result, fmt.Errorf("storageClass must be one of %v", storageClassAllowedValues)
|
||||
}
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/valkey/install"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "password", req.Password, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "storageClass", req.StorageClass, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "appsRepositoryId", req.AppsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "chartsRepositoryId", req.ChartsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "workerGroupName", req.WorkerGroupName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "downloadChartAnyway", req.DownloadChartAnyway, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type UninstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for deleting valkey even if it is not registered
|
||||
CleanAlways bool `json:"cleanAlways" form:"cleanAlways"`
|
||||
// true for ignoring dns server errors
|
||||
IgnoreDNSError bool `json:"ignoreDnsError" form:"ignoreDnsError"`
|
||||
}
|
||||
|
||||
// Uninstall valkey from cluster
|
||||
func (a *DeValkeyService) Uninstall(ctx context.Context, req UninstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/valkey/uninstall"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cleanAlways", req.CleanAlways, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "ignoreDnsError", req.IgnoreDNSError, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_valkey
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeValkey *DeValkeyService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeValkey = (*DeValkeyService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_valkey
|
||||
|
||||
type DescribeValkeyResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry ValkeyRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeValkeyResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeValkeyResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ValkeyRecord struct {
|
||||
Addresses map[string]string `json:"addresses,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
Hostnames map[string]string `json:"hostnames,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
StorageClass string `json:"storageClass,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_valkey
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/BASIS/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
+52
-36
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
@@ -14,42 +15,6 @@ import (
|
||||
|
||||
type OpenIDService service
|
||||
|
||||
// Initiates OIDC login flow and redirects to OIDC provider
|
||||
// The caller must close the response body.
|
||||
func (a *OpenIDService) Authenticate(ctx context.Context) (*http.Response, error) {
|
||||
var (
|
||||
method = http.MethodGet
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/openid/authenticate"
|
||||
|
||||
contentTypes := []string{}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
return a.client.CallAPIWithoutRedirects(httpReq)
|
||||
}
|
||||
|
||||
// Returns OIDC enabled status
|
||||
func (a *OpenIDService) Status(ctx context.Context) (GetOpenIDStatusResult, error) {
|
||||
var (
|
||||
@@ -116,3 +81,54 @@ func (a *OpenIDService) Status(ctx context.Context) (GetOpenIDStatusResult, erro
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type AuthenticateByProviderNameRequest struct {
|
||||
// OIDC provider name
|
||||
//
|
||||
// Required.
|
||||
ProviderName string `json:"providername" form:"providername"`
|
||||
}
|
||||
|
||||
// Initiates OIDC login flow and redirects to OIDC provider
|
||||
// The caller must close the response body.
|
||||
func (a *OpenIDService) AuthenticateByProviderName(ctx context.Context, req AuthenticateByProviderNameRequest) (*http.Response, error) {
|
||||
var (
|
||||
method = http.MethodGet
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ProviderName) {
|
||||
missingRequiredParams = append(missingRequiredParams, "providername")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return nil, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/openid/{providername}/authenticate"
|
||||
requestPath = strings.ReplaceAll(requestPath, "{"+"providername"+"}", url.PathEscape(utils.ParameterValueToString(req.ProviderName)))
|
||||
|
||||
contentTypes := []string{}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
return a.client.CallAPIWithoutRedirects(httpReq)
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
package openid
|
||||
|
||||
type GetOpenIDStatusResult struct {
|
||||
Enabled bool `json:"enabled,omitempty"`
|
||||
OpenIDStatuses []OpenIDStatus `json:"openIdStatuses,omitempty"`
|
||||
}
|
||||
|
||||
type GetOpenIDStatusResultWithError struct {
|
||||
@@ -12,3 +12,8 @@ type GetOpenIDStatusResultWithError struct {
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetOpenIDStatusResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type OpenIDStatus struct {
|
||||
Enabled bool `json:"enabled,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
Reference in new issue
Block a user