v1.0.0
This commit is contained in:
commit
1329892e96
292 files changed
+43992
No files matched your search
@@ -0,0 +1,307 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_apisix
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeAPISIXService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the apisix is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s apisix pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get apisix by id
|
||||
func (a *DeAPISIXService) Describe(ctx context.Context, req DescribeRequest) (DescribeAPISIXResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeAPISIXResult
|
||||
)
|
||||
|
||||
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/apisix/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 DescribeAPISIXResultWithError
|
||||
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 apisix
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// http port
|
||||
//
|
||||
// Required.
|
||||
HTTPPort int64 `json:"httpPort" form:"httpPort"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// https port
|
||||
HTTPSPort int64 `json:"httpsPort" form:"httpsPort"`
|
||||
// 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 apisix in cluster
|
||||
func (a *DeAPISIXService) 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.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.HTTPPort) {
|
||||
missingRequiredParams = append(missingRequiredParams, "httpPort")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/apisix/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, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "httpPort", req.HTTPPort, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "httpsPort", req.HTTPSPort, "", "")
|
||||
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 the apisix 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 apisix from cluster
|
||||
func (a *DeAPISIXService) 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/apisix/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_apisix
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeAPISIX *DeAPISIXService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeAPISIX = (*DeAPISIXService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_apisix
|
||||
|
||||
type APISIXRecord struct {
|
||||
Addresses map[string]string `json:"addresses,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
Hostnames map[string]string `json:"hostnames,omitempty"`
|
||||
HTTPPort int64 `json:"httpPort,omitempty"`
|
||||
HTTPSPort int64 `json:"httpsPort,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"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeAPISIXResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry APISIXRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeAPISIXResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeAPISIXResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_apisix
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,273 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_audits
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeAuditsService service
|
||||
|
||||
type LinkRequest struct {
|
||||
// filter audits by clusterId
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// filter audits by nodeId
|
||||
//
|
||||
// Required.
|
||||
NodeID int64 `json:"nodeId" form:"nodeId"`
|
||||
// filter audits by time after (starttime) as unix timestamp in seconds
|
||||
TimeAfter int64 `json:"timeAfter" form:"timeAfter"`
|
||||
// filter audits by time before (endtime) as unix timestamp in seconds
|
||||
TimeBefore int64 `json:"timeBefore" form:"timeBefore"`
|
||||
// filter audits by request uri
|
||||
RequestURI string `json:"requestUri" form:"requestUri"`
|
||||
// filter audits by verb
|
||||
//
|
||||
// Allowed values:
|
||||
// - "get"
|
||||
// - "list"
|
||||
// - "create"
|
||||
// - "update"
|
||||
// - "patch"
|
||||
// - "delete"
|
||||
// - "watch"
|
||||
// - "deletecollection"
|
||||
// - ""
|
||||
Verb string `json:"verb" form:"verb"`
|
||||
// filter audits by authorization decision
|
||||
//
|
||||
// Allowed values:
|
||||
// - "forbid"
|
||||
// - "allow"
|
||||
// - ""
|
||||
Decision string `json:"decision" form:"decision"`
|
||||
// filter audits by object source ip
|
||||
SourceIP string `json:"sourceIp" form:"sourceIp"`
|
||||
}
|
||||
|
||||
// Get link to download audits
|
||||
func (a *DeAuditsService) Link(ctx context.Context, req LinkRequest) (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.NodeID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "nodeId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
if !utils.IsZeroValue(req.Verb) {
|
||||
verbValue := req.Verb
|
||||
verbAllowedValues := []string{
|
||||
"get",
|
||||
"list",
|
||||
"create",
|
||||
"update",
|
||||
"patch",
|
||||
"delete",
|
||||
"watch",
|
||||
"deletecollection",
|
||||
"",
|
||||
}
|
||||
verbValid := false
|
||||
for _, allowed := range verbAllowedValues {
|
||||
if verbValue == allowed {
|
||||
verbValid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !verbValid {
|
||||
return result, fmt.Errorf("verb must be one of %v", verbAllowedValues)
|
||||
}
|
||||
}
|
||||
if !utils.IsZeroValue(req.Decision) {
|
||||
decisionValue := req.Decision
|
||||
decisionAllowedValues := []string{
|
||||
"forbid",
|
||||
"allow",
|
||||
"",
|
||||
}
|
||||
decisionValid := false
|
||||
for _, allowed := range decisionAllowedValues {
|
||||
if decisionValue == allowed {
|
||||
decisionValid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !decisionValid {
|
||||
return result, fmt.Errorf("decision must be one of %v", decisionAllowedValues)
|
||||
}
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/audit/link"
|
||||
|
||||
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, "nodeId", req.NodeID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "timeAfter", req.TimeAfter, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "timeBefore", req.TimeBefore, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "requestUri", req.RequestURI, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "verb", req.Verb, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "decision", req.Decision, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "sourceIp", req.SourceIP, "", "")
|
||||
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 ListRequest struct {
|
||||
// clusterId for which to show links with downloadable audits
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// if true, only active links are shown. By default, all links (including expired) are shown
|
||||
ShowActive bool `json:"showActive" form:"showActive"`
|
||||
// Limit number of audit links results to be shown in the result. If not set, all results will be shown.
|
||||
Limit int64 `json:"limit" form:"limit"`
|
||||
// Select page of the result. If not set, the first page will be shown.
|
||||
Page int64 `json:"page" form:"page"`
|
||||
}
|
||||
|
||||
// List links to download audits
|
||||
func (a *DeAuditsService) List(ctx context.Context, req ListRequest) (ListLinksAuditsResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result ListLinksAuditsResult
|
||||
)
|
||||
|
||||
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/audit/list"
|
||||
|
||||
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, "showActive", req.ShowActive, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "limit", req.Limit, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "page", req.Page, "", "")
|
||||
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 ListLinksAuditsResultWithError
|
||||
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_audits
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeAudits *DeAuditsService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeAudits = (*DeAuditsService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_audits
|
||||
|
||||
type Audit struct {
|
||||
RequestURIFilter string `json:"RequestUriFilter,omitempty"`
|
||||
AuditsCount int64 `json:"auditsCount,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
DecisionFilter string `json:"decisionFilter,omitempty"`
|
||||
// download info
|
||||
Downloads []Download `json:"downloads,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
FileName string `json:"fileName,omitempty"`
|
||||
FilePath string `json:"filePath,omitempty"`
|
||||
FileSize int64 `json:"fileSize,omitempty"`
|
||||
// audit link info
|
||||
ID int64 `json:"id,omitempty"`
|
||||
IsActive bool `json:"isActive,omitempty"`
|
||||
NodeID int64 `json:"nodeId,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
SourceIPFilter string `json:"sourceIpFilter,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
// optional audit filters
|
||||
TimeAfterFilter int64 `json:"timeAfterFilter,omitempty"`
|
||||
TimeBeforeFilter int64 `json:"timeBeforeFilter,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
VerbFilter string `json:"verbFilter,omitempty"`
|
||||
ZipSize int64 `json:"zipSize,omitempty"`
|
||||
}
|
||||
|
||||
type Download struct {
|
||||
DownloadDate string `json:"downloadDate,omitempty"`
|
||||
Successfull bool `json:"successfull,omitempty"`
|
||||
UserID int64 `json:"userId,omitempty"`
|
||||
UserName string `json:"userName,omitempty"`
|
||||
}
|
||||
|
||||
type ListLinksAuditsResult struct {
|
||||
Audit []Audit `json:"audit,omitempty"`
|
||||
Total int64 `json:"total,omitempty"`
|
||||
}
|
||||
|
||||
type ListLinksAuditsResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListLinksAuditsResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_audits
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
@@ -0,0 +1,432 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_autoscaler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeAutoscalerService service
|
||||
|
||||
type ListAutoscalerDeploymentsRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// The namespace scope
|
||||
//
|
||||
// Required.
|
||||
Namespace string `json:"namespace" form:"namespace"`
|
||||
}
|
||||
|
||||
// Get list of autoscaler deployments
|
||||
func (a *DeAutoscalerService) ListAutoscalerDeployments(ctx context.Context, req ListAutoscalerDeploymentsRequest) (ListAutoscalerDeploymentsResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result ListAutoscalerDeploymentsResult
|
||||
)
|
||||
|
||||
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.Namespace) {
|
||||
missingRequiredParams = append(missingRequiredParams, "namespace")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/autoscaler/listAutoscalerDeployments"
|
||||
|
||||
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, "namespace", req.Namespace, "", "")
|
||||
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 ListAutoscalerDeploymentsResultWithError
|
||||
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 TurnOffAutoscalerDeploymentRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// Name of the deployment to which auto scaling will be applied
|
||||
//
|
||||
// Required.
|
||||
NameDeployment string `json:"nameDeployment" form:"nameDeployment"`
|
||||
// The namespace scope
|
||||
//
|
||||
// Required.
|
||||
Namespace string `json:"namespace" form:"namespace"`
|
||||
}
|
||||
|
||||
// Turn off autoscaler deployment
|
||||
func (a *DeAutoscalerService) TurnOffAutoscalerDeployment(ctx context.Context, req TurnOffAutoscalerDeploymentRequest) (any, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result any
|
||||
)
|
||||
|
||||
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.NameDeployment) {
|
||||
missingRequiredParams = append(missingRequiredParams, "nameDeployment")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Namespace) {
|
||||
missingRequiredParams = append(missingRequiredParams, "namespace")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/autoscaler/turnOffAutoscalerDeployment"
|
||||
|
||||
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, "nameDeployment", req.NameDeployment, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "namespace", req.Namespace, "", "")
|
||||
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 TurnOffAutoscalerDeploymentResultWithError
|
||||
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 TurnOnAutoscalerDeploymentRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// Name of the deployment to which auto scaling will be applied
|
||||
//
|
||||
// Required.
|
||||
NameDeployment string `json:"nameDeployment" form:"nameDeployment"`
|
||||
// The namespace scope
|
||||
//
|
||||
// Required.
|
||||
Namespace string `json:"namespace" form:"namespace"`
|
||||
// The lower limit for the number of pods that can be set by the autoscaler
|
||||
//
|
||||
// Required.
|
||||
MinPods int64 `json:"minPods" form:"minPods"`
|
||||
// The upper limit for the number of pods that can be set by the autoscaler
|
||||
//
|
||||
// Required.
|
||||
MaxPods int64 `json:"maxPods" form:"maxPods"`
|
||||
// The target average CPU utilization (represented as a percent of requested CPU) over all the pods
|
||||
//
|
||||
// Required.
|
||||
CPUPercent int64 `json:"cpuPercent" form:"cpuPercent"`
|
||||
}
|
||||
|
||||
// Turn on autoscaler deployment
|
||||
func (a *DeAutoscalerService) TurnOnAutoscalerDeployment(ctx context.Context, req TurnOnAutoscalerDeploymentRequest) (any, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result any
|
||||
)
|
||||
|
||||
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.NameDeployment) {
|
||||
missingRequiredParams = append(missingRequiredParams, "nameDeployment")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Namespace) {
|
||||
missingRequiredParams = append(missingRequiredParams, "namespace")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.MinPods) {
|
||||
missingRequiredParams = append(missingRequiredParams, "minPods")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.MaxPods) {
|
||||
missingRequiredParams = append(missingRequiredParams, "maxPods")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.CPUPercent) {
|
||||
missingRequiredParams = append(missingRequiredParams, "cpuPercent")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/autoscaler/turnOnAutoscalerDeployment"
|
||||
|
||||
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, "nameDeployment", req.NameDeployment, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "namespace", req.Namespace, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "minPods", req.MinPods, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "maxPods", req.MaxPods, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cpuPercent", req.CPUPercent, "", "")
|
||||
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 TurnOnAutoscalerDeploymentResultWithError
|
||||
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 UpdateAutoscalerDeploymentRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// Name of the deployment to which auto scaling will be applied
|
||||
//
|
||||
// Required.
|
||||
NameDeployment string `json:"nameDeployment" form:"nameDeployment"`
|
||||
// The namespace scope
|
||||
//
|
||||
// Required.
|
||||
Namespace string `json:"namespace" form:"namespace"`
|
||||
// The lower limit for the number of pods that can be set by the autoscaler
|
||||
MinPods int64 `json:"minPods" form:"minPods"`
|
||||
// The upper limit for the number of pods that can be set by the autoscaler
|
||||
MaxPods int64 `json:"maxPods" form:"maxPods"`
|
||||
// The target average CPU utilization (represented as a percent of requested CPU) over all the pods
|
||||
CPUPercent int64 `json:"cpuPercent" form:"cpuPercent"`
|
||||
}
|
||||
|
||||
// Update params autoscaler deployment
|
||||
func (a *DeAutoscalerService) UpdateAutoscalerDeployment(ctx context.Context, req UpdateAutoscalerDeploymentRequest) (any, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result any
|
||||
)
|
||||
|
||||
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.NameDeployment) {
|
||||
missingRequiredParams = append(missingRequiredParams, "nameDeployment")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Namespace) {
|
||||
missingRequiredParams = append(missingRequiredParams, "namespace")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/autoscaler/updateAutoscalerDeployment"
|
||||
|
||||
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, "nameDeployment", req.NameDeployment, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "namespace", req.Namespace, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "minPods", req.MinPods, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "maxPods", req.MaxPods, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cpuPercent", req.CPUPercent, "", "")
|
||||
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 UpdateAutoscalerDeploymentResultWithError
|
||||
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_autoscaler
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeAutoscaler *DeAutoscalerService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeAutoscaler = (*DeAutoscalerService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+83
@@ -0,0 +1,83 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_autoscaler
|
||||
|
||||
type Autoscaler struct {
|
||||
Metadata AutoscalerMetadata `json:"metadata,omitempty"`
|
||||
Spec AutoscalerSpec `json:"spec,omitempty"`
|
||||
Status AutoscalerStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type AutoscalerMetadata struct {
|
||||
Annotations map[string]string `json:"annotations,omitempty"`
|
||||
CreationTimestamp string `json:"creationTimestamp,omitempty"`
|
||||
ManagedFields []ManagedField `json:"managedFields,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
ResourceVersion string `json:"resourceVersion,omitempty"`
|
||||
UID string `json:"uid,omitempty"`
|
||||
}
|
||||
|
||||
type AutoscalerSpec struct {
|
||||
MaxReplicas int64 `json:"maxReplicas,omitempty"`
|
||||
MinReplicas int64 `json:"minReplicas,omitempty"`
|
||||
ScaleTargetRef ScaleTargetRef `json:"scaleTargetRef,omitempty"`
|
||||
TargetCPUUtilizationPercentage int64 `json:"targetCPUUtilizationPercentage,omitempty"`
|
||||
}
|
||||
|
||||
type AutoscalerStatus struct {
|
||||
CurrentReplicas int64 `json:"currentReplicas,omitempty"`
|
||||
DesiredReplicas int64 `json:"desiredReplicas,omitempty"`
|
||||
}
|
||||
|
||||
type ListAutoscalerDeploymentsResult struct {
|
||||
Items []Autoscaler `json:"items,omitempty"`
|
||||
Metadata ListAutoscalerMetadata `json:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
type ListAutoscalerDeploymentsResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListAutoscalerDeploymentsResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListAutoscalerMetadata struct {
|
||||
ResourceVersion string `json:"resourceVersion,omitempty"`
|
||||
}
|
||||
|
||||
type ManagedField struct {
|
||||
APIVersion string `json:"apiVersion,omitempty"`
|
||||
FieldsType string `json:"fieldsType,omitempty"`
|
||||
Manager string `json:"manager,omitempty"`
|
||||
Operation string `json:"operation,omitempty"`
|
||||
Subresource string `json:"subresource,omitempty"`
|
||||
Time string `json:"time,omitempty"`
|
||||
}
|
||||
|
||||
type ScaleTargetRef struct {
|
||||
APIVersion string `json:"apiVersion,omitempty"`
|
||||
Kind string `json:"kind,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type TurnOffAutoscalerDeploymentResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type TurnOnAutoscalerDeploymentResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateAutoscalerDeploymentResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_certificates
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeCertificatesService service
|
||||
|
||||
type KubeadmCheckExpirationRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
}
|
||||
|
||||
// Check certificates expiration for a Kubernetes cluster
|
||||
func (a *DeCertificatesService) KubeadmCheckExpiration(ctx context.Context, req KubeadmCheckExpirationRequest) (KubeadmCertsCheckExpirationResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result KubeadmCertsCheckExpirationResult
|
||||
)
|
||||
|
||||
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/certificates/kubeadm/checkExpiration"
|
||||
|
||||
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, "", "")
|
||||
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 KubeadmCertsCheckExpirationResultWithError
|
||||
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 KubeadmRenewRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
}
|
||||
|
||||
// Renew certificates for a Kubernetes cluster
|
||||
func (a *DeCertificatesService) KubeadmRenew(ctx context.Context, req KubeadmRenewRequest) (KubeadmCertsRenewResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result KubeadmCertsRenewResult
|
||||
)
|
||||
|
||||
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/certificates/kubeadm/renew"
|
||||
|
||||
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, "", "")
|
||||
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 KubeadmCertsRenewResultWithError
|
||||
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_certificates
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeCertificates *DeCertificatesService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeCertificates = (*DeCertificatesService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_certificates
|
||||
|
||||
type KubeadmCertsCheckExpirationResult struct {
|
||||
TaskID int64 `json:"taskID,omitempty"`
|
||||
}
|
||||
|
||||
type KubeadmCertsCheckExpirationResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result KubeadmCertsCheckExpirationResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type KubeadmCertsRenewResult struct {
|
||||
TaskID int64 `json:"taskID,omitempty"`
|
||||
}
|
||||
|
||||
type KubeadmCertsRenewResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result KubeadmCertsRenewResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_certmanager
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeCertmanagerService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the certmanager is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s certmanager pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"CheckLiveness" form:"CheckLiveness"`
|
||||
}
|
||||
|
||||
// Get certmanager by id
|
||||
func (a *DeCertmanagerService) Describe(ctx context.Context, req DescribeRequest) (DescribeCertmanagerResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeCertmanagerResult
|
||||
)
|
||||
|
||||
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/certmanager/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 DescribeCertmanagerResultWithError
|
||||
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 certmanager
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// 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 for certmanager
|
||||
WorkerGroupName string `json:"workerGroupName" form:"workerGroupName"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
}
|
||||
|
||||
// Install certmanager in cluster
|
||||
func (a *DeCertmanagerService) 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.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/certmanager/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, "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 the certmanager 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 certmanager from cluster
|
||||
func (a *DeCertmanagerService) 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/certmanager/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_certmanager
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeCertmanager *DeCertmanagerService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeCertmanager = (*DeCertmanagerService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_certmanager
|
||||
|
||||
type CertmanagerRecord struct {
|
||||
Addresses map[string]string `json:"addresses,omitempty"`
|
||||
CACert string `json:"caCert,omitempty"`
|
||||
CAKey string `json:"caKey,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"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeCertmanagerResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry CertmanagerRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeCertmanagerResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeCertmanagerResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_certmanager
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_cluster
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeCluster *DeClusterService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeCluster = (*DeClusterService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+703
@@ -0,0 +1,703 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_cluster
|
||||
|
||||
type Cluster struct {
|
||||
AppContainerRepository string `json:"appContainerRepository,omitempty"`
|
||||
AuditEnabled bool `json:"auditEnabled,omitempty"`
|
||||
CertificateKey string `json:"certificateKey,omitempty"`
|
||||
CertificateValidityBefore string `json:"certificateValidityBefore,omitempty"`
|
||||
// Cni
|
||||
ContainerNetworkType string `json:"containerNetworkType,omitempty"`
|
||||
// Lifecycle data
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
CreationError string `json:"creationError,omitempty"`
|
||||
CustomMTU int64 `json:"customMTU,omitempty"`
|
||||
// Denergy data
|
||||
DenergyID int64 `json:"denergyId,omitempty"`
|
||||
DenergyName string `json:"denergyName,omitempty"`
|
||||
DenergyStatus string `json:"denergyStatus,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
DescriptionStatus map[string]string `json:"descriptionStatus,omitempty"`
|
||||
DestroyingDate string `json:"destroyingDate,omitempty"`
|
||||
DestroyingError string `json:"destroyingError,omitempty"`
|
||||
DNSDomain string `json:"dnsDomain,omitempty"`
|
||||
DomainResolvers []string `json:"domainResolvers,omitempty"`
|
||||
DynamixCIID int64 `json:"dynamixCIId,omitempty"`
|
||||
DynamixCreateTaskID string `json:"dynamixCreateTaskId,omitempty"`
|
||||
// Dynamyx data
|
||||
DynamixID int64 `json:"dynamixId,omitempty"`
|
||||
DynamixK8CIID int64 `json:"dynamixK8CIId,omitempty"`
|
||||
DynamixOwnerID int64 `json:"dynamixOwnerId,omitempty"`
|
||||
DynamixRGID int64 `json:"dynamixRGId,omitempty"`
|
||||
DynamixSEPID int64 `json:"dynamixSEPId,omitempty"`
|
||||
DynamixSEPPool string `json:"dynamixSEPPool,omitempty"`
|
||||
DynamixStatus string `json:"dynamixStatus,omitempty"`
|
||||
DynamixTechStatus string `json:"dynamixTechStatus,omitempty"`
|
||||
DynamixVersion DynamixVersion `json:"dynamixVersion,omitempty"`
|
||||
// Data encryption information
|
||||
Encrypted bool `json:"encrypted,omitempty"`
|
||||
ExtVirtualAddress string `json:"extVirtualAddress,omitempty"`
|
||||
// Virtual addresses
|
||||
ExtVirtualAddressID int64 `json:"extVirtualAddressId,omitempty"`
|
||||
GlobalNetworkID int64 `json:"globalNetworkId,omitempty"`
|
||||
// Components data
|
||||
ILoadBalancerIDs []int64 `json:"iLoadBalancerIds,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
InitialDynamixSEPID int64 `json:"initialDynamixSEPId,omitempty"`
|
||||
InitialDynamixSEPPool string `json:"initialDynamixSEPPool,omitempty"`
|
||||
InitialMachineOSBuild string `json:"initialMachineOSBuild,omitempty"`
|
||||
InitialMachineOSImageID int64 `json:"initialMachineOSImageId,omitempty"`
|
||||
InitialMachineOSType string `json:"initialMachineOSType,omitempty"`
|
||||
// Reference for next machines
|
||||
InitialMachineProvider string `json:"initialMachineProvider,omitempty"`
|
||||
InitialRuntimeType string `json:"initialRuntimeType,omitempty"`
|
||||
// secure shell
|
||||
InitialSecureShellPort int64 `json:"initialSecureShellPort,omitempty"`
|
||||
// Instaled Components
|
||||
InstalledAutoscaler bool `json:"installedAutoscaler,omitempty"`
|
||||
InstalledCriobox bool `json:"installedCriobox,omitempty"`
|
||||
InstalledIntegagent bool `json:"installedIntegagent,omitempty"`
|
||||
InstalledKyverno bool `json:"installedKyverno,omitempty"`
|
||||
InstalledMetricServer bool `json:"installedMetricServer,omitempty"`
|
||||
InstalledMonitoring bool `json:"installedMonitoring,omitempty"`
|
||||
InstalledPodLogger bool `json:"installedPodLogger,omitempty"`
|
||||
InstalledRBACManager bool `json:"installedRbacManager,omitempty"`
|
||||
InstalledServchecker bool `json:"installedServchecker,omitempty"`
|
||||
InstalledTrivy bool `json:"installedTrivy,omitempty"`
|
||||
IntVirtualAddress string `json:"intVirtualAddress,omitempty"`
|
||||
IntVirtualAddressID int64 `json:"intVirtualAddressId,omitempty"`
|
||||
KubeAddresses []string `json:"kubeAddresses,omitempty"`
|
||||
KubeConfig string `json:"kubeConfig,omitempty"`
|
||||
// Repositories used for cluster nodes preparing and post install operatios
|
||||
KubeContainerRepository string `json:"kubeContainerRepository,omitempty"`
|
||||
KubeHostname string `json:"kubeHostname,omitempty"`
|
||||
// Kube data
|
||||
KubeVersion string `json:"kubeVersion,omitempty"`
|
||||
LoadBalancerCloudInitTemplate string `json:"loadBalancerCloudInitTemplate,omitempty"`
|
||||
LocalNetwork string `json:"localNetwork,omitempty"`
|
||||
LocalNetworkID int64 `json:"localNetworkId,omitempty"`
|
||||
// Templates
|
||||
MasterCloudInitTemplate string `json:"masterCloudInitTemplate,omitempty"`
|
||||
MasterIDs []int64 `json:"masterIds,omitempty"`
|
||||
// Generic data
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
PolicyIDs []int64 `json:"policyIds,omitempty"`
|
||||
PoolVMIDs []int64 `json:"poolVmIds,omitempty"`
|
||||
// DNS data
|
||||
ProvideDNS bool `json:"provideDNS,omitempty"`
|
||||
Quorum int64 `json:"quorum,omitempty"`
|
||||
ReleaseVersion string `json:"releaseVersion,omitempty"`
|
||||
RootCAID int64 `json:"rootCaId,omitempty"`
|
||||
StoragePolicyID int64 `json:"storagePolicyId,omitempty"`
|
||||
TechStatus string `json:"techStatus,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
UpgradeDate string `json:"upgradeDate,omitempty"`
|
||||
UpgradeError string `json:"upgradeError,omitempty"`
|
||||
// UseDynamixExtnet
|
||||
UseDynamixExtNet bool `json:"useDynamixExtnet,omitempty"`
|
||||
UserID int64 `json:"userId,omitempty"`
|
||||
VersionCrypt string `json:"versionCrypt,omitempty"`
|
||||
ViNSGlobalNetworkID int64 `json:"vinsGlobalNetworkId,omitempty"`
|
||||
WorkerGroupIDs []int64 `json:"workerGroupIds,omitempty"`
|
||||
WorkerIDs []int64 `json:"workerIds,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterBrief struct {
|
||||
// Lifecycle data
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
// Denergy data
|
||||
DenergyStatus string `json:"denergyStatus,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
DescriptionStatus map[string]string `json:"descriptionStatus,omitempty"`
|
||||
// Dynamyx data
|
||||
DynamixCreateTaskID string `json:"dynamixCreateTaskId,omitempty"`
|
||||
DynamixStatus string `json:"dynamixStatus,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
// Instaled Components
|
||||
InstalledAutoscaler bool `json:"installedAutoscaler,omitempty"`
|
||||
InstalledCriobox bool `json:"installedCriobox,omitempty"`
|
||||
InstalledKyverno bool `json:"installedKyverno,omitempty"`
|
||||
InstalledMetricServer bool `json:"installedMetricServer,omitempty"`
|
||||
InstalledMonitoring bool `json:"installedMonitoring,omitempty"`
|
||||
InstalledPodLogger bool `json:"installedPodLogger,omitempty"`
|
||||
InstalledRBACManager bool `json:"installedRbacManager,omitempty"`
|
||||
InstalledServchecker bool `json:"installedServchecker,omitempty"`
|
||||
InstalledTrivy bool `json:"installedTrivy,omitempty"`
|
||||
// Generic data
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
// Reference for next machines
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
TechStatus string `json:"techStatus,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterTaskCreationResult struct {
|
||||
AuditID string `json:"auditId,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
ClusterType string `json:"clusterType,omitempty"`
|
||||
TaskID int64 `json:"taskId,omitempty"`
|
||||
TaskIsAsync bool `json:"taskIsAsync,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterTaskCreationResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ClusterTaskCreationResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeClusterResult struct {
|
||||
IncompleteVerificationTaskBriefs []TaskBrief `json:"incompleteVerificationTaskBriefs,omitempty"`
|
||||
TaskBriefs []TaskBrief `json:"taskBriefs,omitempty"`
|
||||
VerificationBriefs []VerificationBriefItem `json:"verificationBriefs,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeClusterResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeClusterResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type DynamixVersion struct {
|
||||
Major int64 `json:"major,omitempty"`
|
||||
Minor int64 `json:"minor,omitempty"`
|
||||
Patch int64 `json:"patch,omitempty"`
|
||||
}
|
||||
|
||||
type GetClusterConfigResult struct {
|
||||
Config string `json:"config,omitempty"`
|
||||
}
|
||||
|
||||
type GetClusterConfigResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetClusterConfigResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetClusterResult struct {
|
||||
Cluster Cluster `json:"cluster,omitempty"`
|
||||
ILoadBalancers []LoadBalancerBrief `json:"iLoadBalancers,omitempty"`
|
||||
Masters []MasterBrief `json:"masters,omitempty"`
|
||||
Policies []PolicyBrief `json:"policies,omitempty"`
|
||||
Products []ProductShortDescr `json:"products,omitempty"`
|
||||
Quorum int64 `json:"quorum,omitempty"`
|
||||
TaskBriefs []TaskBrief `json:"taskBriefs,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
Workers []WorkerBrief `json:"workers,omitempty"`
|
||||
}
|
||||
|
||||
type GetClusterResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetClusterResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetKubeResourcesResult struct {
|
||||
Any any `json:"any,omitempty"`
|
||||
}
|
||||
|
||||
type GetKubeResourcesResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetKubeResourcesResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetLoadBalancerResult struct {
|
||||
LoadBalancer LoadBalancer `json:"loadBalancer,omitempty"`
|
||||
}
|
||||
|
||||
type GetLoadBalancerResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetLoadBalancerResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetMasterResult struct {
|
||||
Master Master `json:"master,omitempty"`
|
||||
}
|
||||
|
||||
type GetMasterResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetMasterResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetWorkerResult struct {
|
||||
Worker Worker `json:"worker,omitempty"`
|
||||
}
|
||||
|
||||
type GetWorkerResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetWorkerResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GPU struct {
|
||||
// TODO
|
||||
CoreCount int64 `json:"coreCount,omitempty"`
|
||||
// TODO change for vendor/ model?
|
||||
GPUName string `json:"gpuName,omitempty"`
|
||||
// TODO
|
||||
VideoMemorySize int64 `json:"videoMemorySize,omitempty"`
|
||||
}
|
||||
|
||||
type ListClustersResult struct {
|
||||
Clusters []ClusterBrief `json:"clusters,omitempty"`
|
||||
}
|
||||
|
||||
type ListClustersResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListClustersResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListKubeResourcesResult struct {
|
||||
Any any `json:"any,omitempty"`
|
||||
}
|
||||
|
||||
type ListKubeResourcesResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListKubeResourcesResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListLoadBalancersResult struct {
|
||||
LoadBalancers []LoadBalancer `json:"loadBalancers,omitempty"`
|
||||
}
|
||||
|
||||
type ListLoadBalancersResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListLoadBalancersResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListMastersResult struct {
|
||||
Masters []Master `json:"masters,omitempty"`
|
||||
Total int64 `json:"total,omitempty"`
|
||||
}
|
||||
|
||||
type ListMastersResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListMastersResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListWorkersResult struct {
|
||||
Workers []Worker `json:"workers,omitempty"`
|
||||
}
|
||||
|
||||
type ListWorkersResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListWorkersResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancer struct {
|
||||
BalancerStatus string `json:"balancerStatus,omitempty"`
|
||||
CloudInit string `json:"cloudInit,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
CPUCount int64 `json:"cpuCount,omitempty"`
|
||||
// Lifecycle data
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
CreationError string `json:"creationError,omitempty"`
|
||||
// UpgradeDate string `json:\"upgradeDate,omitempty\" bson:\"upgradeDate\"` UpgradeError string `json:\"upgradeError,omitempty\" bson:\"upgradeError\"`
|
||||
DestroyingDate string `json:"destroyingDate,omitempty"`
|
||||
DestroyingError string `json:"destroyingError,omitempty"`
|
||||
DiskSize int64 `json:"diskSize,omitempty"`
|
||||
// Volume information
|
||||
DynamixSEPID int64 `json:"dynamixSEPId,omitempty"`
|
||||
DynamixSEPPool string `json:"dynamixSEPPool,omitempty"`
|
||||
// data encryption information
|
||||
Encrypted bool `json:"encrypted,omitempty"`
|
||||
// Access parameters
|
||||
ExtIPAddress string `json:"extIPAddress,omitempty"`
|
||||
GPUID int64 `json:"gpuId,omitempty"`
|
||||
GPUs []GPU `json:"gpus,omitempty"`
|
||||
HasGPU bool `json:"hasGPU,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
IntIPAddress string `json:"intIPAddress,omitempty"`
|
||||
LBManagerPassword string `json:"lbmanagerPassword,omitempty"`
|
||||
LBManagerPort int64 `json:"lbmanagerPort,omitempty"`
|
||||
// Lbmanager
|
||||
LBManagerUsername string `json:"lbmanagerUsername,omitempty"`
|
||||
MachineOSImageID int64 `json:"machineOSImageId,omitempty"`
|
||||
MachineOSBuild string `json:"machineOsBuild,omitempty"`
|
||||
// Reference parametres
|
||||
MachineProvider string `json:"machineProvider,omitempty"`
|
||||
// Operational parameters
|
||||
MachineStatus string `json:"machineStatus,omitempty"`
|
||||
MachineType string `json:"machineType,omitempty"`
|
||||
// Information parameters
|
||||
MemorySize int64 `json:"memorySize,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
ProviderMachineID int64 `json:"providerMachineId,omitempty"`
|
||||
ProviderMachineName string `json:"providerMachineName,omitempty"`
|
||||
ReferenceID int64 `json:"referenceId,omitempty"`
|
||||
SecureShellPort int64 `json:"secureShellPort,omitempty"`
|
||||
SysRootPassword string `json:"sysRootPassword,omitempty"`
|
||||
SysRootUsername string `json:"sysRootUsername,omitempty"`
|
||||
SysUserPassword string `json:"sysUserPassword,omitempty"`
|
||||
// Access parameters of service System & secure shell
|
||||
SysUserUsername string `json:"sysUserUsername,omitempty"`
|
||||
SysagentPassword string `json:"sysagentPassword,omitempty"`
|
||||
SysagentPort int64 `json:"sysagentPort,omitempty"`
|
||||
// Sysagent
|
||||
SysagentUsername string `json:"sysagentUsername,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
VersionCrypt string `json:"versionCrypt,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancerBrief struct {
|
||||
// Operational parameters
|
||||
BalancerStatus string `json:"balancerStatus,omitempty"`
|
||||
CPUCount int64 `json:"cpuCount,omitempty"`
|
||||
// Lifecycle data
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
DiskSize int64 `json:"diskSize,omitempty"`
|
||||
// Access parameters
|
||||
ExtIPAddress string `json:"extIPAddress,omitempty"`
|
||||
GPUID int64 `json:"gpuId,omitempty"`
|
||||
GPUName string `json:"gpuName,omitempty"`
|
||||
HasGPU bool `json:"hasGPU,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
IntIPAddress string `json:"intIPAddress,omitempty"`
|
||||
// Information parameters
|
||||
MemorySize int64 `json:"memorySize,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type Master struct {
|
||||
// Audit parameters for master
|
||||
AuditEnable bool `json:"auditEnable,omitempty"`
|
||||
AuditLogFilepath string `json:"auditLogFilepath,omitempty"`
|
||||
AuditLogMaxAge int64 `json:"auditLogMaxAge,omitempty"`
|
||||
AuditLogMaxBackup int64 `json:"auditLogMaxBackup,omitempty"`
|
||||
AuditLogMaxSize int64 `json:"auditLogMaxSize,omitempty"`
|
||||
AuditPolicy string `json:"auditPolicy,omitempty"`
|
||||
// Input data for cloud-init facility
|
||||
CloudInit string `json:"cloudInit,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
CPUCount int64 `json:"cpuCount,omitempty"`
|
||||
// Lifecycle data
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
CreationError string `json:"creationError,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
// UpgradeDate string `json:\"upgradeDate,omitempty\" bson:\"upgradeDate\"` UpgradeError string `json:\"upgradeError,omitempty\" bson:\"upgradeError\"`
|
||||
DestroyingDate string `json:"destroyingDate,omitempty"`
|
||||
DestroyingError string `json:"destroyingError,omitempty"`
|
||||
DiskSize int64 `json:"diskSize,omitempty"`
|
||||
// Volume information
|
||||
DynamixSEPID int64 `json:"dynamixSEPId,omitempty"`
|
||||
DynamixSEPPool string `json:"dynamixSEPPool,omitempty"`
|
||||
// data encryption information
|
||||
Encrypted bool `json:"encrypted,omitempty"`
|
||||
// Access parameters
|
||||
ExtIPAddress string `json:"extIPAddress,omitempty"`
|
||||
GPUID int64 `json:"gpuId,omitempty"`
|
||||
GPUs []GPU `json:"gpus,omitempty"`
|
||||
HasGPU bool `json:"hasGPU,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
IntIPAddress string `json:"intIPAddress,omitempty"`
|
||||
IsSpare bool `json:"isSpare,omitempty"`
|
||||
// Encryption key for /etc/kubernetes/encryption-config.yaml:
|
||||
KeyForEncryptionConfig string `json:"keyForEncryptionConfig,omitempty"`
|
||||
LogWatcherPassword string `json:"logwatcherPassword,omitempty"`
|
||||
LogWatcherPort int64 `json:"logwatcherPort,omitempty"`
|
||||
LogWatcherUsername string `json:"logwatcherUsername,omitempty"`
|
||||
MachineOSBuild string `json:"machineOSBuild,omitempty"`
|
||||
MachineOSImageID int64 `json:"machineOSImageId,omitempty"`
|
||||
MachineOSType string `json:"machineOSType,omitempty"`
|
||||
// Reference parameters
|
||||
MachineProvider string `json:"machineProvider,omitempty"`
|
||||
// Operational parameters
|
||||
MachineStatus string `json:"machineStatus,omitempty"`
|
||||
// Information parameters
|
||||
MemorySize int64 `json:"memorySize,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
NodeStatus string `json:"nodeStatus,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
ProviderMachineID int64 `json:"providerMachineId,omitempty"`
|
||||
ProviderMachineName string `json:"providerMachineName,omitempty"`
|
||||
ReferenceID int64 `json:"referenceId,omitempty"`
|
||||
// Container runtime info
|
||||
RuntimeEndPoint string `json:"runtimeEndPoint,omitempty"`
|
||||
RuntimeType string `json:"runtimeType,omitempty"`
|
||||
SecureShellPort int64 `json:"secureShellPort,omitempty"`
|
||||
SysRootPassword string `json:"sysRootPassword,omitempty"`
|
||||
SysRootUsername string `json:"sysRootUsername,omitempty"`
|
||||
SysUserPassword string `json:"sysUserPassword,omitempty"`
|
||||
// Access parameters of services System & secure shell
|
||||
SysUserUsername string `json:"sysUserUsername,omitempty"`
|
||||
SysagentPassword string `json:"sysagentPassword,omitempty"`
|
||||
SysagentPort int64 `json:"sysagentPort,omitempty"`
|
||||
// Sysagent
|
||||
SysagentUsername string `json:"sysagentUsername,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
VersionCrypt string `json:"versionCrypt,omitempty"`
|
||||
// WorkerGroup label for worker
|
||||
WorkerGroupID int64 `json:"workerGroupId,omitempty"`
|
||||
}
|
||||
|
||||
type MasterBrief struct {
|
||||
CPUCount int64 `json:"cpuCount,omitempty"`
|
||||
// Lifecycle data
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
DiskSize int64 `json:"diskSize,omitempty"`
|
||||
// Access parameters
|
||||
ExtIPAddress string `json:"extIPAddress,omitempty"`
|
||||
GPUID int64 `json:"gpuId,omitempty"`
|
||||
GPUName string `json:"gpuName,omitempty"`
|
||||
HasGPU bool `json:"hasGPU,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
// Information parameters
|
||||
MemorySize int64 `json:"memorySize,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
// Operational parameters
|
||||
NodeStatus string `json:"nodeStatus,omitempty"`
|
||||
// Container runtime info
|
||||
RuntimeType string `json:"runtimeType,omitempty"`
|
||||
}
|
||||
|
||||
type NetworkDescribeResult struct {
|
||||
ClusterDNS string `json:"clusterDns,omitempty"`
|
||||
Cni string `json:"cni,omitempty"`
|
||||
Encap string `json:"encap,omitempty"`
|
||||
KubeProxy string `json:"kubeProxy,omitempty"`
|
||||
MTU int64 `json:"mtu,omitempty"`
|
||||
NetworkPolicy string `json:"networkPolicy,omitempty"`
|
||||
Overlay bool `json:"overlay,omitempty"`
|
||||
PodCIDR string `json:"podCidr,omitempty"`
|
||||
ServiceCIDR string `json:"serviceCidr,omitempty"`
|
||||
TrafficRouting string `json:"trafficRouting,omitempty"`
|
||||
}
|
||||
|
||||
type NetworkDescribeResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result NetworkDescribeResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type PolicyBrief struct {
|
||||
Background bool `json:"background,omitempty"`
|
||||
Category string `json:"category,omitempty"`
|
||||
Default bool `json:"default,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
// main brief info showed by kubectl get cluterpolicy command
|
||||
Name string `json:"name,omitempty"`
|
||||
Rules []Rule `json:"rules,omitempty"`
|
||||
Severity string `json:"severity,omitempty"`
|
||||
ValidateAction string `json:"validateAction,omitempty"`
|
||||
}
|
||||
|
||||
type ProductShortDescr struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
}
|
||||
|
||||
type SetClusterKubeVersionResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type SetClusterStatusResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type SetLoadBalancerStatusResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type SetMasterStatusResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type SetPoolVMStatusResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type SetWorkerStatusResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateClusterConfigResult struct {
|
||||
KubeConfig string `json:"kubeConfig,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateClusterConfigResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UpdateClusterConfigResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateClusterOwnerIDResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateCNIConfigResult struct {
|
||||
TaskID int64 `json:"taskId,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateCNIConfigResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UpdateCNIConfigResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type VerificationBrief struct {
|
||||
Done bool `json:"done,omitempty"`
|
||||
Error bool `json:"error,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
NodeID int64 `json:"nodeId,omitempty"`
|
||||
Operation string `json:"operation,omitempty"`
|
||||
ReportID int64 `json:"reportId,omitempty"`
|
||||
StartTimestamp string `json:"startTimestamp,omitempty"`
|
||||
StopTimestamp string `json:"stopTimestamp,omitempty"`
|
||||
SubjectID int64 `json:"subjectId,omitempty"`
|
||||
TotalFail int64 `json:"totalFail,omitempty"`
|
||||
TotalInfo int64 `json:"totalInfo,omitempty"`
|
||||
TotalPass int64 `json:"totalPass,omitempty"`
|
||||
TotalWarn int64 `json:"totalWarn,omitempty"`
|
||||
VerificationType string `json:"verificationType,omitempty"`
|
||||
}
|
||||
|
||||
type VerificationBriefItem struct {
|
||||
// Verification briefs for the task
|
||||
BriefsList []VerificationBrief `json:"briefsList,omitempty"`
|
||||
// Task info
|
||||
TaskBrief TaskBrief `json:"taskBrief,omitempty"`
|
||||
}
|
||||
|
||||
type Worker struct {
|
||||
// Audit parameters for master
|
||||
AuditEnable bool `json:"auditEnable,omitempty"`
|
||||
AuditLogFilepath string `json:"auditLogFilepath,omitempty"`
|
||||
AuditLogMaxAge int64 `json:"auditLogMaxAge,omitempty"`
|
||||
AuditLogMaxBackup int64 `json:"auditLogMaxBackup,omitempty"`
|
||||
AuditLogMaxSize int64 `json:"auditLogMaxSize,omitempty"`
|
||||
AuditPolicy string `json:"auditPolicy,omitempty"`
|
||||
// Input data for cloud-init facility
|
||||
CloudInit string `json:"cloudInit,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
CPUCount int64 `json:"cpuCount,omitempty"`
|
||||
// Lifecycle data
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
CreationError string `json:"creationError,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
// UpgradeDate string `json:\"upgradeDate,omitempty\" bson:\"upgradeDate\"` UpgradeError string `json:\"upgradeError,omitempty\" bson:\"upgradeError\"`
|
||||
DestroyingDate string `json:"destroyingDate,omitempty"`
|
||||
DestroyingError string `json:"destroyingError,omitempty"`
|
||||
DiskSize int64 `json:"diskSize,omitempty"`
|
||||
// Volume information
|
||||
DynamixSEPID int64 `json:"dynamixSEPId,omitempty"`
|
||||
DynamixSEPPool string `json:"dynamixSEPPool,omitempty"`
|
||||
// data encryption information
|
||||
Encrypted bool `json:"encrypted,omitempty"`
|
||||
// Access parameters
|
||||
ExtIPAddress string `json:"extIPAddress,omitempty"`
|
||||
GPUID int64 `json:"gpuId,omitempty"`
|
||||
GPUs []GPU `json:"gpus,omitempty"`
|
||||
HasGPU bool `json:"hasGPU,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
IntIPAddress string `json:"intIPAddress,omitempty"`
|
||||
IsSpare bool `json:"isSpare,omitempty"`
|
||||
// Encryption key for /etc/kubernetes/encryption-config.yaml:
|
||||
KeyForEncryptionConfig string `json:"keyForEncryptionConfig,omitempty"`
|
||||
LogWatcherPassword string `json:"logwatcherPassword,omitempty"`
|
||||
LogWatcherPort int64 `json:"logwatcherPort,omitempty"`
|
||||
LogWatcherUsername string `json:"logwatcherUsername,omitempty"`
|
||||
MachineOSBuild string `json:"machineOSBuild,omitempty"`
|
||||
MachineOSImageID int64 `json:"machineOSImageId,omitempty"`
|
||||
MachineOSType string `json:"machineOSType,omitempty"`
|
||||
// Reference parameters
|
||||
MachineProvider string `json:"machineProvider,omitempty"`
|
||||
// Operational parameters
|
||||
MachineStatus string `json:"machineStatus,omitempty"`
|
||||
// Information parameters
|
||||
MemorySize int64 `json:"memorySize,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
NodeStatus string `json:"nodeStatus,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
ProviderMachineID int64 `json:"providerMachineId,omitempty"`
|
||||
ProviderMachineName string `json:"providerMachineName,omitempty"`
|
||||
ReferenceID int64 `json:"referenceId,omitempty"`
|
||||
// Container runtime info
|
||||
RuntimeEndPoint string `json:"runtimeEndPoint,omitempty"`
|
||||
RuntimeType string `json:"runtimeType,omitempty"`
|
||||
SecureShellPort int64 `json:"secureShellPort,omitempty"`
|
||||
SysRootPassword string `json:"sysRootPassword,omitempty"`
|
||||
SysRootUsername string `json:"sysRootUsername,omitempty"`
|
||||
SysUserPassword string `json:"sysUserPassword,omitempty"`
|
||||
// Access parameters of services System & secure shell
|
||||
SysUserUsername string `json:"sysUserUsername,omitempty"`
|
||||
SysagentPassword string `json:"sysagentPassword,omitempty"`
|
||||
SysagentPort int64 `json:"sysagentPort,omitempty"`
|
||||
// Sysagent
|
||||
SysagentUsername string `json:"sysagentUsername,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
VersionCrypt string `json:"versionCrypt,omitempty"`
|
||||
// WorkerGroup label for worker
|
||||
WorkerGroupID int64 `json:"workerGroupId,omitempty"`
|
||||
}
|
||||
|
||||
type WorkerBrief struct {
|
||||
CPUCount int64 `json:"cpuCount,omitempty"`
|
||||
// Lifecycle data
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
DiskSize int64 `json:"diskSize,omitempty"`
|
||||
GPUID int64 `json:"gpuId,omitempty"`
|
||||
GPUName string `json:"gpuName,omitempty"`
|
||||
HasGPU bool `json:"hasGPU,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
// Information parameters
|
||||
MemorySize int64 `json:"memorySize,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
// Operational parameters
|
||||
NodeStatus string `json:"nodeStatus,omitempty"`
|
||||
// Container runtime info
|
||||
RuntimeType string `json:"runtimeType,omitempty"`
|
||||
// WorkerGroup label for worker
|
||||
WorkerGroupID int64 `json:"workerGroupId,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_cluster
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type Rule = shared.Rule
|
||||
type TaskBrief = shared.TaskBrief
|
||||
@@ -0,0 +1,460 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_cluster_template
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeClusterTemplateService service
|
||||
|
||||
type DeleteRequest struct {
|
||||
// cluster template id
|
||||
//
|
||||
// Required.
|
||||
ID int64 `json:"id" form:"id"`
|
||||
}
|
||||
|
||||
// Delete cluster template
|
||||
func (a *DeClusterTemplateService) Delete(ctx context.Context, req DeleteRequest) (DeleteClusterTemplateResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DeleteClusterTemplateResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "id")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/clusterTemplate/delete"
|
||||
|
||||
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, "id", req.ID, "", "")
|
||||
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 DeleteClusterTemplateResultWithError
|
||||
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 DuplicateRequest struct {
|
||||
// cluster template id
|
||||
//
|
||||
// Required.
|
||||
ID int64 `json:"id" form:"id"`
|
||||
// cluster template name (default: from original)
|
||||
ClusterTemplateName string `json:"clusterTemplateName" form:"clusterTemplateName"`
|
||||
// cluster template description (default: from original)
|
||||
ClusterTemplateDescription string `json:"clusterTemplateDescription" form:"clusterTemplateDescription"`
|
||||
// share cluster template with others
|
||||
ShareClusterTemplate bool `json:"shareClusterTemplate" form:"shareClusterTemplate"`
|
||||
}
|
||||
|
||||
// Duplicate cluster template
|
||||
func (a *DeClusterTemplateService) Duplicate(ctx context.Context, req DuplicateRequest) (DuplicateClusterTemplateResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DuplicateClusterTemplateResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "id")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/clusterTemplate/duplicate"
|
||||
|
||||
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, "id", req.ID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterTemplateName", req.ClusterTemplateName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterTemplateDescription", req.ClusterTemplateDescription, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "shareClusterTemplate", req.ShareClusterTemplate, "", "")
|
||||
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 DuplicateClusterTemplateResultWithError
|
||||
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 GetRequest struct {
|
||||
// cluster template id
|
||||
//
|
||||
// Required.
|
||||
ID int64 `json:"id" form:"id"`
|
||||
}
|
||||
|
||||
// Get cluster template
|
||||
func (a *DeClusterTemplateService) Get(ctx context.Context, req GetRequest) (GetClusterTemplateResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result GetClusterTemplateResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "id")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/clusterTemplate/get"
|
||||
|
||||
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, "id", req.ID, "", "")
|
||||
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 GetClusterTemplateResultWithError
|
||||
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 ListRequest struct {
|
||||
// filter by installed cluster type
|
||||
//
|
||||
// Allowed values:
|
||||
// - "dynamix"
|
||||
// - "generic"
|
||||
// - "denergy"
|
||||
// - "baremetal"
|
||||
ClusterType string `json:"clusterType" form:"clusterType"`
|
||||
// Sort by one of supported fields, format +|-(field>)
|
||||
SortBy string `json:"sortBy" form:"sortBy"`
|
||||
// Limit number of tasks results to be shown in the result. If not set, all task results will be shown.
|
||||
Limit int64 `json:"limit" form:"limit"`
|
||||
// Select page of the result. If not set, the first page will be shown.
|
||||
Page int64 `json:"page" form:"page"`
|
||||
}
|
||||
|
||||
// List cluster templates
|
||||
func (a *DeClusterTemplateService) List(ctx context.Context, req ListRequest) (ListClusterTemplatesResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result ListClusterTemplatesResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
|
||||
if !utils.IsZeroValue(req.ClusterType) {
|
||||
clusterTypeValue := req.ClusterType
|
||||
clusterTypeAllowedValues := []string{
|
||||
"dynamix",
|
||||
"generic",
|
||||
"denergy",
|
||||
"baremetal",
|
||||
}
|
||||
clusterTypeValid := false
|
||||
for _, allowed := range clusterTypeAllowedValues {
|
||||
if clusterTypeValue == allowed {
|
||||
clusterTypeValid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !clusterTypeValid {
|
||||
return result, fmt.Errorf("clusterType must be one of %v", clusterTypeAllowedValues)
|
||||
}
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/clusterTemplate/list"
|
||||
|
||||
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, "clusterType", req.ClusterType, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "sortBy", req.SortBy, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "limit", req.Limit, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "page", req.Page, "", "")
|
||||
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 ListClusterTemplatesResultWithError
|
||||
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 UpdateRequest struct {
|
||||
// update cluster templates request
|
||||
//
|
||||
// Required.
|
||||
ExtraCluster UpdateClusterTemplateRequest `json:"extraCluster" form:"extraCluster"`
|
||||
}
|
||||
|
||||
// Update cluster template
|
||||
func (a *DeClusterTemplateService) Update(ctx context.Context, req UpdateRequest) (UpdateClusterTemplateResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result UpdateClusterTemplateResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ExtraCluster) {
|
||||
missingRequiredParams = append(missingRequiredParams, "extraCluster")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/clusterTemplate/update"
|
||||
|
||||
contentTypes := []string{"application/json"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
requestBody = req.ExtraCluster
|
||||
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 UpdateClusterTemplateResultWithError
|
||||
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_cluster_template
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeClusterTemplate *DeClusterTemplateService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeClusterTemplate = (*DeClusterTemplateService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+354
@@ -0,0 +1,354 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_cluster_template
|
||||
|
||||
type ClusterTemplate struct {
|
||||
AppContainerRepository int64 `json:"appContainerRepository,omitempty"`
|
||||
AuditEnable bool `json:"auditEnable,omitempty"`
|
||||
AuditLogMaxAge int64 `json:"auditLogMaxAge,omitempty"`
|
||||
AuditLogMaxBackup int64 `json:"auditLogMaxBackup,omitempty"`
|
||||
AuditLogMaxSize int64 `json:"auditLogMaxSize,omitempty"`
|
||||
AuditPolicy string `json:"auditPolicy,omitempty"`
|
||||
BalancersDynamixSEPID int64 `json:"balancersDynamixSEPId,omitempty"`
|
||||
BalancersDynamixSEPPool string `json:"balancersDynamixSEPPool,omitempty"`
|
||||
CertificateIssuerID int64 `json:"certificateIssuerId,omitempty"`
|
||||
CertificateKey string `json:"certificateKey,omitempty"`
|
||||
CertificateValidityBefore string `json:"certificateValidityBefore,omitempty"`
|
||||
ChartRepository int64 `json:"chartRepository,omitempty"`
|
||||
ClusterHostname string `json:"clusterHostname,omitempty"`
|
||||
ClusterMachineOSBuild string `json:"clusterMachineOSBuild,omitempty"`
|
||||
ClusterMachineOSType string `json:"clusterMachineOSType,omitempty"`
|
||||
ClusterName string `json:"clusterName,omitempty"`
|
||||
ClusterTemplateDescription string `json:"clusterTemplateDescription,omitempty"`
|
||||
ClusterTemplateName string `json:"clusterTemplateName,omitempty"`
|
||||
ClusterType string `json:"clusterType,omitempty"`
|
||||
ContainerNetworkType string `json:"containerNetworkType,omitempty"`
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
CustomMTU int64 `json:"customMTU,omitempty"`
|
||||
DenergyRuntimeType string `json:"denergyRuntimeType,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
DomainResolvers []string `json:"domainResolvers,omitempty"`
|
||||
DynamixAppID string `json:"dynamixAppId,omitempty"`
|
||||
DynamixAppSecret string `json:"dynamixAppSecret,omitempty"`
|
||||
DynamixAuthDomain string `json:"dynamixAuthDomain,omitempty"`
|
||||
DynamixAuthType string `json:"dynamixAuthType,omitempty"`
|
||||
DynamixK8CIID int64 `json:"dynamixK8CIId,omitempty"`
|
||||
DynamixPassword string `json:"dynamixPassword,omitempty"`
|
||||
DynamixRGID int64 `json:"dynamixRGId,omitempty"`
|
||||
DynamixSEPID int64 `json:"dynamixSEPId,omitempty"`
|
||||
DynamixSEPPool string `json:"dynamixSEPPool,omitempty"`
|
||||
DynamixSSOURL string `json:"dynamixSSOURL,omitempty"`
|
||||
DynamixURL string `json:"dynamixURL,omitempty"`
|
||||
DynamixUsername string `json:"dynamixUsername,omitempty"`
|
||||
EnableCustomLoadBalancerHostnames bool `json:"enableCustomLoadBalancerHostnames,omitempty"`
|
||||
EnableCustomMasterHostnames bool `json:"enableCustomMasterHostnames,omitempty"`
|
||||
EnableCustomWorkerHostnames bool `json:"enableCustomWorkerHostnames,omitempty"`
|
||||
// Data encryption information
|
||||
Encrypted bool `json:"encrypted,omitempty"`
|
||||
// VirtualAddresses Section
|
||||
ExtVirtualAddress string `json:"extVirtualAddress,omitempty"`
|
||||
ExternalLBAddresses []string `json:"externalLBAddresses,omitempty"`
|
||||
GlobalNetworkID int64 `json:"globalNetworkId,omitempty"`
|
||||
ILoadBalancerCPUCount int64 `json:"iLoadBalancerCPUCount,omitempty"`
|
||||
ILoadBalancerCloudInit string `json:"iLoadBalancerCloudInit,omitempty"`
|
||||
ILoadBalancerCount int64 `json:"iLoadBalancerCount,omitempty"`
|
||||
ILoadBalancerDiskSize int64 `json:"iLoadBalancerDiskSize,omitempty"`
|
||||
ILoadBalancerGPUIDs []int64 `json:"iLoadBalancerGpuIds,omitempty"`
|
||||
ILoadBalancerMemorySize int64 `json:"iLoadBalancerMemorySize,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
InitialSecureShellPort int64 `json:"initialSecureShellPort,omitempty"`
|
||||
InstallAutoscaler bool `json:"installAutoscaler,omitempty"`
|
||||
InstallCriobox bool `json:"installCriobox,omitempty"`
|
||||
InstallKyverno bool `json:"installKyverno,omitempty"`
|
||||
InstallMetrics bool `json:"installMetrics,omitempty"`
|
||||
InstallMonitoring bool `json:"installMonitoring,omitempty"`
|
||||
InstallPodLogger bool `json:"installPodLogger,omitempty"`
|
||||
InstallRBACManager bool `json:"installRbacManager,omitempty"`
|
||||
InstallTrivy bool `json:"installTrivy,omitempty"`
|
||||
IntVirtualAddress string `json:"intVirtualAddress,omitempty"`
|
||||
InternalLBAddresses []string `json:"internalLBAddresses,omitempty"`
|
||||
KubeConfig string `json:"kubeConfig,omitempty"`
|
||||
KubeContainerRepository int64 `json:"kubeContainerRepository,omitempty"`
|
||||
KubeVersion string `json:"kubeVersion,omitempty"`
|
||||
LastEditor int64 `json:"lastEditor,omitempty"`
|
||||
LoadBalancerExternalIPAddresses []string `json:"loadBalancerExternalIPAddresses,omitempty"`
|
||||
LoadBalancerHostnames []string `json:"loadBalancerHostnames,omitempty"`
|
||||
LoadBalancerInternalIPAddresses []string `json:"loadBalancerInternalIPAddresses,omitempty"`
|
||||
LoadBalancerMachineOSBuild []string `json:"loadBalancerMachineOSBuild,omitempty"`
|
||||
LoadBalancerMachineOSType []string `json:"loadBalancerMachineOSType,omitempty"`
|
||||
LoadBalancerRootPasswords []string `json:"loadBalancerRootPasswords,omitempty"`
|
||||
LoadBalancerRootUsernames []string `json:"loadBalancerRootUsernames,omitempty"`
|
||||
LoadBalancerSecureShellPorts []int64 `json:"loadBalancerSecureShellPorts,omitempty"`
|
||||
LoadBalancerUserPasswords []string `json:"loadBalancerUserPasswords,omitempty"`
|
||||
LoadBalancerUserUsernames []string `json:"loadBalancerUserUsernames,omitempty"`
|
||||
LocalNetworkID int64 `json:"localNetworkId,omitempty"`
|
||||
MachineOSBuild string `json:"machineOSBuild,omitempty"`
|
||||
MachineOSImageID int64 `json:"machineOSImageId,omitempty"`
|
||||
MachineOSType string `json:"machineOSType,omitempty"`
|
||||
MachineProvider string `json:"machineProvider,omitempty"`
|
||||
MasterAddresses []string `json:"masterAddresses,omitempty"`
|
||||
MasterCPUCount int64 `json:"masterCPUCount,omitempty"`
|
||||
MasterCloudInit string `json:"masterCloudInit,omitempty"`
|
||||
MasterCount int64 `json:"masterCount,omitempty"`
|
||||
MasterDiskSize int64 `json:"masterDiskSize,omitempty"`
|
||||
MasterGPUIDs []int64 `json:"masterGpuIds,omitempty"`
|
||||
MasterHostnames []string `json:"masterHostnames,omitempty"`
|
||||
MasterMemorySize int64 `json:"masterMemorySize,omitempty"`
|
||||
MasterNodesExternalIPAdresses []string `json:"masterNodesExternalIPAdresses,omitempty"`
|
||||
MasterNodesMachineOSBuilds []string `json:"masterNodesMachineOSBuilds,omitempty"`
|
||||
MasterNodesMachineOSTypes []string `json:"masterNodesMachineOSTypes,omitempty"`
|
||||
MasterNodesRootPasswords []string `json:"masterNodesRootPasswords,omitempty"`
|
||||
MasterNodesRootUsernames []string `json:"masterNodesRootUsernames,omitempty"`
|
||||
MasterNodesSecureShellPorts []int64 `json:"masterNodesSecureShellPorts,omitempty"`
|
||||
MasterNodesUserPasswords []string `json:"masterNodesUserPasswords,omitempty"`
|
||||
MasterNodesUserUsernames []string `json:"masterNodesUserUsernames,omitempty"`
|
||||
MastersDynamixSEPID int64 `json:"mastersDynamixSEPId,omitempty"`
|
||||
MastersDynamixSEPPool string `json:"mastersDynamixSEPPool,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
PackageRepository int64 `json:"packageRepository,omitempty"`
|
||||
ProvideDNS bool `json:"provideDNS,omitempty"`
|
||||
SaveComputesOnFailedK8SCreation bool `json:"saveComputesOnFailedK8SCreation,omitempty"`
|
||||
Shared bool `json:"shared,omitempty"`
|
||||
StoragePolicyID int64 `json:"storagePolicyID,omitempty"`
|
||||
UseCustomExternalLBAddreses bool `json:"useCustomExternalLBAddreses,omitempty"`
|
||||
UseCustomInternalLBAddreses bool `json:"useCustomInternalLBAddreses,omitempty"`
|
||||
UseCustomMasterIPAddresses bool `json:"useCustomMasterIPAddresses,omitempty"`
|
||||
UseCustomWorkerIPAddresses bool `json:"useCustomWorkerIPAddresses,omitempty"`
|
||||
UseDynamixExtNet bool `json:"useDynamixExtnet,omitempty"`
|
||||
UserID int64 `json:"userId,omitempty"`
|
||||
VersionCrypt string `json:"versionCrypt,omitempty"`
|
||||
ViNSGlobalNetworkID int64 `json:"vinsGlobalNetworkId,omitempty"`
|
||||
WorkerAddresses []string `json:"workerAddresses,omitempty"`
|
||||
WorkerAnnotations []string `json:"workerAnnotations,omitempty"`
|
||||
WorkerCPUCount int64 `json:"workerCPUCount,omitempty"`
|
||||
WorkerCloudInit string `json:"workerCloudInit,omitempty"`
|
||||
WorkerCount int64 `json:"workerCount,omitempty"`
|
||||
WorkerDiskSize int64 `json:"workerDiskSize,omitempty"`
|
||||
WorkerGPUIDs []int64 `json:"workerGpuIds,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
WorkerHostnames []string `json:"workerHostnames,omitempty"`
|
||||
// WorkerGroup string `json:\"workerGroup\" bson:\"workerGroup\"`
|
||||
WorkerLabels []string `json:"workerLabels,omitempty"`
|
||||
WorkerMemorySize int64 `json:"workerMemorySize,omitempty"`
|
||||
WorkerNodesExternalIPAdresses []string `json:"workerNodesExternalIPAdresses,omitempty"`
|
||||
WorkerNodesMachineOSBuilds []string `json:"workerNodesMachineOSBuilds,omitempty"`
|
||||
WorkerNodesMachineOSTypes []string `json:"workerNodesMachineOSTypes,omitempty"`
|
||||
WorkerNodesRootPasswords []string `json:"workerNodesRootPasswords,omitempty"`
|
||||
WorkerNodesRootUsernames []string `json:"workerNodesRootUsernames,omitempty"`
|
||||
WorkerNodesSecureShellPorts []int64 `json:"workerNodesSecureShellPorts,omitempty"`
|
||||
WorkerNodesUserPasswords []string `json:"workerNodesUserPasswords,omitempty"`
|
||||
WorkerNodesUserUsernames []string `json:"workerNodesUserUsernames,omitempty"`
|
||||
WorkerTaints []string `json:"workerTaints,omitempty"`
|
||||
WorkersDynamixSEPID int64 `json:"workersDynamixSEPId,omitempty"`
|
||||
WorkersDynamixSEPPool string `json:"workersDynamixSEPPool,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterTemplateBrief struct {
|
||||
ClusterTemplateName string `json:"clusterTemplateName,omitempty"`
|
||||
ClusterType string `json:"clusterType,omitempty"`
|
||||
ContainerNetworkType string `json:"containerNetworkType,omitempty"`
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
KubeVersion string `json:"kubeVersion,omitempty"`
|
||||
MachineOSType string `json:"machineOSType,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
Shared bool `json:"shared,omitempty"`
|
||||
UserID int64 `json:"userId,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
}
|
||||
|
||||
type CreateClusterRequest struct {
|
||||
AppContainerRepository int64 `json:"appContainerRepository"`
|
||||
AuditEnable bool `json:"auditEnable"`
|
||||
AuditLogMaxAge int64 `json:"auditLogMaxAge"`
|
||||
AuditLogMaxBackup int64 `json:"auditLogMaxBackup"`
|
||||
AuditLogMaxSize int64 `json:"auditLogMaxSize"`
|
||||
AuditPolicy string `json:"auditPolicy"`
|
||||
BalancersDynamixSEPID int64 `json:"balancersDynamixSEPId"`
|
||||
BalancersDynamixSEPPool string `json:"balancersDynamixSEPPool"`
|
||||
CertificateIssuerID int64 `json:"certificateIssuerId"`
|
||||
CertificateKey string `json:"certificateKey"`
|
||||
CertificateValidityBefore string `json:"certificateValidityBefore"`
|
||||
ChartRepository int64 `json:"chartRepository"`
|
||||
ClusterHostname string `json:"clusterHostname"`
|
||||
ClusterMachineOSBuild string `json:"clusterMachineOSBuild"`
|
||||
ClusterMachineOSType string `json:"clusterMachineOSType"`
|
||||
ClusterName string `json:"clusterName"`
|
||||
ClusterTemplateDescription string `json:"clusterTemplateDescription"`
|
||||
ClusterTemplateName string `json:"clusterTemplateName"`
|
||||
ClusterType string `json:"clusterType"`
|
||||
ContainerNetworkType string `json:"containerNetworkType"`
|
||||
CreateClusterTemplate bool `json:"createClusterTemplate"`
|
||||
CustomMTU int64 `json:"customMTU"`
|
||||
DenergyRuntimeType string `json:"denergyRuntimeType"`
|
||||
Description string `json:"description"`
|
||||
DomainResolvers []string `json:"domainResolvers,omitempty"`
|
||||
DynamixAppID string `json:"dynamixAppId"`
|
||||
DynamixAppSecret string `json:"dynamixAppSecret"`
|
||||
DynamixAuthDomain string `json:"dynamixAuthDomain"`
|
||||
DynamixAuthType string `json:"dynamixAuthType"`
|
||||
DynamixK8CIID int64 `json:"dynamixK8CIId"`
|
||||
DynamixPassword string `json:"dynamixPassword"`
|
||||
DynamixRGID int64 `json:"dynamixRGId"`
|
||||
DynamixSEPID int64 `json:"dynamixSEPId"`
|
||||
DynamixSEPPool string `json:"dynamixSEPPool"`
|
||||
DynamixSSOURL string `json:"dynamixSSOURL"`
|
||||
DynamixURL string `json:"dynamixURL"`
|
||||
DynamixUsername string `json:"dynamixUsername"`
|
||||
EnableCustomLoadBalancerHostnames bool `json:"enableCustomLoadBalancerHostnames"`
|
||||
EnableCustomMasterHostnames bool `json:"enableCustomMasterHostnames"`
|
||||
EnableCustomWorkerHostnames bool `json:"enableCustomWorkerHostnames"`
|
||||
// VirtualAddresses Section
|
||||
ExtVirtualAddress string `json:"extVirtualAddress"`
|
||||
ExternalLBAddresses []string `json:"externalLBAddresses,omitempty"`
|
||||
GlobalNetworkID int64 `json:"globalNetworkId"`
|
||||
ILoadBalancerCPUCount int64 `json:"iLoadBalancerCPUCount"`
|
||||
ILoadBalancerCloudInit string `json:"iLoadBalancerCloudInit"`
|
||||
ILoadBalancerCount int64 `json:"iLoadBalancerCount"`
|
||||
ILoadBalancerDiskSize int64 `json:"iLoadBalancerDiskSize"`
|
||||
ILoadBalancerGPUIDs []int64 `json:"iLoadBalancerGpuIds,omitempty"`
|
||||
ILoadBalancerMemorySize int64 `json:"iLoadBalancerMemorySize"`
|
||||
InitialSecureShellPort int64 `json:"initialSecureShellPort"`
|
||||
InstallAutoscaler bool `json:"installAutoscaler"`
|
||||
InstallCriobox bool `json:"installCriobox"`
|
||||
InstallKyverno bool `json:"installKyverno"`
|
||||
InstallMetrics bool `json:"installMetrics"`
|
||||
InstallMonitoring bool `json:"installMonitoring"`
|
||||
InstallPodLogger bool `json:"installPodLogger"`
|
||||
InstallRBACManager bool `json:"installRbacManager"`
|
||||
InstallTrivy bool `json:"installTrivy"`
|
||||
IntVirtualAddress string `json:"intVirtualAddress"`
|
||||
InternalLBAddresses []string `json:"internalLBAddresses,omitempty"`
|
||||
KubeConfig string `json:"kubeConfig"`
|
||||
KubeContainerRepository int64 `json:"kubeContainerRepository"`
|
||||
KubeVersion string `json:"kubeVersion"`
|
||||
LoadBalancerExternalIPAddresses []string `json:"loadBalancerExternalIPAddresses,omitempty"`
|
||||
LoadBalancerHostnames []string `json:"loadBalancerHostnames,omitempty"`
|
||||
LoadBalancerInternalIPAddresses []string `json:"loadBalancerInternalIPAddresses,omitempty"`
|
||||
LoadBalancerMachineOSBuild []string `json:"loadBalancerMachineOSBuild,omitempty"`
|
||||
LoadBalancerMachineOSType []string `json:"loadBalancerMachineOSType,omitempty"`
|
||||
LoadBalancerRootPasswords []string `json:"loadBalancerRootPasswords,omitempty"`
|
||||
LoadBalancerRootUsernames []string `json:"loadBalancerRootUsernames,omitempty"`
|
||||
LoadBalancerSecureShellPorts []int64 `json:"loadBalancerSecureShellPorts,omitempty"`
|
||||
LoadBalancerUserPasswords []string `json:"loadBalancerUserPasswords,omitempty"`
|
||||
LoadBalancerUserUsernames []string `json:"loadBalancerUserUsernames,omitempty"`
|
||||
LocalNetworkID int64 `json:"localNetworkId"`
|
||||
MachineOSBuild string `json:"machineOSBuild"`
|
||||
MachineOSImageID int64 `json:"machineOSImageId"`
|
||||
MachineOSType string `json:"machineOSType"`
|
||||
MachineProvider string `json:"machineProvider"`
|
||||
MasterAddresses []string `json:"masterAddresses,omitempty"`
|
||||
MasterCPUCount int64 `json:"masterCPUCount"`
|
||||
MasterCloudInit string `json:"masterCloudInit"`
|
||||
MasterCount int64 `json:"masterCount"`
|
||||
MasterDiskSize int64 `json:"masterDiskSize"`
|
||||
MasterGPUIDs []int64 `json:"masterGpuIds,omitempty"`
|
||||
MasterHostnames []string `json:"masterHostnames,omitempty"`
|
||||
MasterMemorySize int64 `json:"masterMemorySize"`
|
||||
MasterNodesExternalIPAdresses []string `json:"masterNodesExternalIPAdresses,omitempty"`
|
||||
MasterNodesMachineOSBuilds []string `json:"masterNodesMachineOSBuilds,omitempty"`
|
||||
MasterNodesMachineOSTypes []string `json:"masterNodesMachineOSTypes,omitempty"`
|
||||
MasterNodesRootPasswords []string `json:"masterNodesRootPasswords,omitempty"`
|
||||
MasterNodesRootUsernames []string `json:"masterNodesRootUsernames,omitempty"`
|
||||
MasterNodesSecureShellPorts []int64 `json:"masterNodesSecureShellPorts,omitempty"`
|
||||
MasterNodesUserPasswords []string `json:"masterNodesUserPasswords,omitempty"`
|
||||
MasterNodesUserUsernames []string `json:"masterNodesUserUsernames,omitempty"`
|
||||
MastersDynamixSEPID int64 `json:"mastersDynamixSEPId"`
|
||||
MastersDynamixSEPPool string `json:"mastersDynamixSEPPool"`
|
||||
PackageRepository int64 `json:"packageRepository"`
|
||||
ProvideDNS bool `json:"provideDNS"`
|
||||
SaveComputesOnFailedK8SCreation bool `json:"saveComputesOnFailedK8SCreation"`
|
||||
SharedClusterTemplate bool `json:"sharedClusterTemplate"`
|
||||
StoragePolicyID int64 `json:"storagePolicyId"`
|
||||
UseCustomExternalLBAddreses bool `json:"useCustomExternalLBAddreses"`
|
||||
UseCustomInternalLBAddreses bool `json:"useCustomInternalLBAddreses"`
|
||||
UseCustomMasterIPAddresses bool `json:"useCustomMasterIPAddresses"`
|
||||
UseCustomWorkerIPAddresses bool `json:"useCustomWorkerIPAddresses"`
|
||||
UseDynamixExtNet bool `json:"useDynamixExtnet"`
|
||||
ViNSGlobalNetworkID int64 `json:"vinsGlobalNetworkId"`
|
||||
WorkerAddresses []string `json:"workerAddresses,omitempty"`
|
||||
WorkerAnnotations []string `json:"workerAnnotations,omitempty"`
|
||||
WorkerCPUCount int64 `json:"workerCPUCount"`
|
||||
WorkerCloudInit string `json:"workerCloudInit"`
|
||||
WorkerCount int64 `json:"workerCount"`
|
||||
WorkerDiskSize int64 `json:"workerDiskSize"`
|
||||
WorkerGPUIDs []int64 `json:"workerGpuIds,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName"`
|
||||
WorkerHostnames []string `json:"workerHostnames,omitempty"`
|
||||
// WorkerGroup string `json:\"workerGroup\" form:\"workerGroup\"`
|
||||
WorkerLabels []string `json:"workerLabels,omitempty"`
|
||||
WorkerMemorySize int64 `json:"workerMemorySize"`
|
||||
WorkerNodesExternalIPAdresses []string `json:"workerNodesExternalIPAdresses,omitempty"`
|
||||
WorkerNodesMachineOSBuilds []string `json:"workerNodesMachineOSBuilds,omitempty"`
|
||||
WorkerNodesMachineOSTypes []string `json:"workerNodesMachineOSTypes,omitempty"`
|
||||
WorkerNodesRootPasswords []string `json:"workerNodesRootPasswords,omitempty"`
|
||||
WorkerNodesRootUsernames []string `json:"workerNodesRootUsernames,omitempty"`
|
||||
WorkerNodesSecureShellPorts []int64 `json:"workerNodesSecureShellPorts,omitempty"`
|
||||
WorkerNodesUserPasswords []string `json:"workerNodesUserPasswords,omitempty"`
|
||||
WorkerNodesUserUsernames []string `json:"workerNodesUserUsernames,omitempty"`
|
||||
WorkerTaints []string `json:"workerTaints,omitempty"`
|
||||
WorkersDynamixSEPID int64 `json:"workersDynamixSEPId"`
|
||||
WorkersDynamixSEPPool string `json:"workersDynamixSEPPool"`
|
||||
}
|
||||
|
||||
type DeleteClusterTemplateResult struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
type DeleteClusterTemplateResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DeleteClusterTemplateResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type DuplicateClusterTemplateResult struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
type DuplicateClusterTemplateResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DuplicateClusterTemplateResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetClusterTemplateResult struct {
|
||||
Template ClusterTemplate `json:"template,omitempty"`
|
||||
}
|
||||
|
||||
type GetClusterTemplateResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetClusterTemplateResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListClusterTemplatesResult struct {
|
||||
Templates []ClusterTemplateBrief `json:"templates,omitempty"`
|
||||
Total int64 `json:"total,omitempty"`
|
||||
}
|
||||
|
||||
type ListClusterTemplatesResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListClusterTemplatesResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateClusterTemplateRequest struct {
|
||||
ExtraCluster CreateClusterRequest `json:"extraCluster"`
|
||||
ID int64 `json:"id"`
|
||||
}
|
||||
|
||||
type UpdateClusterTemplateResult struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateClusterTemplateResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UpdateClusterTemplateResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,347 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_codescoring
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeCodeScoringService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the codescoring is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s codescoring pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get codescoring by id
|
||||
func (a *DeCodeScoringService) Describe(ctx context.Context, req DescribeRequest) (DescribeCodeScoringResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeCodeScoringResult
|
||||
)
|
||||
|
||||
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/codescoring/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 DescribeCodeScoringResultWithError
|
||||
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"`
|
||||
// username codescoring
|
||||
//
|
||||
// Required.
|
||||
Username string `json:"username" form:"username"`
|
||||
// password for codescoring
|
||||
//
|
||||
// Required.
|
||||
Password string `json:"password" form:"password"`
|
||||
// secret key for codescoring
|
||||
//
|
||||
// Required.
|
||||
SecretKey string `json:"secretKey" form:"secretKey"`
|
||||
// hostname for codescoring
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// storage type
|
||||
//
|
||||
// Allowed values:
|
||||
// - "longhorn"
|
||||
// - "glusterfs"
|
||||
// - ""
|
||||
StorageClass string `json:"storageClass" form:"storageClass"`
|
||||
// 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 codescoring in cluster
|
||||
func (a *DeCodeScoringService) 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.Username) {
|
||||
missingRequiredParams = append(missingRequiredParams, "username")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Password) {
|
||||
missingRequiredParams = append(missingRequiredParams, "password")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.SecretKey) {
|
||||
missingRequiredParams = append(missingRequiredParams, "secretKey")
|
||||
}
|
||||
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/codescoring/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, "username", req.Username, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "password", req.Password, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "secretKey", req.SecretKey, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "storageClass", req.StorageClass, "", "")
|
||||
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 the codescoring 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 codescoring from cluster
|
||||
func (a *DeCodeScoringService) 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/codescoring/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_codescoring
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeCodeScoring *DeCodeScoringService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeCodeScoring = (*DeCodeScoringService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_codescoring
|
||||
|
||||
type CodeScoringRecord 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"`
|
||||
SecretKey string `json:"secretKey,omitempty"`
|
||||
StorageType string `json:"storageType,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeCodeScoringResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry CodeScoringRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeCodeScoringResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeCodeScoringResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_codescoring
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,312 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_criobox
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeCrioboxService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the criobox is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
}
|
||||
|
||||
// Get criobox by id
|
||||
func (a *DeCrioboxService) Describe(ctx context.Context, req DescribeRequest) (DescribeCrioboxResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeCrioboxResult
|
||||
)
|
||||
|
||||
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/criobox/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, "", "")
|
||||
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 DescribeCrioboxResultWithError
|
||||
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"`
|
||||
// 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"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
// log level for criobox running in cluster. By default is warning
|
||||
//
|
||||
// Allowed values:
|
||||
// - "system"
|
||||
// - "debug"
|
||||
// - "info"
|
||||
// - "warning"
|
||||
// - "error"
|
||||
// - ""
|
||||
LogLevel string `json:"logLevel" form:"logLevel"`
|
||||
}
|
||||
|
||||
// Install Criobox
|
||||
func (a *DeCrioboxService) Install(ctx context.Context, req InstallRequest) (InstallCrioboxResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result InstallCrioboxResult
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
if !utils.IsZeroValue(req.LogLevel) {
|
||||
logLevelValue := req.LogLevel
|
||||
logLevelAllowedValues := []string{
|
||||
"system",
|
||||
"debug",
|
||||
"info",
|
||||
"warning",
|
||||
"error",
|
||||
"",
|
||||
}
|
||||
logLevelValid := false
|
||||
for _, allowed := range logLevelAllowedValues {
|
||||
if logLevelValue == allowed {
|
||||
logLevelValid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !logLevelValid {
|
||||
return result, fmt.Errorf("logLevel must be one of %v", logLevelAllowedValues)
|
||||
}
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/criobox/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, "appsRepositoryId", req.AppsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "chartsRepositoryId", req.ChartsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "downloadChartAnyway", req.DownloadChartAnyway, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "logLevel", req.LogLevel, "", "")
|
||||
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 InstallCrioboxResultWithError
|
||||
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 the certmanager 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 Criobox
|
||||
func (a *DeCrioboxService) Uninstall(ctx context.Context, req UninstallRequest) (UninstallCrioboxResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result UninstallCrioboxResult
|
||||
)
|
||||
|
||||
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/criobox/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 UninstallCrioboxResultWithError
|
||||
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_criobox
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeCriobox *DeCrioboxService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeCriobox = (*DeCrioboxService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_criobox
|
||||
|
||||
type CrioboxRecord struct {
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
Port int64 `json:"port,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeCrioboxResult struct {
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry CrioboxRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeCrioboxResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeCrioboxResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type InstallCrioboxResult struct {
|
||||
TaskID int64 `json:"taskId,omitempty"`
|
||||
}
|
||||
|
||||
type InstallCrioboxResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result InstallCrioboxResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UninstallCrioboxResult struct {
|
||||
TaskID int64 `json:"taskId,omitempty"`
|
||||
}
|
||||
|
||||
type UninstallCrioboxResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UninstallCrioboxResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_criobox
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,405 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_customapp
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeCustomAppService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// custom app ID
|
||||
//
|
||||
// Required.
|
||||
CustomAppID int64 `json:"customAppId" form:"customAppId"`
|
||||
// true for checking whether the custom app is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s custom app pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"CheckLiveness" form:"CheckLiveness"`
|
||||
}
|
||||
|
||||
// Get custom app by id
|
||||
func (a *DeCustomAppService) Describe(ctx context.Context, req DescribeRequest) (DescribeCustomAppResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeCustomAppResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.CustomAppID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "customAppId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/customapp/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, "customAppId", req.CustomAppID, "", "")
|
||||
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 DescribeCustomAppResultWithError
|
||||
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"`
|
||||
// custom chart ID
|
||||
//
|
||||
// Required.
|
||||
ChartID string `json:"chartId" form:"chartId"`
|
||||
// custom release name
|
||||
//
|
||||
// Required.
|
||||
ReleaseName string `json:"releaseName" form:"releaseName"`
|
||||
// custom release namespace
|
||||
//
|
||||
// Required.
|
||||
ReleaseNamespace string `json:"releaseNamespace" form:"releaseNamespace"`
|
||||
// Hostname for custom app
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// Install timeout in minutes. Max is 60 minutes, min is 5 minutes. If not specified, default timeout of 10 minutes will be used
|
||||
InstallTimeout int64 `json:"installTimeout" form:"installTimeout"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
}
|
||||
|
||||
// Install custom app in cluster
|
||||
func (a *DeCustomAppService) 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.ChartID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "chartId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.ReleaseName) {
|
||||
missingRequiredParams = append(missingRequiredParams, "releaseName")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.ReleaseNamespace) {
|
||||
missingRequiredParams = append(missingRequiredParams, "releaseNamespace")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/customapp/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, "chartId", req.ChartID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "releaseName", req.ReleaseName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "releaseNamespace", req.ReleaseNamespace, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "installTimeout", req.InstallTimeout, "", "")
|
||||
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 ListRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether custom apps are installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking custom apps pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"CheckLiveness" form:"CheckLiveness"`
|
||||
}
|
||||
|
||||
// List custom app by cluster id
|
||||
func (a *DeCustomAppService) List(ctx context.Context, req ListRequest) (ListCustomAppsResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result ListCustomAppsResult
|
||||
)
|
||||
|
||||
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/customapp/list"
|
||||
|
||||
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 ListCustomAppsResultWithError
|
||||
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 {
|
||||
// custom app ID
|
||||
//
|
||||
// Required.
|
||||
CustomAppID int64 `json:"customAppId" form:"customAppId"`
|
||||
// true for deleting the custom app even if it is not registered
|
||||
CleanAlways bool `json:"cleanAlways" form:"cleanAlways"`
|
||||
// true for deleting namespace
|
||||
DeleteNamespace bool `json:"deleteNamespace" form:"deleteNamespace"`
|
||||
// true for ignoring dns server errors
|
||||
IgnoreDNSError bool `json:"ignoreDnsError" form:"ignoreDnsError"`
|
||||
// Uninstall timeout in minutes. Max is 30 minutes, min is 5 minutes. If not specified, default timeout of 10 minutes will be used
|
||||
UninstallTimeout int64 `json:"uninstallTimeout" form:"uninstallTimeout"`
|
||||
}
|
||||
|
||||
// Uninstall custom app from cluster
|
||||
func (a *DeCustomAppService) 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.CustomAppID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "customAppId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/customapp/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, "customAppId", req.CustomAppID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cleanAlways", req.CleanAlways, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "deleteNamespace", req.DeleteNamespace, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "ignoreDnsError", req.IgnoreDNSError, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "uninstallTimeout", req.UninstallTimeout, "", "")
|
||||
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_customapp
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeCustomApp *DeCustomAppService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeCustomApp = (*DeCustomAppService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_customapp
|
||||
|
||||
type CustomAppRecord struct {
|
||||
ChartID string `json:"chartId,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeCustomAppResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
IconPath string `json:"iconPath,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry CustomAppRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeCustomAppResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeCustomAppResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListCustomAppsResult struct {
|
||||
CustomApps []DescribeCustomAppResult `json:"customApps,omitempty"`
|
||||
}
|
||||
|
||||
type ListCustomAppsResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListCustomAppsResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_customapp
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,398 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_database
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeDatabaseService service
|
||||
|
||||
type CreateDatabasesRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// drop existing
|
||||
//
|
||||
// Required.
|
||||
DropExisting bool `json:"dropExisting" form:"dropExisting"`
|
||||
// comma separated list of databases
|
||||
Databases string `json:"databases" form:"databases"`
|
||||
// owner of databases
|
||||
Owner string `json:"owner" form:"owner"`
|
||||
}
|
||||
|
||||
// Create databases
|
||||
func (a *DeDatabaseService) CreateDatabases(ctx context.Context, req CreateDatabasesRequest) (any, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result any
|
||||
)
|
||||
|
||||
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.DropExisting) {
|
||||
missingRequiredParams = append(missingRequiredParams, "dropExisting")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/database/createDatabases"
|
||||
|
||||
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, "databases", req.Databases, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "owner", req.Owner, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "dropExisting", req.DropExisting, "", "")
|
||||
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 CreateDatabasesResultWithError
|
||||
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 CreateDBUserRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// database name for postgresql
|
||||
//
|
||||
// Required.
|
||||
Username string `json:"username" form:"username"`
|
||||
// password for postgresql user
|
||||
//
|
||||
// Required.
|
||||
Password string `json:"password" form:"password"`
|
||||
// drop existings databases
|
||||
DropExisting bool `json:"dropExisting" form:"dropExisting"`
|
||||
// comma separated list of databases
|
||||
Databases string `json:"databases" form:"databases"`
|
||||
}
|
||||
|
||||
// Create database user & databases
|
||||
func (a *DeDatabaseService) CreateDBUser(ctx context.Context, req CreateDBUserRequest) (any, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result any
|
||||
)
|
||||
|
||||
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.Username) {
|
||||
missingRequiredParams = append(missingRequiredParams, "username")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Password) {
|
||||
missingRequiredParams = append(missingRequiredParams, "password")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/database/createDbUser"
|
||||
|
||||
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, "username", req.Username, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "password", req.Password, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "dropExisting", req.DropExisting, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "databases", req.Databases, "", "")
|
||||
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 CreateDBUserResultWithError
|
||||
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 DeleteDatabaseRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// comma separated list of databases
|
||||
Databases string `json:"databases" form:"databases"`
|
||||
}
|
||||
|
||||
// Delete databases
|
||||
func (a *DeDatabaseService) DeleteDatabase(ctx context.Context, req DeleteDatabaseRequest) (any, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result any
|
||||
)
|
||||
|
||||
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/database/deleteDatabase"
|
||||
|
||||
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, "databases", req.Databases, "", "")
|
||||
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 DeleteDatabasesResultWithError
|
||||
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 DeleteDBUserRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// database name for postgresql
|
||||
//
|
||||
// Required.
|
||||
Username string `json:"username" form:"username"`
|
||||
// drop databases
|
||||
//
|
||||
// Required.
|
||||
DropDatabases bool `json:"dropDatabases" form:"dropDatabases"`
|
||||
}
|
||||
|
||||
// Delete database user & databases
|
||||
func (a *DeDatabaseService) DeleteDBUser(ctx context.Context, req DeleteDBUserRequest) (any, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result any
|
||||
)
|
||||
|
||||
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.Username) {
|
||||
missingRequiredParams = append(missingRequiredParams, "username")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.DropDatabases) {
|
||||
missingRequiredParams = append(missingRequiredParams, "dropDatabases")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/database/deleteDbUser"
|
||||
|
||||
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, "username", req.Username, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "dropDatabases", req.DropDatabases, "", "")
|
||||
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 DeleteDBUserResultWithError
|
||||
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_database
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeDatabase *DeDatabaseService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeDatabase = (*DeDatabaseService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_database
|
||||
|
||||
type CreateDatabasesResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type CreateDBUserResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type DeleteDatabasesResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type DeleteDBUserResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,326 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_dependency_track
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeDependencyTrackService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the dtrack is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s dtrack pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get dependency-track by id
|
||||
func (a *DeDependencyTrackService) Describe(ctx context.Context, req DescribeRequest) (DescribeDeptrackResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeDeptrackResult
|
||||
)
|
||||
|
||||
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/dependency-track/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 DescribeDeptrackResultWithError
|
||||
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 dependency track
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// password for the admin user. Do not use the password 'admin' because it will not work
|
||||
Password string `json:"password" form:"password"`
|
||||
// storage type
|
||||
//
|
||||
// Allowed values:
|
||||
// - "longhorn"
|
||||
// - "glusterfs"
|
||||
// - ""
|
||||
StorageClass string `json:"storageClass" form:"storageClass"`
|
||||
// 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 dependency-track in cluster
|
||||
func (a *DeDependencyTrackService) 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.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/dependency-track/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, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "password", req.Password, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "storageClass", req.StorageClass, "", "")
|
||||
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 the dtrack 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 dependency-track from cluster
|
||||
func (a *DeDependencyTrackService) 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/dependency-track/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_dependency_track
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeDependencyTrack *DeDependencyTrackService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeDependencyTrack = (*DeDependencyTrackService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_dependency_track
|
||||
|
||||
type DeptrackRecord 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"`
|
||||
PsqlPassword string `json:"psqlPassword,omitempty"`
|
||||
PsqlUsername string `json:"psqlUsername,omitempty"`
|
||||
StorageType string `json:"storageType,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeDeptrackResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry DeptrackRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeDeptrackResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeDeptrackResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_dependency_track
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,82 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_deployment
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeDeploymentService service
|
||||
|
||||
// Get deployment
|
||||
func (a *DeDeploymentService) Get(ctx context.Context) (GetDeploymentResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result GetDeploymentResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/deployment/get"
|
||||
|
||||
contentTypes := []string{}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
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 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 GetDeploymentResultWithError
|
||||
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_deployment
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeDeployment *DeDeploymentService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeDeployment = (*DeDeploymentService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_deployment
|
||||
|
||||
type GetDeploymentResult struct {
|
||||
BuildBranchName string `json:"buildBranchName,omitempty"`
|
||||
BuildTime string `json:"buildTime,omitempty"`
|
||||
BuildVersionShort string `json:"buildVersionShort,omitempty"`
|
||||
CheckIstoreEntityResult string `json:"checkIstoreEntityResult,omitempty"`
|
||||
ReleaseVersion string `json:"releaseVersion,omitempty"`
|
||||
}
|
||||
|
||||
type GetDeploymentResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetDeploymentResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_files
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeFilesService service
|
||||
|
||||
type FileUploadRequest struct {
|
||||
// file to upload
|
||||
//
|
||||
// Required.
|
||||
File *core.UploadFile `json:"file" form:"file"`
|
||||
// the time after which the file will be deleted
|
||||
TimeToDelete int64 `json:"timeToDelete" form:"timeToDelete"`
|
||||
}
|
||||
|
||||
// Upload file to server
|
||||
func (a *DeFilesService) FileUpload(ctx context.Context, req FileUploadRequest) (FileUploadResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result FileUploadResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if req.File == nil {
|
||||
missingRequiredParams = append(missingRequiredParams, "file")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/files/fileUpload"
|
||||
|
||||
contentTypes := []string{"multipart/form-data"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
if file := req.File; file != nil {
|
||||
formFiles = append(formFiles, utils.FormFile{
|
||||
FieldName: "file",
|
||||
Filename: file.Filename,
|
||||
Reader: file.Reader,
|
||||
})
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "timeToDelete", req.TimeToDelete, "", "")
|
||||
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 FileUploadResultWithError
|
||||
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_files
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeFiles *DeFilesService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeFiles = (*DeFilesService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_files
|
||||
|
||||
type FileUploadResult struct {
|
||||
FilePath string `json:"filePath,omitempty"`
|
||||
}
|
||||
|
||||
type FileUploadResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result FileUploadResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_gitlab
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeGitLabService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the gitlab is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s gitlab pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get gitlab by id
|
||||
func (a *DeGitLabService) Describe(ctx context.Context, req DescribeRequest) (DescribeGitLabResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeGitLabResult
|
||||
)
|
||||
|
||||
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/gitlab/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 DescribeGitLabResultWithError
|
||||
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 gitlab
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// storage type
|
||||
//
|
||||
// Allowed values:
|
||||
// - "longhorn"
|
||||
// - "glusterfs"
|
||||
// - ""
|
||||
StorageClass string `json:"storageClass" form:"storageClass"`
|
||||
// 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 gitlab in cluster
|
||||
func (a *DeGitLabService) 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.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/gitlab/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, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "storageClass", req.StorageClass, "", "")
|
||||
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 the gitlab 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 gitlab from cluster
|
||||
func (a *DeGitLabService) 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/gitlab/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_gitlab
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeGitLab *DeGitLabService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeGitLab = (*DeGitLabService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_gitlab
|
||||
|
||||
type DescribeGitLabResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry GitLabRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeGitLabResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeGitLabResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GitLabRecord 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"`
|
||||
PsqlPassword string `json:"psqlPassword,omitempty"`
|
||||
PsqlUsername string `json:"psqlUsername,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_gitlab
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,339 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_grafana
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeGrafanaService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the grafana is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s grafana pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get grafana by id
|
||||
func (a *DeGrafanaService) Describe(ctx context.Context, req DescribeRequest) (DescribeGrafanaResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeGrafanaResult
|
||||
)
|
||||
|
||||
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/grafana/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 DescribeGrafanaResultWithError
|
||||
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"`
|
||||
// grafana hostname
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// username
|
||||
//
|
||||
// Required.
|
||||
Username string `json:"username" form:"username"`
|
||||
// password
|
||||
//
|
||||
// Required.
|
||||
Password string `json:"password" form:"password"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// storage type
|
||||
//
|
||||
// Allowed values:
|
||||
// - "longhorn"
|
||||
// - "glusterfs"
|
||||
// - ""
|
||||
StorageClass string `json:"storageClass" form:"storageClass"`
|
||||
// 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 grafana in cluster
|
||||
func (a *DeGrafanaService) 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.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Username) {
|
||||
missingRequiredParams = append(missingRequiredParams, "username")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Password) {
|
||||
missingRequiredParams = append(missingRequiredParams, "password")
|
||||
}
|
||||
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/grafana/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, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "username", req.Username, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "password", req.Password, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "storageClass", req.StorageClass, "", "")
|
||||
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 the grafana 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 grafana from cluster
|
||||
func (a *DeGrafanaService) 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/grafana/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_grafana
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeGrafana *DeGrafanaService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeGrafana = (*DeGrafanaService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_grafana
|
||||
|
||||
type DescribeGrafanaResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry GrafanaRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeGrafanaResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeGrafanaResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GrafanaRecord 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"`
|
||||
RootToken string `json:"rootToken,omitempty"`
|
||||
StorageType string `json:"storageType,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
UnsealKeys []string `json:"unsealKeys,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_grafana
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,439 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_group
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeGroupService service
|
||||
|
||||
type CreateRequest struct {
|
||||
// Group description
|
||||
//
|
||||
// Required.
|
||||
Name string `json:"name" form:"name"`
|
||||
}
|
||||
|
||||
// Create group for service
|
||||
func (a *DeGroupService) Create(ctx context.Context, req CreateRequest) (CreateGroupResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateGroupResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.Name) {
|
||||
missingRequiredParams = append(missingRequiredParams, "name")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/group/create"
|
||||
|
||||
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, "name", req.Name, "", "")
|
||||
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 CreateGroupResultWithError
|
||||
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 DeleteRequest struct {
|
||||
// Group ID
|
||||
//
|
||||
// Required.
|
||||
ID int64 `json:"id" form:"id"`
|
||||
}
|
||||
|
||||
// Delete group
|
||||
func (a *DeGroupService) Delete(ctx context.Context, req DeleteRequest) (any, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result any
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "id")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/group/delete"
|
||||
|
||||
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, "id", req.ID, "", "")
|
||||
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 DeleteGroupResultWithError
|
||||
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 GetRequest struct {
|
||||
// Group ID
|
||||
//
|
||||
// Required.
|
||||
ID int64 `json:"id" form:"id"`
|
||||
}
|
||||
|
||||
// Get group by id
|
||||
func (a *DeGroupService) Get(ctx context.Context, req GetRequest) (GetGroupResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result GetGroupResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "id")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/group/get"
|
||||
|
||||
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, "id", req.ID, "", "")
|
||||
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 GetGroupResultWithError
|
||||
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 ListRequest struct {
|
||||
// include archive groups
|
||||
IncludeArchiveGroups bool `json:"includeArchiveGroups" form:"includeArchiveGroups"`
|
||||
// filter by Group ID
|
||||
ID int64 `json:"id" form:"id"`
|
||||
// filter by Group name
|
||||
Name string `json:"name" form:"name"`
|
||||
// Sort by one of supported fields, format +|-(field>)
|
||||
SortBy string `json:"sortBy" form:"sortBy"`
|
||||
// Limit number of groups outputs to be shown in the result. If not set, all groups will be shown.
|
||||
Limit int64 `json:"limit" form:"limit"`
|
||||
// Select page of the result. If not set, the first page will be shown.
|
||||
Page int64 `json:"page" form:"page"`
|
||||
}
|
||||
|
||||
// Get group list
|
||||
func (a *DeGroupService) List(ctx context.Context, req ListRequest) (ListGroupsResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result ListGroupsResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/group/list"
|
||||
|
||||
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, "includeArchiveGroups", req.IncludeArchiveGroups, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "id", req.ID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "name", req.Name, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "sortBy", req.SortBy, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "limit", req.Limit, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "page", req.Page, "", "")
|
||||
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 ListGroupsResultWithError
|
||||
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 UpdateRequest struct {
|
||||
// Group ID
|
||||
//
|
||||
// Required.
|
||||
ID int64 `json:"id" form:"id"`
|
||||
// Group description
|
||||
//
|
||||
// Required.
|
||||
Name string `json:"name" form:"name"`
|
||||
}
|
||||
|
||||
// Upgrade group server for cluster
|
||||
func (a *DeGroupService) Update(ctx context.Context, req UpdateRequest) (UpdateGroupResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result UpdateGroupResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "id")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Name) {
|
||||
missingRequiredParams = append(missingRequiredParams, "name")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/group/update"
|
||||
|
||||
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, "id", req.ID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "name", req.Name, "", "")
|
||||
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 UpdateGroupResultWithError
|
||||
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_group
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeGroup *DeGroupService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeGroup = (*DeGroupService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_group
|
||||
|
||||
type CreateGroupResult struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
type CreateGroupResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result CreateGroupResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type DeleteGroupResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetGroupResult struct {
|
||||
Record Group `json:"record,omitempty"`
|
||||
}
|
||||
|
||||
type GetGroupResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetGroupResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type Group struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Locked bool `json:"locked,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type ListGroupsResult struct {
|
||||
Records []Group `json:"records,omitempty"`
|
||||
}
|
||||
|
||||
type ListGroupsResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListGroupsResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateGroupResult struct {
|
||||
Record Group `json:"record,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateGroupResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UpdateGroupResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_harbor
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeHarborService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the harbor is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s harbor pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get harbor by id
|
||||
func (a *DeHarborService) Describe(ctx context.Context, req DescribeRequest) (DescribeHarborResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeHarborResult
|
||||
)
|
||||
|
||||
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/harbor/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 DescribeHarborResultWithError
|
||||
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"`
|
||||
// username for harbor
|
||||
//
|
||||
// Required.
|
||||
Username string `json:"username" form:"username"`
|
||||
// password for the admin user
|
||||
//
|
||||
// Required.
|
||||
Password string `json:"password" form:"password"`
|
||||
// hostname for harbor
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// storage type
|
||||
//
|
||||
// Allowed values:
|
||||
// - "longhorn"
|
||||
// - "glusterfs"
|
||||
// - ""
|
||||
StorageClass string `json:"storageClass" form:"storageClass"`
|
||||
// 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 harbor in cluster
|
||||
func (a *DeHarborService) 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.Username) {
|
||||
missingRequiredParams = append(missingRequiredParams, "username")
|
||||
}
|
||||
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/harbor/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, "username", req.Username, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "password", req.Password, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "storageClass", req.StorageClass, "", "")
|
||||
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 the harbor 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 harbor from cluster
|
||||
func (a *DeHarborService) 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/harbor/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_harbor
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeHarbor *DeHarborService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeHarbor = (*DeHarborService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_harbor
|
||||
|
||||
type DescribeHarborResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry HarborRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeHarborResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeHarborResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type HarborRecord 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"`
|
||||
PsqlPassword string `json:"psqlPassword,omitempty"`
|
||||
PsqlUsername string `json:"psqlUsername,omitempty"`
|
||||
StorageType string `json:"storageType,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_harbor
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,307 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_ingress_nginx
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeIngressNginxService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the nginx is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s nginx pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get nginx by id
|
||||
func (a *DeIngressNginxService) Describe(ctx context.Context, req DescribeRequest) (DescribeNginxResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeNginxResult
|
||||
)
|
||||
|
||||
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/ingress-nginx/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 DescribeNginxResultWithError
|
||||
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 nginx
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// http port
|
||||
//
|
||||
// Required.
|
||||
HTTPPort int64 `json:"httpPort" form:"httpPort"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// https port
|
||||
HTTPSPort int64 `json:"httpsPort" form:"httpsPort"`
|
||||
// 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 nginx in cluster
|
||||
func (a *DeIngressNginxService) 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.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.HTTPPort) {
|
||||
missingRequiredParams = append(missingRequiredParams, "httpPort")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/ingress-nginx/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, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "httpPort", req.HTTPPort, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "httpsPort", req.HTTPSPort, "", "")
|
||||
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 the nginx 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 nginx from cluster
|
||||
func (a *DeIngressNginxService) 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/ingress-nginx/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_ingress_nginx
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeIngressNginx *DeIngressNginxService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeIngressNginx = (*DeIngressNginxService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_ingress_nginx
|
||||
|
||||
type DescribeNginxResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry NginxRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeNginxResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeNginxResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type NginxRecord struct {
|
||||
Addresses map[string]string `json:"addresses,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
Hostnames map[string]string `json:"hostnames,omitempty"`
|
||||
HTTPPort int64 `json:"httpPort,omitempty"`
|
||||
HTTPSPort int64 `json:"httpsPort,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"`
|
||||
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_ingress_nginx
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,284 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_integagent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeIntegagentService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the podlogger is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
}
|
||||
|
||||
// Get Integagent by id
|
||||
func (a *DeIntegagentService) Describe(ctx context.Context, req DescribeRequest) (DescribeIntegagentResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeIntegagentResult
|
||||
)
|
||||
|
||||
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/integagent/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, "", "")
|
||||
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 DescribeIntegagentResultWithError
|
||||
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"`
|
||||
// integagent hostname
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// 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 Integagent
|
||||
func (a *DeIntegagentService) Install(ctx context.Context, req InstallRequest) (InstallIntegagentResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result InstallIntegagentResult
|
||||
)
|
||||
|
||||
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.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/integagent/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, "hostname", req.Hostname, "", "")
|
||||
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 InstallIntegagentResultWithError
|
||||
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"`
|
||||
}
|
||||
|
||||
// Uninstall Integagent
|
||||
func (a *DeIntegagentService) Uninstall(ctx context.Context, req UninstallRequest) (UninstallIntegagentResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result UninstallIntegagentResult
|
||||
)
|
||||
|
||||
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/integagent/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, "", "")
|
||||
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 UninstallIntegagentResultWithError
|
||||
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_integagent
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeIntegagent *DeIntegagentService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeIntegagent = (*DeIntegagentService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_integagent
|
||||
|
||||
type DescribeIntegagentResult struct {
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry IntegagentRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeIntegagentResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeIntegagentResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type InstallIntegagentResult struct {
|
||||
TaskID int64 `json:"taskId,omitempty"`
|
||||
}
|
||||
|
||||
type InstallIntegagentResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result InstallIntegagentResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type IntegagentRecord 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"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
|
||||
type UninstallIntegagentResult struct {
|
||||
TaskID int64 `json:"taskId,omitempty"`
|
||||
}
|
||||
|
||||
type UninstallIntegagentResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UninstallIntegagentResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_integagent
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,296 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_istio
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeIstioService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the istio is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s istio pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get istio by id
|
||||
func (a *DeIstioService) Describe(ctx context.Context, req DescribeRequest) (DescribeIstioResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeIstioResult
|
||||
)
|
||||
|
||||
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/istio/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 DescribeIstioResultWithError
|
||||
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
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// 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 istio in cluster
|
||||
func (a *DeIstioService) 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.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/istio/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, "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 the istio 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 istio from cluster
|
||||
func (a *DeIstioService) 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/istio/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_istio
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeIstio *DeIstioService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeIstio = (*DeIstioService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_istio
|
||||
|
||||
type DescribeIstioResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry IstioRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeIstioResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeIstioResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type IstioRecord 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"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,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_istio
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_istore
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeIstore *DeIstoreService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeIstore = (*DeIstoreService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+196
@@ -0,0 +1,196 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_istore
|
||||
|
||||
type Blob struct {
|
||||
CreatedAt string `json:"createdAt,omitempty"`
|
||||
Digest string `json:"digest,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
MediaType string `json:"mediaType,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Reference string `json:"reference,omitempty"`
|
||||
Size int64 `json:"size,omitempty"`
|
||||
UpdatedAt string `json:"updatedAt,omitempty"`
|
||||
}
|
||||
|
||||
type Chart struct {
|
||||
Checksum string `json:"checksum,omitempty"`
|
||||
Collection string `json:"collection,omitempty"`
|
||||
CreatedAt string `json:"createdAt,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
IconPath string `json:"iconPath,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
Path string `json:"path,omitempty"`
|
||||
Public bool `json:"public,omitempty"`
|
||||
ReadOnly bool `json:"readOnly,omitempty"`
|
||||
Shared bool `json:"shared,omitempty"`
|
||||
Size int64 `json:"size,omitempty"`
|
||||
UpdatedAt string `json:"updatedAt,omitempty"`
|
||||
UpdatedBy int64 `json:"updatedBy,omitempty"`
|
||||
UserID int64 `json:"userId,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
type DeleteChartResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type DeleteImageResult struct {
|
||||
Result string `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type DeleteImageResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DeleteImageResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetChartResult struct {
|
||||
Chart Chart `json:"chart,omitempty"`
|
||||
}
|
||||
|
||||
type GetChartResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetChartResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetImageResult struct {
|
||||
Manifest Manifest `json:"manifest,omitempty"`
|
||||
}
|
||||
|
||||
type GetImageResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetImageResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListChartsResult struct {
|
||||
Charts []Chart `json:"charts,omitempty"`
|
||||
Page int64 `json:"page,omitempty"`
|
||||
PageSize int64 `json:"pageSize,omitempty"`
|
||||
Total int64 `json:"total,omitempty"`
|
||||
TotalPages int64 `json:"totalPages,omitempty"`
|
||||
}
|
||||
|
||||
type ListChartsResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListChartsResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListImagesResult struct {
|
||||
Manifests []Manifest `json:"manifests,omitempty"`
|
||||
Total int64 `json:"total,omitempty"`
|
||||
}
|
||||
|
||||
type ListImagesResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListImagesResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListOprecordsResult struct {
|
||||
Oprecords []Oprecord `json:"oprecords,omitempty"`
|
||||
Page int64 `json:"page,omitempty"`
|
||||
PageSize int64 `json:"pageSize,omitempty"`
|
||||
Total int64 `json:"total,omitempty"`
|
||||
TotalPages int64 `json:"totalPages,omitempty"`
|
||||
}
|
||||
|
||||
type ListOprecordsResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListOprecordsResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type Manifest struct {
|
||||
Collection string `json:"collection,omitempty"`
|
||||
ContentType string `json:"contentType,omitempty"`
|
||||
CreatedAt string `json:"createdAt,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Digest string `json:"digest,omitempty"`
|
||||
GroupID int64 `json:"groupId,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Public bool `json:"public,omitempty"`
|
||||
ReadOnly bool `json:"readOnly,omitempty"`
|
||||
Reference string `json:"reference,omitempty"`
|
||||
Shared bool `json:"shared,omitempty"`
|
||||
UpdatedAt string `json:"updatedAt,omitempty"`
|
||||
UpdatedBy int64 `json:"updatedBy,omitempty"`
|
||||
UserID int64 `json:"userId,omitempty"`
|
||||
}
|
||||
|
||||
type Oprecord struct {
|
||||
IP string `json:"IP,omitempty"`
|
||||
APIEndpoint string `json:"apiEndpoint,omitempty"`
|
||||
CreatedAt string `json:"createdAt,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
ErrorMessage string `json:"errorMessage,omitempty"`
|
||||
FinishedWithError bool `json:"finishedWithError,omitempty"`
|
||||
GroupID int64 `json:"groupId,omitempty"`
|
||||
GroupName string `json:"groupName,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Operation string `json:"operation,omitempty"`
|
||||
UserID int64 `json:"userId,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateChartResult struct {
|
||||
Chart Chart `json:"chart,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateChartResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UpdateChartResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateImageResult struct {
|
||||
Manifest Manifest `json:"manifest,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateImageResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UpdateImageResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UploadChartResult struct {
|
||||
Chart Chart `json:"chart,omitempty"`
|
||||
Replace bool `json:"replace,omitempty"`
|
||||
UploadInGroup bool `json:"uploadInGroup,omitempty"`
|
||||
}
|
||||
|
||||
type UploadChartResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UploadChartResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UploadImageResult struct {
|
||||
Blobs []Blob `json:"blobs,omitempty"`
|
||||
Manifest Manifest `json:"manifest,omitempty"`
|
||||
}
|
||||
|
||||
type UploadImageResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UploadImageResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_jenkins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeJenkinsService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the jenkins is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s jenkins pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get jenkins by id
|
||||
func (a *DeJenkinsService) Describe(ctx context.Context, req DescribeRequest) (DescribeJenkinsResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeJenkinsResult
|
||||
)
|
||||
|
||||
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/jenkins/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 DescribeJenkinsResultWithError
|
||||
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"`
|
||||
// username for the admin user
|
||||
//
|
||||
// Required.
|
||||
Username string `json:"username" form:"username"`
|
||||
// password for the admin user
|
||||
//
|
||||
// Required.
|
||||
Password string `json:"password" form:"password"`
|
||||
// hostname for jenkins
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// storage class
|
||||
//
|
||||
// Allowed values:
|
||||
// - "longhorn"
|
||||
// - "glusterfs"
|
||||
// - ""
|
||||
StorageClass string `json:"storageClass" form:"storageClass"`
|
||||
// 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 jenkins in cluster
|
||||
func (a *DeJenkinsService) 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.Username) {
|
||||
missingRequiredParams = append(missingRequiredParams, "username")
|
||||
}
|
||||
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/jenkins/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, "username", req.Username, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "password", req.Password, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "storageClass", req.StorageClass, "", "")
|
||||
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 the jenkins 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 jenkins from cluster
|
||||
func (a *DeJenkinsService) 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/jenkins/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_jenkins
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeJenkins *DeJenkinsService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeJenkins = (*DeJenkinsService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_jenkins
|
||||
|
||||
type DescribeJenkinsResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry JenkinsRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeJenkinsResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeJenkinsResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type JenkinsRecord 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"`
|
||||
StorageType string `json:"storageType,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
WithDepcheck bool `json:"withDepcheck,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_jenkins
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,669 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_kubernetes_user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeKubernetesUserService service
|
||||
|
||||
type CreateRequest struct {
|
||||
// username
|
||||
//
|
||||
// Required.
|
||||
Username string `json:"username" form:"username"`
|
||||
// description
|
||||
//
|
||||
// Required.
|
||||
Description string `json:"description" form:"description"`
|
||||
// clusterId
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// user rights settings (base64-encoded JSON)
|
||||
//
|
||||
// Required.
|
||||
Settings string `json:"settings" form:"settings"`
|
||||
}
|
||||
|
||||
// Create user for kubernetes
|
||||
func (a *DeKubernetesUserService) Create(ctx context.Context, req CreateRequest) (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.Username) {
|
||||
missingRequiredParams = append(missingRequiredParams, "username")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Description) {
|
||||
missingRequiredParams = append(missingRequiredParams, "description")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Settings) {
|
||||
missingRequiredParams = append(missingRequiredParams, "settings")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/kubernetesUser/create"
|
||||
|
||||
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, "username", req.Username, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "description", req.Description, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "settings", req.Settings, "", "")
|
||||
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 DeleteRequest struct {
|
||||
// User ID
|
||||
//
|
||||
// Required.
|
||||
ID int64 `json:"id" form:"id"`
|
||||
// clusterID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
}
|
||||
|
||||
// Delete kubernetes user
|
||||
func (a *DeKubernetesUserService) Delete(ctx context.Context, req DeleteRequest) (any, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result any
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "id")
|
||||
}
|
||||
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/kubernetesUser/delete"
|
||||
|
||||
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, "id", req.ID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
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 DeleteUserResultWithError
|
||||
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 GetRequest struct {
|
||||
// clusterID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// User ID
|
||||
ID int64 `json:"id" form:"id"`
|
||||
}
|
||||
|
||||
// Get kubernetes user by id
|
||||
func (a *DeKubernetesUserService) Get(ctx context.Context, req GetRequest) (GetUserResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result GetUserResult
|
||||
)
|
||||
|
||||
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/kubernetesUser/get"
|
||||
|
||||
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, "id", req.ID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
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 GetUserResultWithError
|
||||
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 ListRequest struct {
|
||||
// clusterID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// filter by User ID
|
||||
ID int64 `json:"id" form:"id"`
|
||||
// filter by kubeUser login name; musthave adequate grant
|
||||
Username string `json:"username" form:"username"`
|
||||
// filter by status
|
||||
Status string `json:"status" form:"status"`
|
||||
// Sort by one of supported fields, format +|-(field>)
|
||||
SortBy string `json:"sortBy" form:"sortBy"`
|
||||
// Limit number of users outputs to be shown in the result. If not set, all users will be shown.
|
||||
Limit int64 `json:"limit" form:"limit"`
|
||||
// Select page of the result. If not set, the first page will be shown.
|
||||
Page int64 `json:"page" form:"page"`
|
||||
}
|
||||
|
||||
// Get kubernetes user list
|
||||
func (a *DeKubernetesUserService) List(ctx context.Context, req ListRequest) (ListUsersResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result ListUsersResult
|
||||
)
|
||||
|
||||
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/kubernetesUser/list"
|
||||
|
||||
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, "id", req.ID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "username", req.Username, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "status", req.Status, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "sortBy", req.SortBy, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "limit", req.Limit, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "page", req.Page, "", "")
|
||||
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 ListUsersResultWithError
|
||||
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 ListNamespacesRequest struct {
|
||||
// clusterId
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
}
|
||||
|
||||
// List Kubernetes Namespaces
|
||||
func (a *DeKubernetesUserService) ListNamespaces(ctx context.Context, req ListNamespacesRequest) (ListNamespacesResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result ListNamespacesResult
|
||||
)
|
||||
|
||||
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/kubernetesUser/listNamespaces"
|
||||
|
||||
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, "", "")
|
||||
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 ListNamespacesResultWithError
|
||||
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 ListResourcesRequest struct {
|
||||
// clusterId
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
}
|
||||
|
||||
// List Kubernetes Resources
|
||||
func (a *DeKubernetesUserService) ListResources(ctx context.Context, req ListResourcesRequest) (ListResourcesResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result ListResourcesResult
|
||||
)
|
||||
|
||||
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/kubernetesUser/listResources"
|
||||
|
||||
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, "", "")
|
||||
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 ListResourcesResultWithError
|
||||
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 UpdateRequest struct {
|
||||
// user id
|
||||
//
|
||||
// Required.
|
||||
ID int64 `json:"id" form:"id"`
|
||||
// user description
|
||||
//
|
||||
// Required.
|
||||
Description string `json:"description" form:"description"`
|
||||
// clusterId
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// user rights settings
|
||||
//
|
||||
// Required.
|
||||
Settings string `json:"settings" form:"settings"`
|
||||
// delete user kubeconfig
|
||||
DeleteKubeConfig bool `json:"deleteKubeconfig" form:"deleteKubeconfig"`
|
||||
}
|
||||
|
||||
// Upgrade kubernetes user server for cluster
|
||||
func (a *DeKubernetesUserService) Update(ctx context.Context, req UpdateRequest) (UpdateUserResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result UpdateUserResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "id")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Description) {
|
||||
missingRequiredParams = append(missingRequiredParams, "description")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Settings) {
|
||||
missingRequiredParams = append(missingRequiredParams, "settings")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/kubernetesUser/update"
|
||||
|
||||
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, "id", req.ID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "description", req.Description, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "settings", req.Settings, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "deleteKubeconfig", req.DeleteKubeConfig, "", "")
|
||||
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 UpdateUserResultWithError
|
||||
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_kubernetes_user
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeKubernetesUser *DeKubernetesUserService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeKubernetesUser = (*DeKubernetesUserService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+93
@@ -0,0 +1,93 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_kubernetes_user
|
||||
|
||||
type DeleteUserResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetUserResult struct {
|
||||
IsRightsOk bool `json:"isRightsOk,omitempty"`
|
||||
Record User `json:"record,omitempty"`
|
||||
}
|
||||
|
||||
type GetUserResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetUserResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListNamespacesResult struct {
|
||||
Namespaces []Namespace `json:"namespaces,omitempty"`
|
||||
}
|
||||
|
||||
type ListNamespacesResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListNamespacesResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListResourcesResult struct {
|
||||
Resources []Resource `json:"resources,omitempty"`
|
||||
}
|
||||
|
||||
type ListResourcesResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListResourcesResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListUsersResult struct {
|
||||
Records []User `json:"records,omitempty"`
|
||||
}
|
||||
|
||||
type ListUsersResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListUsersResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type Namespace struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type Resource struct {
|
||||
APIGroup string `json:"apiGroup,omitempty"`
|
||||
Kind string `json:"kind,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Namespaced bool `json:"namespaced,omitempty"`
|
||||
SingularName string `json:"singularName,omitempty"`
|
||||
Verbs []string `json:"verbs,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateUserResult struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateUserResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UpdateUserResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
// data encryption information
|
||||
Encrypted bool `json:"encrypted,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
KubeConfig string `json:"kubeconfig,omitempty"`
|
||||
Settings string `json:"settings,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
VersionCrypt string `json:"versionCrypt,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_kubernetes_user
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
@@ -0,0 +1,279 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_kyverno
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeKyvernoService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the kyverno is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
}
|
||||
|
||||
// Get kyverno by id
|
||||
func (a *DeKyvernoService) Describe(ctx context.Context, req DescribeRequest) (DescribeKyvernoResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeKyvernoResult
|
||||
)
|
||||
|
||||
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/kyverno/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, "", "")
|
||||
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 DescribeKyvernoResultWithError
|
||||
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"`
|
||||
// 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"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
}
|
||||
|
||||
// Install Kyverno
|
||||
func (a *DeKyvernoService) Install(ctx context.Context, req InstallRequest) (InstallKyvernoResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result InstallKyvernoResult
|
||||
)
|
||||
|
||||
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/kyverno/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, "appsRepositoryId", req.AppsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "chartsRepositoryId", req.ChartsRepositoryID, "", "")
|
||||
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 InstallKyvernoResultWithError
|
||||
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 the certmanager 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 Kyverno
|
||||
func (a *DeKyvernoService) Uninstall(ctx context.Context, req UninstallRequest) (UninstallKyvernoResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result UninstallKyvernoResult
|
||||
)
|
||||
|
||||
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/kyverno/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 UninstallKyvernoResultWithError
|
||||
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_kyverno
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeKyverno *DeKyvernoService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeKyverno = (*DeKyvernoService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_kyverno
|
||||
|
||||
type DescribeKyvernoResult struct {
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry KyvernoRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeKyvernoResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeKyvernoResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type InstallKyvernoResult struct {
|
||||
TaskID int64 `json:"taskId,omitempty"`
|
||||
}
|
||||
|
||||
type InstallKyvernoResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result InstallKyvernoResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type KyvernoRecord struct {
|
||||
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"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
|
||||
type UninstallKyvernoResult struct {
|
||||
TaskID int64 `json:"taskId,omitempty"`
|
||||
}
|
||||
|
||||
type UninstallKyvernoResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UninstallKyvernoResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_kyverno
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,896 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_kyverno_policy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeKyvernoPolicyService service
|
||||
|
||||
type ApplyRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// kyverno policy ID
|
||||
ID int64 `json:"id" form:"id"`
|
||||
// kyverno policy name
|
||||
PolicyName string `json:"policyName" form:"policyName"`
|
||||
}
|
||||
|
||||
// Apply existing kyverno policy for the cluster. If the `id` is not passed, the `policyName` is used. One of the parameters is required. Cannot be applied to template policies.
|
||||
func (a *DeKyvernoPolicyService) Apply(ctx context.Context, req ApplyRequest) (ApplyKyvernoPolicyResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result ApplyKyvernoPolicyResult
|
||||
)
|
||||
|
||||
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/kyverno/policy/apply"
|
||||
|
||||
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, "id", req.ID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "policyName", req.PolicyName, "", "")
|
||||
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 ApplyKyvernoPolicyResultWithError
|
||||
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 CompareRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
}
|
||||
|
||||
// Compare kyverno policy records in the cluster and database Policy comparison uses the kubectl.kubernetes.io/last-applied-configuration annotation (if present). Because kubectl patch does not update this annotation, we recommend modifying policies via DE or kubectl apply.
|
||||
func (a *DeKyvernoPolicyService) Compare(ctx context.Context, req CompareRequest) (CompareKyvernoPolicyResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CompareKyvernoPolicyResult
|
||||
)
|
||||
|
||||
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/kyverno/policy/compare"
|
||||
|
||||
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, "", "")
|
||||
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 CompareKyvernoPolicyResultWithError
|
||||
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 CreateRequest struct {
|
||||
// base64 encoded policy content in .yaml format
|
||||
//
|
||||
// Required.
|
||||
Policy string `json:"policy" form:"policy"`
|
||||
// policy template status. Template policies cannot be installed in a cluster
|
||||
//
|
||||
// Required.
|
||||
Template bool `json:"template" form:"template"`
|
||||
}
|
||||
|
||||
// Create new kyverno policy record for group
|
||||
func (a *DeKyvernoPolicyService) Create(ctx context.Context, req CreateRequest) (CreateKyvernoPolicyResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateKyvernoPolicyResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.Policy) {
|
||||
missingRequiredParams = append(missingRequiredParams, "policy")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Template) {
|
||||
missingRequiredParams = append(missingRequiredParams, "template")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/kyverno/policy/create"
|
||||
|
||||
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, "policy", req.Policy, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "template", req.Template, "", "")
|
||||
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 CreateKyvernoPolicyResultWithError
|
||||
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 DeleteRequest struct {
|
||||
// kyverno policy ID
|
||||
ID int64 `json:"id" form:"id"`
|
||||
// kyverno policy name
|
||||
PolicyName string `json:"policyName" form:"policyName"`
|
||||
// policy template status.
|
||||
Template bool `json:"template" form:"template"`
|
||||
}
|
||||
|
||||
// Delete kyverno policy record from group. If the `id` is not passed, the `policyName` and `template` is used. One of the parameters is required. The record is deleted only if the policy is not present in the clusters.
|
||||
func (a *DeKyvernoPolicyService) Delete(ctx context.Context, req DeleteRequest) (any, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result any
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/kyverno/policy/delete"
|
||||
|
||||
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, "id", req.ID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "policyName", req.PolicyName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "template", req.Template, "", "")
|
||||
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 DeleteKyvernoPolicyResultWithError
|
||||
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 GetRequest struct {
|
||||
// kyverno policy ID
|
||||
ID int64 `json:"id" form:"id"`
|
||||
// kyverno policy name
|
||||
PolicyName string `json:"policyName" form:"policyName"`
|
||||
// policy template status.
|
||||
Template bool `json:"template" form:"template"`
|
||||
}
|
||||
|
||||
// Get info about kyverno policy. If the `id` is not passed, the `policyName` and `template` is used. One of the parameters is required.
|
||||
func (a *DeKyvernoPolicyService) Get(ctx context.Context, req GetRequest) (GetKyvernoPolicyResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result GetKyvernoPolicyResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/kyverno/policy/get"
|
||||
|
||||
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, "id", req.ID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "policyName", req.PolicyName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "template", req.Template, "", "")
|
||||
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 GetKyvernoPolicyResultWithError
|
||||
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 ListRequest struct {
|
||||
// filter by cluster ID
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// filter by category of kyverno policy
|
||||
Category string `json:"category" form:"category"`
|
||||
// filter by severity of kyverno policy
|
||||
Severity string `json:"severity" form:"severity"`
|
||||
// filter by validation action of kyverno policy
|
||||
ValidationAction string `json:"validationAction" form:"validationAction"`
|
||||
// filter by type of kyverno policy
|
||||
Type_ string `json:"type" form:"type"`
|
||||
// template or not template policies
|
||||
Template bool `json:"template" form:"template"`
|
||||
// Limit number of policies to be shown in the result. If not set, all policies will be shown.
|
||||
Limit int64 `json:"limit" form:"limit"`
|
||||
// Select page of the result. If not set, the first page will be shown.
|
||||
Page int64 `json:"page" form:"page"`
|
||||
}
|
||||
|
||||
// Get list of kyverno policies
|
||||
func (a *DeKyvernoPolicyService) List(ctx context.Context, req ListRequest) (ListKyvernoPoliciesResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result ListKyvernoPoliciesResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/kyverno/policy/list"
|
||||
|
||||
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, "category", req.Category, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "severity", req.Severity, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "validationAction", req.ValidationAction, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "type", req.Type_, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "template", req.Template, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "limit", req.Limit, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "page", req.Page, "", "")
|
||||
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 ListKyvernoPoliciesResultWithError
|
||||
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 ResolveRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// policy name that has a mismatch in the cluster and database
|
||||
//
|
||||
// Required.
|
||||
PolicyConflictName string `json:"policyConflictName" form:"policyConflictName"`
|
||||
// policy name to be changed in the cluster
|
||||
//
|
||||
// Required.
|
||||
PolicyUpdatedName string `json:"policyUpdatedName" form:"policyUpdatedName"`
|
||||
}
|
||||
|
||||
// Resolve the conflict of two conflicting policies by changing the name of one in the cluster. Adds an entry to the database of the new policy. Cannot be applied to template policies. In this case, a copy of the conflict policy is created in the cluster with a new name. Then the old policy is removed from the cluster. After that, the new policy is saved to the database. ID of the old policy is removed from the cluster record. The record of the old policy in the group will not change Policy comparison uses the kubectl.kubernetes.io/last-applied-configuration annotation (if present). Because kubectl patch does not update this annotation, we recommend modifying policies via DE or kubectl apply.
|
||||
func (a *DeKyvernoPolicyService) Resolve(ctx context.Context, req ResolveRequest) (RestoreKyvernoPolicyResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result RestoreKyvernoPolicyResult
|
||||
)
|
||||
|
||||
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.PolicyConflictName) {
|
||||
missingRequiredParams = append(missingRequiredParams, "policyConflictName")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.PolicyUpdatedName) {
|
||||
missingRequiredParams = append(missingRequiredParams, "policyUpdatedName")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/kyverno/policy/resolve"
|
||||
|
||||
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, "policyConflictName", req.PolicyConflictName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "policyUpdatedName", req.PolicyUpdatedName, "", "")
|
||||
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 RestoreKyvernoPolicyResultWithError
|
||||
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 RestoreRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// policy name in the cluster
|
||||
//
|
||||
// Required.
|
||||
PolicyName string `json:"policyName" form:"policyName"`
|
||||
}
|
||||
|
||||
// Restore policy record from cluster to database Extracts the policy from the cluster, parses and writes the information to the database If a policy record with the same name already exists in the database for the given group and is not a template, the policy is imported from the database. (The id of this policy is added to the cluster record.) In this case, content conflicts may occur.
|
||||
func (a *DeKyvernoPolicyService) Restore(ctx context.Context, req RestoreRequest) (RestoreKyvernoPolicyResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result RestoreKyvernoPolicyResult
|
||||
)
|
||||
|
||||
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.PolicyName) {
|
||||
missingRequiredParams = append(missingRequiredParams, "policyName")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/kyverno/policy/restore"
|
||||
|
||||
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, "policyName", req.PolicyName, "", "")
|
||||
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 RestoreKyvernoPolicyResultWithError
|
||||
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 StopRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// kyverno policy ID
|
||||
ID int64 `json:"id" form:"id"`
|
||||
// kyverno policy name
|
||||
PolicyName string `json:"policyName" form:"policyName"`
|
||||
}
|
||||
|
||||
// Stop kyverno policy in specified cluster. If the `id` is not passed, the `policyName` is used. One of the parameters is required. Cannot be applied to template policies.
|
||||
func (a *DeKyvernoPolicyService) Stop(ctx context.Context, req StopRequest) (StopKyvernoPolicyResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result StopKyvernoPolicyResult
|
||||
)
|
||||
|
||||
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/kyverno/policy/stop"
|
||||
|
||||
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, "id", req.ID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "policyName", req.PolicyName, "", "")
|
||||
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 StopKyvernoPolicyResultWithError
|
||||
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 UpdateRequest struct {
|
||||
// kyverno policy ID
|
||||
//
|
||||
// Required.
|
||||
ID int64 `json:"id" form:"id"`
|
||||
// policy template status. Template policies cannot be installed in a cluster
|
||||
//
|
||||
// Required.
|
||||
Template bool `json:"template" form:"template"`
|
||||
// base64 encoded template policy content in .yaml format
|
||||
Policy string `json:"policy" form:"policy"`
|
||||
}
|
||||
|
||||
// Update kyverno policy in the group. You can only edit the content of template policies.
|
||||
func (a *DeKyvernoPolicyService) Update(ctx context.Context, req UpdateRequest) (UpdateKyvernoPolicyResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result UpdateKyvernoPolicyResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "id")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Template) {
|
||||
missingRequiredParams = append(missingRequiredParams, "template")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/kyverno/policy/update"
|
||||
|
||||
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, "id", req.ID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "policy", req.Policy, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "template", req.Template, "", "")
|
||||
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 UpdateKyvernoPolicyResultWithError
|
||||
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_kyverno_policy
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeKyvernoPolicy *DeKyvernoPolicyService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeKyvernoPolicy = (*DeKyvernoPolicyService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+131
@@ -0,0 +1,131 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_kyverno_policy
|
||||
|
||||
type ApplyKyvernoPolicyResult struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
type ApplyKyvernoPolicyResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ApplyKyvernoPolicyResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type CompareKyvernoPolicyResult struct {
|
||||
MatchedCount int64 `json:"matchedCount,omitempty"`
|
||||
Mismatched []MismatchedPolicyResult `json:"mismatched,omitempty"`
|
||||
MissingInCluster []string `json:"missingInCluster,omitempty"`
|
||||
MissingInDatabase []string `json:"missingInDatabase,omitempty"`
|
||||
TotalClusterPolicies int64 `json:"totalClusterPolicies,omitempty"`
|
||||
TotalDatabasePolicies int64 `json:"totalDatabasePolicies,omitempty"`
|
||||
}
|
||||
|
||||
type CompareKyvernoPolicyResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result CompareKyvernoPolicyResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type CreateKyvernoPolicyResult struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
type CreateKyvernoPolicyResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result CreateKyvernoPolicyResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type DeleteKyvernoPolicyResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetKyvernoPolicyResult struct {
|
||||
Record KyvernoPolicy `json:"record,omitempty"`
|
||||
}
|
||||
|
||||
type GetKyvernoPolicyResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetKyvernoPolicyResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type KyvernoPolicy struct {
|
||||
Background bool `json:"background,omitempty"`
|
||||
Category string `json:"category,omitempty"`
|
||||
ClusterIDs []int64 `json:"clusterIds,omitempty"`
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
// generated id
|
||||
ID int64 `json:"id,omitempty"`
|
||||
ImportFrom string `json:"importFrom,omitempty"`
|
||||
// main cluster policy information
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
// user provided or user dependent information
|
||||
Policy string `json:"policy,omitempty"`
|
||||
Rules []Rule `json:"rules,omitempty"`
|
||||
Severity string `json:"severity,omitempty"`
|
||||
Template bool `json:"template,omitempty"`
|
||||
UpdatedDate string `json:"updatedDate,omitempty"`
|
||||
ValidateAction string `json:"validateAction,omitempty"`
|
||||
}
|
||||
|
||||
type ListKyvernoPoliciesResult struct {
|
||||
Records []KyvernoPolicy `json:"records,omitempty"`
|
||||
Total int64 `json:"total,omitempty"`
|
||||
}
|
||||
|
||||
type ListKyvernoPoliciesResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListKyvernoPoliciesResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type MismatchedPolicyResult struct {
|
||||
ClusterPolicyContent string `json:"clusterPolicyContent,omitempty"`
|
||||
DatabasePolicyContent string `json:"databasePolicyContent,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type RestoreKyvernoPolicyResult struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
type RestoreKyvernoPolicyResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result RestoreKyvernoPolicyResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type StopKyvernoPolicyResult struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
type StopKyvernoPolicyResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result StopKyvernoPolicyResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateKyvernoPolicyResult struct {
|
||||
Record KyvernoPolicy `json:"record,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateKyvernoPolicyResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UpdateKyvernoPolicyResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_kyverno_policy
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type Rule = shared.Rule
|
||||
@@ -0,0 +1,100 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_logwatcher
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeLogWatcherService service
|
||||
|
||||
type PackagesUpgradeLogWatcherRequest struct {
|
||||
// Cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// Operation system package repository
|
||||
PackageRepository int64 `json:"packageRepository" form:"packageRepository"`
|
||||
}
|
||||
|
||||
// Upgrade Logwatcher
|
||||
func (a *DeLogWatcherService) PackagesUpgradeLogWatcher(ctx context.Context, req PackagesUpgradeLogWatcherRequest) (UpgradeLogWatcherResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result UpgradeLogWatcherResult
|
||||
)
|
||||
|
||||
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/packages/upgradeLogwatcher"
|
||||
|
||||
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, "packageRepository", req.PackageRepository, "", "")
|
||||
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 UpgradeLogWatcherResultWithError
|
||||
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_logwatcher
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeLogWatcher *DeLogWatcherService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeLogWatcher = (*DeLogWatcherService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_logwatcher
|
||||
|
||||
type UpgradeLogWatcherResult struct {
|
||||
TaskID int64 `json:"taskId,omitempty"`
|
||||
}
|
||||
|
||||
type UpgradeLogWatcherResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UpgradeLogWatcherResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,315 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_longhorn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/de-golang-sdk/core"
|
||||
"repository.basistech.ru/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeLonghornService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the longhorn is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s longhorn pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get longhorn by id
|
||||
func (a *DeLonghornService) Describe(ctx context.Context, req DescribeRequest) (DescribeLonghornResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeLonghornResult
|
||||
)
|
||||
|
||||
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/longhorn/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 DescribeLonghornResultWithError
|
||||
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"`
|
||||
// username
|
||||
//
|
||||
// Required.
|
||||
Username string `json:"username" form:"username"`
|
||||
// password
|
||||
//
|
||||
// Required.
|
||||
Password string `json:"password" form:"password"`
|
||||
// hostname for longhorn
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// 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"`
|
||||
// class replica count
|
||||
ClassReplicaCount int64 `json:"classReplicaCount" form:"classReplicaCount"`
|
||||
// hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// worker group name
|
||||
WorkerGroupName string `json:"workerGroupName" form:"workerGroupName"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
}
|
||||
|
||||
// Install longhorn in cluster
|
||||
func (a *DeLonghornService) 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.Username) {
|
||||
missingRequiredParams = append(missingRequiredParams, "username")
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/longhorn/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, "username", req.Username, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "password", req.Password, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "appsRepositoryId", req.AppsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "chartsRepositoryId", req.ChartsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "classReplicaCount", req.ClassReplicaCount, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
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 the longhorn 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 longhorn from cluster
|
||||
func (a *DeLonghornService) 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/longhorn/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
|
||||
}
|
||||
Loaded 100 of 292 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user