Skip to content

Commit

Permalink
chore: merge cloud main
Browse files Browse the repository at this point in the history
  • Loading branch information
ldming committed Nov 14, 2024
1 parent 9854cc7 commit 111459e
Show file tree
Hide file tree
Showing 40 changed files with 2,203 additions and 989 deletions.
26 changes: 17 additions & 9 deletions .generator/schemas/adminapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16485,35 +16485,35 @@ components:
status:
description: Backup status
type: string
backupNum:
num:
description: Number of backups for each status
format: int64
type: integer
type: object
backupStatsEngine:
description: Totalsize and number of backups for the engine
properties:
engineName:
engine:
description: Engine name
type: string
backupSize:
size:
description: totalsize of backups for each engine, A string with capacity units in the form of "1Gi", "1Mi", "1Ki".
type: string
backupNum:
num:
description: The number of backups for each engine
format: int64
type: integer
type: object
backupStatsType:
description: Totalsize and number of backups for the backup type
properties:
backupType:
type:
description: backup type
type: string
backupSize:
size:
description: totalsize of backups for each engine, A string with capacity units in the form of "1Gi", "1Mi", "1Ki".
type: string
backupNum:
num:
description: The number of backups for each engine
format: int64
type: integer
Expand Down Expand Up @@ -16553,6 +16553,9 @@ components:
items:
$ref: '#/components/schemas/backupRepoStats'
type: array
current:
description: current backup repo stats
$ref: '#/components/schemas/backupRepoStats'
pageResult:
$ref: '#/components/schemas/pageResult'
required:
Expand Down Expand Up @@ -16797,15 +16800,20 @@ components:
description: Backup statistic info
properties:
backupStatsStatus:
description: Number of backups for each defferent status
description: Number of backups for each different status
items:
$ref: '#/components/schemas/backupStatsStatus'
type: array
backupStatsEngine:
description: Totalsize and number of backups for each engine
description: TotalSize and number of backups for each engine
items:
$ref: '#/components/schemas/backupStatsEngine'
type: array
backupStatsType:
description: TotalSize and number of backups for each type
items:
$ref: '#/components/schemas/backupStatsType'
type: array
latestBackupTime:
description: create time of the latest backup
type: string
Expand Down
31 changes: 25 additions & 6 deletions .generator/schemas/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11847,21 +11847,35 @@ components:
status:
description: Backup status
type: string
backupNum:
num:
description: Number of backups for each status
format: int64
type: integer
type: object
backupStatsEngine:
description: Totalsize and number of backups for the engine
properties:
engineName:
engine:
description: Engine name
type: string
backupSize:
size:
description: totalsize of backups for each engine, A string with capacity units in the form of "1Gi", "1Mi", "1Ki".
type: string
backupNum:
num:
description: The number of backups for each engine
format: int64
type: integer
type: object
backupStatsType:
description: Totalsize and number of backups for the backup type
properties:
type:
description: backup type
type: string
size:
description: totalsize of backups for each engine, A string with capacity units in the form of "1Gi", "1Mi", "1Ki".
type: string
num:
description: The number of backups for each engine
format: int64
type: integer
Expand All @@ -11870,15 +11884,20 @@ components:
description: Backup statistic info
properties:
backupStatsStatus:
description: Number of backups for each defferent status
description: Number of backups for each different status
items:
$ref: '#/components/schemas/backupStatsStatus'
type: array
backupStatsEngine:
description: Totalsize and number of backups for each engine
description: TotalSize and number of backups for each engine
items:
$ref: '#/components/schemas/backupStatsEngine'
type: array
backupStatsType:
description: TotalSize and number of backups for each type
items:
$ref: '#/components/schemas/backupStatsType'
type: array
latestBackupTime:
description: create time of the latest backup
type: string
Expand Down
225 changes: 225 additions & 0 deletions api/kbcloud/admin/api_project.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
// This product includes software developed at ApeCloud (https://www.apecloud.com/).
// Copyright 2022-Present ApeCloud Co., Ltd

package admin

import (
_context "context"
_nethttp "net/http"
_neturl "net/url"
"strings"

"github.com/apecloud/kb-cloud-client-go/api/common"
)

// ProjectApi service type
type ProjectApi common.Service

// CreateProject Create a project in an environment.
func (a *ProjectApi) CreateProject(ctx _context.Context, environmentName string, body ProjectCreate) (Project, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodPost
localVarPostBody interface{}
localVarReturnValue Project
)

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, ".ProjectApi.CreateProject")
if err != nil {
return localVarReturnValue, nil, common.GenericOpenAPIError{ErrorMessage: err.Error()}
}

localVarPath := localBasePath + "/admin/v1/environments/{environmentName}/projects"
localVarPath = strings.Replace(localVarPath, "{"+"environmentName"+"}", _neturl.PathEscape(common.ParameterToString(environmentName, "")), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}
localVarHeaderParams["Content-Type"] = "application/json"
localVarHeaderParams["Accept"] = "application/json"

// body params
localVarPostBody = &body
common.SetAuthKeys(
ctx,
&localVarHeaderParams,
[2]string{"BearerToken", "authorization"},
)
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
if err != nil {
return localVarReturnValue, nil, err
}

localVarHTTPResponse, err := a.Client.CallAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}

localVarBody, err := common.ReadBody(localVarHTTPResponse)
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}

if localVarHTTPResponse.StatusCode >= 300 {
newErr := common.GenericOpenAPIError{
ErrorBody: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 {
var v APIErrorResponse
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.ErrorModel = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}

err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := common.GenericOpenAPIError{
ErrorBody: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}

return localVarReturnValue, localVarHTTPResponse, nil
}

// DeleteProject Delete a project in an environment.
func (a *ProjectApi) DeleteProject(ctx _context.Context, environmentName string, projectName string) (*_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodDelete
localVarPostBody interface{}
)

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, ".ProjectApi.DeleteProject")
if err != nil {
return nil, common.GenericOpenAPIError{ErrorMessage: err.Error()}
}

localVarPath := localBasePath + "/admin/v1/environments/{environmentName}/projects/{projectName}"
localVarPath = strings.Replace(localVarPath, "{"+"environmentName"+"}", _neturl.PathEscape(common.ParameterToString(environmentName, "")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"projectName"+"}", _neturl.PathEscape(common.ParameterToString(projectName, "")), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}
localVarHeaderParams["Accept"] = "application/json"

common.SetAuthKeys(
ctx,
&localVarHeaderParams,
[2]string{"BearerToken", "authorization"},
)
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
if err != nil {
return nil, err
}

localVarHTTPResponse, err := a.Client.CallAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}

localVarBody, err := common.ReadBody(localVarHTTPResponse)
if err != nil {
return localVarHTTPResponse, err
}

if localVarHTTPResponse.StatusCode >= 300 {
newErr := common.GenericOpenAPIError{
ErrorBody: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 {
var v APIErrorResponse
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
return localVarHTTPResponse, newErr
}
newErr.ErrorModel = v
}
return localVarHTTPResponse, newErr
}

return localVarHTTPResponse, nil
}

// ListProjects List projects in an environment.
func (a *ProjectApi) ListProjects(ctx _context.Context, environmentName string) (ProjectList, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodGet
localVarPostBody interface{}
localVarReturnValue ProjectList
)

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, ".ProjectApi.ListProjects")
if err != nil {
return localVarReturnValue, nil, common.GenericOpenAPIError{ErrorMessage: err.Error()}
}

localVarPath := localBasePath + "/admin/v1/environments/{environmentName}/projects"
localVarPath = strings.Replace(localVarPath, "{"+"environmentName"+"}", _neturl.PathEscape(common.ParameterToString(environmentName, "")), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}
localVarHeaderParams["Accept"] = "application/json"

common.SetAuthKeys(
ctx,
&localVarHeaderParams,
[2]string{"BearerToken", "authorization"},
)
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
if err != nil {
return localVarReturnValue, nil, err
}

localVarHTTPResponse, err := a.Client.CallAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}

localVarBody, err := common.ReadBody(localVarHTTPResponse)
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}

if localVarHTTPResponse.StatusCode >= 300 {
newErr := common.GenericOpenAPIError{
ErrorBody: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 {
var v APIErrorResponse
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.ErrorModel = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}

err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := common.GenericOpenAPIError{
ErrorBody: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}

return localVarReturnValue, localVarHTTPResponse, nil
}

// NewProjectApi Returns NewProjectApi.
func NewProjectApi(client *common.APIClient) *ProjectApi {
return &ProjectApi{
Client: client,
}
}
Loading

0 comments on commit 111459e

Please sign in to comment.