From 90340d04d8281ffac6ab72735a9d1c92745b8066 Mon Sep 17 00:00:00 2001 From: zhangyangyu Date: Fri, 30 Aug 2024 10:52:28 +0800 Subject: [PATCH] fmt --- .../serverless/branch/api_branch_service.go | 185 +++++++++--------- .../v1beta1/serverless/branch/client.go | 153 +++++++-------- .../serverless/branch/configuration.go | 17 +- .../v1beta1/serverless/branch/model_any.go | 6 +- .../v1beta1/serverless/branch/model_branch.go | 20 +- .../branch/model_branch_endpoints.go | 4 +- .../branch/model_branch_endpoints_private.go | 10 +- .../model_branch_endpoints_private_aws.go | 4 +- .../model_branch_endpoints_private_gcp.go | 4 +- .../branch/model_branch_endpoints_public.go | 10 +- .../serverless/branch/model_branch_state.go | 7 +- .../serverless/branch/model_branch_usage.go | 4 +- .../serverless/branch/model_branch_view.go | 3 +- .../branch/model_list_branches_response.go | 6 +- .../v1beta1/serverless/branch/model_status.go | 8 +- .../v1beta1/serverless/branch/utils.go | 2 +- 16 files changed, 212 insertions(+), 231 deletions(-) diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/api_branch_service.go b/pkg/tidbcloud/v1beta1/serverless/branch/api_branch_service.go index 587ae53b..2ded3b4b 100644 --- a/pkg/tidbcloud/v1beta1/serverless/branch/api_branch_service.go +++ b/pkg/tidbcloud/v1beta1/serverless/branch/api_branch_service.go @@ -19,15 +19,14 @@ import ( "strings" ) - // BranchServiceAPIService BranchServiceAPI service type BranchServiceAPIService service type ApiBranchServiceCreateBranchRequest struct { - ctx context.Context + ctx context.Context ApiService *BranchServiceAPIService - clusterId string - branch *Branch + clusterId string + branch *Branch } // Required. The resource being created @@ -43,26 +42,27 @@ func (r ApiBranchServiceCreateBranchRequest) Execute() (*Branch, *http.Response, /* BranchServiceCreateBranch Creates a branch. - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param clusterId Required. The cluster ID of the branch - @return ApiBranchServiceCreateBranchRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param clusterId Required. The cluster ID of the branch + @return ApiBranchServiceCreateBranchRequest */ func (a *BranchServiceAPIService) BranchServiceCreateBranch(ctx context.Context, clusterId string) ApiBranchServiceCreateBranchRequest { return ApiBranchServiceCreateBranchRequest{ ApiService: a, - ctx: ctx, - clusterId: clusterId, + ctx: ctx, + clusterId: clusterId, } } // Execute executes the request -// @return Branch +// +// @return Branch func (a *BranchServiceAPIService) BranchServiceCreateBranchExecute(r ApiBranchServiceCreateBranchRequest) (*Branch, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *Branch + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Branch ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BranchServiceAPIService.BranchServiceCreateBranch") @@ -121,14 +121,14 @@ func (a *BranchServiceAPIService) BranchServiceCreateBranchExecute(r ApiBranchSe body: localVarBody, error: localVarHTTPResponse.Status, } - var v Status - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v return localVarReturnValue, localVarHTTPResponse, newErr } @@ -145,10 +145,10 @@ func (a *BranchServiceAPIService) BranchServiceCreateBranchExecute(r ApiBranchSe } type ApiBranchServiceDeleteBranchRequest struct { - ctx context.Context + ctx context.Context ApiService *BranchServiceAPIService - clusterId string - branchId string + clusterId string + branchId string } func (r ApiBranchServiceDeleteBranchRequest) Execute() (*Branch, *http.Response, error) { @@ -158,28 +158,29 @@ func (r ApiBranchServiceDeleteBranchRequest) Execute() (*Branch, *http.Response, /* BranchServiceDeleteBranch Deletes a branch. - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param clusterId Required. The cluster ID of the branch - @param branchId Required. The branch ID - @return ApiBranchServiceDeleteBranchRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param clusterId Required. The cluster ID of the branch + @param branchId Required. The branch ID + @return ApiBranchServiceDeleteBranchRequest */ func (a *BranchServiceAPIService) BranchServiceDeleteBranch(ctx context.Context, clusterId string, branchId string) ApiBranchServiceDeleteBranchRequest { return ApiBranchServiceDeleteBranchRequest{ ApiService: a, - ctx: ctx, - clusterId: clusterId, - branchId: branchId, + ctx: ctx, + clusterId: clusterId, + branchId: branchId, } } // Execute executes the request -// @return Branch +// +// @return Branch func (a *BranchServiceAPIService) BranchServiceDeleteBranchExecute(r ApiBranchServiceDeleteBranchRequest) (*Branch, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodDelete - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *Branch + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Branch ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BranchServiceAPIService.BranchServiceDeleteBranch") @@ -234,14 +235,14 @@ func (a *BranchServiceAPIService) BranchServiceDeleteBranchExecute(r ApiBranchSe body: localVarBody, error: localVarHTTPResponse.Status, } - var v Status - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v return localVarReturnValue, localVarHTTPResponse, newErr } @@ -258,11 +259,11 @@ func (a *BranchServiceAPIService) BranchServiceDeleteBranchExecute(r ApiBranchSe } type ApiBranchServiceGetBranchRequest struct { - ctx context.Context + ctx context.Context ApiService *BranchServiceAPIService - clusterId string - branchId string - view *string + clusterId string + branchId string + view *string } // Optional. The view of the branch to return. Defaults to FULL - BASIC: Basic response contains basic information for a branch. - FULL: FULL response contains all detailed information for a branch. @@ -278,28 +279,29 @@ func (r ApiBranchServiceGetBranchRequest) Execute() (*Branch, *http.Response, er /* BranchServiceGetBranch Gets information about a branch. - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param clusterId Required. The cluster ID of the branch - @param branchId Required. The branch ID - @return ApiBranchServiceGetBranchRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param clusterId Required. The cluster ID of the branch + @param branchId Required. The branch ID + @return ApiBranchServiceGetBranchRequest */ func (a *BranchServiceAPIService) BranchServiceGetBranch(ctx context.Context, clusterId string, branchId string) ApiBranchServiceGetBranchRequest { return ApiBranchServiceGetBranchRequest{ ApiService: a, - ctx: ctx, - clusterId: clusterId, - branchId: branchId, + ctx: ctx, + clusterId: clusterId, + branchId: branchId, } } // Execute executes the request -// @return Branch +// +// @return Branch func (a *BranchServiceAPIService) BranchServiceGetBranchExecute(r ApiBranchServiceGetBranchRequest) (*Branch, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *Branch + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Branch ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BranchServiceAPIService.BranchServiceGetBranch") @@ -357,14 +359,14 @@ func (a *BranchServiceAPIService) BranchServiceGetBranchExecute(r ApiBranchServi body: localVarBody, error: localVarHTTPResponse.Status, } - var v Status - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v return localVarReturnValue, localVarHTTPResponse, newErr } @@ -381,11 +383,11 @@ func (a *BranchServiceAPIService) BranchServiceGetBranchExecute(r ApiBranchServi } type ApiBranchServiceListBranchesRequest struct { - ctx context.Context + ctx context.Context ApiService *BranchServiceAPIService - clusterId string - pageSize *int32 - pageToken *string + clusterId string + pageSize *int32 + pageToken *string } // Optional. Requested page size. Server may return fewer items than requested. If unspecified, server will pick an appropriate default. @@ -407,26 +409,27 @@ func (r ApiBranchServiceListBranchesRequest) Execute() (*ListBranchesResponse, * /* BranchServiceListBranches Lists information about branches. - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param clusterId Required. The ID of the project to which the clusters belong. - @return ApiBranchServiceListBranchesRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param clusterId Required. The ID of the project to which the clusters belong. + @return ApiBranchServiceListBranchesRequest */ func (a *BranchServiceAPIService) BranchServiceListBranches(ctx context.Context, clusterId string) ApiBranchServiceListBranchesRequest { return ApiBranchServiceListBranchesRequest{ ApiService: a, - ctx: ctx, - clusterId: clusterId, + ctx: ctx, + clusterId: clusterId, } } // Execute executes the request -// @return ListBranchesResponse +// +// @return ListBranchesResponse func (a *BranchServiceAPIService) BranchServiceListBranchesExecute(r ApiBranchServiceListBranchesRequest) (*ListBranchesResponse, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ListBranchesResponse + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ListBranchesResponse ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BranchServiceAPIService.BranchServiceListBranches") @@ -486,14 +489,14 @@ func (a *BranchServiceAPIService) BranchServiceListBranchesExecute(r ApiBranchSe body: localVarBody, error: localVarHTTPResponse.Status, } - var v Status - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v return localVarReturnValue, localVarHTTPResponse, newErr } diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/client.go b/pkg/tidbcloud/v1beta1/serverless/branch/client.go index 1844e5e9..bb2ec4ed 100644 --- a/pkg/tidbcloud/v1beta1/serverless/branch/client.go +++ b/pkg/tidbcloud/v1beta1/serverless/branch/client.go @@ -31,14 +31,13 @@ import ( "strings" "time" "unicode/utf8" - ) var ( JsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?json)`) XmlCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?xml)`) queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`) - queryDescape = strings.NewReplacer( "%5B", "[", "%5D", "]" ) + queryDescape = strings.NewReplacer("%5B", "[", "%5D", "]") ) // APIClient manages communication with the TiDB Cloud Serverless Open API API vv1beta1 @@ -125,15 +124,15 @@ func typeCheckParameter(obj interface{}, expected string, name string) error { return nil } -func parameterValueToString( obj interface{}, key string ) string { +func parameterValueToString(obj interface{}, key string) string { if reflect.TypeOf(obj).Kind() != reflect.Ptr { return fmt.Sprintf("%v", obj) } - var param,ok = obj.(MappedNullable) + var param, ok = obj.(MappedNullable) if !ok { return "" } - dataMap,err := param.ToMap() + dataMap, err := param.ToMap() if err != nil { return "" } @@ -149,85 +148,85 @@ func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix stri value = "null" } else { switch v.Kind() { - case reflect.Invalid: - value = "invalid" + case reflect.Invalid: + value = "invalid" - case reflect.Struct: - if t,ok := obj.(MappedNullable); ok { - dataMap,err := t.ToMap() - if err != nil { - return - } - parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, dataMap, style, collectionType) - return - } - if t, ok := obj.(time.Time); ok { - parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339Nano), style, collectionType) - return - } - value = v.Type().String() + " value" - case reflect.Slice: - var indValue = reflect.ValueOf(obj) - if indValue == reflect.ValueOf(nil) { + case reflect.Struct: + if t, ok := obj.(MappedNullable); ok { + dataMap, err := t.ToMap() + if err != nil { return } - var lenIndValue = indValue.Len() - for i:=0;i