From de83e4daa6e91bea8bd6ab0b4e565358547b823f Mon Sep 17 00:00:00 2001 From: zhangyangyu Date: Fri, 30 Aug 2024 01:20:41 +0800 Subject: [PATCH 1/4] refactor --- Makefile | 3 +- internal/cli/serverless/branch/create.go | 55 +- internal/cli/serverless/branch/create_test.go | 25 +- internal/cli/serverless/branch/delete.go | 5 +- internal/cli/serverless/branch/delete_test.go | 6 +- internal/cli/serverless/branch/describe.go | 7 +- .../cli/serverless/branch/describe_test.go | 16 +- internal/cli/serverless/branch/list.go | 19 +- internal/cli/serverless/branch/list_test.go | 48 +- internal/cli/serverless/branch/shell.go | 12 +- internal/mock/api_client.go | 184 ++--- internal/service/cloud/api_client.go | 91 ++- internal/service/cloud/logic.go | 30 +- .../v1beta1/branch/branch.swagger.json | 477 ------------ .../branch_service/branch_service_client.go | 219 ------ ...branch_service_create_branch_parameters.go | 175 ----- .../branch_service_create_branch_responses.go | 187 ----- ...branch_service_delete_branch_parameters.go | 173 ----- .../branch_service_delete_branch_responses.go | 187 ----- .../branch_service_get_branch_parameters.go | 211 ------ .../branch_service_get_branch_responses.go | 187 ----- ...branch_service_list_branches_parameters.go | 223 ------ .../branch_service_list_branches_responses.go | 187 ----- .../client/tidbcloud_serverless_client.go | 112 --- .../v1beta1/branch/models/branch_endpoints.go | 160 ---- .../v1beta1/branch/models/branch_state.go | 89 --- .../v1beta1/branch/models/branch_usage.go | 105 --- .../branch/models/endpoints_private.go | 197 ----- .../v1beta1/branch/models/endpoints_public.go | 91 --- .../v1beta1/branch/models/private_a_w_s.go | 89 --- .../v1beta1/branch/models/private_g_c_p.go | 71 -- .../v1beta1/branch/models/protobuf_any.go | 127 ---- .../v1beta1/branch/models/rpc_status.go | 127 ---- .../v1beta1/branch/models/v1beta1_branch.go | 409 ---------- .../branch/models/v1beta1_branch_state.go | 90 --- .../branch/models/v1beta1_branch_view.go | 82 --- .../models/v1beta1_list_branches_response.go | 127 ---- .../v1beta1/serverless/branch.swagger.json | 501 +++++++++++++ .../v1beta1/serverless/branch/.gitignore | 24 + .../branch/.openapi-generator-ignore | 23 + .../branch/.openapi-generator/FILES | 23 + .../branch/.openapi-generator/VERSION | 1 + .../v1beta1/serverless/branch/.travis.yml | 8 + .../v1beta1/serverless/branch/README.md | 127 ++++ .../serverless/branch/api/openapi.yaml | 456 ++++++++++++ .../serverless/branch/api_branch_service.go | 510 +++++++++++++ .../v1beta1/serverless/branch/client.go | 652 ++++++++++++++++ .../serverless/branch/configuration.go | 215 ++++++ .../v1beta1/serverless/branch/git_push.sh | 57 ++ .../v1beta1/serverless/branch/model_any.go | 155 ++++ .../v1beta1/serverless/branch/model_branch.go | 696 ++++++++++++++++++ .../branch/model_branch_endpoints.go | 164 +++++ .../branch/model_branch_endpoints_private.go | 236 ++++++ .../model_branch_endpoints_private_aws.go | 164 +++++ .../model_branch_endpoints_private_gcp.go | 127 ++++ .../branch/model_branch_endpoints_public.go | 198 +++++ .../serverless/branch/model_branch_state.go | 115 +++ .../serverless/branch/model_branch_usage.go | 201 +++++ .../serverless/branch/model_branch_view.go | 111 +++ .../branch/model_list_branches_response.go | 199 +++++ .../v1beta1/serverless/branch/model_status.go | 198 +++++ .../v1beta1/serverless/branch/response.go | 47 ++ .../v1beta1/serverless/branch/utils.go | 361 +++++++++ 63 files changed, 5786 insertions(+), 4386 deletions(-) delete mode 100644 pkg/tidbcloud/v1beta1/branch/branch.swagger.json delete mode 100644 pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_client.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_create_branch_parameters.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_create_branch_responses.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_delete_branch_parameters.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_delete_branch_responses.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_get_branch_parameters.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_get_branch_responses.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_list_branches_parameters.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_list_branches_responses.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/client/tidbcloud_serverless_client.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/models/branch_endpoints.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/models/branch_state.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/models/branch_usage.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/models/endpoints_private.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/models/endpoints_public.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/models/private_a_w_s.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/models/private_g_c_p.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/models/protobuf_any.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/models/rpc_status.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/models/v1beta1_branch.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/models/v1beta1_branch_state.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/models/v1beta1_branch_view.go delete mode 100644 pkg/tidbcloud/v1beta1/branch/models/v1beta1_list_branches_response.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch.swagger.json create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/.gitignore create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/.openapi-generator-ignore create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/.openapi-generator/FILES create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/.openapi-generator/VERSION create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/.travis.yml create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/README.md create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/api/openapi.yaml create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/api_branch_service.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/client.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/configuration.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/git_push.sh create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/model_any.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/model_branch.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints_private.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints_private_aws.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints_private_gcp.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints_public.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/model_branch_state.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/model_branch_usage.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/model_branch_view.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/model_list_branches_response.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/model_status.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/response.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/branch/utils.go diff --git a/Makefile b/Makefile index d491aa5e..08b6fa52 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ addcopy: ## Add copyright to all files generate-v1beta1-client: install-openapi-generator## Generate v1beta1 client go install github.com/go-swagger/go-swagger/cmd/swagger@latest @echo "==> Generating serverless branch client" - swagger generate client -f pkg/tidbcloud/v1beta1/branch/branch.swagger.json -A tidbcloud-serverless -t pkg/tidbcloud/v1beta1/branch + cd tools/openapi-generator && npx openapi-generator-cli generate --additional-properties=withGoMod=false,enumClassPrefix=true --global-property=apiTests=false,apiDocs=false,modelDocs=fasle,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/branch.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/branch --package-name branch @echo "==> Generating serverless client" swagger generate client -f pkg/tidbcloud/v1beta1/serverless/serverless.swagger.json -A tidbcloud-serverless -t pkg/tidbcloud/v1beta1/serverless @echo "==> Generating serverless br client" @@ -55,7 +55,6 @@ generate-v1beta1-client: install-openapi-generator## Generate v1beta1 client @echo "==> Generating serverless import client" swagger generate client -f pkg/tidbcloud/v1beta1/serverless_import/import.swagger.json -A tidbcloud-serverless -t pkg/tidbcloud/v1beta1/serverless_import @echo "==> Generating serverless export client" - rm -rf pkg/tidbcloud/v1beta1/serverless/export cd tools/openapi-generator && npx openapi-generator-cli generate --additional-properties=withGoMod=false,enumClassPrefix=true --global-property=apiTests=false,apiDocs=false,modelDocs=fasle,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/export.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/export --package-name export @echo "==> Generating iam client" swagger generate client -f pkg/tidbcloud/v1beta1/iam/iam.swagger.json -A tidbcloud-serverless -t pkg/tidbcloud/v1beta1/iam diff --git a/internal/cli/serverless/branch/create.go b/internal/cli/serverless/branch/create.go index c43159fe..791589a9 100644 --- a/internal/cli/serverless/branch/create.go +++ b/internal/cli/serverless/branch/create.go @@ -25,13 +25,11 @@ import ( "tidbcloud-cli/internal/service/cloud" "tidbcloud-cli/internal/ui" "tidbcloud-cli/internal/util" - branchApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/client/branch_service" - branchModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/branch" "github.com/charmbracelet/bubbles/textinput" tea "github.com/charmbracelet/bubbletea" "github.com/fatih/color" - "github.com/go-openapi/strfmt" "github.com/juju/errors" "github.com/spf13/cobra" ) @@ -119,7 +117,7 @@ func CreateCmd(h *internal.Helper) *cobra.Command { var clusterId string var parentID string var parentTimestampStr string - var parentTimestamp *strfmt.DateTime + var parentTimestamp time.Time if opts.interactive { if !h.IOStreams.CanPrompt { return errors.New("The terminal doesn't support interactive mode, please use non-interactive mode") @@ -173,27 +171,26 @@ func CreateCmd(h *internal.Helper) *cobra.Command { } if len(parentTimestampStr) != 0 { - t, err := time.Parse(time.RFC3339, parentTimestampStr) + parentTimestamp, err = time.Parse(time.RFC3339, parentTimestampStr) if err != nil { return errors.New("Invalid parent timestamp format, please use RFC3339 format") } - tFormated := strfmt.DateTime(t) - parentTimestamp = &tFormated } - params := branchApi.NewBranchServiceCreateBranchParams().WithClusterID(clusterId).WithBranch(&branchModel.V1beta1Branch{ - DisplayName: &branchName, - ParentID: parentID, - ParentTimestamp: parentTimestamp, - }).WithContext(ctx) - + body := branch.NewBranch(branchName) + if parentID != "" { + body.SetParentId(parentID) + } + if !parentTimestamp.IsZero() { + body.SetParentTimestamp(parentTimestamp) + } if h.IOStreams.CanPrompt { - err := CreateAndSpinnerWait(ctx, d, params, h) + err := CreateAndSpinnerWait(ctx, h, d, clusterId, body) if err != nil { return errors.Trace(err) } } else { - err := CreateAndWaitReady(ctx, h, d, params) + err := CreateAndWaitReady(ctx, h, d, clusterId, body) if err != nil { return err } @@ -210,12 +207,12 @@ func CreateCmd(h *internal.Helper) *cobra.Command { return createCmd } -func CreateAndWaitReady(ctx context.Context, h *internal.Helper, d cloud.TiDBCloudClient, params *branchApi.BranchServiceCreateBranchParams) error { - createBranchResult, err := d.CreateBranch(params) +func CreateAndWaitReady(ctx context.Context, h *internal.Helper, d cloud.TiDBCloudClient, clusterId string, body *branch.Branch) error { + b, err := d.CreateBranch(ctx, clusterId, body) if err != nil { return errors.Trace(err) } - newBranchID := createBranchResult.GetPayload().BranchID + newBranchID := *b.BranchId fmt.Fprintln(h.IOStreams.Out, "... Waiting for branch to be ready") ticker := time.NewTicker(WaitInterval) @@ -226,15 +223,11 @@ func CreateAndWaitReady(ctx context.Context, h *internal.Helper, d cloud.TiDBClo case <-timer: return errors.New(fmt.Sprintf("Timeout waiting for branch %s to be ready, please check status on dashboard.", newBranchID)) case <-ticker.C: - clusterResult, err := d.GetBranch(branchApi.NewBranchServiceGetBranchParams(). - WithClusterID(params.ClusterID). - WithBranchID(newBranchID). - WithContext(ctx)) + b, err := d.GetBranch(ctx, clusterId, newBranchID) if err != nil { return errors.Trace(err) } - s := clusterResult.GetPayload().State - if s == branchModel.V1beta1BranchStateACTIVE { + if *b.State == branch.BRANCHSTATE_ACTIVE { fmt.Fprint(h.IOStreams.Out, color.GreenString("Branch %s is ready.", newBranchID)) return nil } @@ -242,14 +235,14 @@ func CreateAndWaitReady(ctx context.Context, h *internal.Helper, d cloud.TiDBClo } } -func CreateAndSpinnerWait(ctx context.Context, d cloud.TiDBCloudClient, params *branchApi.BranchServiceCreateBranchParams, h *internal.Helper) error { +func CreateAndSpinnerWait(ctx context.Context, h *internal.Helper, d cloud.TiDBCloudClient, clusterId string, body *branch.Branch) error { // use spinner to indicate that the cluster is being created task := func() tea.Msg { - createBranchResult, err := d.CreateBranch(params) + b, err := d.CreateBranch(ctx, clusterId, body) if err != nil { return errors.Trace(err) } - newBranchID := createBranchResult.GetPayload().BranchID + newBranchID := *b.BranchId ticker := time.NewTicker(WaitInterval) defer ticker.Stop() @@ -259,15 +252,11 @@ func CreateAndSpinnerWait(ctx context.Context, d cloud.TiDBCloudClient, params * case <-timer: return ui.Result(fmt.Sprintf("Timeout waiting for branch %s to be ready, please check status on dashboard.", newBranchID)) case <-ticker.C: - clusterResult, err := d.GetBranch(branchApi.NewBranchServiceGetBranchParams(). - WithClusterID(params.ClusterID). - WithBranchID(newBranchID). - WithContext(ctx)) + b, err := d.GetBranch(ctx, clusterId, newBranchID) if err != nil { return errors.Trace(err) } - s := clusterResult.GetPayload().State - if s == branchModel.V1beta1BranchStateACTIVE { + if *b.State == branch.BRANCHSTATE_ACTIVE { return ui.Result(fmt.Sprintf("Branch %s is ready.", newBranchID)) } case <-ctx.Done(): diff --git a/internal/cli/serverless/branch/create_test.go b/internal/cli/serverless/branch/create_test.go index a1936901..4cb0ceb8 100644 --- a/internal/cli/serverless/branch/create_test.go +++ b/internal/cli/serverless/branch/create_test.go @@ -26,8 +26,7 @@ import ( "tidbcloud-cli/internal/iostream" "tidbcloud-cli/internal/mock" "tidbcloud-cli/internal/service/cloud" - branchApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/client/branch_service" - branchModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/branch" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -63,26 +62,18 @@ func (suite *CreateBranchSuite) TestCreateBranchArgs() { branchName := "test" branchId := "12345" - createBranchBody := &branchModel.V1beta1Branch{ - DisplayName: &branchName, + createBranchBody := &branch.Branch{ + DisplayName: branchName, } - suite.mockClient.On("CreateBranch", branchApi.NewBranchServiceCreateBranchParams(). - WithClusterID(clusterID).WithBranch(createBranchBody).WithContext(ctx)). - Return(&branchApi.BranchServiceCreateBranchOK{ - Payload: &branchModel.V1beta1Branch{ - BranchID: branchId, - }, + suite.mockClient.On("CreateBranch", ctx, clusterID, createBranchBody). + Return(&branch.Branch{ + BranchId: &branchId, }, nil) - body := &branchModel.V1beta1Branch{} + body := &branch.Branch{} err := json.Unmarshal([]byte(getBranchResultStr), body) assert.Nil(err) - result := &branchApi.BranchServiceGetBranchOK{ - Payload: body, - } - suite.mockClient.On("GetBranch", branchApi.NewBranchServiceGetBranchParams(). - WithClusterID(clusterID).WithBranchID(branchId).WithContext(ctx)). - Return(result, nil) + suite.mockClient.On("GetBranch", ctx, clusterID, branchId).Return(body, nil) tests := []struct { name string diff --git a/internal/cli/serverless/branch/delete.go b/internal/cli/serverless/branch/delete.go index d92d6646..cda13fa0 100644 --- a/internal/cli/serverless/branch/delete.go +++ b/internal/cli/serverless/branch/delete.go @@ -22,7 +22,6 @@ import ( "tidbcloud-cli/internal/flag" "tidbcloud-cli/internal/service/cloud" "tidbcloud-cli/internal/util" - branchApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/client/branch_service" "github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2/terminal" @@ -159,9 +158,7 @@ func DeleteCmd(h *internal.Helper) *cobra.Command { } } - params := branchApi.NewBranchServiceDeleteBranchParams(). - WithClusterID(clusterID).WithBranchID(branchID).WithContext(ctx) - _, err = d.DeleteBranch(params) + _, err = d.DeleteBranch(ctx, clusterID, branchID) if err != nil { return errors.Trace(err) } diff --git a/internal/cli/serverless/branch/delete_test.go b/internal/cli/serverless/branch/delete_test.go index 0384b5a2..6c6f8541 100644 --- a/internal/cli/serverless/branch/delete_test.go +++ b/internal/cli/serverless/branch/delete_test.go @@ -25,7 +25,7 @@ import ( "tidbcloud-cli/internal/iostream" "tidbcloud-cli/internal/mock" "tidbcloud-cli/internal/service/cloud" - branchApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/client/branch_service" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/branch" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -59,9 +59,7 @@ func (suite *DeleteBranchSuite) TestDeleteBranchArgs() { clusterID := "12345" branchID := "12345" - suite.mockClient.On("DeleteBranch", branchApi.NewBranchServiceDeleteBranchParams(). - WithBranchID(branchID).WithClusterID(clusterID).WithContext(ctx)). - Return(&branchApi.BranchServiceDeleteBranchOK{}, nil) + suite.mockClient.On("DeleteBranch", ctx, clusterID, branchID).Return(&branch.Branch{}, nil) tests := []struct { name string diff --git a/internal/cli/serverless/branch/describe.go b/internal/cli/serverless/branch/describe.go index c3e9be92..9bd2f403 100644 --- a/internal/cli/serverless/branch/describe.go +++ b/internal/cli/serverless/branch/describe.go @@ -22,7 +22,6 @@ import ( "tidbcloud-cli/internal/config" "tidbcloud-cli/internal/flag" "tidbcloud-cli/internal/service/cloud" - branchApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/client/branch_service" "github.com/juju/errors" "github.com/spf13/cobra" @@ -125,14 +124,12 @@ func DescribeCmd(h *internal.Helper) *cobra.Command { } } - params := branchApi.NewBranchServiceGetBranchParams(). - WithClusterID(clusterID).WithBranchID(branchID).WithContext(ctx) - branch, err := d.GetBranch(params) + branch, err := d.GetBranch(ctx, clusterID, branchID) if err != nil { return errors.Trace(err) } - v, err := json.MarshalIndent(branch.Payload, "", " ") + v, err := json.MarshalIndent(branch, "", " ") if err != nil { return errors.Trace(err) } diff --git a/internal/cli/serverless/branch/describe_test.go b/internal/cli/serverless/branch/describe_test.go index f20b0129..c1b30f48 100644 --- a/internal/cli/serverless/branch/describe_test.go +++ b/internal/cli/serverless/branch/describe_test.go @@ -26,8 +26,7 @@ import ( "tidbcloud-cli/internal/iostream" "tidbcloud-cli/internal/mock" "tidbcloud-cli/internal/service/cloud" - branchApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/client/branch_service" - branchModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/branch" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -39,7 +38,7 @@ const getBranchResultStr = `{ }, "branchId": "bran-fgwdnpasmrahnh5iozqawnmijq", "clusterId": "10202848322613926203", - "createTime": "2023-12-11T09:41:44.000Z", + "createTime": "2023-12-11T09:41:44Z", "createdBy": "yuhang.shi@pingcap.com", "displayName": "t2", "endpoints": { @@ -51,7 +50,7 @@ const getBranchResultStr = `{ "name": "clusters/10202848322613926203/branches/bran-fgwdnpasmrahnh5iozqawnmijq", "parentId": "10202848322613926203", "state": "ACTIVE", - "updateTime": "2023-12-11T09:44:05.000Z", + "updateTime": "2023-12-11T09:44:05Z", "usage": { "requestUnit": "0", "rowStorage": 951526 @@ -86,17 +85,12 @@ func (suite *DescribeBranchSuite) TestDescribeBranchArgs() { assert := require.New(suite.T()) ctx := context.Background() - body := &branchModel.V1beta1Branch{} + body := &branch.Branch{} err := json.Unmarshal([]byte(getBranchResultStr), body) assert.Nil(err) - result := &branchApi.BranchServiceGetBranchOK{ - Payload: body, - } clusterID := "10202848322613926203" branchID := "bran-fgwdnpasmrahnh5iozqawnmijq" - suite.mockClient.On("GetBranch", branchApi.NewBranchServiceGetBranchParams(). - WithBranchID(branchID).WithClusterID(clusterID).WithContext(ctx)). - Return(result, nil) + suite.mockClient.On("GetBranch", ctx, clusterID, branchID).Return(body, nil) tests := []struct { name string diff --git a/internal/cli/serverless/branch/list.go b/internal/cli/serverless/branch/list.go index 8d55ff2c..b3b295b5 100644 --- a/internal/cli/serverless/branch/list.go +++ b/internal/cli/serverless/branch/list.go @@ -16,13 +16,14 @@ package branch import ( "fmt" + "time" "tidbcloud-cli/internal" "tidbcloud-cli/internal/config" "tidbcloud-cli/internal/flag" "tidbcloud-cli/internal/output" "tidbcloud-cli/internal/service/cloud" - branchModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/branch" "github.com/juju/errors" "github.com/spf13/cobra" @@ -126,9 +127,9 @@ func ListCmd(h *internal.Helper) *cobra.Command { // for terminal which can prompt, humanFormat is the default format. // for other terminals, json format is the default format. if format == output.JsonFormat || !h.IOStreams.CanPrompt { - res := &branchModel.V1beta1ListBranchesResponse{ + res := &branch.ListBranchesResponse{ Branches: items, - TotalSize: total, + TotalSize: &total, } err := output.PrintJson(h.IOStreams.Out, res) if err != nil { @@ -147,12 +148,12 @@ func ListCmd(h *internal.Helper) *cobra.Command { var rows []output.Row for _, item := range items { rows = append(rows, output.Row{ - item.BranchID, - *item.DisplayName, - item.ParentID, - item.ParentDisplayName, - string(item.State), - item.CreateTime.String(), + *item.BranchId, + item.DisplayName, + *item.ParentId, + *item.ParentDisplayName, + string(*item.State), + item.CreateTime.Format(time.RFC3339), }) } diff --git a/internal/cli/serverless/branch/list_test.go b/internal/cli/serverless/branch/list_test.go index 7a20a26c..4c0058ce 100644 --- a/internal/cli/serverless/branch/list_test.go +++ b/internal/cli/serverless/branch/list_test.go @@ -26,8 +26,7 @@ import ( "tidbcloud-cli/internal/iostream" "tidbcloud-cli/internal/mock" "tidbcloud-cli/internal/service/cloud" - branchApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/client/branch_service" - branchModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/branch" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -80,13 +79,13 @@ const listResultMultiPageStr = `{ } ` -type ListBranchSuite struct { +type ListBranchesSuite struct { suite.Suite h *internal.Helper mockClient *mock.TiDBCloudClient } -func (suite *ListBranchSuite) SetupTest() { +func (suite *ListBranchesSuite) SetupTest() { if err := os.Setenv("NO_COLOR", "true"); err != nil { suite.T().Error(err) } @@ -102,21 +101,16 @@ func (suite *ListBranchSuite) SetupTest() { } } -func (suite *ListBranchSuite) TestListBranchesArgs() { +func (suite *ListBranchesSuite) TestListBranchesArgs() { assert := require.New(suite.T()) pageSize := int32(suite.h.QueryPageSize) ctx := context.Background() - body := &branchModel.V1beta1ListBranchesResponse{} + body := &branch.ListBranchesResponse{} err := json.Unmarshal([]byte(listResultStr), body) assert.Nil(err) - result := &branchApi.BranchServiceListBranchesOK{ - Payload: body, - } clusterID := "12345" - suite.mockClient.On("ListBranches", branchApi.NewBranchServiceListBranchesParams(). - WithClusterID(clusterID).WithPageSize(&pageSize).WithContext(ctx)). - Return(result, nil) + suite.mockClient.On("ListBranches", ctx, clusterID, &pageSize, (*string)(nil)).Return(body, nil) tests := []struct { name string @@ -161,35 +155,25 @@ func (suite *ListBranchSuite) TestListBranchesArgs() { } } -func (suite *ListBranchSuite) TestListBranchesWithMultiPages() { +func (suite *ListBranchesSuite) TestListBranchesWithMultiPages() { assert := require.New(suite.T()) ctx := context.Background() pageSize := int32(suite.h.QueryPageSize) pageToken := "2" - body := &branchModel.V1beta1ListBranchesResponse{} - err := json.Unmarshal([]byte(strings.ReplaceAll(listResultStr, `"total": 1`, `"total": 2`)), body) + body := &branch.ListBranchesResponse{} + err := json.Unmarshal([]byte(strings.ReplaceAll(listResultStr, `"totalSize": 1`, `"totalSize": 2`)), body) assert.Nil(err) - body.NextPageToken = pageToken - result := &branchApi.BranchServiceListBranchesOK{ - Payload: body, - } + body.NextPageToken = &pageToken clusterID := "12345" - suite.mockClient.On("ListBranches", branchApi.NewBranchServiceListBranchesParams(). - WithClusterID(clusterID).WithPageSize(&pageSize).WithContext(ctx)). - Return(result, nil) + suite.mockClient.On("ListBranches", ctx, clusterID, &pageSize, nil).Return(body, nil) - body2 := &branchModel.V1beta1ListBranchesResponse{} - err = json.Unmarshal([]byte(strings.ReplaceAll(listResultStr, `"total": 1`, `"total": 2`)), body2) + body2 := &branch.ListBranchesResponse{} + err = json.Unmarshal([]byte(strings.ReplaceAll(listResultStr, `"totalSize": 1`, `"totalSize": 2`)), body2) assert.Nil(err) - result2 := &branchApi.BranchServiceListBranchesOK{ - Payload: body2, - } - suite.mockClient.On("ListBranches", branchApi.NewBranchServiceListBranchesParams(). - WithClusterID(clusterID).WithPageToken(&pageToken).WithPageSize(&pageSize).WithContext(ctx)). - Return(result2, nil) - cmd := ListCmd(suite.h) + suite.mockClient.On("ListBranches", ctx, clusterID, &pageSize, &pageToken).Return(body2, nil) + cmd := ListCmd(suite.h) tests := []struct { name string args []string @@ -220,5 +204,5 @@ func (suite *ListBranchSuite) TestListBranchesWithMultiPages() { } func TestListBranchSuite(t *testing.T) { - suite.Run(t, new(ListBranchSuite)) + suite.Run(t, new(ListBranchesSuite)) } diff --git a/internal/cli/serverless/branch/shell.go b/internal/cli/serverless/branch/shell.go index 1f493df6..48198567 100644 --- a/internal/cli/serverless/branch/shell.go +++ b/internal/cli/serverless/branch/shell.go @@ -23,7 +23,6 @@ import ( "tidbcloud-cli/internal/flag" "tidbcloud-cli/internal/service/cloud" "tidbcloud-cli/internal/util" - branchApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/client/branch_service" "github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2/terminal" @@ -190,16 +189,15 @@ The connection forces the [ANSI SQL mode](https://dev.mysql.com/doc/refman/8.0/e } var host, name, port string - params := branchApi.NewBranchServiceGetBranchParams().WithClusterID(clusterID).WithBranchID(branchID).WithContext(ctx) - branchInfo, err := d.GetBranch(params) + branchInfo, err := d.GetBranch(ctx, clusterID, branchID) if err != nil { return errors.Trace(err) } - host = branchInfo.Payload.Endpoints.Public.Host - port = strconv.Itoa(int(branchInfo.Payload.Endpoints.Public.Port)) - name = *branchInfo.Payload.DisplayName + host = *branchInfo.Endpoints.Public.Host + port = strconv.Itoa(int(*branchInfo.Endpoints.Public.Port)) + name = branchInfo.DisplayName if userName == "" { - userName = fmt.Sprintf("%s.root", *branchInfo.Payload.UserPrefix) + userName = fmt.Sprintf("%s.root", *branchInfo.UserPrefix.Get()) fmt.Fprintln(h.IOStreams.Out, color.GreenString("Current user: ")+color.HiGreenString(userName)) } diff --git a/internal/mock/api_client.go b/internal/mock/api_client.go index f73b18b0..39c4abee 100644 --- a/internal/mock/api_client.go +++ b/internal/mock/api_client.go @@ -3,18 +3,18 @@ package mock import ( - branch_service "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/client/branch_service" account "tidbcloud-cli/pkg/tidbcloud/v1beta1/iam/client/account" + branch "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/branch" backup_restore_service "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service" context "context" + export "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/export" + import_service "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_import/client/import_service" mock "github.com/stretchr/testify/mock" - openapi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/export" - operations "tidbcloud-cli/pkg/tidbcloud/pingchat/client/operations" serverless_service "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" @@ -26,23 +26,23 @@ type TiDBCloudClient struct { } // CancelExport provides a mock function with given fields: ctx, clusterId, exportId -func (_m *TiDBCloudClient) CancelExport(ctx context.Context, clusterId string, exportId string) (*openapi.Export, error) { +func (_m *TiDBCloudClient) CancelExport(ctx context.Context, clusterId string, exportId string) (*export.Export, error) { ret := _m.Called(ctx, clusterId, exportId) if len(ret) == 0 { panic("no return value specified for CancelExport") } - var r0 *openapi.Export + var r0 *export.Export var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (*openapi.Export, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string) (*export.Export, error)); ok { return rf(ctx, clusterId, exportId) } - if rf, ok := ret.Get(0).(func(context.Context, string, string) *openapi.Export); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string) *export.Export); ok { r0 = rf(ctx, clusterId, exportId) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*openapi.Export) + r0 = ret.Get(0).(*export.Export) } } @@ -203,36 +203,29 @@ func (_m *TiDBCloudClient) CompleteUpload(params *import_service.ImportServiceCo return r0, r1 } -// CreateBranch provides a mock function with given fields: params, opts -func (_m *TiDBCloudClient) CreateBranch(params *branch_service.BranchServiceCreateBranchParams, opts ...branch_service.ClientOption) (*branch_service.BranchServiceCreateBranchOK, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) +// CreateBranch provides a mock function with given fields: ctx, clusterId, body +func (_m *TiDBCloudClient) CreateBranch(ctx context.Context, clusterId string, body *branch.Branch) (*branch.Branch, error) { + ret := _m.Called(ctx, clusterId, body) if len(ret) == 0 { panic("no return value specified for CreateBranch") } - var r0 *branch_service.BranchServiceCreateBranchOK + var r0 *branch.Branch var r1 error - if rf, ok := ret.Get(0).(func(*branch_service.BranchServiceCreateBranchParams, ...branch_service.ClientOption) (*branch_service.BranchServiceCreateBranchOK, error)); ok { - return rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, string, *branch.Branch) (*branch.Branch, error)); ok { + return rf(ctx, clusterId, body) } - if rf, ok := ret.Get(0).(func(*branch_service.BranchServiceCreateBranchParams, ...branch_service.ClientOption) *branch_service.BranchServiceCreateBranchOK); ok { - r0 = rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, string, *branch.Branch) *branch.Branch); ok { + r0 = rf(ctx, clusterId, body) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*branch_service.BranchServiceCreateBranchOK) + r0 = ret.Get(0).(*branch.Branch) } } - if rf, ok := ret.Get(1).(func(*branch_service.BranchServiceCreateBranchParams, ...branch_service.ClientOption) error); ok { - r1 = rf(params, opts...) + if rf, ok := ret.Get(1).(func(context.Context, string, *branch.Branch) error); ok { + r1 = rf(ctx, clusterId, body) } else { r1 = ret.Error(1) } @@ -278,27 +271,27 @@ func (_m *TiDBCloudClient) CreateCluster(params *serverless_service.ServerlessSe } // CreateExport provides a mock function with given fields: ctx, clusterId, body -func (_m *TiDBCloudClient) CreateExport(ctx context.Context, clusterId string, body *openapi.ExportServiceCreateExportBody) (*openapi.Export, error) { +func (_m *TiDBCloudClient) CreateExport(ctx context.Context, clusterId string, body *export.ExportServiceCreateExportBody) (*export.Export, error) { ret := _m.Called(ctx, clusterId, body) if len(ret) == 0 { panic("no return value specified for CreateExport") } - var r0 *openapi.Export + var r0 *export.Export var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, *openapi.ExportServiceCreateExportBody) (*openapi.Export, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, *export.ExportServiceCreateExportBody) (*export.Export, error)); ok { return rf(ctx, clusterId, body) } - if rf, ok := ret.Get(0).(func(context.Context, string, *openapi.ExportServiceCreateExportBody) *openapi.Export); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, *export.ExportServiceCreateExportBody) *export.Export); ok { r0 = rf(ctx, clusterId, body) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*openapi.Export) + r0 = ret.Get(0).(*export.Export) } } - if rf, ok := ret.Get(1).(func(context.Context, string, *openapi.ExportServiceCreateExportBody) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, *export.ExportServiceCreateExportBody) error); ok { r1 = rf(ctx, clusterId, body) } else { r1 = ret.Error(1) @@ -418,36 +411,29 @@ func (_m *TiDBCloudClient) DeleteBackup(params *backup_restore_service.BackupRes return r0, r1 } -// DeleteBranch provides a mock function with given fields: params, opts -func (_m *TiDBCloudClient) DeleteBranch(params *branch_service.BranchServiceDeleteBranchParams, opts ...branch_service.ClientOption) (*branch_service.BranchServiceDeleteBranchOK, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) +// DeleteBranch provides a mock function with given fields: ctx, clusterId, branchId +func (_m *TiDBCloudClient) DeleteBranch(ctx context.Context, clusterId string, branchId string) (*branch.Branch, error) { + ret := _m.Called(ctx, clusterId, branchId) if len(ret) == 0 { panic("no return value specified for DeleteBranch") } - var r0 *branch_service.BranchServiceDeleteBranchOK + var r0 *branch.Branch var r1 error - if rf, ok := ret.Get(0).(func(*branch_service.BranchServiceDeleteBranchParams, ...branch_service.ClientOption) (*branch_service.BranchServiceDeleteBranchOK, error)); ok { - return rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, string, string) (*branch.Branch, error)); ok { + return rf(ctx, clusterId, branchId) } - if rf, ok := ret.Get(0).(func(*branch_service.BranchServiceDeleteBranchParams, ...branch_service.ClientOption) *branch_service.BranchServiceDeleteBranchOK); ok { - r0 = rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, string, string) *branch.Branch); ok { + r0 = rf(ctx, clusterId, branchId) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*branch_service.BranchServiceDeleteBranchOK) + r0 = ret.Get(0).(*branch.Branch) } } - if rf, ok := ret.Get(1).(func(*branch_service.BranchServiceDeleteBranchParams, ...branch_service.ClientOption) error); ok { - r1 = rf(params, opts...) + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, clusterId, branchId) } else { r1 = ret.Error(1) } @@ -493,23 +479,23 @@ func (_m *TiDBCloudClient) DeleteCluster(params *serverless_service.ServerlessSe } // DeleteExport provides a mock function with given fields: ctx, clusterId, exportId -func (_m *TiDBCloudClient) DeleteExport(ctx context.Context, clusterId string, exportId string) (*openapi.Export, error) { +func (_m *TiDBCloudClient) DeleteExport(ctx context.Context, clusterId string, exportId string) (*export.Export, error) { ret := _m.Called(ctx, clusterId, exportId) if len(ret) == 0 { panic("no return value specified for DeleteExport") } - var r0 *openapi.Export + var r0 *export.Export var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (*openapi.Export, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string) (*export.Export, error)); ok { return rf(ctx, clusterId, exportId) } - if rf, ok := ret.Get(0).(func(context.Context, string, string) *openapi.Export); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string) *export.Export); ok { r0 = rf(ctx, clusterId, exportId) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*openapi.Export) + r0 = ret.Get(0).(*export.Export) } } @@ -560,23 +546,23 @@ func (_m *TiDBCloudClient) DeleteSQLUser(params *account.DeleteV1beta1ClustersCl } // DownloadExport provides a mock function with given fields: ctx, clusterId, exportId -func (_m *TiDBCloudClient) DownloadExport(ctx context.Context, clusterId string, exportId string) (*openapi.DownloadExportsResponse, error) { +func (_m *TiDBCloudClient) DownloadExport(ctx context.Context, clusterId string, exportId string) (*export.DownloadExportsResponse, error) { ret := _m.Called(ctx, clusterId, exportId) if len(ret) == 0 { panic("no return value specified for DownloadExport") } - var r0 *openapi.DownloadExportsResponse + var r0 *export.DownloadExportsResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (*openapi.DownloadExportsResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string) (*export.DownloadExportsResponse, error)); ok { return rf(ctx, clusterId, exportId) } - if rf, ok := ret.Get(0).(func(context.Context, string, string) *openapi.DownloadExportsResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string) *export.DownloadExportsResponse); ok { r0 = rf(ctx, clusterId, exportId) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*openapi.DownloadExportsResponse) + r0 = ret.Get(0).(*export.DownloadExportsResponse) } } @@ -626,36 +612,29 @@ func (_m *TiDBCloudClient) GetBackup(params *backup_restore_service.BackupRestor return r0, r1 } -// GetBranch provides a mock function with given fields: params, opts -func (_m *TiDBCloudClient) GetBranch(params *branch_service.BranchServiceGetBranchParams, opts ...branch_service.ClientOption) (*branch_service.BranchServiceGetBranchOK, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) +// GetBranch provides a mock function with given fields: ctx, clusterId, branchId +func (_m *TiDBCloudClient) GetBranch(ctx context.Context, clusterId string, branchId string) (*branch.Branch, error) { + ret := _m.Called(ctx, clusterId, branchId) if len(ret) == 0 { panic("no return value specified for GetBranch") } - var r0 *branch_service.BranchServiceGetBranchOK + var r0 *branch.Branch var r1 error - if rf, ok := ret.Get(0).(func(*branch_service.BranchServiceGetBranchParams, ...branch_service.ClientOption) (*branch_service.BranchServiceGetBranchOK, error)); ok { - return rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, string, string) (*branch.Branch, error)); ok { + return rf(ctx, clusterId, branchId) } - if rf, ok := ret.Get(0).(func(*branch_service.BranchServiceGetBranchParams, ...branch_service.ClientOption) *branch_service.BranchServiceGetBranchOK); ok { - r0 = rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, string, string) *branch.Branch); ok { + r0 = rf(ctx, clusterId, branchId) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*branch_service.BranchServiceGetBranchOK) + r0 = ret.Get(0).(*branch.Branch) } } - if rf, ok := ret.Get(1).(func(*branch_service.BranchServiceGetBranchParams, ...branch_service.ClientOption) error); ok { - r1 = rf(params, opts...) + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, clusterId, branchId) } else { r1 = ret.Error(1) } @@ -701,23 +680,23 @@ func (_m *TiDBCloudClient) GetCluster(params *serverless_service.ServerlessServi } // GetExport provides a mock function with given fields: ctx, clusterId, exportId -func (_m *TiDBCloudClient) GetExport(ctx context.Context, clusterId string, exportId string) (*openapi.Export, error) { +func (_m *TiDBCloudClient) GetExport(ctx context.Context, clusterId string, exportId string) (*export.Export, error) { ret := _m.Called(ctx, clusterId, exportId) if len(ret) == 0 { panic("no return value specified for GetExport") } - var r0 *openapi.Export + var r0 *export.Export var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (*openapi.Export, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string) (*export.Export, error)); ok { return rf(ctx, clusterId, exportId) } - if rf, ok := ret.Get(0).(func(context.Context, string, string) *openapi.Export); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string) *export.Export); ok { r0 = rf(ctx, clusterId, exportId) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*openapi.Export) + r0 = ret.Get(0).(*export.Export) } } @@ -841,36 +820,29 @@ func (_m *TiDBCloudClient) ListBackups(params *backup_restore_service.BackupRest return r0, r1 } -// ListBranches provides a mock function with given fields: params, opts -func (_m *TiDBCloudClient) ListBranches(params *branch_service.BranchServiceListBranchesParams, opts ...branch_service.ClientOption) (*branch_service.BranchServiceListBranchesOK, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) +// ListBranches provides a mock function with given fields: ctx, clusterId, pageSize, pageToken +func (_m *TiDBCloudClient) ListBranches(ctx context.Context, clusterId string, pageSize *int32, pageToken *string) (*branch.ListBranchesResponse, error) { + ret := _m.Called(ctx, clusterId, pageSize, pageToken) if len(ret) == 0 { panic("no return value specified for ListBranches") } - var r0 *branch_service.BranchServiceListBranchesOK + var r0 *branch.ListBranchesResponse var r1 error - if rf, ok := ret.Get(0).(func(*branch_service.BranchServiceListBranchesParams, ...branch_service.ClientOption) (*branch_service.BranchServiceListBranchesOK, error)); ok { - return rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, string, *int32, *string) (*branch.ListBranchesResponse, error)); ok { + return rf(ctx, clusterId, pageSize, pageToken) } - if rf, ok := ret.Get(0).(func(*branch_service.BranchServiceListBranchesParams, ...branch_service.ClientOption) *branch_service.BranchServiceListBranchesOK); ok { - r0 = rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, string, *int32, *string) *branch.ListBranchesResponse); ok { + r0 = rf(ctx, clusterId, pageSize, pageToken) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*branch_service.BranchServiceListBranchesOK) + r0 = ret.Get(0).(*branch.ListBranchesResponse) } } - if rf, ok := ret.Get(1).(func(*branch_service.BranchServiceListBranchesParams, ...branch_service.ClientOption) error); ok { - r1 = rf(params, opts...) + if rf, ok := ret.Get(1).(func(context.Context, string, *int32, *string) error); ok { + r1 = rf(ctx, clusterId, pageSize, pageToken) } else { r1 = ret.Error(1) } @@ -916,23 +888,23 @@ func (_m *TiDBCloudClient) ListClustersOfProject(params *serverless_service.Serv } // ListExports provides a mock function with given fields: ctx, clusterId, pageSize, pageToken, orderBy -func (_m *TiDBCloudClient) ListExports(ctx context.Context, clusterId string, pageSize *int32, pageToken *string, orderBy *string) (*openapi.ListExportsResponse, error) { +func (_m *TiDBCloudClient) ListExports(ctx context.Context, clusterId string, pageSize *int32, pageToken *string, orderBy *string) (*export.ListExportsResponse, error) { ret := _m.Called(ctx, clusterId, pageSize, pageToken, orderBy) if len(ret) == 0 { panic("no return value specified for ListExports") } - var r0 *openapi.ListExportsResponse + var r0 *export.ListExportsResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, *int32, *string, *string) (*openapi.ListExportsResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, *int32, *string, *string) (*export.ListExportsResponse, error)); ok { return rf(ctx, clusterId, pageSize, pageToken, orderBy) } - if rf, ok := ret.Get(0).(func(context.Context, string, *int32, *string, *string) *openapi.ListExportsResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, *int32, *string, *string) *export.ListExportsResponse); ok { r0 = rf(ctx, clusterId, pageSize, pageToken, orderBy) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*openapi.ListExportsResponse) + r0 = ret.Get(0).(*export.ListExportsResponse) } } diff --git a/internal/service/cloud/api_client.go b/internal/service/cloud/api_client.go index 34573aeb..42a4a08b 100644 --- a/internal/service/cloud/api_client.go +++ b/internal/service/cloud/api_client.go @@ -28,13 +28,12 @@ import ( "tidbcloud-cli/internal/version" pingchatClient "tidbcloud-cli/pkg/tidbcloud/pingchat/client" pingchatOp "tidbcloud-cli/pkg/tidbcloud/pingchat/client/operations" - branchClient "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/client" - branchOp "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/client/branch_service" iamClient "tidbcloud-cli/pkg/tidbcloud/v1beta1/iam/client" iamOp "tidbcloud-cli/pkg/tidbcloud/v1beta1/iam/client/account" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/branch" serverlessClient "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client" serverlessOp "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" - expClient "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/export" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/export" brClient "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/client" brOp "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service" serverlessImportClient "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_import/client" @@ -76,13 +75,13 @@ type TiDBCloudClient interface { ListImports(params *serverlessImportOp.ImportServiceListImportsParams, opts ...serverlessImportOp.ClientOption) (*serverlessImportOp.ImportServiceListImportsOK, error) - GetBranch(params *branchOp.BranchServiceGetBranchParams, opts ...branchOp.ClientOption) (*branchOp.BranchServiceGetBranchOK, error) + GetBranch(ctx context.Context, clusterId, branchId string) (*branch.Branch, error) - ListBranches(params *branchOp.BranchServiceListBranchesParams, opts ...branchOp.ClientOption) (*branchOp.BranchServiceListBranchesOK, error) + ListBranches(ctx context.Context, clusterId string, pageSize *int32, pageToken *string) (*branch.ListBranchesResponse, error) - CreateBranch(params *branchOp.BranchServiceCreateBranchParams, opts ...branchOp.ClientOption) (*branchOp.BranchServiceCreateBranchOK, error) + CreateBranch(ctx context.Context, clusterId string, body *branch.Branch) (*branch.Branch, error) - DeleteBranch(params *branchOp.BranchServiceDeleteBranchParams, opts ...branchOp.ClientOption) (*branchOp.BranchServiceDeleteBranchOK, error) + DeleteBranch(ctx context.Context, clusterId string, branchId string) (*branch.Branch, error) Chat(params *pingchatOp.ChatParams, opts ...pingchatOp.ClientOption) (*pingchatOp.ChatOK, error) @@ -100,17 +99,17 @@ type TiDBCloudClient interface { CancelUpload(params *serverlessImportOp.ImportServiceCancelUploadParams, opts ...serverlessImportOp.ClientOption) (*serverlessImportOp.ImportServiceCancelUploadOK, error) - GetExport(ctx context.Context, clusterId string, exportId string) (*expClient.Export, error) + GetExport(ctx context.Context, clusterId string, exportId string) (*export.Export, error) - CancelExport(ctx context.Context, clusterId string, exportId string) (*expClient.Export, error) + CancelExport(ctx context.Context, clusterId string, exportId string) (*export.Export, error) - CreateExport(ctx context.Context, clusterId string, body *expClient.ExportServiceCreateExportBody) (*expClient.Export, error) + CreateExport(ctx context.Context, clusterId string, body *export.ExportServiceCreateExportBody) (*export.Export, error) - DeleteExport(ctx context.Context, clusterId string, exportId string) (*expClient.Export, error) + DeleteExport(ctx context.Context, clusterId string, exportId string) (*export.Export, error) - ListExports(ctx context.Context, clusterId string, pageSize *int32, pageToken *string, orderBy *string) (*expClient.ListExportsResponse, error) + ListExports(ctx context.Context, clusterId string, pageSize *int32, pageToken *string, orderBy *string) (*export.ListExportsResponse, error) - DownloadExport(ctx context.Context, clusterId string, exportId string) (*expClient.DownloadExportsResponse, error) + DownloadExport(ctx context.Context, clusterId string, exportId string) (*export.DownloadExportsResponse, error) ListSQLUsers(params *iamOp.GetV1beta1ClustersClusterIDSQLUsersParams, opts ...iamOp.ClientOption) (*iamOp.GetV1beta1ClustersClusterIDSQLUsersOK, error) @@ -125,12 +124,12 @@ type TiDBCloudClient interface { type ClientDelegate struct { ic *iamClient.TidbcloudServerless - bc *branchClient.TidbcloudServerless + bc *branch.APIClient pc *pingchatClient.TidbcloudPingchat sc *serverlessClient.TidbcloudServerless brc *brClient.TidbcloudServerless sic *serverlessImportClient.TidbcloudServerless - ec *expClient.APIClient + ec *export.APIClient } func NewClientDelegateWithToken(token string, apiUrl string, serverlessEndpoint string, iamEndpoint string) (*ClientDelegate, error) { @@ -211,24 +210,35 @@ func (d *ClientDelegate) ListImports(params *serverlessImportOp.ImportServiceLis return d.sic.ImportService.ImportServiceListImports(params, opts...) } -func (d *ClientDelegate) GetBranch(params *branchOp.BranchServiceGetBranchParams, opts ...branchOp.ClientOption) (*branchOp.BranchServiceGetBranchOK, error) { - r, err := d.bc.BranchService.BranchServiceGetBranch(params, opts...) - return r, err +func (d *ClientDelegate) GetBranch(ctx context.Context, clusterId, branchId string) (*branch.Branch, error) { + b, h, err := d.bc.BranchServiceAPI.BranchServiceGetBranch(ctx, clusterId, branchId).Execute() + return b, parseError(err, h) } -func (d *ClientDelegate) ListBranches(params *branchOp.BranchServiceListBranchesParams, opts ...branchOp.ClientOption) (*branchOp.BranchServiceListBranchesOK, error) { - r, err := d.bc.BranchService.BranchServiceListBranches(params, opts...) - return r, err +func (d *ClientDelegate) ListBranches(ctx context.Context, clusterId string, pageSize *int32, pageToken *string) (*branch.ListBranchesResponse, error) { + r := d.bc.BranchServiceAPI.BranchServiceListBranches(ctx, clusterId) + if pageSize != nil { + r = r.PageSize(*pageSize) + } + if pageToken != nil { + r = r.PageToken(*pageToken) + } + bs, h, err := r.Execute() + return bs, parseError(err, h) } -func (d *ClientDelegate) CreateBranch(params *branchOp.BranchServiceCreateBranchParams, opts ...branchOp.ClientOption) (*branchOp.BranchServiceCreateBranchOK, error) { - r, err := d.bc.BranchService.BranchServiceCreateBranch(params, opts...) - return r, err +func (d *ClientDelegate) CreateBranch(ctx context.Context, clusterId string, body *branch.Branch) (*branch.Branch, error) { + r := d.bc.BranchServiceAPI.BranchServiceCreateBranch(ctx, clusterId) + if body != nil { + r = r.Branch(*body) + } + b, h, err := r.Execute() + return b, parseError(err, h) } -func (d *ClientDelegate) DeleteBranch(params *branchOp.BranchServiceDeleteBranchParams, opts ...branchOp.ClientOption) (*branchOp.BranchServiceDeleteBranchOK, error) { - r, err := d.bc.BranchService.BranchServiceDeleteBranch(params, opts...) - return r, err +func (d *ClientDelegate) DeleteBranch(ctx context.Context, clusterId string, branchId string) (*branch.Branch, error) { + b, h, err := d.bc.BranchServiceAPI.BranchServiceDeleteBranch(ctx, clusterId, branchId).Execute() + return b, parseError(err, h) } func (d *ClientDelegate) Chat(params *pingchatOp.ChatParams, opts ...pingchatOp.ClientOption) (*pingchatOp.ChatOK, error) { @@ -263,17 +273,17 @@ func (d *ClientDelegate) CancelUpload(params *serverlessImportOp.ImportServiceCa return d.sic.ImportService.ImportServiceCancelUpload(params, opts...) } -func (d *ClientDelegate) GetExport(ctx context.Context, clusterId string, exportId string) (*expClient.Export, error) { +func (d *ClientDelegate) GetExport(ctx context.Context, clusterId string, exportId string) (*export.Export, error) { res, h, err := d.ec.ExportServiceAPI.ExportServiceGetExport(ctx, clusterId, exportId).Execute() return res, parseError(err, h) } -func (d *ClientDelegate) CancelExport(ctx context.Context, clusterId string, exportId string) (*expClient.Export, error) { +func (d *ClientDelegate) CancelExport(ctx context.Context, clusterId string, exportId string) (*export.Export, error) { res, h, err := d.ec.ExportServiceAPI.ExportServiceCancelExport(ctx, clusterId, exportId).Execute() return res, parseError(err, h) } -func (d *ClientDelegate) CreateExport(ctx context.Context, clusterId string, body *expClient.ExportServiceCreateExportBody) (*expClient.Export, error) { +func (d *ClientDelegate) CreateExport(ctx context.Context, clusterId string, body *export.ExportServiceCreateExportBody) (*export.Export, error) { r := d.ec.ExportServiceAPI.ExportServiceCreateExport(ctx, clusterId) if body != nil { r = r.Body(*body) @@ -282,12 +292,12 @@ func (d *ClientDelegate) CreateExport(ctx context.Context, clusterId string, bod return res, parseError(err, h) } -func (d *ClientDelegate) DeleteExport(ctx context.Context, clusterId string, exportId string) (*expClient.Export, error) { +func (d *ClientDelegate) DeleteExport(ctx context.Context, clusterId string, exportId string) (*export.Export, error) { res, h, err := d.ec.ExportServiceAPI.ExportServiceDeleteExport(ctx, clusterId, exportId).Execute() return res, parseError(err, h) } -func (d *ClientDelegate) ListExports(ctx context.Context, clusterId string, pageSize *int32, pageToken *string, orderBy *string) (*expClient.ListExportsResponse, error) { +func (d *ClientDelegate) ListExports(ctx context.Context, clusterId string, pageSize *int32, pageToken *string, orderBy *string) (*export.ListExportsResponse, error) { r := d.ec.ExportServiceAPI.ExportServiceListExports(ctx, clusterId) if pageSize != nil { r = r.PageSize(*pageSize) @@ -302,7 +312,7 @@ func (d *ClientDelegate) ListExports(ctx context.Context, clusterId string, page return res, parseError(err, h) } -func (d *ClientDelegate) DownloadExport(ctx context.Context, clusterId string, exportId string) (*expClient.DownloadExportsResponse, error) { +func (d *ClientDelegate) DownloadExport(ctx context.Context, clusterId string, exportId string) (*export.DownloadExportsResponse, error) { r := d.ec.ExportServiceAPI.ExportServiceDownloadExport(ctx, clusterId, exportId) r = r.Body(make(map[string]interface{})) res, h, err := r.Execute() @@ -329,7 +339,7 @@ func (d *ClientDelegate) UpdateSQLUser(params *iamOp.PatchV1beta1ClustersCluster return d.ic.Account.PatchV1beta1ClustersClusterIDSQLUsersUserName(params, opts...) } -func NewApiClient(rt http.RoundTripper, apiUrl string, serverlessEndpoint string, iamEndpoint string) (*branchClient.TidbcloudServerless, *serverlessClient.TidbcloudServerless, *pingchatClient.TidbcloudPingchat, *brClient.TidbcloudServerless, *serverlessImportClient.TidbcloudServerless, *expClient.APIClient, *iamClient.TidbcloudServerless, error) { +func NewApiClient(rt http.RoundTripper, apiUrl string, serverlessEndpoint string, iamEndpoint string) (*branch.APIClient, *serverlessClient.TidbcloudServerless, *pingchatClient.TidbcloudPingchat, *brClient.TidbcloudServerless, *serverlessImportClient.TidbcloudServerless, *export.APIClient, *iamClient.TidbcloudServerless, error) { httpclient := &http.Client{ Transport: rt, } @@ -351,21 +361,26 @@ func NewApiClient(rt http.RoundTripper, apiUrl string, serverlessEndpoint string return nil, nil, nil, nil, nil, nil, nil, err } serverlessTransport := httpTransport.NewWithClient(serverlessURL.Host, serverlessClient.DefaultBasePath, []string{serverlessURL.Scheme}, httpclient) - branchTransport := httpTransport.NewWithClient(serverlessURL.Host, branchClient.DefaultBasePath, []string{serverlessURL.Scheme}, httpclient) backRestoreTransport := httpTransport.NewWithClient(serverlessURL.Host, brClient.DefaultBasePath, []string{serverlessURL.Scheme}, httpclient) importTransport := httpTransport.NewWithClient(serverlessURL.Host, serverlessImportClient.DefaultBasePath, []string{serverlessURL.Scheme}, httpclient) iamTransport := httpTransport.NewWithClient(iamUrl.Host, iamClient.DefaultBasePath, []string{iamUrl.Scheme}, httpclient) - exportCfg := expClient.NewConfiguration() + branchCfg := branch.NewConfiguration() + branchCfg.HTTPClient = httpclient + branchCfg.Host = serverlessURL.Host + + exportCfg := export.NewConfiguration() exportCfg.HTTPClient = httpclient exportCfg.Host = serverlessURL.Host + if os.Getenv(config.DebugEnv) == "true" || os.Getenv(config.DebugEnv) == "1" { + branchCfg.Debug = true exportCfg.Debug = true } - return branchClient.New(branchTransport, strfmt.Default), serverlessClient.New(serverlessTransport, strfmt.Default), + return branch.NewAPIClient(branchCfg), serverlessClient.New(serverlessTransport, strfmt.Default), pingchatClient.New(transport, strfmt.Default), brClient.New(backRestoreTransport, strfmt.Default), - serverlessImportClient.New(importTransport, strfmt.Default), expClient.NewAPIClient(exportCfg), + serverlessImportClient.New(importTransport, strfmt.Default), export.NewAPIClient(exportCfg), iamClient.New(iamTransport, strfmt.Default), nil } diff --git a/internal/service/cloud/logic.go b/internal/service/cloud/logic.go index b05f35bc..7491d17f 100644 --- a/internal/service/cloud/logic.go +++ b/internal/service/cloud/logic.go @@ -21,10 +21,9 @@ import ( "tidbcloud-cli/internal/ui" "tidbcloud-cli/internal/util" - branchApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/client/branch_service" - branchModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/models" iamApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/iam/client/account" iamModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/iam/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/branch" serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/export" serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models" @@ -298,8 +297,8 @@ func GetSelectedBranch(ctx context.Context, clusterID string, pageSize int64, cl var items = make([]interface{}, 0, len(branchItems)) for _, item := range branchItems { items = append(items, &Branch{ - ID: item.BranchID, - DisplayName: *item.DisplayName, + ID: *item.BranchId, + DisplayName: item.DisplayName, IsCluster: false, }) } @@ -647,28 +646,27 @@ func RetrieveClusters(ctx context.Context, pID string, pageSize int64, d TiDBClo return int64(len(items)), items, nil } -func RetrieveBranches(ctx context.Context, cID string, pageSize int64, d TiDBCloudClient) (int64, []*branchModel.V1beta1Branch, error) { - var items []*branchModel.V1beta1Branch +func RetrieveBranches(ctx context.Context, cID string, pageSize int64, d TiDBCloudClient) (int64, []branch.Branch, error) { + var items []branch.Branch pageSizeInt32 := int32(pageSize) - var pageToken string + var pageToken *string - params := branchApi.NewBranchServiceListBranchesParams().WithClusterID(cID).WithContext(ctx) - branches, err := d.ListBranches(params.WithPageSize(&pageSizeInt32)) + branches, err := d.ListBranches(ctx, cID, &pageSizeInt32, nil) if err != nil { return 0, nil, errors.Trace(err) } - items = append(items, branches.Payload.Branches...) + items = append(items, branches.Branches...) // loop to get all branches for { - pageToken = branches.Payload.NextPageToken - if pageToken == "" { + pageToken = branches.NextPageToken + if pageToken != nil && *pageToken == "" { break } - branches, err = d.ListBranches(params.WithPageSize(&pageSizeInt32).WithPageToken(&pageToken)) + branches, err = d.ListBranches(ctx, cID, &pageSizeInt32, pageToken) if err != nil { return 0, nil, errors.Trace(err) } - items = append(items, branches.Payload.Branches...) + items = append(items, branches.Branches...) } return int64(len(items)), items, nil } @@ -795,8 +793,8 @@ func GetSelectedParentID(ctx context.Context, cluster *Cluster, pageSize int64, }) for _, item := range branchItems { items = append(items, &Branch{ - ID: item.BranchID, - DisplayName: *item.DisplayName, + ID: *item.BranchId, + DisplayName: item.DisplayName, IsCluster: false, }) } diff --git a/pkg/tidbcloud/v1beta1/branch/branch.swagger.json b/pkg/tidbcloud/v1beta1/branch/branch.swagger.json deleted file mode 100644 index d1447b60..00000000 --- a/pkg/tidbcloud/v1beta1/branch/branch.swagger.json +++ /dev/null @@ -1,477 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "TiDB Cloud Serverless Open API", - "description": "TiDB Cloud Serverless Open API", - "version": "v1beta1" - }, - "tags": [ - { - "name": "BranchService" - } - ], - "host": "serverless.tidbapi.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "paths": { - "/v1beta1/clusters/{clusterId}/branches": { - "get": { - "summary": "Lists information about branches.", - "operationId": "BranchService_ListBranches", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/v1beta1ListBranchesResponse" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/rpcStatus" - } - } - }, - "parameters": [ - { - "name": "clusterId", - "description": "Required. The ID of the project to which the clusters belong.", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "pageSize", - "description": "Optional. Requested page size. Server may return fewer items than\nrequested. If unspecified, server will pick an appropriate default.", - "in": "query", - "required": false, - "type": "integer", - "format": "int32" - }, - { - "name": "pageToken", - "description": "Optional. A token identifying a page of results the server should return.", - "in": "query", - "required": false, - "type": "string" - } - ], - "tags": [ - "BranchService" - ] - }, - "post": { - "summary": "Creates a branch.", - "operationId": "BranchService_CreateBranch", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/v1beta1Branch" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/rpcStatus" - } - } - }, - "parameters": [ - { - "name": "clusterId", - "description": "Required. The cluster ID of the branch", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "branch", - "description": "Required. The resource being created", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/v1beta1Branch", - "required": [ - "branch" - ] - } - } - ], - "tags": [ - "BranchService" - ] - } - }, - "/v1beta1/clusters/{clusterId}/branches/{branchId}": { - "get": { - "summary": "Gets information about a branch.", - "operationId": "BranchService_GetBranch", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/v1beta1Branch" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/rpcStatus" - } - } - }, - "parameters": [ - { - "name": "clusterId", - "description": "Required. The cluster ID of the branch", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "branchId", - "description": "Required. The branch ID", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "view", - "description": "Optional. The view of the branch to return. Defaults to FULL\n\n - BRANCH_VIEW_UNSPECIFIED: BRANCH_VIEW_UNSPECIFIED Not specified, equivalent to BASIC.\n - BASIC: Basic response contains basic information for a branch.\n - FULL: FULL response contains all detailed information for a branch.", - "in": "query", - "required": false, - "type": "string", - "enum": [ - "BASIC", - "FULL" - ] - } - ], - "tags": [ - "BranchService" - ] - }, - "delete": { - "summary": "Deletes a branch.", - "operationId": "BranchService_DeleteBranch", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/v1beta1Branch" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/rpcStatus" - } - } - }, - "parameters": [ - { - "name": "clusterId", - "description": "Required. The cluster ID of the branch", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "branchId", - "description": "Required. The branch ID", - "in": "path", - "required": true, - "type": "string" - } - ], - "tags": [ - "BranchService" - ] - } - } - }, - "definitions": { - "BranchEndpoints": { - "type": "object", - "properties": { - "public": { - "$ref": "#/definitions/EndpointsPublic", - "x-nullable": true, - "description": "Optional . Public Endpoint for this branch." - }, - "private": { - "$ref": "#/definitions/EndpointsPrivate", - "x-nullable": true, - "description": "Optional . Private Endpoint for this branch." - } - }, - "description": "Message for the Endpoints for this branch." - }, - "BranchUsage": { - "type": "object", - "properties": { - "requestUnit": { - "type": "string", - "format": "int64", - "description": "Output Only. The latest value of Request Unit Metric for this cluster.", - "readOnly": true - }, - "rowStorage": { - "type": "number", - "format": "double", - "description": "Output Only. The latest value of Row Storage Metric for this cluster.", - "readOnly": true - }, - "columnarStorage": { - "type": "number", - "format": "double", - "description": "Output Only. The latest value of Columnar Storage Metric for this cluster.", - "readOnly": true - } - }, - "description": "Message for usage metrics for this cluster." - }, - "EndpointsPrivate": { - "type": "object", - "properties": { - "host": { - "type": "string", - "description": "Output Only. Host Name of Public Endpoint.", - "readOnly": true - }, - "port": { - "type": "integer", - "format": "int32", - "description": "Output Only. Port of Public Endpoint.", - "readOnly": true - }, - "aws": { - "$ref": "#/definitions/PrivateAWS", - "title": "Message for AWS", - "readOnly": true - }, - "gcp": { - "$ref": "#/definitions/PrivateGCP", - "title": "Message for GCP", - "readOnly": true - } - }, - "description": "Message for Private Endpoint for this branch." - }, - "EndpointsPublic": { - "type": "object", - "properties": { - "host": { - "type": "string", - "title": "Output Only. Host name of Public Endpoint", - "readOnly": true - }, - "port": { - "type": "integer", - "format": "int32", - "title": "Output Only. Port of Public Endpoint", - "readOnly": true - }, - "disabled": { - "type": "boolean", - "title": "Output, Disable Public Endpoint" - } - }, - "description": "Message for Public Endpoint for this branch." - }, - "PrivateAWS": { - "type": "object", - "properties": { - "serviceName": { - "type": "string", - "title": "Output Only. Service Name for Private Link Service.\n(-- api-linter: core::0122::name-suffix=disabled --)", - "readOnly": true - }, - "availabilityZone": { - "type": "array", - "items": { - "type": "string" - }, - "description": "Output Only. Availability Zone for Private Link Service.", - "readOnly": true - } - }, - "description": "Message for AWS Private Link Service." - }, - "PrivateGCP": { - "type": "object", - "properties": { - "serviceAttachmentName": { - "type": "string", - "description": "Output Only. Target Service Account for Private Link Service.", - "readOnly": true - } - }, - "description": "Message for GCP Private Link Service." - }, - "protobufAny": { - "type": "object", - "properties": { - "@type": { - "type": "string" - } - }, - "additionalProperties": {} - }, - "rpcStatus": { - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - }, - "details": { - "type": "array", - "items": { - "type": "object", - "$ref": "#/definitions/protobufAny" - } - } - } - }, - "v1beta1Branch": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "Output Only. The name of the resource.", - "readOnly": true - }, - "branchId": { - "type": "string", - "description": "Output only. The system-generated ID of the resource.", - "readOnly": true - }, - "displayName": { - "type": "string", - "description": "Required. User-settable and human-readable display name for the branch." - }, - "clusterId": { - "type": "string", - "description": "Output only. The cluster ID of this branch.", - "readOnly": true - }, - "parentId": { - "type": "string", - "description": "OPTIONAL. The parent ID of this branch." - }, - "createdBy": { - "type": "string", - "description": "Output only. The creator of the branch.", - "readOnly": true - }, - "state": { - "$ref": "#/definitions/v1beta1BranchState", - "description": "Output only. The state of this branch.", - "readOnly": true - }, - "endpoints": { - "$ref": "#/definitions/BranchEndpoints", - "x-nullable": true, - "description": "Optional. The endpoints of this branch." - }, - "userPrefix": { - "type": "string", - "x-nullable": true, - "description": "Output only. User name prefix of this branch. For each TiDB Serverless branch,\nTiDB Cloud generates a unique prefix to distinguish it from other branches.\nWhenever you use or set a database user name, you must include the prefix in the user name.", - "readOnly": true - }, - "usage": { - "$ref": "#/definitions/BranchUsage", - "x-nullable": true, - "description": "OPTIONAL. Usage metrics of this branch. Only display in FULL view." - }, - "createTime": { - "type": "string", - "format": "date-time", - "title": "Output only. Create timestamp", - "readOnly": true - }, - "updateTime": { - "type": "string", - "format": "date-time", - "title": "Output only. Update timestamp", - "readOnly": true - }, - "annotations": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "Optional. The annotations of this branch. Only display in FULL view." - }, - "parentDisplayName": { - "type": "string", - "description": "OPTIONAL. The parent display name of this branch." - }, - "parentTimestamp": { - "type": "string", - "format": "date-time", - "x-nullable": true, - "description": "Optional. The point in time on the parent branch the branch will be created from." - } - }, - "title": "Message for branch", - "required": [ - "displayName" - ] - }, - "v1beta1BranchState": { - "type": "string", - "enum": [ - "CREATING", - "ACTIVE", - "DELETED", - "MAINTENANCE" - ], - "description": "Output Only. Branch State.\n\n - STATE_UNSPECIFIED: The state of the branch is unknown.\n - CREATING: The branch is being created.\n - ACTIVE: The branch is active and running.\n - DELETED: The branch is being deleted.\n - MAINTENANCE: The branch is under maintenance." - }, - "v1beta1BranchView": { - "type": "string", - "enum": [ - "BASIC", - "FULL" - ], - "description": "View on branch. Pass this enum to control which subsets of fields to get.\n\n - BRANCH_VIEW_UNSPECIFIED: BRANCH_VIEW_UNSPECIFIED Not specified, equivalent to BASIC.\n - BASIC: Basic response contains basic information for a branch.\n - FULL: FULL response contains all detailed information for a branch." - }, - "v1beta1ListBranchesResponse": { - "type": "object", - "properties": { - "branches": { - "type": "array", - "items": { - "type": "object", - "$ref": "#/definitions/v1beta1Branch" - }, - "title": "The list of branches" - }, - "nextPageToken": { - "type": "string", - "description": "A token identifying a page of results the server should return." - }, - "totalSize": { - "type": "integer", - "format": "int64", - "title": "Total number of branches" - } - }, - "title": "Message for response to list branches" - } - } -} diff --git a/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_client.go b/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_client.go deleted file mode 100644 index d1e7a365..00000000 --- a/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_client.go +++ /dev/null @@ -1,219 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package branch_service - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "github.com/go-openapi/runtime" - httptransport "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// New creates a new branch service API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { - return &Client{transport: transport, formats: formats} -} - -// New creates a new branch service API client with basic auth credentials. -// It takes the following parameters: -// - host: http host (github.com). -// - basePath: any base path for the API client ("/v1", "/v3"). -// - scheme: http scheme ("http", "https"). -// - user: user for basic authentication header. -// - password: password for basic authentication header. -func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { - transport := httptransport.New(host, basePath, []string{scheme}) - transport.DefaultAuthentication = httptransport.BasicAuth(user, password) - return &Client{transport: transport, formats: strfmt.Default} -} - -// New creates a new branch service API client with a bearer token for authentication. -// It takes the following parameters: -// - host: http host (github.com). -// - basePath: any base path for the API client ("/v1", "/v3"). -// - scheme: http scheme ("http", "https"). -// - bearerToken: bearer token for Bearer authentication header. -func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { - transport := httptransport.New(host, basePath, []string{scheme}) - transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) - return &Client{transport: transport, formats: strfmt.Default} -} - -/* -Client for branch service API -*/ -type Client struct { - transport runtime.ClientTransport - formats strfmt.Registry -} - -// ClientOption may be used to customize the behavior of Client methods. -type ClientOption func(*runtime.ClientOperation) - -// ClientService is the interface for Client methods -type ClientService interface { - BranchServiceCreateBranch(params *BranchServiceCreateBranchParams, opts ...ClientOption) (*BranchServiceCreateBranchOK, error) - - BranchServiceDeleteBranch(params *BranchServiceDeleteBranchParams, opts ...ClientOption) (*BranchServiceDeleteBranchOK, error) - - BranchServiceGetBranch(params *BranchServiceGetBranchParams, opts ...ClientOption) (*BranchServiceGetBranchOK, error) - - BranchServiceListBranches(params *BranchServiceListBranchesParams, opts ...ClientOption) (*BranchServiceListBranchesOK, error) - - SetTransport(transport runtime.ClientTransport) -} - -/* -BranchServiceCreateBranch creates a branch -*/ -func (a *Client) BranchServiceCreateBranch(params *BranchServiceCreateBranchParams, opts ...ClientOption) (*BranchServiceCreateBranchOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewBranchServiceCreateBranchParams() - } - op := &runtime.ClientOperation{ - ID: "BranchService_CreateBranch", - Method: "POST", - PathPattern: "/v1beta1/clusters/{clusterId}/branches", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &BranchServiceCreateBranchReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*BranchServiceCreateBranchOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*BranchServiceCreateBranchDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) -} - -/* -BranchServiceDeleteBranch deletes a branch -*/ -func (a *Client) BranchServiceDeleteBranch(params *BranchServiceDeleteBranchParams, opts ...ClientOption) (*BranchServiceDeleteBranchOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewBranchServiceDeleteBranchParams() - } - op := &runtime.ClientOperation{ - ID: "BranchService_DeleteBranch", - Method: "DELETE", - PathPattern: "/v1beta1/clusters/{clusterId}/branches/{branchId}", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &BranchServiceDeleteBranchReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*BranchServiceDeleteBranchOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*BranchServiceDeleteBranchDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) -} - -/* -BranchServiceGetBranch gets information about a branch -*/ -func (a *Client) BranchServiceGetBranch(params *BranchServiceGetBranchParams, opts ...ClientOption) (*BranchServiceGetBranchOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewBranchServiceGetBranchParams() - } - op := &runtime.ClientOperation{ - ID: "BranchService_GetBranch", - Method: "GET", - PathPattern: "/v1beta1/clusters/{clusterId}/branches/{branchId}", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &BranchServiceGetBranchReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*BranchServiceGetBranchOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*BranchServiceGetBranchDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) -} - -/* -BranchServiceListBranches lists information about branches -*/ -func (a *Client) BranchServiceListBranches(params *BranchServiceListBranchesParams, opts ...ClientOption) (*BranchServiceListBranchesOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewBranchServiceListBranchesParams() - } - op := &runtime.ClientOperation{ - ID: "BranchService_ListBranches", - Method: "GET", - PathPattern: "/v1beta1/clusters/{clusterId}/branches", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &BranchServiceListBranchesReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*BranchServiceListBranchesOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*BranchServiceListBranchesDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) -} - -// SetTransport changes the transport on the client -func (a *Client) SetTransport(transport runtime.ClientTransport) { - a.transport = transport -} diff --git a/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_create_branch_parameters.go b/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_create_branch_parameters.go deleted file mode 100644 index 66f6be09..00000000 --- a/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_create_branch_parameters.go +++ /dev/null @@ -1,175 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package branch_service - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" - - "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/models" -) - -// NewBranchServiceCreateBranchParams creates a new BranchServiceCreateBranchParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewBranchServiceCreateBranchParams() *BranchServiceCreateBranchParams { - return &BranchServiceCreateBranchParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewBranchServiceCreateBranchParamsWithTimeout creates a new BranchServiceCreateBranchParams object -// with the ability to set a timeout on a request. -func NewBranchServiceCreateBranchParamsWithTimeout(timeout time.Duration) *BranchServiceCreateBranchParams { - return &BranchServiceCreateBranchParams{ - timeout: timeout, - } -} - -// NewBranchServiceCreateBranchParamsWithContext creates a new BranchServiceCreateBranchParams object -// with the ability to set a context for a request. -func NewBranchServiceCreateBranchParamsWithContext(ctx context.Context) *BranchServiceCreateBranchParams { - return &BranchServiceCreateBranchParams{ - Context: ctx, - } -} - -// NewBranchServiceCreateBranchParamsWithHTTPClient creates a new BranchServiceCreateBranchParams object -// with the ability to set a custom HTTPClient for a request. -func NewBranchServiceCreateBranchParamsWithHTTPClient(client *http.Client) *BranchServiceCreateBranchParams { - return &BranchServiceCreateBranchParams{ - HTTPClient: client, - } -} - -/* -BranchServiceCreateBranchParams contains all the parameters to send to the API endpoint - - for the branch service create branch operation. - - Typically these are written to a http.Request. -*/ -type BranchServiceCreateBranchParams struct { - - /* Branch. - - Required. The resource being created - */ - Branch *models.V1beta1Branch - - /* ClusterID. - - Required. The cluster ID of the branch - */ - ClusterID string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the branch service create branch params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *BranchServiceCreateBranchParams) WithDefaults() *BranchServiceCreateBranchParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the branch service create branch params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *BranchServiceCreateBranchParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the branch service create branch params -func (o *BranchServiceCreateBranchParams) WithTimeout(timeout time.Duration) *BranchServiceCreateBranchParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the branch service create branch params -func (o *BranchServiceCreateBranchParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the branch service create branch params -func (o *BranchServiceCreateBranchParams) WithContext(ctx context.Context) *BranchServiceCreateBranchParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the branch service create branch params -func (o *BranchServiceCreateBranchParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the branch service create branch params -func (o *BranchServiceCreateBranchParams) WithHTTPClient(client *http.Client) *BranchServiceCreateBranchParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the branch service create branch params -func (o *BranchServiceCreateBranchParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithBranch adds the branch to the branch service create branch params -func (o *BranchServiceCreateBranchParams) WithBranch(branch *models.V1beta1Branch) *BranchServiceCreateBranchParams { - o.SetBranch(branch) - return o -} - -// SetBranch adds the branch to the branch service create branch params -func (o *BranchServiceCreateBranchParams) SetBranch(branch *models.V1beta1Branch) { - o.Branch = branch -} - -// WithClusterID adds the clusterID to the branch service create branch params -func (o *BranchServiceCreateBranchParams) WithClusterID(clusterID string) *BranchServiceCreateBranchParams { - o.SetClusterID(clusterID) - return o -} - -// SetClusterID adds the clusterId to the branch service create branch params -func (o *BranchServiceCreateBranchParams) SetClusterID(clusterID string) { - o.ClusterID = clusterID -} - -// WriteToRequest writes these params to a swagger request -func (o *BranchServiceCreateBranchParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - if o.Branch != nil { - if err := r.SetBodyParam(o.Branch); err != nil { - return err - } - } - - // path param clusterId - if err := r.SetPathParam("clusterId", o.ClusterID); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_create_branch_responses.go b/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_create_branch_responses.go deleted file mode 100644 index eeb63724..00000000 --- a/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_create_branch_responses.go +++ /dev/null @@ -1,187 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package branch_service - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "encoding/json" - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/models" -) - -// BranchServiceCreateBranchReader is a Reader for the BranchServiceCreateBranch structure. -type BranchServiceCreateBranchReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *BranchServiceCreateBranchReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewBranchServiceCreateBranchOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - default: - result := NewBranchServiceCreateBranchDefault(response.Code()) - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - if response.Code()/100 == 2 { - return result, nil - } - return nil, result - } -} - -// NewBranchServiceCreateBranchOK creates a BranchServiceCreateBranchOK with default headers values -func NewBranchServiceCreateBranchOK() *BranchServiceCreateBranchOK { - return &BranchServiceCreateBranchOK{} -} - -/* -BranchServiceCreateBranchOK describes a response with status code 200, with default header values. - -A successful response. -*/ -type BranchServiceCreateBranchOK struct { - Payload *models.V1beta1Branch -} - -// IsSuccess returns true when this branch service create branch o k response has a 2xx status code -func (o *BranchServiceCreateBranchOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this branch service create branch o k response has a 3xx status code -func (o *BranchServiceCreateBranchOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this branch service create branch o k response has a 4xx status code -func (o *BranchServiceCreateBranchOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this branch service create branch o k response has a 5xx status code -func (o *BranchServiceCreateBranchOK) IsServerError() bool { - return false -} - -// IsCode returns true when this branch service create branch o k response a status code equal to that given -func (o *BranchServiceCreateBranchOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the branch service create branch o k response -func (o *BranchServiceCreateBranchOK) Code() int { - return 200 -} - -func (o *BranchServiceCreateBranchOK) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[POST /v1beta1/clusters/{clusterId}/branches][%d] branchServiceCreateBranchOK %s", 200, payload) -} - -func (o *BranchServiceCreateBranchOK) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[POST /v1beta1/clusters/{clusterId}/branches][%d] branchServiceCreateBranchOK %s", 200, payload) -} - -func (o *BranchServiceCreateBranchOK) GetPayload() *models.V1beta1Branch { - return o.Payload -} - -func (o *BranchServiceCreateBranchOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.V1beta1Branch) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewBranchServiceCreateBranchDefault creates a BranchServiceCreateBranchDefault with default headers values -func NewBranchServiceCreateBranchDefault(code int) *BranchServiceCreateBranchDefault { - return &BranchServiceCreateBranchDefault{ - _statusCode: code, - } -} - -/* -BranchServiceCreateBranchDefault describes a response with status code -1, with default header values. - -An unexpected error response. -*/ -type BranchServiceCreateBranchDefault struct { - _statusCode int - - Payload *models.RPCStatus -} - -// IsSuccess returns true when this branch service create branch default response has a 2xx status code -func (o *BranchServiceCreateBranchDefault) IsSuccess() bool { - return o._statusCode/100 == 2 -} - -// IsRedirect returns true when this branch service create branch default response has a 3xx status code -func (o *BranchServiceCreateBranchDefault) IsRedirect() bool { - return o._statusCode/100 == 3 -} - -// IsClientError returns true when this branch service create branch default response has a 4xx status code -func (o *BranchServiceCreateBranchDefault) IsClientError() bool { - return o._statusCode/100 == 4 -} - -// IsServerError returns true when this branch service create branch default response has a 5xx status code -func (o *BranchServiceCreateBranchDefault) IsServerError() bool { - return o._statusCode/100 == 5 -} - -// IsCode returns true when this branch service create branch default response a status code equal to that given -func (o *BranchServiceCreateBranchDefault) IsCode(code int) bool { - return o._statusCode == code -} - -// Code gets the status code for the branch service create branch default response -func (o *BranchServiceCreateBranchDefault) Code() int { - return o._statusCode -} - -func (o *BranchServiceCreateBranchDefault) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[POST /v1beta1/clusters/{clusterId}/branches][%d] BranchService_CreateBranch default %s", o._statusCode, payload) -} - -func (o *BranchServiceCreateBranchDefault) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[POST /v1beta1/clusters/{clusterId}/branches][%d] BranchService_CreateBranch default %s", o._statusCode, payload) -} - -func (o *BranchServiceCreateBranchDefault) GetPayload() *models.RPCStatus { - return o.Payload -} - -func (o *BranchServiceCreateBranchDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.RPCStatus) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_delete_branch_parameters.go b/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_delete_branch_parameters.go deleted file mode 100644 index ee441fc1..00000000 --- a/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_delete_branch_parameters.go +++ /dev/null @@ -1,173 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package branch_service - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewBranchServiceDeleteBranchParams creates a new BranchServiceDeleteBranchParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewBranchServiceDeleteBranchParams() *BranchServiceDeleteBranchParams { - return &BranchServiceDeleteBranchParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewBranchServiceDeleteBranchParamsWithTimeout creates a new BranchServiceDeleteBranchParams object -// with the ability to set a timeout on a request. -func NewBranchServiceDeleteBranchParamsWithTimeout(timeout time.Duration) *BranchServiceDeleteBranchParams { - return &BranchServiceDeleteBranchParams{ - timeout: timeout, - } -} - -// NewBranchServiceDeleteBranchParamsWithContext creates a new BranchServiceDeleteBranchParams object -// with the ability to set a context for a request. -func NewBranchServiceDeleteBranchParamsWithContext(ctx context.Context) *BranchServiceDeleteBranchParams { - return &BranchServiceDeleteBranchParams{ - Context: ctx, - } -} - -// NewBranchServiceDeleteBranchParamsWithHTTPClient creates a new BranchServiceDeleteBranchParams object -// with the ability to set a custom HTTPClient for a request. -func NewBranchServiceDeleteBranchParamsWithHTTPClient(client *http.Client) *BranchServiceDeleteBranchParams { - return &BranchServiceDeleteBranchParams{ - HTTPClient: client, - } -} - -/* -BranchServiceDeleteBranchParams contains all the parameters to send to the API endpoint - - for the branch service delete branch operation. - - Typically these are written to a http.Request. -*/ -type BranchServiceDeleteBranchParams struct { - - /* BranchID. - - Required. The branch ID - */ - BranchID string - - /* ClusterID. - - Required. The cluster ID of the branch - */ - ClusterID string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the branch service delete branch params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *BranchServiceDeleteBranchParams) WithDefaults() *BranchServiceDeleteBranchParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the branch service delete branch params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *BranchServiceDeleteBranchParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the branch service delete branch params -func (o *BranchServiceDeleteBranchParams) WithTimeout(timeout time.Duration) *BranchServiceDeleteBranchParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the branch service delete branch params -func (o *BranchServiceDeleteBranchParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the branch service delete branch params -func (o *BranchServiceDeleteBranchParams) WithContext(ctx context.Context) *BranchServiceDeleteBranchParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the branch service delete branch params -func (o *BranchServiceDeleteBranchParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the branch service delete branch params -func (o *BranchServiceDeleteBranchParams) WithHTTPClient(client *http.Client) *BranchServiceDeleteBranchParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the branch service delete branch params -func (o *BranchServiceDeleteBranchParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithBranchID adds the branchID to the branch service delete branch params -func (o *BranchServiceDeleteBranchParams) WithBranchID(branchID string) *BranchServiceDeleteBranchParams { - o.SetBranchID(branchID) - return o -} - -// SetBranchID adds the branchId to the branch service delete branch params -func (o *BranchServiceDeleteBranchParams) SetBranchID(branchID string) { - o.BranchID = branchID -} - -// WithClusterID adds the clusterID to the branch service delete branch params -func (o *BranchServiceDeleteBranchParams) WithClusterID(clusterID string) *BranchServiceDeleteBranchParams { - o.SetClusterID(clusterID) - return o -} - -// SetClusterID adds the clusterId to the branch service delete branch params -func (o *BranchServiceDeleteBranchParams) SetClusterID(clusterID string) { - o.ClusterID = clusterID -} - -// WriteToRequest writes these params to a swagger request -func (o *BranchServiceDeleteBranchParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - // path param branchId - if err := r.SetPathParam("branchId", o.BranchID); err != nil { - return err - } - - // path param clusterId - if err := r.SetPathParam("clusterId", o.ClusterID); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_delete_branch_responses.go b/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_delete_branch_responses.go deleted file mode 100644 index 17cc35d5..00000000 --- a/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_delete_branch_responses.go +++ /dev/null @@ -1,187 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package branch_service - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "encoding/json" - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/models" -) - -// BranchServiceDeleteBranchReader is a Reader for the BranchServiceDeleteBranch structure. -type BranchServiceDeleteBranchReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *BranchServiceDeleteBranchReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewBranchServiceDeleteBranchOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - default: - result := NewBranchServiceDeleteBranchDefault(response.Code()) - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - if response.Code()/100 == 2 { - return result, nil - } - return nil, result - } -} - -// NewBranchServiceDeleteBranchOK creates a BranchServiceDeleteBranchOK with default headers values -func NewBranchServiceDeleteBranchOK() *BranchServiceDeleteBranchOK { - return &BranchServiceDeleteBranchOK{} -} - -/* -BranchServiceDeleteBranchOK describes a response with status code 200, with default header values. - -A successful response. -*/ -type BranchServiceDeleteBranchOK struct { - Payload *models.V1beta1Branch -} - -// IsSuccess returns true when this branch service delete branch o k response has a 2xx status code -func (o *BranchServiceDeleteBranchOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this branch service delete branch o k response has a 3xx status code -func (o *BranchServiceDeleteBranchOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this branch service delete branch o k response has a 4xx status code -func (o *BranchServiceDeleteBranchOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this branch service delete branch o k response has a 5xx status code -func (o *BranchServiceDeleteBranchOK) IsServerError() bool { - return false -} - -// IsCode returns true when this branch service delete branch o k response a status code equal to that given -func (o *BranchServiceDeleteBranchOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the branch service delete branch o k response -func (o *BranchServiceDeleteBranchOK) Code() int { - return 200 -} - -func (o *BranchServiceDeleteBranchOK) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[DELETE /v1beta1/clusters/{clusterId}/branches/{branchId}][%d] branchServiceDeleteBranchOK %s", 200, payload) -} - -func (o *BranchServiceDeleteBranchOK) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[DELETE /v1beta1/clusters/{clusterId}/branches/{branchId}][%d] branchServiceDeleteBranchOK %s", 200, payload) -} - -func (o *BranchServiceDeleteBranchOK) GetPayload() *models.V1beta1Branch { - return o.Payload -} - -func (o *BranchServiceDeleteBranchOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.V1beta1Branch) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewBranchServiceDeleteBranchDefault creates a BranchServiceDeleteBranchDefault with default headers values -func NewBranchServiceDeleteBranchDefault(code int) *BranchServiceDeleteBranchDefault { - return &BranchServiceDeleteBranchDefault{ - _statusCode: code, - } -} - -/* -BranchServiceDeleteBranchDefault describes a response with status code -1, with default header values. - -An unexpected error response. -*/ -type BranchServiceDeleteBranchDefault struct { - _statusCode int - - Payload *models.RPCStatus -} - -// IsSuccess returns true when this branch service delete branch default response has a 2xx status code -func (o *BranchServiceDeleteBranchDefault) IsSuccess() bool { - return o._statusCode/100 == 2 -} - -// IsRedirect returns true when this branch service delete branch default response has a 3xx status code -func (o *BranchServiceDeleteBranchDefault) IsRedirect() bool { - return o._statusCode/100 == 3 -} - -// IsClientError returns true when this branch service delete branch default response has a 4xx status code -func (o *BranchServiceDeleteBranchDefault) IsClientError() bool { - return o._statusCode/100 == 4 -} - -// IsServerError returns true when this branch service delete branch default response has a 5xx status code -func (o *BranchServiceDeleteBranchDefault) IsServerError() bool { - return o._statusCode/100 == 5 -} - -// IsCode returns true when this branch service delete branch default response a status code equal to that given -func (o *BranchServiceDeleteBranchDefault) IsCode(code int) bool { - return o._statusCode == code -} - -// Code gets the status code for the branch service delete branch default response -func (o *BranchServiceDeleteBranchDefault) Code() int { - return o._statusCode -} - -func (o *BranchServiceDeleteBranchDefault) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[DELETE /v1beta1/clusters/{clusterId}/branches/{branchId}][%d] BranchService_DeleteBranch default %s", o._statusCode, payload) -} - -func (o *BranchServiceDeleteBranchDefault) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[DELETE /v1beta1/clusters/{clusterId}/branches/{branchId}][%d] BranchService_DeleteBranch default %s", o._statusCode, payload) -} - -func (o *BranchServiceDeleteBranchDefault) GetPayload() *models.RPCStatus { - return o.Payload -} - -func (o *BranchServiceDeleteBranchDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.RPCStatus) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_get_branch_parameters.go b/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_get_branch_parameters.go deleted file mode 100644 index 3c6d5729..00000000 --- a/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_get_branch_parameters.go +++ /dev/null @@ -1,211 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package branch_service - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewBranchServiceGetBranchParams creates a new BranchServiceGetBranchParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewBranchServiceGetBranchParams() *BranchServiceGetBranchParams { - return &BranchServiceGetBranchParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewBranchServiceGetBranchParamsWithTimeout creates a new BranchServiceGetBranchParams object -// with the ability to set a timeout on a request. -func NewBranchServiceGetBranchParamsWithTimeout(timeout time.Duration) *BranchServiceGetBranchParams { - return &BranchServiceGetBranchParams{ - timeout: timeout, - } -} - -// NewBranchServiceGetBranchParamsWithContext creates a new BranchServiceGetBranchParams object -// with the ability to set a context for a request. -func NewBranchServiceGetBranchParamsWithContext(ctx context.Context) *BranchServiceGetBranchParams { - return &BranchServiceGetBranchParams{ - Context: ctx, - } -} - -// NewBranchServiceGetBranchParamsWithHTTPClient creates a new BranchServiceGetBranchParams object -// with the ability to set a custom HTTPClient for a request. -func NewBranchServiceGetBranchParamsWithHTTPClient(client *http.Client) *BranchServiceGetBranchParams { - return &BranchServiceGetBranchParams{ - HTTPClient: client, - } -} - -/* -BranchServiceGetBranchParams contains all the parameters to send to the API endpoint - - for the branch service get branch operation. - - Typically these are written to a http.Request. -*/ -type BranchServiceGetBranchParams struct { - - /* BranchID. - - Required. The branch ID - */ - BranchID string - - /* ClusterID. - - Required. The cluster ID of the branch - */ - ClusterID string - - /* View. - - Optional. The view of the branch to return. Defaults to FULL - - - BRANCH_VIEW_UNSPECIFIED: BRANCH_VIEW_UNSPECIFIED Not specified, equivalent to BASIC. - - BASIC: Basic response contains basic information for a branch. - - FULL: FULL response contains all detailed information for a branch. - */ - View *string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the branch service get branch params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *BranchServiceGetBranchParams) WithDefaults() *BranchServiceGetBranchParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the branch service get branch params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *BranchServiceGetBranchParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the branch service get branch params -func (o *BranchServiceGetBranchParams) WithTimeout(timeout time.Duration) *BranchServiceGetBranchParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the branch service get branch params -func (o *BranchServiceGetBranchParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the branch service get branch params -func (o *BranchServiceGetBranchParams) WithContext(ctx context.Context) *BranchServiceGetBranchParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the branch service get branch params -func (o *BranchServiceGetBranchParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the branch service get branch params -func (o *BranchServiceGetBranchParams) WithHTTPClient(client *http.Client) *BranchServiceGetBranchParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the branch service get branch params -func (o *BranchServiceGetBranchParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithBranchID adds the branchID to the branch service get branch params -func (o *BranchServiceGetBranchParams) WithBranchID(branchID string) *BranchServiceGetBranchParams { - o.SetBranchID(branchID) - return o -} - -// SetBranchID adds the branchId to the branch service get branch params -func (o *BranchServiceGetBranchParams) SetBranchID(branchID string) { - o.BranchID = branchID -} - -// WithClusterID adds the clusterID to the branch service get branch params -func (o *BranchServiceGetBranchParams) WithClusterID(clusterID string) *BranchServiceGetBranchParams { - o.SetClusterID(clusterID) - return o -} - -// SetClusterID adds the clusterId to the branch service get branch params -func (o *BranchServiceGetBranchParams) SetClusterID(clusterID string) { - o.ClusterID = clusterID -} - -// WithView adds the view to the branch service get branch params -func (o *BranchServiceGetBranchParams) WithView(view *string) *BranchServiceGetBranchParams { - o.SetView(view) - return o -} - -// SetView adds the view to the branch service get branch params -func (o *BranchServiceGetBranchParams) SetView(view *string) { - o.View = view -} - -// WriteToRequest writes these params to a swagger request -func (o *BranchServiceGetBranchParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - // path param branchId - if err := r.SetPathParam("branchId", o.BranchID); err != nil { - return err - } - - // path param clusterId - if err := r.SetPathParam("clusterId", o.ClusterID); err != nil { - return err - } - - if o.View != nil { - - // query param view - var qrView string - - if o.View != nil { - qrView = *o.View - } - qView := qrView - if qView != "" { - - if err := r.SetQueryParam("view", qView); err != nil { - return err - } - } - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_get_branch_responses.go b/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_get_branch_responses.go deleted file mode 100644 index c21d4854..00000000 --- a/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_get_branch_responses.go +++ /dev/null @@ -1,187 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package branch_service - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "encoding/json" - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/models" -) - -// BranchServiceGetBranchReader is a Reader for the BranchServiceGetBranch structure. -type BranchServiceGetBranchReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *BranchServiceGetBranchReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewBranchServiceGetBranchOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - default: - result := NewBranchServiceGetBranchDefault(response.Code()) - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - if response.Code()/100 == 2 { - return result, nil - } - return nil, result - } -} - -// NewBranchServiceGetBranchOK creates a BranchServiceGetBranchOK with default headers values -func NewBranchServiceGetBranchOK() *BranchServiceGetBranchOK { - return &BranchServiceGetBranchOK{} -} - -/* -BranchServiceGetBranchOK describes a response with status code 200, with default header values. - -A successful response. -*/ -type BranchServiceGetBranchOK struct { - Payload *models.V1beta1Branch -} - -// IsSuccess returns true when this branch service get branch o k response has a 2xx status code -func (o *BranchServiceGetBranchOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this branch service get branch o k response has a 3xx status code -func (o *BranchServiceGetBranchOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this branch service get branch o k response has a 4xx status code -func (o *BranchServiceGetBranchOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this branch service get branch o k response has a 5xx status code -func (o *BranchServiceGetBranchOK) IsServerError() bool { - return false -} - -// IsCode returns true when this branch service get branch o k response a status code equal to that given -func (o *BranchServiceGetBranchOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the branch service get branch o k response -func (o *BranchServiceGetBranchOK) Code() int { - return 200 -} - -func (o *BranchServiceGetBranchOK) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /v1beta1/clusters/{clusterId}/branches/{branchId}][%d] branchServiceGetBranchOK %s", 200, payload) -} - -func (o *BranchServiceGetBranchOK) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /v1beta1/clusters/{clusterId}/branches/{branchId}][%d] branchServiceGetBranchOK %s", 200, payload) -} - -func (o *BranchServiceGetBranchOK) GetPayload() *models.V1beta1Branch { - return o.Payload -} - -func (o *BranchServiceGetBranchOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.V1beta1Branch) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewBranchServiceGetBranchDefault creates a BranchServiceGetBranchDefault with default headers values -func NewBranchServiceGetBranchDefault(code int) *BranchServiceGetBranchDefault { - return &BranchServiceGetBranchDefault{ - _statusCode: code, - } -} - -/* -BranchServiceGetBranchDefault describes a response with status code -1, with default header values. - -An unexpected error response. -*/ -type BranchServiceGetBranchDefault struct { - _statusCode int - - Payload *models.RPCStatus -} - -// IsSuccess returns true when this branch service get branch default response has a 2xx status code -func (o *BranchServiceGetBranchDefault) IsSuccess() bool { - return o._statusCode/100 == 2 -} - -// IsRedirect returns true when this branch service get branch default response has a 3xx status code -func (o *BranchServiceGetBranchDefault) IsRedirect() bool { - return o._statusCode/100 == 3 -} - -// IsClientError returns true when this branch service get branch default response has a 4xx status code -func (o *BranchServiceGetBranchDefault) IsClientError() bool { - return o._statusCode/100 == 4 -} - -// IsServerError returns true when this branch service get branch default response has a 5xx status code -func (o *BranchServiceGetBranchDefault) IsServerError() bool { - return o._statusCode/100 == 5 -} - -// IsCode returns true when this branch service get branch default response a status code equal to that given -func (o *BranchServiceGetBranchDefault) IsCode(code int) bool { - return o._statusCode == code -} - -// Code gets the status code for the branch service get branch default response -func (o *BranchServiceGetBranchDefault) Code() int { - return o._statusCode -} - -func (o *BranchServiceGetBranchDefault) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /v1beta1/clusters/{clusterId}/branches/{branchId}][%d] BranchService_GetBranch default %s", o._statusCode, payload) -} - -func (o *BranchServiceGetBranchDefault) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /v1beta1/clusters/{clusterId}/branches/{branchId}][%d] BranchService_GetBranch default %s", o._statusCode, payload) -} - -func (o *BranchServiceGetBranchDefault) GetPayload() *models.RPCStatus { - return o.Payload -} - -func (o *BranchServiceGetBranchDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.RPCStatus) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_list_branches_parameters.go b/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_list_branches_parameters.go deleted file mode 100644 index 3d62130c..00000000 --- a/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_list_branches_parameters.go +++ /dev/null @@ -1,223 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package branch_service - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// NewBranchServiceListBranchesParams creates a new BranchServiceListBranchesParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewBranchServiceListBranchesParams() *BranchServiceListBranchesParams { - return &BranchServiceListBranchesParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewBranchServiceListBranchesParamsWithTimeout creates a new BranchServiceListBranchesParams object -// with the ability to set a timeout on a request. -func NewBranchServiceListBranchesParamsWithTimeout(timeout time.Duration) *BranchServiceListBranchesParams { - return &BranchServiceListBranchesParams{ - timeout: timeout, - } -} - -// NewBranchServiceListBranchesParamsWithContext creates a new BranchServiceListBranchesParams object -// with the ability to set a context for a request. -func NewBranchServiceListBranchesParamsWithContext(ctx context.Context) *BranchServiceListBranchesParams { - return &BranchServiceListBranchesParams{ - Context: ctx, - } -} - -// NewBranchServiceListBranchesParamsWithHTTPClient creates a new BranchServiceListBranchesParams object -// with the ability to set a custom HTTPClient for a request. -func NewBranchServiceListBranchesParamsWithHTTPClient(client *http.Client) *BranchServiceListBranchesParams { - return &BranchServiceListBranchesParams{ - HTTPClient: client, - } -} - -/* -BranchServiceListBranchesParams contains all the parameters to send to the API endpoint - - for the branch service list branches operation. - - Typically these are written to a http.Request. -*/ -type BranchServiceListBranchesParams struct { - - /* ClusterID. - - Required. The ID of the project to which the clusters belong. - */ - ClusterID string - - /* PageSize. - - Optional. Requested page size. Server may return fewer items than - requested. If unspecified, server will pick an appropriate default. - - Format: int32 - */ - PageSize *int32 - - /* PageToken. - - Optional. A token identifying a page of results the server should return. - */ - PageToken *string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the branch service list branches params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *BranchServiceListBranchesParams) WithDefaults() *BranchServiceListBranchesParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the branch service list branches params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *BranchServiceListBranchesParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the branch service list branches params -func (o *BranchServiceListBranchesParams) WithTimeout(timeout time.Duration) *BranchServiceListBranchesParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the branch service list branches params -func (o *BranchServiceListBranchesParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the branch service list branches params -func (o *BranchServiceListBranchesParams) WithContext(ctx context.Context) *BranchServiceListBranchesParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the branch service list branches params -func (o *BranchServiceListBranchesParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the branch service list branches params -func (o *BranchServiceListBranchesParams) WithHTTPClient(client *http.Client) *BranchServiceListBranchesParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the branch service list branches params -func (o *BranchServiceListBranchesParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithClusterID adds the clusterID to the branch service list branches params -func (o *BranchServiceListBranchesParams) WithClusterID(clusterID string) *BranchServiceListBranchesParams { - o.SetClusterID(clusterID) - return o -} - -// SetClusterID adds the clusterId to the branch service list branches params -func (o *BranchServiceListBranchesParams) SetClusterID(clusterID string) { - o.ClusterID = clusterID -} - -// WithPageSize adds the pageSize to the branch service list branches params -func (o *BranchServiceListBranchesParams) WithPageSize(pageSize *int32) *BranchServiceListBranchesParams { - o.SetPageSize(pageSize) - return o -} - -// SetPageSize adds the pageSize to the branch service list branches params -func (o *BranchServiceListBranchesParams) SetPageSize(pageSize *int32) { - o.PageSize = pageSize -} - -// WithPageToken adds the pageToken to the branch service list branches params -func (o *BranchServiceListBranchesParams) WithPageToken(pageToken *string) *BranchServiceListBranchesParams { - o.SetPageToken(pageToken) - return o -} - -// SetPageToken adds the pageToken to the branch service list branches params -func (o *BranchServiceListBranchesParams) SetPageToken(pageToken *string) { - o.PageToken = pageToken -} - -// WriteToRequest writes these params to a swagger request -func (o *BranchServiceListBranchesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - // path param clusterId - if err := r.SetPathParam("clusterId", o.ClusterID); err != nil { - return err - } - - if o.PageSize != nil { - - // query param pageSize - var qrPageSize int32 - - if o.PageSize != nil { - qrPageSize = *o.PageSize - } - qPageSize := swag.FormatInt32(qrPageSize) - if qPageSize != "" { - - if err := r.SetQueryParam("pageSize", qPageSize); err != nil { - return err - } - } - } - - if o.PageToken != nil { - - // query param pageToken - var qrPageToken string - - if o.PageToken != nil { - qrPageToken = *o.PageToken - } - qPageToken := qrPageToken - if qPageToken != "" { - - if err := r.SetQueryParam("pageToken", qPageToken); err != nil { - return err - } - } - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_list_branches_responses.go b/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_list_branches_responses.go deleted file mode 100644 index cdbb75a4..00000000 --- a/pkg/tidbcloud/v1beta1/branch/client/branch_service/branch_service_list_branches_responses.go +++ /dev/null @@ -1,187 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package branch_service - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "encoding/json" - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/models" -) - -// BranchServiceListBranchesReader is a Reader for the BranchServiceListBranches structure. -type BranchServiceListBranchesReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *BranchServiceListBranchesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewBranchServiceListBranchesOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - default: - result := NewBranchServiceListBranchesDefault(response.Code()) - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - if response.Code()/100 == 2 { - return result, nil - } - return nil, result - } -} - -// NewBranchServiceListBranchesOK creates a BranchServiceListBranchesOK with default headers values -func NewBranchServiceListBranchesOK() *BranchServiceListBranchesOK { - return &BranchServiceListBranchesOK{} -} - -/* -BranchServiceListBranchesOK describes a response with status code 200, with default header values. - -A successful response. -*/ -type BranchServiceListBranchesOK struct { - Payload *models.V1beta1ListBranchesResponse -} - -// IsSuccess returns true when this branch service list branches o k response has a 2xx status code -func (o *BranchServiceListBranchesOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this branch service list branches o k response has a 3xx status code -func (o *BranchServiceListBranchesOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this branch service list branches o k response has a 4xx status code -func (o *BranchServiceListBranchesOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this branch service list branches o k response has a 5xx status code -func (o *BranchServiceListBranchesOK) IsServerError() bool { - return false -} - -// IsCode returns true when this branch service list branches o k response a status code equal to that given -func (o *BranchServiceListBranchesOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the branch service list branches o k response -func (o *BranchServiceListBranchesOK) Code() int { - return 200 -} - -func (o *BranchServiceListBranchesOK) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /v1beta1/clusters/{clusterId}/branches][%d] branchServiceListBranchesOK %s", 200, payload) -} - -func (o *BranchServiceListBranchesOK) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /v1beta1/clusters/{clusterId}/branches][%d] branchServiceListBranchesOK %s", 200, payload) -} - -func (o *BranchServiceListBranchesOK) GetPayload() *models.V1beta1ListBranchesResponse { - return o.Payload -} - -func (o *BranchServiceListBranchesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.V1beta1ListBranchesResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewBranchServiceListBranchesDefault creates a BranchServiceListBranchesDefault with default headers values -func NewBranchServiceListBranchesDefault(code int) *BranchServiceListBranchesDefault { - return &BranchServiceListBranchesDefault{ - _statusCode: code, - } -} - -/* -BranchServiceListBranchesDefault describes a response with status code -1, with default header values. - -An unexpected error response. -*/ -type BranchServiceListBranchesDefault struct { - _statusCode int - - Payload *models.RPCStatus -} - -// IsSuccess returns true when this branch service list branches default response has a 2xx status code -func (o *BranchServiceListBranchesDefault) IsSuccess() bool { - return o._statusCode/100 == 2 -} - -// IsRedirect returns true when this branch service list branches default response has a 3xx status code -func (o *BranchServiceListBranchesDefault) IsRedirect() bool { - return o._statusCode/100 == 3 -} - -// IsClientError returns true when this branch service list branches default response has a 4xx status code -func (o *BranchServiceListBranchesDefault) IsClientError() bool { - return o._statusCode/100 == 4 -} - -// IsServerError returns true when this branch service list branches default response has a 5xx status code -func (o *BranchServiceListBranchesDefault) IsServerError() bool { - return o._statusCode/100 == 5 -} - -// IsCode returns true when this branch service list branches default response a status code equal to that given -func (o *BranchServiceListBranchesDefault) IsCode(code int) bool { - return o._statusCode == code -} - -// Code gets the status code for the branch service list branches default response -func (o *BranchServiceListBranchesDefault) Code() int { - return o._statusCode -} - -func (o *BranchServiceListBranchesDefault) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /v1beta1/clusters/{clusterId}/branches][%d] BranchService_ListBranches default %s", o._statusCode, payload) -} - -func (o *BranchServiceListBranchesDefault) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /v1beta1/clusters/{clusterId}/branches][%d] BranchService_ListBranches default %s", o._statusCode, payload) -} - -func (o *BranchServiceListBranchesDefault) GetPayload() *models.RPCStatus { - return o.Payload -} - -func (o *BranchServiceListBranchesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.RPCStatus) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/client/tidbcloud_serverless_client.go b/pkg/tidbcloud/v1beta1/branch/client/tidbcloud_serverless_client.go deleted file mode 100644 index 64f0730d..00000000 --- a/pkg/tidbcloud/v1beta1/branch/client/tidbcloud_serverless_client.go +++ /dev/null @@ -1,112 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package client - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "github.com/go-openapi/runtime" - httptransport "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" - - "tidbcloud-cli/pkg/tidbcloud/v1beta1/branch/client/branch_service" -) - -// Default tidbcloud serverless HTTP client. -var Default = NewHTTPClient(nil) - -const ( - // DefaultHost is the default Host - // found in Meta (info) section of spec file - DefaultHost string = "serverless.tidbapi.com" - // DefaultBasePath is the default BasePath - // found in Meta (info) section of spec file - DefaultBasePath string = "/" -) - -// DefaultSchemes are the default schemes found in Meta (info) section of spec file -var DefaultSchemes = []string{"https"} - -// NewHTTPClient creates a new tidbcloud serverless HTTP client. -func NewHTTPClient(formats strfmt.Registry) *TidbcloudServerless { - return NewHTTPClientWithConfig(formats, nil) -} - -// NewHTTPClientWithConfig creates a new tidbcloud serverless HTTP client, -// using a customizable transport config. -func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *TidbcloudServerless { - // ensure nullable parameters have default - if cfg == nil { - cfg = DefaultTransportConfig() - } - - // create transport and client - transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes) - return New(transport, formats) -} - -// New creates a new tidbcloud serverless client -func New(transport runtime.ClientTransport, formats strfmt.Registry) *TidbcloudServerless { - // ensure nullable parameters have default - if formats == nil { - formats = strfmt.Default - } - - cli := new(TidbcloudServerless) - cli.Transport = transport - cli.BranchService = branch_service.New(transport, formats) - return cli -} - -// DefaultTransportConfig creates a TransportConfig with the -// default settings taken from the meta section of the spec file. -func DefaultTransportConfig() *TransportConfig { - return &TransportConfig{ - Host: DefaultHost, - BasePath: DefaultBasePath, - Schemes: DefaultSchemes, - } -} - -// TransportConfig contains the transport related info, -// found in the meta section of the spec file. -type TransportConfig struct { - Host string - BasePath string - Schemes []string -} - -// WithHost overrides the default host, -// provided by the meta section of the spec file. -func (cfg *TransportConfig) WithHost(host string) *TransportConfig { - cfg.Host = host - return cfg -} - -// WithBasePath overrides the default basePath, -// provided by the meta section of the spec file. -func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig { - cfg.BasePath = basePath - return cfg -} - -// WithSchemes overrides the default schemes, -// provided by the meta section of the spec file. -func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { - cfg.Schemes = schemes - return cfg -} - -// TidbcloudServerless is a client for tidbcloud serverless -type TidbcloudServerless struct { - BranchService branch_service.ClientService - - Transport runtime.ClientTransport -} - -// SetTransport changes the transport on the client and all its subresources -func (c *TidbcloudServerless) SetTransport(transport runtime.ClientTransport) { - c.Transport = transport - c.BranchService.SetTransport(transport) -} diff --git a/pkg/tidbcloud/v1beta1/branch/models/branch_endpoints.go b/pkg/tidbcloud/v1beta1/branch/models/branch_endpoints.go deleted file mode 100644 index b3bcacbb..00000000 --- a/pkg/tidbcloud/v1beta1/branch/models/branch_endpoints.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// BranchEndpoints Message for the Endpoints for this branch. -// -// swagger:model BranchEndpoints -type BranchEndpoints struct { - - // Optional . Private Endpoint for this branch. - Private *EndpointsPrivate `json:"private,omitempty"` - - // Optional . Public Endpoint for this branch. - Public *EndpointsPublic `json:"public,omitempty"` -} - -// Validate validates this branch endpoints -func (m *BranchEndpoints) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validatePrivate(formats); err != nil { - res = append(res, err) - } - - if err := m.validatePublic(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *BranchEndpoints) validatePrivate(formats strfmt.Registry) error { - if swag.IsZero(m.Private) { // not required - return nil - } - - if m.Private != nil { - if err := m.Private.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("private") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("private") - } - return err - } - } - - return nil -} - -func (m *BranchEndpoints) validatePublic(formats strfmt.Registry) error { - if swag.IsZero(m.Public) { // not required - return nil - } - - if m.Public != nil { - if err := m.Public.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("public") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("public") - } - return err - } - } - - return nil -} - -// ContextValidate validate this branch endpoints based on the context it is used -func (m *BranchEndpoints) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidatePrivate(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidatePublic(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *BranchEndpoints) contextValidatePrivate(ctx context.Context, formats strfmt.Registry) error { - - if m.Private != nil { - - if swag.IsZero(m.Private) { // not required - return nil - } - - if err := m.Private.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("private") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("private") - } - return err - } - } - - return nil -} - -func (m *BranchEndpoints) contextValidatePublic(ctx context.Context, formats strfmt.Registry) error { - - if m.Public != nil { - - if swag.IsZero(m.Public) { // not required - return nil - } - - if err := m.Public.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("public") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("public") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (m *BranchEndpoints) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *BranchEndpoints) UnmarshalBinary(b []byte) error { - var res BranchEndpoints - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/models/branch_state.go b/pkg/tidbcloud/v1beta1/branch/models/branch_state.go deleted file mode 100644 index 0789137d..00000000 --- a/pkg/tidbcloud/v1beta1/branch/models/branch_state.go +++ /dev/null @@ -1,89 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "encoding/json" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/validate" -) - -// BranchState Output Only. Branch State. -// -// - CREATING: The branch is being created. -// - ACTIVE: The branch is active and running. -// - DELETED: The branch is being deleted. -// - MAINTENANCE: The branch is under maintenance. -// -// swagger:model Branch.State -type BranchState string - -func NewBranchState(value BranchState) *BranchState { - return &value -} - -// Pointer returns a pointer to a freshly-allocated BranchState. -func (m BranchState) Pointer() *BranchState { - return &m -} - -const ( - - // BranchStateCREATING captures enum value "CREATING" - BranchStateCREATING BranchState = "CREATING" - - // BranchStateACTIVE captures enum value "ACTIVE" - BranchStateACTIVE BranchState = "ACTIVE" - - // BranchStateDELETED captures enum value "DELETED" - BranchStateDELETED BranchState = "DELETED" - - // BranchStateMAINTENANCE captures enum value "MAINTENANCE" - BranchStateMAINTENANCE BranchState = "MAINTENANCE" -) - -// for schema -var branchStateEnum []interface{} - -func init() { - var res []BranchState - if err := json.Unmarshal([]byte(`["CREATING","ACTIVE","DELETED","MAINTENANCE"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - branchStateEnum = append(branchStateEnum, v) - } -} - -func (m BranchState) validateBranchStateEnum(path, location string, value BranchState) error { - if err := validate.EnumCase(path, location, value, branchStateEnum, true); err != nil { - return err - } - return nil -} - -// Validate validates this branch state -func (m BranchState) Validate(formats strfmt.Registry) error { - var res []error - - // value enum - if err := m.validateBranchStateEnum("", "body", m); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// ContextValidate validates this branch state based on context it is used -func (m BranchState) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/models/branch_usage.go b/pkg/tidbcloud/v1beta1/branch/models/branch_usage.go deleted file mode 100644 index 74ecc844..00000000 --- a/pkg/tidbcloud/v1beta1/branch/models/branch_usage.go +++ /dev/null @@ -1,105 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// BranchUsage Message for usage metrics for this cluster. -// -// swagger:model BranchUsage -type BranchUsage struct { - - // Output Only. The latest value of Columnar Storage Metric for this cluster. - // Read Only: true - ColumnarStorage float64 `json:"columnarStorage,omitempty"` - - // Output Only. The latest value of Request Unit Metric for this cluster. - // Read Only: true - RequestUnit string `json:"requestUnit,omitempty"` - - // Output Only. The latest value of Row Storage Metric for this cluster. - // Read Only: true - RowStorage float64 `json:"rowStorage,omitempty"` -} - -// Validate validates this branch usage -func (m *BranchUsage) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validate this branch usage based on the context it is used -func (m *BranchUsage) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateColumnarStorage(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateRequestUnit(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateRowStorage(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *BranchUsage) contextValidateColumnarStorage(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "columnarStorage", "body", float64(m.ColumnarStorage)); err != nil { - return err - } - - return nil -} - -func (m *BranchUsage) contextValidateRequestUnit(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "requestUnit", "body", string(m.RequestUnit)); err != nil { - return err - } - - return nil -} - -func (m *BranchUsage) contextValidateRowStorage(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "rowStorage", "body", float64(m.RowStorage)); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *BranchUsage) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *BranchUsage) UnmarshalBinary(b []byte) error { - var res BranchUsage - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/models/endpoints_private.go b/pkg/tidbcloud/v1beta1/branch/models/endpoints_private.go deleted file mode 100644 index ff5b3bd5..00000000 --- a/pkg/tidbcloud/v1beta1/branch/models/endpoints_private.go +++ /dev/null @@ -1,197 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// EndpointsPrivate Message for Private Endpoint for this branch. -// -// swagger:model EndpointsPrivate -type EndpointsPrivate struct { - - // Message for AWS - // Read Only: true - Aws *PrivateAWS `json:"aws,omitempty"` - - // Message for GCP - // Read Only: true - Gcp *PrivateGCP `json:"gcp,omitempty"` - - // Output Only. Host Name of Public Endpoint. - // Read Only: true - Host string `json:"host,omitempty"` - - // Output Only. Port of Public Endpoint. - // Read Only: true - Port int32 `json:"port,omitempty"` -} - -// Validate validates this endpoints private -func (m *EndpointsPrivate) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateAws(formats); err != nil { - res = append(res, err) - } - - if err := m.validateGcp(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *EndpointsPrivate) validateAws(formats strfmt.Registry) error { - if swag.IsZero(m.Aws) { // not required - return nil - } - - if m.Aws != nil { - if err := m.Aws.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("aws") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("aws") - } - return err - } - } - - return nil -} - -func (m *EndpointsPrivate) validateGcp(formats strfmt.Registry) error { - if swag.IsZero(m.Gcp) { // not required - return nil - } - - if m.Gcp != nil { - if err := m.Gcp.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("gcp") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("gcp") - } - return err - } - } - - return nil -} - -// ContextValidate validate this endpoints private based on the context it is used -func (m *EndpointsPrivate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateAws(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateGcp(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateHost(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidatePort(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *EndpointsPrivate) contextValidateAws(ctx context.Context, formats strfmt.Registry) error { - - if m.Aws != nil { - - if swag.IsZero(m.Aws) { // not required - return nil - } - - if err := m.Aws.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("aws") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("aws") - } - return err - } - } - - return nil -} - -func (m *EndpointsPrivate) contextValidateGcp(ctx context.Context, formats strfmt.Registry) error { - - if m.Gcp != nil { - - if swag.IsZero(m.Gcp) { // not required - return nil - } - - if err := m.Gcp.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("gcp") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("gcp") - } - return err - } - } - - return nil -} - -func (m *EndpointsPrivate) contextValidateHost(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "host", "body", string(m.Host)); err != nil { - return err - } - - return nil -} - -func (m *EndpointsPrivate) contextValidatePort(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "port", "body", int32(m.Port)); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *EndpointsPrivate) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *EndpointsPrivate) UnmarshalBinary(b []byte) error { - var res EndpointsPrivate - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/models/endpoints_public.go b/pkg/tidbcloud/v1beta1/branch/models/endpoints_public.go deleted file mode 100644 index 369bf3a9..00000000 --- a/pkg/tidbcloud/v1beta1/branch/models/endpoints_public.go +++ /dev/null @@ -1,91 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// EndpointsPublic Message for Public Endpoint for this branch. -// -// swagger:model EndpointsPublic -type EndpointsPublic struct { - - // Output, Disable Public Endpoint - Disabled bool `json:"disabled,omitempty"` - - // Output Only. Host name of Public Endpoint - // Read Only: true - Host string `json:"host,omitempty"` - - // Output Only. Port of Public Endpoint - // Read Only: true - Port int32 `json:"port,omitempty"` -} - -// Validate validates this endpoints public -func (m *EndpointsPublic) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validate this endpoints public based on the context it is used -func (m *EndpointsPublic) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateHost(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidatePort(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *EndpointsPublic) contextValidateHost(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "host", "body", string(m.Host)); err != nil { - return err - } - - return nil -} - -func (m *EndpointsPublic) contextValidatePort(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "port", "body", int32(m.Port)); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *EndpointsPublic) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *EndpointsPublic) UnmarshalBinary(b []byte) error { - var res EndpointsPublic - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/models/private_a_w_s.go b/pkg/tidbcloud/v1beta1/branch/models/private_a_w_s.go deleted file mode 100644 index dbc606fc..00000000 --- a/pkg/tidbcloud/v1beta1/branch/models/private_a_w_s.go +++ /dev/null @@ -1,89 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// PrivateAWS Message for AWS Private Link Service. -// -// swagger:model PrivateAWS -type PrivateAWS struct { - - // Output Only. Availability Zone for Private Link Service. - // Read Only: true - AvailabilityZone []string `json:"availabilityZone"` - - // Output Only. Service Name for Private Link Service. - // (-- api-linter: core::0122::name-suffix=disabled --) - // Read Only: true - ServiceName string `json:"serviceName,omitempty"` -} - -// Validate validates this private a w s -func (m *PrivateAWS) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validate this private a w s based on the context it is used -func (m *PrivateAWS) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateAvailabilityZone(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateServiceName(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *PrivateAWS) contextValidateAvailabilityZone(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "availabilityZone", "body", []string(m.AvailabilityZone)); err != nil { - return err - } - - return nil -} - -func (m *PrivateAWS) contextValidateServiceName(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "serviceName", "body", string(m.ServiceName)); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *PrivateAWS) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *PrivateAWS) UnmarshalBinary(b []byte) error { - var res PrivateAWS - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/models/private_g_c_p.go b/pkg/tidbcloud/v1beta1/branch/models/private_g_c_p.go deleted file mode 100644 index 992ea90c..00000000 --- a/pkg/tidbcloud/v1beta1/branch/models/private_g_c_p.go +++ /dev/null @@ -1,71 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// PrivateGCP Message for GCP Private Link Service. -// -// swagger:model PrivateGCP -type PrivateGCP struct { - - // Output Only. Target Service Account for Private Link Service. - // Read Only: true - ServiceAttachmentName string `json:"serviceAttachmentName,omitempty"` -} - -// Validate validates this private g c p -func (m *PrivateGCP) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validate this private g c p based on the context it is used -func (m *PrivateGCP) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateServiceAttachmentName(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *PrivateGCP) contextValidateServiceAttachmentName(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "serviceAttachmentName", "body", string(m.ServiceAttachmentName)); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *PrivateGCP) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *PrivateGCP) UnmarshalBinary(b []byte) error { - var res PrivateGCP - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/models/protobuf_any.go b/pkg/tidbcloud/v1beta1/branch/models/protobuf_any.go deleted file mode 100644 index f25b51ed..00000000 --- a/pkg/tidbcloud/v1beta1/branch/models/protobuf_any.go +++ /dev/null @@ -1,127 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "encoding/json" - - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// ProtobufAny protobuf any -// -// swagger:model protobufAny -type ProtobufAny struct { - - // at type - AtType string `json:"@type,omitempty"` - - // protobuf any - ProtobufAny map[string]interface{} `json:"-"` -} - -// UnmarshalJSON unmarshals this object with additional properties from JSON -func (m *ProtobufAny) UnmarshalJSON(data []byte) error { - // stage 1, bind the properties - var stage1 struct { - - // at type - AtType string `json:"@type,omitempty"` - } - if err := json.Unmarshal(data, &stage1); err != nil { - return err - } - var rcv ProtobufAny - - rcv.AtType = stage1.AtType - *m = rcv - - // stage 2, remove properties and add to map - stage2 := make(map[string]json.RawMessage) - if err := json.Unmarshal(data, &stage2); err != nil { - return err - } - - delete(stage2, "@type") - // stage 3, add additional properties values - if len(stage2) > 0 { - result := make(map[string]interface{}) - for k, v := range stage2 { - var toadd interface{} - if err := json.Unmarshal(v, &toadd); err != nil { - return err - } - result[k] = toadd - } - m.ProtobufAny = result - } - - return nil -} - -// MarshalJSON marshals this object with additional properties into a JSON object -func (m ProtobufAny) MarshalJSON() ([]byte, error) { - var stage1 struct { - - // at type - AtType string `json:"@type,omitempty"` - } - - stage1.AtType = m.AtType - - // make JSON object for known properties - props, err := json.Marshal(stage1) - if err != nil { - return nil, err - } - - if len(m.ProtobufAny) == 0 { // no additional properties - return props, nil - } - - // make JSON object for the additional properties - additional, err := json.Marshal(m.ProtobufAny) - if err != nil { - return nil, err - } - - if len(props) < 3 { // "{}": only additional properties - return additional, nil - } - - // concatenate the 2 objects - return swag.ConcatJSON(props, additional), nil -} - -// Validate validates this protobuf any -func (m *ProtobufAny) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this protobuf any based on context it is used -func (m *ProtobufAny) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *ProtobufAny) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ProtobufAny) UnmarshalBinary(b []byte) error { - var res ProtobufAny - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/models/rpc_status.go b/pkg/tidbcloud/v1beta1/branch/models/rpc_status.go deleted file mode 100644 index 922eaa86..00000000 --- a/pkg/tidbcloud/v1beta1/branch/models/rpc_status.go +++ /dev/null @@ -1,127 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "strconv" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// RPCStatus rpc status -// -// swagger:model rpcStatus -type RPCStatus struct { - - // code - Code int32 `json:"code,omitempty"` - - // details - Details []*ProtobufAny `json:"details"` - - // message - Message string `json:"message,omitempty"` -} - -// Validate validates this rpc status -func (m *RPCStatus) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateDetails(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *RPCStatus) validateDetails(formats strfmt.Registry) error { - if swag.IsZero(m.Details) { // not required - return nil - } - - for i := 0; i < len(m.Details); i++ { - if swag.IsZero(m.Details[i]) { // not required - continue - } - - if m.Details[i] != nil { - if err := m.Details[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("details" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("details" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// ContextValidate validate this rpc status based on the context it is used -func (m *RPCStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateDetails(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *RPCStatus) contextValidateDetails(ctx context.Context, formats strfmt.Registry) error { - - for i := 0; i < len(m.Details); i++ { - - if m.Details[i] != nil { - - if swag.IsZero(m.Details[i]) { // not required - return nil - } - - if err := m.Details[i].ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("details" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("details" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// MarshalBinary interface implementation -func (m *RPCStatus) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *RPCStatus) UnmarshalBinary(b []byte) error { - var res RPCStatus - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/models/v1beta1_branch.go b/pkg/tidbcloud/v1beta1/branch/models/v1beta1_branch.go deleted file mode 100644 index 50af2ec8..00000000 --- a/pkg/tidbcloud/v1beta1/branch/models/v1beta1_branch.go +++ /dev/null @@ -1,409 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// V1beta1Branch Message for branch -// -// swagger:model v1beta1Branch -type V1beta1Branch struct { - - // Optional. The annotations of this branch. Only display in FULL view. - Annotations map[string]string `json:"annotations,omitempty"` - - // Output only. The system-generated ID of the resource. - // Read Only: true - BranchID string `json:"branchId,omitempty"` - - // Output only. The cluster ID of this branch. - // Read Only: true - ClusterID string `json:"clusterId,omitempty"` - - // Output only. Create timestamp - // Read Only: true - // Format: date-time - CreateTime strfmt.DateTime `json:"createTime,omitempty"` - - // Output only. The creator of the branch. - // Read Only: true - CreatedBy string `json:"createdBy,omitempty"` - - // Required. User-settable and human-readable display name for the branch. - // Required: true - DisplayName *string `json:"displayName"` - - // Optional. The endpoints of this branch. - Endpoints *BranchEndpoints `json:"endpoints,omitempty"` - - // Output Only. The name of the resource. - // Read Only: true - Name string `json:"name,omitempty"` - - // OPTIONAL. The parent display name of this branch. - ParentDisplayName string `json:"parentDisplayName,omitempty"` - - // OPTIONAL. The parent ID of this branch. - ParentID string `json:"parentId,omitempty"` - - // Optional. The point in time on the parent branch the branch will be created from. - // Format: date-time - ParentTimestamp *strfmt.DateTime `json:"parentTimestamp,omitempty"` - - // Output only. The state of this branch. - // Read Only: true - State V1beta1BranchState `json:"state,omitempty"` - - // Output only. Update timestamp - // Read Only: true - // Format: date-time - UpdateTime strfmt.DateTime `json:"updateTime,omitempty"` - - // OPTIONAL. Usage metrics of this branch. Only display in FULL view. - Usage *BranchUsage `json:"usage,omitempty"` - - // Output only. User name prefix of this branch. For each TiDB Serverless branch, - // TiDB Cloud generates a unique prefix to distinguish it from other branches. - // Whenever you use or set a database user name, you must include the prefix in the user name. - // Read Only: true - UserPrefix *string `json:"userPrefix,omitempty"` -} - -// Validate validates this v1beta1 branch -func (m *V1beta1Branch) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateCreateTime(formats); err != nil { - res = append(res, err) - } - - if err := m.validateDisplayName(formats); err != nil { - res = append(res, err) - } - - if err := m.validateEndpoints(formats); err != nil { - res = append(res, err) - } - - if err := m.validateParentTimestamp(formats); err != nil { - res = append(res, err) - } - - if err := m.validateState(formats); err != nil { - res = append(res, err) - } - - if err := m.validateUpdateTime(formats); err != nil { - res = append(res, err) - } - - if err := m.validateUsage(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *V1beta1Branch) validateCreateTime(formats strfmt.Registry) error { - if swag.IsZero(m.CreateTime) { // not required - return nil - } - - if err := validate.FormatOf("createTime", "body", "date-time", m.CreateTime.String(), formats); err != nil { - return err - } - - return nil -} - -func (m *V1beta1Branch) validateDisplayName(formats strfmt.Registry) error { - - if err := validate.Required("displayName", "body", m.DisplayName); err != nil { - return err - } - - return nil -} - -func (m *V1beta1Branch) validateEndpoints(formats strfmt.Registry) error { - if swag.IsZero(m.Endpoints) { // not required - return nil - } - - if m.Endpoints != nil { - if err := m.Endpoints.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("endpoints") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("endpoints") - } - return err - } - } - - return nil -} - -func (m *V1beta1Branch) validateParentTimestamp(formats strfmt.Registry) error { - if swag.IsZero(m.ParentTimestamp) { // not required - return nil - } - - if err := validate.FormatOf("parentTimestamp", "body", "date-time", m.ParentTimestamp.String(), formats); err != nil { - return err - } - - return nil -} - -func (m *V1beta1Branch) validateState(formats strfmt.Registry) error { - if swag.IsZero(m.State) { // not required - return nil - } - - if err := m.State.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("state") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("state") - } - return err - } - - return nil -} - -func (m *V1beta1Branch) validateUpdateTime(formats strfmt.Registry) error { - if swag.IsZero(m.UpdateTime) { // not required - return nil - } - - if err := validate.FormatOf("updateTime", "body", "date-time", m.UpdateTime.String(), formats); err != nil { - return err - } - - return nil -} - -func (m *V1beta1Branch) validateUsage(formats strfmt.Registry) error { - if swag.IsZero(m.Usage) { // not required - return nil - } - - if m.Usage != nil { - if err := m.Usage.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("usage") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("usage") - } - return err - } - } - - return nil -} - -// ContextValidate validate this v1beta1 branch based on the context it is used -func (m *V1beta1Branch) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateBranchID(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateClusterID(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateCreateTime(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateCreatedBy(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateEndpoints(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateName(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateState(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateUpdateTime(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateUsage(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateUserPrefix(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *V1beta1Branch) contextValidateBranchID(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "branchId", "body", string(m.BranchID)); err != nil { - return err - } - - return nil -} - -func (m *V1beta1Branch) contextValidateClusterID(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "clusterId", "body", string(m.ClusterID)); err != nil { - return err - } - - return nil -} - -func (m *V1beta1Branch) contextValidateCreateTime(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "createTime", "body", strfmt.DateTime(m.CreateTime)); err != nil { - return err - } - - return nil -} - -func (m *V1beta1Branch) contextValidateCreatedBy(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "createdBy", "body", string(m.CreatedBy)); err != nil { - return err - } - - return nil -} - -func (m *V1beta1Branch) contextValidateEndpoints(ctx context.Context, formats strfmt.Registry) error { - - if m.Endpoints != nil { - - if swag.IsZero(m.Endpoints) { // not required - return nil - } - - if err := m.Endpoints.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("endpoints") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("endpoints") - } - return err - } - } - - return nil -} - -func (m *V1beta1Branch) contextValidateName(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "name", "body", string(m.Name)); err != nil { - return err - } - - return nil -} - -func (m *V1beta1Branch) contextValidateState(ctx context.Context, formats strfmt.Registry) error { - - if swag.IsZero(m.State) { // not required - return nil - } - - if err := m.State.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("state") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("state") - } - return err - } - - return nil -} - -func (m *V1beta1Branch) contextValidateUpdateTime(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "updateTime", "body", strfmt.DateTime(m.UpdateTime)); err != nil { - return err - } - - return nil -} - -func (m *V1beta1Branch) contextValidateUsage(ctx context.Context, formats strfmt.Registry) error { - - if m.Usage != nil { - - if swag.IsZero(m.Usage) { // not required - return nil - } - - if err := m.Usage.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("usage") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("usage") - } - return err - } - } - - return nil -} - -func (m *V1beta1Branch) contextValidateUserPrefix(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "userPrefix", "body", m.UserPrefix); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *V1beta1Branch) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *V1beta1Branch) UnmarshalBinary(b []byte) error { - var res V1beta1Branch - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/models/v1beta1_branch_state.go b/pkg/tidbcloud/v1beta1/branch/models/v1beta1_branch_state.go deleted file mode 100644 index bd6b8264..00000000 --- a/pkg/tidbcloud/v1beta1/branch/models/v1beta1_branch_state.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "encoding/json" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/validate" -) - -// V1beta1BranchState Output Only. Branch State. -// -// - STATE_UNSPECIFIED: The state of the branch is unknown. -// - CREATING: The branch is being created. -// - ACTIVE: The branch is active and running. -// - DELETED: The branch is being deleted. -// - MAINTENANCE: The branch is under maintenance. -// -// swagger:model v1beta1BranchState -type V1beta1BranchState string - -func NewV1beta1BranchState(value V1beta1BranchState) *V1beta1BranchState { - return &value -} - -// Pointer returns a pointer to a freshly-allocated V1beta1BranchState. -func (m V1beta1BranchState) Pointer() *V1beta1BranchState { - return &m -} - -const ( - - // V1beta1BranchStateCREATING captures enum value "CREATING" - V1beta1BranchStateCREATING V1beta1BranchState = "CREATING" - - // V1beta1BranchStateACTIVE captures enum value "ACTIVE" - V1beta1BranchStateACTIVE V1beta1BranchState = "ACTIVE" - - // V1beta1BranchStateDELETED captures enum value "DELETED" - V1beta1BranchStateDELETED V1beta1BranchState = "DELETED" - - // V1beta1BranchStateMAINTENANCE captures enum value "MAINTENANCE" - V1beta1BranchStateMAINTENANCE V1beta1BranchState = "MAINTENANCE" -) - -// for schema -var v1beta1BranchStateEnum []interface{} - -func init() { - var res []V1beta1BranchState - if err := json.Unmarshal([]byte(`["CREATING","ACTIVE","DELETED","MAINTENANCE"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - v1beta1BranchStateEnum = append(v1beta1BranchStateEnum, v) - } -} - -func (m V1beta1BranchState) validateV1beta1BranchStateEnum(path, location string, value V1beta1BranchState) error { - if err := validate.EnumCase(path, location, value, v1beta1BranchStateEnum, true); err != nil { - return err - } - return nil -} - -// Validate validates this v1beta1 branch state -func (m V1beta1BranchState) Validate(formats strfmt.Registry) error { - var res []error - - // value enum - if err := m.validateV1beta1BranchStateEnum("", "body", m); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// ContextValidate validates this v1beta1 branch state based on context it is used -func (m V1beta1BranchState) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/models/v1beta1_branch_view.go b/pkg/tidbcloud/v1beta1/branch/models/v1beta1_branch_view.go deleted file mode 100644 index 98adb474..00000000 --- a/pkg/tidbcloud/v1beta1/branch/models/v1beta1_branch_view.go +++ /dev/null @@ -1,82 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "encoding/json" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/validate" -) - -// V1beta1BranchView View on branch. Pass this enum to control which subsets of fields to get. -// -// - BRANCH_VIEW_UNSPECIFIED: BRANCH_VIEW_UNSPECIFIED Not specified, equivalent to BASIC. -// - BASIC: Basic response contains basic information for a branch. -// - FULL: FULL response contains all detailed information for a branch. -// -// swagger:model v1beta1BranchView -type V1beta1BranchView string - -func NewV1beta1BranchView(value V1beta1BranchView) *V1beta1BranchView { - return &value -} - -// Pointer returns a pointer to a freshly-allocated V1beta1BranchView. -func (m V1beta1BranchView) Pointer() *V1beta1BranchView { - return &m -} - -const ( - - // V1beta1BranchViewBASIC captures enum value "BASIC" - V1beta1BranchViewBASIC V1beta1BranchView = "BASIC" - - // V1beta1BranchViewFULL captures enum value "FULL" - V1beta1BranchViewFULL V1beta1BranchView = "FULL" -) - -// for schema -var v1beta1BranchViewEnum []interface{} - -func init() { - var res []V1beta1BranchView - if err := json.Unmarshal([]byte(`["BASIC","FULL"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - v1beta1BranchViewEnum = append(v1beta1BranchViewEnum, v) - } -} - -func (m V1beta1BranchView) validateV1beta1BranchViewEnum(path, location string, value V1beta1BranchView) error { - if err := validate.EnumCase(path, location, value, v1beta1BranchViewEnum, true); err != nil { - return err - } - return nil -} - -// Validate validates this v1beta1 branch view -func (m V1beta1BranchView) Validate(formats strfmt.Registry) error { - var res []error - - // value enum - if err := m.validateV1beta1BranchViewEnum("", "body", m); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// ContextValidate validates this v1beta1 branch view based on context it is used -func (m V1beta1BranchView) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} diff --git a/pkg/tidbcloud/v1beta1/branch/models/v1beta1_list_branches_response.go b/pkg/tidbcloud/v1beta1/branch/models/v1beta1_list_branches_response.go deleted file mode 100644 index 8f194c0b..00000000 --- a/pkg/tidbcloud/v1beta1/branch/models/v1beta1_list_branches_response.go +++ /dev/null @@ -1,127 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "strconv" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// V1beta1ListBranchesResponse Message for response to list branches -// -// swagger:model v1beta1ListBranchesResponse -type V1beta1ListBranchesResponse struct { - - // The list of branches - Branches []*V1beta1Branch `json:"branches"` - - // A token identifying a page of results the server should return. - NextPageToken string `json:"nextPageToken,omitempty"` - - // Total number of branches - TotalSize int64 `json:"totalSize,omitempty"` -} - -// Validate validates this v1beta1 list branches response -func (m *V1beta1ListBranchesResponse) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateBranches(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *V1beta1ListBranchesResponse) validateBranches(formats strfmt.Registry) error { - if swag.IsZero(m.Branches) { // not required - return nil - } - - for i := 0; i < len(m.Branches); i++ { - if swag.IsZero(m.Branches[i]) { // not required - continue - } - - if m.Branches[i] != nil { - if err := m.Branches[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("branches" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("branches" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// ContextValidate validate this v1beta1 list branches response based on the context it is used -func (m *V1beta1ListBranchesResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateBranches(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *V1beta1ListBranchesResponse) contextValidateBranches(ctx context.Context, formats strfmt.Registry) error { - - for i := 0; i < len(m.Branches); i++ { - - if m.Branches[i] != nil { - - if swag.IsZero(m.Branches[i]) { // not required - return nil - } - - if err := m.Branches[i].ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("branches" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("branches" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// MarshalBinary interface implementation -func (m *V1beta1ListBranchesResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *V1beta1ListBranchesResponse) UnmarshalBinary(b []byte) error { - var res V1beta1ListBranchesResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/branch.swagger.json b/pkg/tidbcloud/v1beta1/serverless/branch.swagger.json new file mode 100644 index 00000000..cbcd07ef --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch.swagger.json @@ -0,0 +1,501 @@ +{ + "swagger": "2.0", + "info": { + "title": "TiDB Cloud Serverless Open API", + "description": "TiDB Cloud Serverless Open API", + "version": "v1beta1" + }, + "tags": [ + { + "name": "BranchService" + } + ], + "host": "serverless.tidbapi.com", + "schemes": [ + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/v1beta1/clusters/{clusterId}/branches": { + "get": { + "summary": "Lists information about branches.", + "operationId": "BranchService_ListBranches", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/ListBranchesResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Status" + } + } + }, + "parameters": [ + { + "name": "clusterId", + "description": "Required. The ID of the project to which the clusters belong.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "pageSize", + "description": "Optional. Requested page size. Server may return fewer items than\nrequested. If unspecified, server will pick an appropriate default.", + "in": "query", + "required": false, + "type": "integer", + "format": "int32" + }, + { + "name": "pageToken", + "description": "Optional. A token identifying a page of results the server should return.", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "BranchService" + ] + }, + "post": { + "summary": "Creates a branch.", + "operationId": "BranchService_CreateBranch", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/Branch" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Status" + } + } + }, + "parameters": [ + { + "name": "clusterId", + "description": "Required. The cluster ID of the branch", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "branch", + "description": "Required. The resource being created", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Branch" + } + } + ], + "tags": [ + "BranchService" + ] + } + }, + "/v1beta1/clusters/{clusterId}/branches/{branchId}": { + "get": { + "summary": "Gets information about a branch.", + "operationId": "BranchService_GetBranch", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/Branch" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Status" + } + } + }, + "parameters": [ + { + "name": "clusterId", + "description": "Required. The cluster ID of the branch", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "branchId", + "description": "Required. The branch ID", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "view", + "description": "Optional. The view of the branch to return. Defaults to FULL\n\n - BASIC: Basic response contains basic information for a branch.\n - FULL: FULL response contains all detailed information for a branch.", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "BASIC", + "FULL" + ] + } + ], + "tags": [ + "BranchService" + ] + }, + "delete": { + "summary": "Deletes a branch.", + "operationId": "BranchService_DeleteBranch", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/Branch" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Status" + } + } + }, + "parameters": [ + { + "name": "clusterId", + "description": "Required. The cluster ID of the branch", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "branchId", + "description": "Required. The branch ID", + "in": "path", + "required": true, + "type": "string" + } + ], + "tags": [ + "BranchService" + ] + } + } + }, + "definitions": { + "Any": { + "type": "object", + "properties": { + "@type": { + "type": "string" + } + }, + "additionalProperties": {} + }, + "Branch": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Output Only. The name of the resource.", + "readOnly": true + }, + "branchId": { + "type": "string", + "description": "Output only. The system-generated ID of the resource.", + "readOnly": true + }, + "displayName": { + "type": "string", + "description": "Required. User-settable and human-readable display name for the branch." + }, + "clusterId": { + "type": "string", + "description": "Output only. The cluster ID of this branch.", + "readOnly": true + }, + "parentId": { + "type": "string", + "description": "Optional. The parent ID of this branch." + }, + "createdBy": { + "type": "string", + "description": "Output only. The creator of the branch.", + "readOnly": true + }, + "state": { + "description": "Output only. The state of this branch.", + "readOnly": true, + "allOf": [ + { + "$ref": "#/definitions/Branch.State" + } + ] + }, + "endpoints": { + "description": "Optional. The endpoints of this branch.", + "allOf": [ + { + "$ref": "#/definitions/Branch.Endpoints" + } + ] + }, + "userPrefix": { + "type": "string", + "x-nullable": true, + "description": "Output only. User name prefix of this branch. For each TiDB Serverless branch,\nTiDB Cloud generates a unique prefix to distinguish it from other branches.\nWhenever you use or set a database user name, you must include the prefix in the user name.", + "readOnly": true + }, + "usage": { + "description": "Output only. Usage metrics of this branch. Only display in FULL view.", + "readOnly": true, + "allOf": [ + { + "$ref": "#/definitions/Branch.Usage" + } + ] + }, + "createTime": { + "type": "string", + "format": "date-time", + "title": "Output only. Create timestamp", + "readOnly": true + }, + "updateTime": { + "type": "string", + "format": "date-time", + "title": "Output only. Update timestamp", + "readOnly": true + }, + "annotations": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Optional. The annotations of this branch.." + }, + "parentDisplayName": { + "type": "string", + "description": "Output only. The parent display name of this branch.", + "readOnly": true + }, + "parentTimestamp": { + "type": "string", + "format": "date-time", + "x-nullable": true, + "description": "Optional. The point in time on the parent branch the branch will be created from." + } + }, + "title": "Message for branch", + "required": [ + "displayName" + ] + }, + "Branch.Endpoints": { + "type": "object", + "properties": { + "public": { + "description": "Optional. Public Endpoint for this branch.", + "allOf": [ + { + "$ref": "#/definitions/Branch.Endpoints.Public" + } + ] + }, + "private": { + "description": "Output only. Private Endpoint for this branch.", + "readOnly": true, + "allOf": [ + { + "$ref": "#/definitions/Branch.Endpoints.Private" + } + ] + } + }, + "description": "Message for the Endpoints for this branch." + }, + "Branch.Endpoints.Private": { + "type": "object", + "properties": { + "host": { + "type": "string", + "description": "Output Only. Host Name of Public Endpoint.", + "readOnly": true + }, + "port": { + "type": "integer", + "format": "int32", + "description": "Output Only. Port of Public Endpoint.", + "readOnly": true + }, + "aws": { + "title": "Message for AWS", + "readOnly": true, + "allOf": [ + { + "$ref": "#/definitions/Branch.Endpoints.Private.AWS" + } + ] + }, + "gcp": { + "title": "Message for GCP", + "readOnly": true, + "allOf": [ + { + "$ref": "#/definitions/Branch.Endpoints.Private.GCP" + } + ] + } + }, + "description": "Message for Private Endpoint for this branch." + }, + "Branch.Endpoints.Private.AWS": { + "type": "object", + "properties": { + "serviceName": { + "type": "string", + "description": "Output Only. Service Name for Private Link Service.", + "readOnly": true + }, + "availabilityZone": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Output Only. Availability Zone for Private Link Service.", + "readOnly": true + } + }, + "description": "Message for AWS Private Link Service." + }, + "Branch.Endpoints.Private.GCP": { + "type": "object", + "properties": { + "serviceAttachmentName": { + "type": "string", + "description": "Output Only. Target Service Account for Private Link Service.", + "readOnly": true + } + }, + "description": "Message for GCP Private Link Service." + }, + "Branch.Endpoints.Public": { + "type": "object", + "properties": { + "host": { + "type": "string", + "title": "Output Only. Host name of Public Endpoint", + "readOnly": true + }, + "port": { + "type": "integer", + "format": "int32", + "title": "Output Only. Port of Public Endpoint", + "readOnly": true + }, + "disabled": { + "type": "boolean", + "title": "Optional. Disable Public Endpoint" + } + }, + "description": "Message for Public Endpoint for this branch." + }, + "Branch.State": { + "type": "string", + "enum": [ + "CREATING", + "ACTIVE", + "DELETED", + "MAINTENANCE" + ], + "description": "Output Only. Branch State.\n\n - CREATING: The branch is being created.\n - ACTIVE: The branch is active and running.\n - DELETED: The branch is being deleted.\n - MAINTENANCE: The branch is under maintenance." + }, + "Branch.Usage": { + "type": "object", + "properties": { + "requestUnit": { + "type": "string", + "format": "int64", + "description": "Output Only. The latest value of Request Unit Metric for this cluster.", + "readOnly": true + }, + "rowStorage": { + "type": "number", + "format": "double", + "description": "Output Only. The latest value of Row Storage Metric for this cluster.", + "readOnly": true + }, + "columnarStorage": { + "type": "number", + "format": "double", + "description": "Output Only. The latest value of Columnar Storage Metric for this cluster.", + "readOnly": true + } + }, + "description": "Message for usage metrics for this cluster." + }, + "BranchView": { + "type": "string", + "enum": [ + "BASIC", + "FULL" + ], + "description": "View on branch. Pass this enum to control which subsets of fields to get.\n\n - BASIC: Basic response contains basic information for a branch.\n - FULL: FULL response contains all detailed information for a branch." + }, + "ListBranchesResponse": { + "type": "object", + "properties": { + "branches": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/Branch" + }, + "title": "The list of branches" + }, + "nextPageToken": { + "type": "string", + "description": "A token identifying a page of results the server should return." + }, + "totalSize": { + "type": "integer", + "format": "int64", + "title": "Total number of branches" + } + }, + "title": "Message for response to list branches" + }, + "Status": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/Any" + } + } + } + } + } + } \ No newline at end of file diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/.gitignore b/pkg/tidbcloud/v1beta1/serverless/branch/.gitignore new file mode 100644 index 00000000..daf913b1 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/.openapi-generator-ignore b/pkg/tidbcloud/v1beta1/serverless/branch/.openapi-generator-ignore new file mode 100644 index 00000000..7484ee59 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/.openapi-generator/FILES b/pkg/tidbcloud/v1beta1/serverless/branch/.openapi-generator/FILES new file mode 100644 index 00000000..c9f6b400 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/.openapi-generator/FILES @@ -0,0 +1,23 @@ +.gitignore +.openapi-generator-ignore +.travis.yml +README.md +api/openapi.yaml +api_branch_service.go +client.go +configuration.go +git_push.sh +model_any.go +model_branch.go +model_branch_endpoints.go +model_branch_endpoints_private.go +model_branch_endpoints_private_aws.go +model_branch_endpoints_private_gcp.go +model_branch_endpoints_public.go +model_branch_state.go +model_branch_usage.go +model_branch_view.go +model_list_branches_response.go +model_status.go +response.go +utils.go diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/.openapi-generator/VERSION b/pkg/tidbcloud/v1beta1/serverless/branch/.openapi-generator/VERSION new file mode 100644 index 00000000..09a6d308 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.8.0 diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/.travis.yml b/pkg/tidbcloud/v1beta1/serverless/branch/.travis.yml new file mode 100644 index 00000000..f5cb2ce9 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/.travis.yml @@ -0,0 +1,8 @@ +language: go + +install: + - go get -d -v . + +script: + - go build -v ./ + diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/README.md b/pkg/tidbcloud/v1beta1/serverless/branch/README.md new file mode 100644 index 00000000..d954e716 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/README.md @@ -0,0 +1,127 @@ +# Go API client for branch + +TiDB Cloud Serverless Open API + +## Overview +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client. + +- API version: v1beta1 +- Package version: 1.0.0 +- Generator version: 7.8.0 +- Build package: org.openapitools.codegen.languages.GoClientCodegen + +## Installation + +Install the following dependencies: + +```sh +go get github.com/stretchr/testify/assert +go get golang.org/x/net/context +``` + +Put the package under your project folder and add the following in import: + +```go +import branch "github.com/GIT_USER_ID/GIT_REPO_ID" +``` + +To use a proxy, set the environment variable `HTTP_PROXY`: + +```go +os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port") +``` + +## Configuration of Server URL + +Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification. + +### Select Server Configuration + +For using other server than the one defined on index 0 set context value `branch.ContextServerIndex` of type `int`. + +```go +ctx := context.WithValue(context.Background(), branch.ContextServerIndex, 1) +``` + +### Templated Server URL + +Templated server URL is formatted using default variables from configuration or from context value `branch.ContextServerVariables` of type `map[string]string`. + +```go +ctx := context.WithValue(context.Background(), branch.ContextServerVariables, map[string]string{ + "basePath": "v2", +}) +``` + +Note, enum values are always validated and all unused variables are silently ignored. + +### URLs Configuration per Operation + +Each operation can use different server URL defined using `OperationServers` map in the `Configuration`. +An operation is uniquely identified by `"{classname}Service.{nickname}"` string. +Similar rules for overriding default operation server index and variables applies by using `branch.ContextOperationServerIndices` and `branch.ContextOperationServerVariables` context maps. + +```go +ctx := context.WithValue(context.Background(), branch.ContextOperationServerIndices, map[string]int{ + "{classname}Service.{nickname}": 2, +}) +ctx = context.WithValue(context.Background(), branch.ContextOperationServerVariables, map[string]map[string]string{ + "{classname}Service.{nickname}": { + "port": "8443", + }, +}) +``` + +## Documentation for API Endpoints + +All URIs are relative to *https://serverless.tidbapi.com* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*BranchServiceAPI* | [**BranchServiceCreateBranch**](docs/BranchServiceAPI.md#branchservicecreatebranch) | **Post** /v1beta1/clusters/{clusterId}/branches | Creates a branch. +*BranchServiceAPI* | [**BranchServiceDeleteBranch**](docs/BranchServiceAPI.md#branchservicedeletebranch) | **Delete** /v1beta1/clusters/{clusterId}/branches/{branchId} | Deletes a branch. +*BranchServiceAPI* | [**BranchServiceGetBranch**](docs/BranchServiceAPI.md#branchservicegetbranch) | **Get** /v1beta1/clusters/{clusterId}/branches/{branchId} | Gets information about a branch. +*BranchServiceAPI* | [**BranchServiceListBranches**](docs/BranchServiceAPI.md#branchservicelistbranches) | **Get** /v1beta1/clusters/{clusterId}/branches | Lists information about branches. + + +## Documentation For Models + + - [Any](docs/Any.md) + - [Branch](docs/Branch.md) + - [BranchEndpoints](docs/BranchEndpoints.md) + - [BranchEndpointsPrivate](docs/BranchEndpointsPrivate.md) + - [BranchEndpointsPrivateAWS](docs/BranchEndpointsPrivateAWS.md) + - [BranchEndpointsPrivateGCP](docs/BranchEndpointsPrivateGCP.md) + - [BranchEndpointsPublic](docs/BranchEndpointsPublic.md) + - [BranchState](docs/BranchState.md) + - [BranchUsage](docs/BranchUsage.md) + - [BranchView](docs/BranchView.md) + - [ListBranchesResponse](docs/ListBranchesResponse.md) + - [Status](docs/Status.md) + + +## Documentation For Authorization + +Endpoints do not require authorization. + + +## Documentation for Utility Methods + +Due to the fact that model structure members are all pointers, this package contains +a number of utility functions to easily obtain pointers to values of basic types. +Each of these functions takes a value of the given basic type and returns a pointer to it: + +* `PtrBool` +* `PtrInt` +* `PtrInt32` +* `PtrInt64` +* `PtrFloat` +* `PtrFloat32` +* `PtrFloat64` +* `PtrString` +* `PtrTime` + +## Author + + + diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/api/openapi.yaml b/pkg/tidbcloud/v1beta1/serverless/branch/api/openapi.yaml new file mode 100644 index 00000000..fd91109d --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/api/openapi.yaml @@ -0,0 +1,456 @@ +openapi: 3.0.1 +info: + description: TiDB Cloud Serverless Open API + title: TiDB Cloud Serverless Open API + version: v1beta1 +servers: +- url: https://serverless.tidbapi.com/ +tags: +- name: BranchService +paths: + /v1beta1/clusters/{clusterId}/branches: + get: + operationId: BranchService_ListBranches + parameters: + - description: Required. The ID of the project to which the clusters belong. + in: path + name: clusterId + required: true + schema: + type: string + - description: |- + Optional. Requested page size. Server may return fewer items than + requested. If unspecified, server will pick an appropriate default. + in: query + name: pageSize + schema: + format: int32 + type: integer + - description: Optional. A token identifying a page of results the server should + return. + in: query + name: pageToken + schema: + type: string + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ListBranchesResponse' + description: A successful response. + default: + content: + application/json: + schema: + $ref: '#/components/schemas/Status' + description: An unexpected error response. + summary: Lists information about branches. + tags: + - BranchService + post: + operationId: BranchService_CreateBranch + parameters: + - description: Required. The cluster ID of the branch + in: path + name: clusterId + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Branch' + description: Required. The resource being created + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Branch' + description: A successful response. + default: + content: + application/json: + schema: + $ref: '#/components/schemas/Status' + description: An unexpected error response. + summary: Creates a branch. + tags: + - BranchService + x-codegen-request-body-name: branch + /v1beta1/clusters/{clusterId}/branches/{branchId}: + delete: + operationId: BranchService_DeleteBranch + parameters: + - description: Required. The cluster ID of the branch + in: path + name: clusterId + required: true + schema: + type: string + - description: Required. The branch ID + in: path + name: branchId + required: true + schema: + type: string + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Branch' + description: A successful response. + default: + content: + application/json: + schema: + $ref: '#/components/schemas/Status' + description: An unexpected error response. + summary: Deletes a branch. + tags: + - BranchService + get: + operationId: BranchService_GetBranch + parameters: + - description: Required. The cluster ID of the branch + in: path + name: clusterId + required: true + schema: + type: string + - description: Required. The branch ID + in: path + name: branchId + required: true + schema: + type: string + - description: |- + 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. + in: query + name: view + schema: + enum: + - BASIC + - FULL + type: string + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Branch' + description: A successful response. + default: + content: + application/json: + schema: + $ref: '#/components/schemas/Status' + description: An unexpected error response. + summary: Gets information about a branch. + tags: + - BranchService +components: + schemas: + Any: + additionalProperties: + type: object + example: + '@type': '@type' + properties: + '@type': + type: string + type: object + Branch: + example: + branchId: branchId + endpoints: "{}" + displayName: displayName + usage: "{}" + annotations: + key: annotations + updateTime: 2000-01-23T04:56:07.000+00:00 + clusterId: clusterId + parentId: parentId + parentDisplayName: parentDisplayName + parentTimestamp: 2000-01-23T04:56:07.000+00:00 + createdBy: createdBy + createTime: 2000-01-23T04:56:07.000+00:00 + name: name + userPrefix: userPrefix + state: "{}" + properties: + name: + description: Output Only. The name of the resource. + readOnly: true + type: string + branchId: + description: Output only. The system-generated ID of the resource. + readOnly: true + type: string + displayName: + description: Required. User-settable and human-readable display name for + the branch. + type: string + clusterId: + description: Output only. The cluster ID of this branch. + readOnly: true + type: string + parentId: + description: Optional. The parent ID of this branch. + type: string + createdBy: + description: Output only. The creator of the branch. + readOnly: true + type: string + state: + allOf: + - $ref: '#/components/schemas/Branch.State' + description: Output only. The state of this branch. + type: object + endpoints: + allOf: + - $ref: '#/components/schemas/Branch.Endpoints' + description: Optional. The endpoints of this branch. + type: object + userPrefix: + description: |- + Output only. User name prefix of this branch. For each TiDB Serverless branch, + TiDB Cloud generates a unique prefix to distinguish it from other branches. + Whenever you use or set a database user name, you must include the prefix in the user name. + nullable: true + readOnly: true + type: string + usage: + allOf: + - $ref: '#/components/schemas/Branch.Usage' + description: Output only. Usage metrics of this branch. Only display in + FULL view. + type: object + createTime: + format: date-time + readOnly: true + title: Output only. Create timestamp + type: string + updateTime: + format: date-time + readOnly: true + title: Output only. Update timestamp + type: string + annotations: + additionalProperties: + type: string + description: Optional. The annotations of this branch.. + type: object + parentDisplayName: + description: Output only. The parent display name of this branch. + readOnly: true + type: string + parentTimestamp: + description: Optional. The point in time on the parent branch the branch + will be created from. + format: date-time + nullable: true + type: string + required: + - displayName + title: Message for branch + type: object + Branch.Endpoints: + description: Message for the Endpoints for this branch. + properties: + public: + allOf: + - $ref: '#/components/schemas/Branch.Endpoints.Public' + description: Optional. Public Endpoint for this branch. + type: object + private: + allOf: + - $ref: '#/components/schemas/Branch.Endpoints.Private' + description: Output only. Private Endpoint for this branch. + type: object + type: object + Branch.Endpoints.Private: + description: Message for Private Endpoint for this branch. + properties: + host: + description: Output Only. Host Name of Public Endpoint. + readOnly: true + type: string + port: + description: Output Only. Port of Public Endpoint. + format: int32 + readOnly: true + type: integer + aws: + allOf: + - $ref: '#/components/schemas/Branch.Endpoints.Private.AWS' + title: Message for AWS + type: object + gcp: + allOf: + - $ref: '#/components/schemas/Branch.Endpoints.Private.GCP' + title: Message for GCP + type: object + type: object + Branch.Endpoints.Private.AWS: + description: Message for AWS Private Link Service. + properties: + serviceName: + description: Output Only. Service Name for Private Link Service. + readOnly: true + type: string + availabilityZone: + description: Output Only. Availability Zone for Private Link Service. + items: + type: string + readOnly: true + type: array + type: object + Branch.Endpoints.Private.GCP: + description: Message for GCP Private Link Service. + properties: + serviceAttachmentName: + description: Output Only. Target Service Account for Private Link Service. + readOnly: true + type: string + type: object + Branch.Endpoints.Public: + description: Message for Public Endpoint for this branch. + properties: + host: + readOnly: true + title: Output Only. Host name of Public Endpoint + type: string + port: + format: int32 + readOnly: true + title: Output Only. Port of Public Endpoint + type: integer + disabled: + title: Optional. Disable Public Endpoint + type: boolean + type: object + Branch.State: + description: |- + Output Only. Branch State. + + - CREATING: The branch is being created. + - ACTIVE: The branch is active and running. + - DELETED: The branch is being deleted. + - MAINTENANCE: The branch is under maintenance. + enum: + - CREATING + - ACTIVE + - DELETED + - MAINTENANCE + type: string + Branch.Usage: + description: Message for usage metrics for this cluster. + properties: + requestUnit: + description: Output Only. The latest value of Request Unit Metric for this + cluster. + format: int64 + readOnly: true + type: string + rowStorage: + description: Output Only. The latest value of Row Storage Metric for this + cluster. + format: double + readOnly: true + type: number + columnarStorage: + description: Output Only. The latest value of Columnar Storage Metric for + this cluster. + format: double + readOnly: true + type: number + type: object + BranchView: + description: |- + View on branch. Pass this enum to control which subsets of fields to get. + + - BASIC: Basic response contains basic information for a branch. + - FULL: FULL response contains all detailed information for a branch. + enum: + - BASIC + - FULL + type: string + ListBranchesResponse: + example: + totalSize: 0 + nextPageToken: nextPageToken + branches: + - branchId: branchId + endpoints: "{}" + displayName: displayName + usage: "{}" + annotations: + key: annotations + updateTime: 2000-01-23T04:56:07.000+00:00 + clusterId: clusterId + parentId: parentId + parentDisplayName: parentDisplayName + parentTimestamp: 2000-01-23T04:56:07.000+00:00 + createdBy: createdBy + createTime: 2000-01-23T04:56:07.000+00:00 + name: name + userPrefix: userPrefix + state: "{}" + - branchId: branchId + endpoints: "{}" + displayName: displayName + usage: "{}" + annotations: + key: annotations + updateTime: 2000-01-23T04:56:07.000+00:00 + clusterId: clusterId + parentId: parentId + parentDisplayName: parentDisplayName + parentTimestamp: 2000-01-23T04:56:07.000+00:00 + createdBy: createdBy + createTime: 2000-01-23T04:56:07.000+00:00 + name: name + userPrefix: userPrefix + state: "{}" + properties: + branches: + items: + $ref: '#/components/schemas/Branch' + title: The list of branches + type: array + nextPageToken: + description: A token identifying a page of results the server should return. + type: string + totalSize: + format: int64 + title: Total number of branches + type: integer + title: Message for response to list branches + type: object + Status: + example: + code: 6 + details: + - '@type': '@type' + - '@type': '@type' + message: message + properties: + code: + format: int32 + type: integer + message: + type: string + details: + items: + $ref: '#/components/schemas/Any' + type: array + type: object +x-original-swagger-version: "2.0" diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/api_branch_service.go b/pkg/tidbcloud/v1beta1/serverless/branch/api_branch_service.go new file mode 100644 index 00000000..587ae53b --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/api_branch_service.go @@ -0,0 +1,510 @@ +/* +TiDB Cloud Serverless Open API + +TiDB Cloud Serverless Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package branch + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" + "strings" +) + + +// BranchServiceAPIService BranchServiceAPI service +type BranchServiceAPIService service + +type ApiBranchServiceCreateBranchRequest struct { + ctx context.Context + ApiService *BranchServiceAPIService + clusterId string + branch *Branch +} + +// Required. The resource being created +func (r ApiBranchServiceCreateBranchRequest) Branch(branch Branch) ApiBranchServiceCreateBranchRequest { + r.branch = &branch + return r +} + +func (r ApiBranchServiceCreateBranchRequest) Execute() (*Branch, *http.Response, error) { + return r.ApiService.BranchServiceCreateBranchExecute(r) +} + +/* +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 +*/ +func (a *BranchServiceAPIService) BranchServiceCreateBranch(ctx context.Context, clusterId string) ApiBranchServiceCreateBranchRequest { + return ApiBranchServiceCreateBranchRequest{ + ApiService: a, + ctx: ctx, + clusterId: clusterId, + } +} + +// Execute executes the request +// @return Branch +func (a *BranchServiceAPIService) BranchServiceCreateBranchExecute(r ApiBranchServiceCreateBranchRequest) (*Branch, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Branch + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BranchServiceAPIService.BranchServiceCreateBranch") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1beta1/clusters/{clusterId}/branches" + localVarPath = strings.Replace(localVarPath, "{"+"clusterId"+"}", url.PathEscape(parameterValueToString(r.clusterId, "clusterId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.branch == nil { + return localVarReturnValue, nil, reportError("branch is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.branch + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + 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 + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiBranchServiceDeleteBranchRequest struct { + ctx context.Context + ApiService *BranchServiceAPIService + clusterId string + branchId string +} + +func (r ApiBranchServiceDeleteBranchRequest) Execute() (*Branch, *http.Response, error) { + return r.ApiService.BranchServiceDeleteBranchExecute(r) +} + +/* +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 +*/ +func (a *BranchServiceAPIService) BranchServiceDeleteBranch(ctx context.Context, clusterId string, branchId string) ApiBranchServiceDeleteBranchRequest { + return ApiBranchServiceDeleteBranchRequest{ + ApiService: a, + ctx: ctx, + clusterId: clusterId, + branchId: branchId, + } +} + +// Execute executes the request +// @return Branch +func (a *BranchServiceAPIService) BranchServiceDeleteBranchExecute(r ApiBranchServiceDeleteBranchRequest) (*Branch, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Branch + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BranchServiceAPIService.BranchServiceDeleteBranch") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1beta1/clusters/{clusterId}/branches/{branchId}" + localVarPath = strings.Replace(localVarPath, "{"+"clusterId"+"}", url.PathEscape(parameterValueToString(r.clusterId, "clusterId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"branchId"+"}", url.PathEscape(parameterValueToString(r.branchId, "branchId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + 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 + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiBranchServiceGetBranchRequest struct { + ctx context.Context + ApiService *BranchServiceAPIService + 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. +func (r ApiBranchServiceGetBranchRequest) View(view string) ApiBranchServiceGetBranchRequest { + r.view = &view + return r +} + +func (r ApiBranchServiceGetBranchRequest) Execute() (*Branch, *http.Response, error) { + return r.ApiService.BranchServiceGetBranchExecute(r) +} + +/* +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 +*/ +func (a *BranchServiceAPIService) BranchServiceGetBranch(ctx context.Context, clusterId string, branchId string) ApiBranchServiceGetBranchRequest { + return ApiBranchServiceGetBranchRequest{ + ApiService: a, + ctx: ctx, + clusterId: clusterId, + branchId: branchId, + } +} + +// Execute executes the request +// @return Branch +func (a *BranchServiceAPIService) BranchServiceGetBranchExecute(r ApiBranchServiceGetBranchRequest) (*Branch, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Branch + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BranchServiceAPIService.BranchServiceGetBranch") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1beta1/clusters/{clusterId}/branches/{branchId}" + localVarPath = strings.Replace(localVarPath, "{"+"clusterId"+"}", url.PathEscape(parameterValueToString(r.clusterId, "clusterId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"branchId"+"}", url.PathEscape(parameterValueToString(r.branchId, "branchId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if r.view != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "view", r.view, "", "") + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + 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 + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiBranchServiceListBranchesRequest struct { + ctx context.Context + ApiService *BranchServiceAPIService + 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. +func (r ApiBranchServiceListBranchesRequest) PageSize(pageSize int32) ApiBranchServiceListBranchesRequest { + r.pageSize = &pageSize + return r +} + +// Optional. A token identifying a page of results the server should return. +func (r ApiBranchServiceListBranchesRequest) PageToken(pageToken string) ApiBranchServiceListBranchesRequest { + r.pageToken = &pageToken + return r +} + +func (r ApiBranchServiceListBranchesRequest) Execute() (*ListBranchesResponse, *http.Response, error) { + return r.ApiService.BranchServiceListBranchesExecute(r) +} + +/* +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 +*/ +func (a *BranchServiceAPIService) BranchServiceListBranches(ctx context.Context, clusterId string) ApiBranchServiceListBranchesRequest { + return ApiBranchServiceListBranchesRequest{ + ApiService: a, + ctx: ctx, + clusterId: clusterId, + } +} + +// Execute executes the request +// @return ListBranchesResponse +func (a *BranchServiceAPIService) BranchServiceListBranchesExecute(r ApiBranchServiceListBranchesRequest) (*ListBranchesResponse, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ListBranchesResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BranchServiceAPIService.BranchServiceListBranches") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1beta1/clusters/{clusterId}/branches" + localVarPath = strings.Replace(localVarPath, "{"+"clusterId"+"}", url.PathEscape(parameterValueToString(r.clusterId, "clusterId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if r.pageSize != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "pageSize", r.pageSize, "", "") + } + if r.pageToken != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "pageToken", r.pageToken, "", "") + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + 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 + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/client.go b/pkg/tidbcloud/v1beta1/serverless/branch/client.go new file mode 100644 index 00000000..1844e5e9 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/client.go @@ -0,0 +1,652 @@ +/* +TiDB Cloud Serverless Open API + +TiDB Cloud Serverless Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package branch + +import ( + "bytes" + "context" + "encoding/json" + "encoding/xml" + "errors" + "fmt" + "io" + "log" + "mime/multipart" + "net/http" + "net/http/httputil" + "net/url" + "os" + "path/filepath" + "reflect" + "regexp" + "strconv" + "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", "]" ) +) + +// APIClient manages communication with the TiDB Cloud Serverless Open API API vv1beta1 +// In most cases there should be only one, shared, APIClient. +type APIClient struct { + cfg *Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. + + // API Services + + BranchServiceAPI *BranchServiceAPIService +} + +type service struct { + client *APIClient +} + +// NewAPIClient creates a new API client. Requires a userAgent string describing your application. +// optionally a custom http.Client to allow for advanced features such as caching. +func NewAPIClient(cfg *Configuration) *APIClient { + if cfg.HTTPClient == nil { + cfg.HTTPClient = http.DefaultClient + } + + c := &APIClient{} + c.cfg = cfg + c.common.client = c + + // API Services + c.BranchServiceAPI = (*BranchServiceAPIService)(&c.common) + + return c +} + +func atoi(in string) (int, error) { + return strconv.Atoi(in) +} + +// selectHeaderContentType select a content type from the available list. +func selectHeaderContentType(contentTypes []string) string { + if len(contentTypes) == 0 { + return "" + } + if contains(contentTypes, "application/json") { + return "application/json" + } + return contentTypes[0] // use the first content type specified in 'consumes' +} + +// selectHeaderAccept join all accept types and return +func selectHeaderAccept(accepts []string) string { + if len(accepts) == 0 { + return "" + } + + if contains(accepts, "application/json") { + return "application/json" + } + + return strings.Join(accepts, ",") +} + +// contains is a case insensitive match, finding needle in a haystack +func contains(haystack []string, needle string) bool { + for _, a := range haystack { + if strings.EqualFold(a, needle) { + return true + } + } + return false +} + +// Verify optional parameters are of the correct type. +func typeCheckParameter(obj interface{}, expected string, name string) error { + // Make sure there is an object. + if obj == nil { + return nil + } + + // Check the type is as expected. + if reflect.TypeOf(obj).String() != expected { + return fmt.Errorf("expected %s to be of type %s but received %s", name, expected, reflect.TypeOf(obj).String()) + } + return nil +} + +func parameterValueToString( obj interface{}, key string ) string { + if reflect.TypeOf(obj).Kind() != reflect.Ptr { + return fmt.Sprintf("%v", obj) + } + var param,ok = obj.(MappedNullable) + if !ok { + return "" + } + dataMap,err := param.ToMap() + if err != nil { + return "" + } + return fmt.Sprintf("%v", dataMap[key]) +} + +// parameterAddToHeaderOrQuery adds the provided object to the request header or url query +// supporting deep object syntax +func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, style string, collectionType string) { + var v = reflect.ValueOf(obj) + var value = "" + if v == reflect.ValueOf(nil) { + value = "null" + } else { + switch v.Kind() { + 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) { + return + } + var lenIndValue = indValue.Len() + for i:=0;i 0 || (len(formFiles) > 0) { + if body != nil { + return nil, errors.New("Cannot specify postBody and multipart form at the same time.") + } + body = &bytes.Buffer{} + w := multipart.NewWriter(body) + + for k, v := range formParams { + for _, iv := range v { + if strings.HasPrefix(k, "@") { // file + err = addFile(w, k[1:], iv) + if err != nil { + return nil, err + } + } else { // form value + w.WriteField(k, iv) + } + } + } + for _, formFile := range formFiles { + if len(formFile.fileBytes) > 0 && formFile.fileName != "" { + w.Boundary() + part, err := w.CreateFormFile(formFile.formFileName, filepath.Base(formFile.fileName)) + if err != nil { + return nil, err + } + _, err = part.Write(formFile.fileBytes) + if err != nil { + return nil, err + } + } + } + + // Set the Boundary in the Content-Type + headerParams["Content-Type"] = w.FormDataContentType() + + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + w.Close() + } + + if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 { + if body != nil { + return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.") + } + body = &bytes.Buffer{} + body.WriteString(formParams.Encode()) + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + } + + // Setup path and query parameters + url, err := url.Parse(path) + if err != nil { + return nil, err + } + + // Override request host, if applicable + if c.cfg.Host != "" { + url.Host = c.cfg.Host + } + + // Override request scheme, if applicable + if c.cfg.Scheme != "" { + url.Scheme = c.cfg.Scheme + } + + // Adding Query Param + query := url.Query() + for k, v := range queryParams { + for _, iv := range v { + query.Add(k, iv) + } + } + + // Encode the parameters. + url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string { + pieces := strings.Split(s, "=") + pieces[0] = queryDescape.Replace(pieces[0]) + return strings.Join(pieces, "=") + }) + + // Generate a new request + if body != nil { + localVarRequest, err = http.NewRequest(method, url.String(), body) + } else { + localVarRequest, err = http.NewRequest(method, url.String(), nil) + } + if err != nil { + return nil, err + } + + // add header parameters, if any + if len(headerParams) > 0 { + headers := http.Header{} + for h, v := range headerParams { + headers[h] = []string{v} + } + localVarRequest.Header = headers + } + + // Add the user agent to the request. + localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) + + if ctx != nil { + // add context to the request + localVarRequest = localVarRequest.WithContext(ctx) + + // Walk through any authentication. + + } + + for header, value := range c.cfg.DefaultHeader { + localVarRequest.Header.Add(header, value) + } + return localVarRequest, nil +} + +func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { + if len(b) == 0 { + return nil + } + if s, ok := v.(*string); ok { + *s = string(b) + return nil + } + if f, ok := v.(*os.File); ok { + f, err = os.CreateTemp("", "HttpClientFile") + if err != nil { + return + } + _, err = f.Write(b) + if err != nil { + return + } + _, err = f.Seek(0, io.SeekStart) + return + } + if f, ok := v.(**os.File); ok { + *f, err = os.CreateTemp("", "HttpClientFile") + if err != nil { + return + } + _, err = (*f).Write(b) + if err != nil { + return + } + _, err = (*f).Seek(0, io.SeekStart) + return + } + if XmlCheck.MatchString(contentType) { + if err = xml.Unmarshal(b, v); err != nil { + return err + } + return nil + } + if JsonCheck.MatchString(contentType) { + if actualObj, ok := v.(interface{ GetActualInstance() interface{} }); ok { // oneOf, anyOf schemas + if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok { // make sure it has UnmarshalJSON defined + if err = unmarshalObj.UnmarshalJSON(b); err != nil { + return err + } + } else { + return errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined") + } + } else if err = json.Unmarshal(b, v); err != nil { // simple model + return err + } + return nil + } + return errors.New("undefined response type") +} + +// Add a file to the multipart request +func addFile(w *multipart.Writer, fieldName, path string) error { + file, err := os.Open(filepath.Clean(path)) + if err != nil { + return err + } + err = file.Close() + if err != nil { + return err + } + + part, err := w.CreateFormFile(fieldName, filepath.Base(path)) + if err != nil { + return err + } + _, err = io.Copy(part, file) + + return err +} + +// Set request body from an interface{} +func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { + if bodyBuf == nil { + bodyBuf = &bytes.Buffer{} + } + + if reader, ok := body.(io.Reader); ok { + _, err = bodyBuf.ReadFrom(reader) + } else if fp, ok := body.(*os.File); ok { + _, err = bodyBuf.ReadFrom(fp) + } else if b, ok := body.([]byte); ok { + _, err = bodyBuf.Write(b) + } else if s, ok := body.(string); ok { + _, err = bodyBuf.WriteString(s) + } else if s, ok := body.(*string); ok { + _, err = bodyBuf.WriteString(*s) + } else if JsonCheck.MatchString(contentType) { + err = json.NewEncoder(bodyBuf).Encode(body) + } else if XmlCheck.MatchString(contentType) { + var bs []byte + bs, err = xml.Marshal(body) + if err == nil { + bodyBuf.Write(bs) + } + } + + if err != nil { + return nil, err + } + + if bodyBuf.Len() == 0 { + err = fmt.Errorf("invalid body type %s\n", contentType) + return nil, err + } + return bodyBuf, nil +} + +// detectContentType method is used to figure out `Request.Body` content type for request header +func detectContentType(body interface{}) string { + contentType := "text/plain; charset=utf-8" + kind := reflect.TypeOf(body).Kind() + + switch kind { + case reflect.Struct, reflect.Map, reflect.Ptr: + contentType = "application/json; charset=utf-8" + case reflect.String: + contentType = "text/plain; charset=utf-8" + default: + if b, ok := body.([]byte); ok { + contentType = http.DetectContentType(b) + } else if kind == reflect.Slice { + contentType = "application/json; charset=utf-8" + } + } + + return contentType +} + +// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go +type cacheControl map[string]string + +func parseCacheControl(headers http.Header) cacheControl { + cc := cacheControl{} + ccHeader := headers.Get("Cache-Control") + for _, part := range strings.Split(ccHeader, ",") { + part = strings.Trim(part, " ") + if part == "" { + continue + } + if strings.ContainsRune(part, '=') { + keyval := strings.Split(part, "=") + cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") + } else { + cc[part] = "" + } + } + return cc +} + +// CacheExpires helper function to determine remaining time before repeating a request. +func CacheExpires(r *http.Response) time.Time { + // Figure out when the cache expires. + var expires time.Time + now, err := time.Parse(time.RFC1123, r.Header.Get("date")) + if err != nil { + return time.Now() + } + respCacheControl := parseCacheControl(r.Header) + + if maxAge, ok := respCacheControl["max-age"]; ok { + lifetime, err := time.ParseDuration(maxAge + "s") + if err != nil { + expires = now + } else { + expires = now.Add(lifetime) + } + } else { + expiresHeader := r.Header.Get("Expires") + if expiresHeader != "" { + expires, err = time.Parse(time.RFC1123, expiresHeader) + if err != nil { + expires = now + } + } + } + return expires +} + +func strlen(s string) int { + return utf8.RuneCountInString(s) +} + +// GenericOpenAPIError Provides access to the body, error and model on returned errors. +type GenericOpenAPIError struct { + body []byte + error string + model interface{} +} + +// Error returns non-empty string if there was an error. +func (e GenericOpenAPIError) Error() string { + return e.error +} + +// Body returns the raw bytes of the response +func (e GenericOpenAPIError) Body() []byte { + return e.body +} + +// Model returns the unpacked model of the error +func (e GenericOpenAPIError) Model() interface{} { + return e.model +} + +// format error message using title and detail when model implements rfc7807 +func formatErrorMessage(status string, v interface{}) string { + str := "" + metaValue := reflect.ValueOf(v).Elem() + + if metaValue.Kind() == reflect.Struct { + field := metaValue.FieldByName("Title") + if field != (reflect.Value{}) { + str = fmt.Sprintf("%s", field.Interface()) + } + + field = metaValue.FieldByName("Detail") + if field != (reflect.Value{}) { + str = fmt.Sprintf("%s (%s)", str, field.Interface()) + } + } + + return strings.TrimSpace(fmt.Sprintf("%s %s", status, str)) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/configuration.go b/pkg/tidbcloud/v1beta1/serverless/branch/configuration.go new file mode 100644 index 00000000..de71f169 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/configuration.go @@ -0,0 +1,215 @@ +/* +TiDB Cloud Serverless Open API + +TiDB Cloud Serverless Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package branch + +import ( + "context" + "fmt" + "net/http" + "strings" +) + +// contextKeys are used to identify the type of value in the context. +// Since these are string, it is possible to get a short description of the +// context key for logging and debugging using key.String(). + +type contextKey string + +func (c contextKey) String() string { + return "auth " + string(c) +} + +var ( + // ContextServerIndex uses a server configuration from the index. + ContextServerIndex = contextKey("serverIndex") + + // ContextOperationServerIndices uses a server configuration from the index mapping. + ContextOperationServerIndices = contextKey("serverOperationIndices") + + // ContextServerVariables overrides a server configuration variables. + ContextServerVariables = contextKey("serverVariables") + + // ContextOperationServerVariables overrides a server configuration variables using operation specific values. + ContextOperationServerVariables = contextKey("serverOperationVariables") +) + +// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth +type BasicAuth struct { + UserName string `json:"userName,omitempty"` + Password string `json:"password,omitempty"` +} + +// APIKey provides API key based authentication to a request passed via context using ContextAPIKey +type APIKey struct { + Key string + Prefix string +} + +// ServerVariable stores the information about a server variable +type ServerVariable struct { + Description string + DefaultValue string + EnumValues []string +} + +// ServerConfiguration stores the information about a server +type ServerConfiguration struct { + URL string + Description string + Variables map[string]ServerVariable +} + +// ServerConfigurations stores multiple ServerConfiguration items +type ServerConfigurations []ServerConfiguration + +// Configuration stores the configuration of the API client +type Configuration struct { + Host string `json:"host,omitempty"` + Scheme string `json:"scheme,omitempty"` + DefaultHeader map[string]string `json:"defaultHeader,omitempty"` + UserAgent string `json:"userAgent,omitempty"` + Debug bool `json:"debug,omitempty"` + Servers ServerConfigurations + OperationServers map[string]ServerConfigurations + HTTPClient *http.Client +} + +// NewConfiguration returns a new Configuration object +func NewConfiguration() *Configuration { + cfg := &Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Servers: ServerConfigurations{ + { + URL: "https://serverless.tidbapi.com", + Description: "No description provided", + }, + }, + OperationServers: map[string]ServerConfigurations{ + }, + } + return cfg +} + +// AddDefaultHeader adds a new HTTP header to the default header in the request +func (c *Configuration) AddDefaultHeader(key string, value string) { + c.DefaultHeader[key] = value +} + +// URL formats template on a index using given variables +func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error) { + if index < 0 || len(sc) <= index { + return "", fmt.Errorf("index %v out of range %v", index, len(sc)-1) + } + server := sc[index] + url := server.URL + + // go through variables and replace placeholders + for name, variable := range server.Variables { + if value, ok := variables[name]; ok { + found := bool(len(variable.EnumValues) == 0) + for _, enumValue := range variable.EnumValues { + if value == enumValue { + found = true + } + } + if !found { + return "", fmt.Errorf("the variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues) + } + url = strings.Replace(url, "{"+name+"}", value, -1) + } else { + url = strings.Replace(url, "{"+name+"}", variable.DefaultValue, -1) + } + } + return url, nil +} + +// ServerURL returns URL based on server settings +func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error) { + return c.Servers.URL(index, variables) +} + +func getServerIndex(ctx context.Context) (int, error) { + si := ctx.Value(ContextServerIndex) + if si != nil { + if index, ok := si.(int); ok { + return index, nil + } + return 0, reportError("Invalid type %T should be int", si) + } + return 0, nil +} + +func getServerOperationIndex(ctx context.Context, endpoint string) (int, error) { + osi := ctx.Value(ContextOperationServerIndices) + if osi != nil { + if operationIndices, ok := osi.(map[string]int); !ok { + return 0, reportError("Invalid type %T should be map[string]int", osi) + } else { + index, ok := operationIndices[endpoint] + if ok { + return index, nil + } + } + } + return getServerIndex(ctx) +} + +func getServerVariables(ctx context.Context) (map[string]string, error) { + sv := ctx.Value(ContextServerVariables) + if sv != nil { + if variables, ok := sv.(map[string]string); ok { + return variables, nil + } + return nil, reportError("ctx value of ContextServerVariables has invalid type %T should be map[string]string", sv) + } + return nil, nil +} + +func getServerOperationVariables(ctx context.Context, endpoint string) (map[string]string, error) { + osv := ctx.Value(ContextOperationServerVariables) + if osv != nil { + if operationVariables, ok := osv.(map[string]map[string]string); !ok { + return nil, reportError("ctx value of ContextOperationServerVariables has invalid type %T should be map[string]map[string]string", osv) + } else { + variables, ok := operationVariables[endpoint] + if ok { + return variables, nil + } + } + } + return getServerVariables(ctx) +} + +// ServerURLWithContext returns a new server URL given an endpoint +func (c *Configuration) ServerURLWithContext(ctx context.Context, endpoint string) (string, error) { + sc, ok := c.OperationServers[endpoint] + if !ok { + sc = c.Servers + } + + if ctx == nil { + return sc.URL(0, nil) + } + + index, err := getServerOperationIndex(ctx, endpoint) + if err != nil { + return "", err + } + + variables, err := getServerOperationVariables(ctx, endpoint) + if err != nil { + return "", err + } + + return sc.URL(index, variables) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/git_push.sh b/pkg/tidbcloud/v1beta1/serverless/branch/git_push.sh new file mode 100644 index 00000000..f53a75d4 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/model_any.go b/pkg/tidbcloud/v1beta1/serverless/branch/model_any.go new file mode 100644 index 00000000..a4efd76c --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/model_any.go @@ -0,0 +1,155 @@ +/* +TiDB Cloud Serverless Open API + +TiDB Cloud Serverless Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package branch + +import ( + "encoding/json" +) + +// checks if the Any type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Any{} + +// Any struct for Any +type Any struct { + Type *string `json:"@type,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _Any Any + +// NewAny instantiates a new Any object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewAny() *Any { + this := Any{} + return &this +} + +// NewAnyWithDefaults instantiates a new Any object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewAnyWithDefaults() *Any { + this := Any{} + return &this +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *Any) GetType() string { + if o == nil || IsNil(o.Type) { + var ret string + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Any) GetTypeOk() (*string, bool) { + if o == nil || IsNil(o.Type) { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *Any) HasType() bool { + if o != nil && !IsNil(o.Type) { + return true + } + + return false +} + +// SetType gets a reference to the given string and assigns it to the Type field. +func (o *Any) SetType(v string) { + o.Type = &v +} + +func (o Any) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Any) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Type) { + toSerialize["@type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *Any) UnmarshalJSON(data []byte) (err error) { + varAny := _Any{} + + err = json.Unmarshal(data, &varAny) + + if err != nil { + return err + } + + *o = Any(varAny) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "@type") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableAny struct { + value *Any + isSet bool +} + +func (v NullableAny) Get() *Any { + return v.value +} + +func (v *NullableAny) Set(val *Any) { + v.value = val + v.isSet = true +} + +func (v NullableAny) IsSet() bool { + return v.isSet +} + +func (v *NullableAny) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableAny(val *Any) *NullableAny { + return &NullableAny{value: val, isSet: true} +} + +func (v NullableAny) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableAny) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/model_branch.go b/pkg/tidbcloud/v1beta1/serverless/branch/model_branch.go new file mode 100644 index 00000000..cab64677 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/model_branch.go @@ -0,0 +1,696 @@ +/* +TiDB Cloud Serverless Open API + +TiDB Cloud Serverless Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package branch + +import ( + "encoding/json" + "time" + "bytes" + "fmt" +) + +// checks if the Branch type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Branch{} + +// Branch struct for Branch +type Branch struct { + // Output Only. The name of the resource. + Name *string `json:"name,omitempty"` + // Output only. The system-generated ID of the resource. + BranchId *string `json:"branchId,omitempty"` + // Required. User-settable and human-readable display name for the branch. + DisplayName string `json:"displayName"` + // Output only. The cluster ID of this branch. + ClusterId *string `json:"clusterId,omitempty"` + // Optional. The parent ID of this branch. + ParentId *string `json:"parentId,omitempty"` + // Output only. The creator of the branch. + CreatedBy *string `json:"createdBy,omitempty"` + // Output only. The state of this branch. + State *BranchState `json:"state,omitempty"` + // Optional. The endpoints of this branch. + Endpoints *BranchEndpoints `json:"endpoints,omitempty"` + // Output only. User name prefix of this branch. For each TiDB Serverless branch, TiDB Cloud generates a unique prefix to distinguish it from other branches. Whenever you use or set a database user name, you must include the prefix in the user name. + UserPrefix NullableString `json:"userPrefix,omitempty"` + // Output only. Usage metrics of this branch. Only display in FULL view. + Usage *BranchUsage `json:"usage,omitempty"` + CreateTime *time.Time `json:"createTime,omitempty"` + UpdateTime *time.Time `json:"updateTime,omitempty"` + // Optional. The annotations of this branch.. + Annotations *map[string]string `json:"annotations,omitempty"` + // Output only. The parent display name of this branch. + ParentDisplayName *string `json:"parentDisplayName,omitempty"` + // Optional. The point in time on the parent branch the branch will be created from. + ParentTimestamp NullableTime `json:"parentTimestamp,omitempty"` +} + +type _Branch Branch + +// NewBranch instantiates a new Branch object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewBranch(displayName string) *Branch { + this := Branch{} + this.DisplayName = displayName + return &this +} + +// NewBranchWithDefaults instantiates a new Branch object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewBranchWithDefaults() *Branch { + this := Branch{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *Branch) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Branch) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *Branch) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *Branch) SetName(v string) { + o.Name = &v +} + +// GetBranchId returns the BranchId field value if set, zero value otherwise. +func (o *Branch) GetBranchId() string { + if o == nil || IsNil(o.BranchId) { + var ret string + return ret + } + return *o.BranchId +} + +// GetBranchIdOk returns a tuple with the BranchId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Branch) GetBranchIdOk() (*string, bool) { + if o == nil || IsNil(o.BranchId) { + return nil, false + } + return o.BranchId, true +} + +// HasBranchId returns a boolean if a field has been set. +func (o *Branch) HasBranchId() bool { + if o != nil && !IsNil(o.BranchId) { + return true + } + + return false +} + +// SetBranchId gets a reference to the given string and assigns it to the BranchId field. +func (o *Branch) SetBranchId(v string) { + o.BranchId = &v +} + +// GetDisplayName returns the DisplayName field value +func (o *Branch) GetDisplayName() string { + if o == nil { + var ret string + return ret + } + + return o.DisplayName +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value +// and a boolean to check if the value has been set. +func (o *Branch) GetDisplayNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.DisplayName, true +} + +// SetDisplayName sets field value +func (o *Branch) SetDisplayName(v string) { + o.DisplayName = v +} + +// GetClusterId returns the ClusterId field value if set, zero value otherwise. +func (o *Branch) GetClusterId() string { + if o == nil || IsNil(o.ClusterId) { + var ret string + return ret + } + return *o.ClusterId +} + +// GetClusterIdOk returns a tuple with the ClusterId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Branch) GetClusterIdOk() (*string, bool) { + if o == nil || IsNil(o.ClusterId) { + return nil, false + } + return o.ClusterId, true +} + +// HasClusterId returns a boolean if a field has been set. +func (o *Branch) HasClusterId() bool { + if o != nil && !IsNil(o.ClusterId) { + return true + } + + return false +} + +// SetClusterId gets a reference to the given string and assigns it to the ClusterId field. +func (o *Branch) SetClusterId(v string) { + o.ClusterId = &v +} + +// GetParentId returns the ParentId field value if set, zero value otherwise. +func (o *Branch) GetParentId() string { + if o == nil || IsNil(o.ParentId) { + var ret string + return ret + } + return *o.ParentId +} + +// GetParentIdOk returns a tuple with the ParentId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Branch) GetParentIdOk() (*string, bool) { + if o == nil || IsNil(o.ParentId) { + return nil, false + } + return o.ParentId, true +} + +// HasParentId returns a boolean if a field has been set. +func (o *Branch) HasParentId() bool { + if o != nil && !IsNil(o.ParentId) { + return true + } + + return false +} + +// SetParentId gets a reference to the given string and assigns it to the ParentId field. +func (o *Branch) SetParentId(v string) { + o.ParentId = &v +} + +// GetCreatedBy returns the CreatedBy field value if set, zero value otherwise. +func (o *Branch) GetCreatedBy() string { + if o == nil || IsNil(o.CreatedBy) { + var ret string + return ret + } + return *o.CreatedBy +} + +// GetCreatedByOk returns a tuple with the CreatedBy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Branch) GetCreatedByOk() (*string, bool) { + if o == nil || IsNil(o.CreatedBy) { + return nil, false + } + return o.CreatedBy, true +} + +// HasCreatedBy returns a boolean if a field has been set. +func (o *Branch) HasCreatedBy() bool { + if o != nil && !IsNil(o.CreatedBy) { + return true + } + + return false +} + +// SetCreatedBy gets a reference to the given string and assigns it to the CreatedBy field. +func (o *Branch) SetCreatedBy(v string) { + o.CreatedBy = &v +} + +// GetState returns the State field value if set, zero value otherwise. +func (o *Branch) GetState() BranchState { + if o == nil || IsNil(o.State) { + var ret BranchState + return ret + } + return *o.State +} + +// GetStateOk returns a tuple with the State field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Branch) GetStateOk() (*BranchState, bool) { + if o == nil || IsNil(o.State) { + return nil, false + } + return o.State, true +} + +// HasState returns a boolean if a field has been set. +func (o *Branch) HasState() bool { + if o != nil && !IsNil(o.State) { + return true + } + + return false +} + +// SetState gets a reference to the given BranchState and assigns it to the State field. +func (o *Branch) SetState(v BranchState) { + o.State = &v +} + +// GetEndpoints returns the Endpoints field value if set, zero value otherwise. +func (o *Branch) GetEndpoints() BranchEndpoints { + if o == nil || IsNil(o.Endpoints) { + var ret BranchEndpoints + return ret + } + return *o.Endpoints +} + +// GetEndpointsOk returns a tuple with the Endpoints field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Branch) GetEndpointsOk() (*BranchEndpoints, bool) { + if o == nil || IsNil(o.Endpoints) { + return nil, false + } + return o.Endpoints, true +} + +// HasEndpoints returns a boolean if a field has been set. +func (o *Branch) HasEndpoints() bool { + if o != nil && !IsNil(o.Endpoints) { + return true + } + + return false +} + +// SetEndpoints gets a reference to the given BranchEndpoints and assigns it to the Endpoints field. +func (o *Branch) SetEndpoints(v BranchEndpoints) { + o.Endpoints = &v +} + +// GetUserPrefix returns the UserPrefix field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *Branch) GetUserPrefix() string { + if o == nil || IsNil(o.UserPrefix.Get()) { + var ret string + return ret + } + return *o.UserPrefix.Get() +} + +// GetUserPrefixOk returns a tuple with the UserPrefix field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *Branch) GetUserPrefixOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.UserPrefix.Get(), o.UserPrefix.IsSet() +} + +// HasUserPrefix returns a boolean if a field has been set. +func (o *Branch) HasUserPrefix() bool { + if o != nil && o.UserPrefix.IsSet() { + return true + } + + return false +} + +// SetUserPrefix gets a reference to the given NullableString and assigns it to the UserPrefix field. +func (o *Branch) SetUserPrefix(v string) { + o.UserPrefix.Set(&v) +} +// SetUserPrefixNil sets the value for UserPrefix to be an explicit nil +func (o *Branch) SetUserPrefixNil() { + o.UserPrefix.Set(nil) +} + +// UnsetUserPrefix ensures that no value is present for UserPrefix, not even an explicit nil +func (o *Branch) UnsetUserPrefix() { + o.UserPrefix.Unset() +} + +// GetUsage returns the Usage field value if set, zero value otherwise. +func (o *Branch) GetUsage() BranchUsage { + if o == nil || IsNil(o.Usage) { + var ret BranchUsage + return ret + } + return *o.Usage +} + +// GetUsageOk returns a tuple with the Usage field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Branch) GetUsageOk() (*BranchUsage, bool) { + if o == nil || IsNil(o.Usage) { + return nil, false + } + return o.Usage, true +} + +// HasUsage returns a boolean if a field has been set. +func (o *Branch) HasUsage() bool { + if o != nil && !IsNil(o.Usage) { + return true + } + + return false +} + +// SetUsage gets a reference to the given BranchUsage and assigns it to the Usage field. +func (o *Branch) SetUsage(v BranchUsage) { + o.Usage = &v +} + +// GetCreateTime returns the CreateTime field value if set, zero value otherwise. +func (o *Branch) GetCreateTime() time.Time { + if o == nil || IsNil(o.CreateTime) { + var ret time.Time + return ret + } + return *o.CreateTime +} + +// GetCreateTimeOk returns a tuple with the CreateTime field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Branch) GetCreateTimeOk() (*time.Time, bool) { + if o == nil || IsNil(o.CreateTime) { + return nil, false + } + return o.CreateTime, true +} + +// HasCreateTime returns a boolean if a field has been set. +func (o *Branch) HasCreateTime() bool { + if o != nil && !IsNil(o.CreateTime) { + return true + } + + return false +} + +// SetCreateTime gets a reference to the given time.Time and assigns it to the CreateTime field. +func (o *Branch) SetCreateTime(v time.Time) { + o.CreateTime = &v +} + +// GetUpdateTime returns the UpdateTime field value if set, zero value otherwise. +func (o *Branch) GetUpdateTime() time.Time { + if o == nil || IsNil(o.UpdateTime) { + var ret time.Time + return ret + } + return *o.UpdateTime +} + +// GetUpdateTimeOk returns a tuple with the UpdateTime field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Branch) GetUpdateTimeOk() (*time.Time, bool) { + if o == nil || IsNil(o.UpdateTime) { + return nil, false + } + return o.UpdateTime, true +} + +// HasUpdateTime returns a boolean if a field has been set. +func (o *Branch) HasUpdateTime() bool { + if o != nil && !IsNil(o.UpdateTime) { + return true + } + + return false +} + +// SetUpdateTime gets a reference to the given time.Time and assigns it to the UpdateTime field. +func (o *Branch) SetUpdateTime(v time.Time) { + o.UpdateTime = &v +} + +// GetAnnotations returns the Annotations field value if set, zero value otherwise. +func (o *Branch) GetAnnotations() map[string]string { + if o == nil || IsNil(o.Annotations) { + var ret map[string]string + return ret + } + return *o.Annotations +} + +// GetAnnotationsOk returns a tuple with the Annotations field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Branch) GetAnnotationsOk() (*map[string]string, bool) { + if o == nil || IsNil(o.Annotations) { + return nil, false + } + return o.Annotations, true +} + +// HasAnnotations returns a boolean if a field has been set. +func (o *Branch) HasAnnotations() bool { + if o != nil && !IsNil(o.Annotations) { + return true + } + + return false +} + +// SetAnnotations gets a reference to the given map[string]string and assigns it to the Annotations field. +func (o *Branch) SetAnnotations(v map[string]string) { + o.Annotations = &v +} + +// GetParentDisplayName returns the ParentDisplayName field value if set, zero value otherwise. +func (o *Branch) GetParentDisplayName() string { + if o == nil || IsNil(o.ParentDisplayName) { + var ret string + return ret + } + return *o.ParentDisplayName +} + +// GetParentDisplayNameOk returns a tuple with the ParentDisplayName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Branch) GetParentDisplayNameOk() (*string, bool) { + if o == nil || IsNil(o.ParentDisplayName) { + return nil, false + } + return o.ParentDisplayName, true +} + +// HasParentDisplayName returns a boolean if a field has been set. +func (o *Branch) HasParentDisplayName() bool { + if o != nil && !IsNil(o.ParentDisplayName) { + return true + } + + return false +} + +// SetParentDisplayName gets a reference to the given string and assigns it to the ParentDisplayName field. +func (o *Branch) SetParentDisplayName(v string) { + o.ParentDisplayName = &v +} + +// GetParentTimestamp returns the ParentTimestamp field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *Branch) GetParentTimestamp() time.Time { + if o == nil || IsNil(o.ParentTimestamp.Get()) { + var ret time.Time + return ret + } + return *o.ParentTimestamp.Get() +} + +// GetParentTimestampOk returns a tuple with the ParentTimestamp field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *Branch) GetParentTimestampOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return o.ParentTimestamp.Get(), o.ParentTimestamp.IsSet() +} + +// HasParentTimestamp returns a boolean if a field has been set. +func (o *Branch) HasParentTimestamp() bool { + if o != nil && o.ParentTimestamp.IsSet() { + return true + } + + return false +} + +// SetParentTimestamp gets a reference to the given NullableTime and assigns it to the ParentTimestamp field. +func (o *Branch) SetParentTimestamp(v time.Time) { + o.ParentTimestamp.Set(&v) +} +// SetParentTimestampNil sets the value for ParentTimestamp to be an explicit nil +func (o *Branch) SetParentTimestampNil() { + o.ParentTimestamp.Set(nil) +} + +// UnsetParentTimestamp ensures that no value is present for ParentTimestamp, not even an explicit nil +func (o *Branch) UnsetParentTimestamp() { + o.ParentTimestamp.Unset() +} + +func (o Branch) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Branch) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.BranchId) { + toSerialize["branchId"] = o.BranchId + } + toSerialize["displayName"] = o.DisplayName + if !IsNil(o.ClusterId) { + toSerialize["clusterId"] = o.ClusterId + } + if !IsNil(o.ParentId) { + toSerialize["parentId"] = o.ParentId + } + if !IsNil(o.CreatedBy) { + toSerialize["createdBy"] = o.CreatedBy + } + if !IsNil(o.State) { + toSerialize["state"] = o.State + } + if !IsNil(o.Endpoints) { + toSerialize["endpoints"] = o.Endpoints + } + if o.UserPrefix.IsSet() { + toSerialize["userPrefix"] = o.UserPrefix.Get() + } + if !IsNil(o.Usage) { + toSerialize["usage"] = o.Usage + } + if !IsNil(o.CreateTime) { + toSerialize["createTime"] = o.CreateTime + } + if !IsNil(o.UpdateTime) { + toSerialize["updateTime"] = o.UpdateTime + } + if !IsNil(o.Annotations) { + toSerialize["annotations"] = o.Annotations + } + if !IsNil(o.ParentDisplayName) { + toSerialize["parentDisplayName"] = o.ParentDisplayName + } + if o.ParentTimestamp.IsSet() { + toSerialize["parentTimestamp"] = o.ParentTimestamp.Get() + } + return toSerialize, nil +} + +func (o *Branch) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "displayName", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err; + } + + for _, requiredProperty := range(requiredProperties) { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varBranch := _Branch{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varBranch) + + if err != nil { + return err + } + + *o = Branch(varBranch) + + return err +} + +type NullableBranch struct { + value *Branch + isSet bool +} + +func (v NullableBranch) Get() *Branch { + return v.value +} + +func (v *NullableBranch) Set(val *Branch) { + v.value = val + v.isSet = true +} + +func (v NullableBranch) IsSet() bool { + return v.isSet +} + +func (v *NullableBranch) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBranch(val *Branch) *NullableBranch { + return &NullableBranch{value: val, isSet: true} +} + +func (v NullableBranch) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBranch) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints.go b/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints.go new file mode 100644 index 00000000..a33c2020 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints.go @@ -0,0 +1,164 @@ +/* +TiDB Cloud Serverless Open API + +TiDB Cloud Serverless Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package branch + +import ( + "encoding/json" +) + +// checks if the BranchEndpoints type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &BranchEndpoints{} + +// BranchEndpoints Message for the Endpoints for this branch. +type BranchEndpoints struct { + // Optional. Public Endpoint for this branch. + Public *BranchEndpointsPublic `json:"public,omitempty"` + // Output only. Private Endpoint for this branch. + Private *BranchEndpointsPrivate `json:"private,omitempty"` +} + +// NewBranchEndpoints instantiates a new BranchEndpoints object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewBranchEndpoints() *BranchEndpoints { + this := BranchEndpoints{} + return &this +} + +// NewBranchEndpointsWithDefaults instantiates a new BranchEndpoints object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewBranchEndpointsWithDefaults() *BranchEndpoints { + this := BranchEndpoints{} + return &this +} + +// GetPublic returns the Public field value if set, zero value otherwise. +func (o *BranchEndpoints) GetPublic() BranchEndpointsPublic { + if o == nil || IsNil(o.Public) { + var ret BranchEndpointsPublic + return ret + } + return *o.Public +} + +// GetPublicOk returns a tuple with the Public field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BranchEndpoints) GetPublicOk() (*BranchEndpointsPublic, bool) { + if o == nil || IsNil(o.Public) { + return nil, false + } + return o.Public, true +} + +// HasPublic returns a boolean if a field has been set. +func (o *BranchEndpoints) HasPublic() bool { + if o != nil && !IsNil(o.Public) { + return true + } + + return false +} + +// SetPublic gets a reference to the given BranchEndpointsPublic and assigns it to the Public field. +func (o *BranchEndpoints) SetPublic(v BranchEndpointsPublic) { + o.Public = &v +} + +// GetPrivate returns the Private field value if set, zero value otherwise. +func (o *BranchEndpoints) GetPrivate() BranchEndpointsPrivate { + if o == nil || IsNil(o.Private) { + var ret BranchEndpointsPrivate + return ret + } + return *o.Private +} + +// GetPrivateOk returns a tuple with the Private field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BranchEndpoints) GetPrivateOk() (*BranchEndpointsPrivate, bool) { + if o == nil || IsNil(o.Private) { + return nil, false + } + return o.Private, true +} + +// HasPrivate returns a boolean if a field has been set. +func (o *BranchEndpoints) HasPrivate() bool { + if o != nil && !IsNil(o.Private) { + return true + } + + return false +} + +// SetPrivate gets a reference to the given BranchEndpointsPrivate and assigns it to the Private field. +func (o *BranchEndpoints) SetPrivate(v BranchEndpointsPrivate) { + o.Private = &v +} + +func (o BranchEndpoints) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o BranchEndpoints) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Public) { + toSerialize["public"] = o.Public + } + if !IsNil(o.Private) { + toSerialize["private"] = o.Private + } + return toSerialize, nil +} + +type NullableBranchEndpoints struct { + value *BranchEndpoints + isSet bool +} + +func (v NullableBranchEndpoints) Get() *BranchEndpoints { + return v.value +} + +func (v *NullableBranchEndpoints) Set(val *BranchEndpoints) { + v.value = val + v.isSet = true +} + +func (v NullableBranchEndpoints) IsSet() bool { + return v.isSet +} + +func (v *NullableBranchEndpoints) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBranchEndpoints(val *BranchEndpoints) *NullableBranchEndpoints { + return &NullableBranchEndpoints{value: val, isSet: true} +} + +func (v NullableBranchEndpoints) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBranchEndpoints) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints_private.go b/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints_private.go new file mode 100644 index 00000000..793a84e6 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints_private.go @@ -0,0 +1,236 @@ +/* +TiDB Cloud Serverless Open API + +TiDB Cloud Serverless Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package branch + +import ( + "encoding/json" +) + +// checks if the BranchEndpointsPrivate type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &BranchEndpointsPrivate{} + +// BranchEndpointsPrivate Message for Private Endpoint for this branch. +type BranchEndpointsPrivate struct { + // Output Only. Host Name of Public Endpoint. + Host *string `json:"host,omitempty"` + // Output Only. Port of Public Endpoint. + Port *int32 `json:"port,omitempty"` + Aws *BranchEndpointsPrivateAWS `json:"aws,omitempty"` + Gcp *BranchEndpointsPrivateGCP `json:"gcp,omitempty"` +} + +// NewBranchEndpointsPrivate instantiates a new BranchEndpointsPrivate object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewBranchEndpointsPrivate() *BranchEndpointsPrivate { + this := BranchEndpointsPrivate{} + return &this +} + +// NewBranchEndpointsPrivateWithDefaults instantiates a new BranchEndpointsPrivate object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewBranchEndpointsPrivateWithDefaults() *BranchEndpointsPrivate { + this := BranchEndpointsPrivate{} + return &this +} + +// GetHost returns the Host field value if set, zero value otherwise. +func (o *BranchEndpointsPrivate) GetHost() string { + if o == nil || IsNil(o.Host) { + var ret string + return ret + } + return *o.Host +} + +// GetHostOk returns a tuple with the Host field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BranchEndpointsPrivate) GetHostOk() (*string, bool) { + if o == nil || IsNil(o.Host) { + return nil, false + } + return o.Host, true +} + +// HasHost returns a boolean if a field has been set. +func (o *BranchEndpointsPrivate) HasHost() bool { + if o != nil && !IsNil(o.Host) { + return true + } + + return false +} + +// SetHost gets a reference to the given string and assigns it to the Host field. +func (o *BranchEndpointsPrivate) SetHost(v string) { + o.Host = &v +} + +// GetPort returns the Port field value if set, zero value otherwise. +func (o *BranchEndpointsPrivate) GetPort() int32 { + if o == nil || IsNil(o.Port) { + var ret int32 + return ret + } + return *o.Port +} + +// GetPortOk returns a tuple with the Port field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BranchEndpointsPrivate) GetPortOk() (*int32, bool) { + if o == nil || IsNil(o.Port) { + return nil, false + } + return o.Port, true +} + +// HasPort returns a boolean if a field has been set. +func (o *BranchEndpointsPrivate) HasPort() bool { + if o != nil && !IsNil(o.Port) { + return true + } + + return false +} + +// SetPort gets a reference to the given int32 and assigns it to the Port field. +func (o *BranchEndpointsPrivate) SetPort(v int32) { + o.Port = &v +} + +// GetAws returns the Aws field value if set, zero value otherwise. +func (o *BranchEndpointsPrivate) GetAws() BranchEndpointsPrivateAWS { + if o == nil || IsNil(o.Aws) { + var ret BranchEndpointsPrivateAWS + return ret + } + return *o.Aws +} + +// GetAwsOk returns a tuple with the Aws field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BranchEndpointsPrivate) GetAwsOk() (*BranchEndpointsPrivateAWS, bool) { + if o == nil || IsNil(o.Aws) { + return nil, false + } + return o.Aws, true +} + +// HasAws returns a boolean if a field has been set. +func (o *BranchEndpointsPrivate) HasAws() bool { + if o != nil && !IsNil(o.Aws) { + return true + } + + return false +} + +// SetAws gets a reference to the given BranchEndpointsPrivateAWS and assigns it to the Aws field. +func (o *BranchEndpointsPrivate) SetAws(v BranchEndpointsPrivateAWS) { + o.Aws = &v +} + +// GetGcp returns the Gcp field value if set, zero value otherwise. +func (o *BranchEndpointsPrivate) GetGcp() BranchEndpointsPrivateGCP { + if o == nil || IsNil(o.Gcp) { + var ret BranchEndpointsPrivateGCP + return ret + } + return *o.Gcp +} + +// GetGcpOk returns a tuple with the Gcp field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BranchEndpointsPrivate) GetGcpOk() (*BranchEndpointsPrivateGCP, bool) { + if o == nil || IsNil(o.Gcp) { + return nil, false + } + return o.Gcp, true +} + +// HasGcp returns a boolean if a field has been set. +func (o *BranchEndpointsPrivate) HasGcp() bool { + if o != nil && !IsNil(o.Gcp) { + return true + } + + return false +} + +// SetGcp gets a reference to the given BranchEndpointsPrivateGCP and assigns it to the Gcp field. +func (o *BranchEndpointsPrivate) SetGcp(v BranchEndpointsPrivateGCP) { + o.Gcp = &v +} + +func (o BranchEndpointsPrivate) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o BranchEndpointsPrivate) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Host) { + toSerialize["host"] = o.Host + } + if !IsNil(o.Port) { + toSerialize["port"] = o.Port + } + if !IsNil(o.Aws) { + toSerialize["aws"] = o.Aws + } + if !IsNil(o.Gcp) { + toSerialize["gcp"] = o.Gcp + } + return toSerialize, nil +} + +type NullableBranchEndpointsPrivate struct { + value *BranchEndpointsPrivate + isSet bool +} + +func (v NullableBranchEndpointsPrivate) Get() *BranchEndpointsPrivate { + return v.value +} + +func (v *NullableBranchEndpointsPrivate) Set(val *BranchEndpointsPrivate) { + v.value = val + v.isSet = true +} + +func (v NullableBranchEndpointsPrivate) IsSet() bool { + return v.isSet +} + +func (v *NullableBranchEndpointsPrivate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBranchEndpointsPrivate(val *BranchEndpointsPrivate) *NullableBranchEndpointsPrivate { + return &NullableBranchEndpointsPrivate{value: val, isSet: true} +} + +func (v NullableBranchEndpointsPrivate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBranchEndpointsPrivate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints_private_aws.go b/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints_private_aws.go new file mode 100644 index 00000000..a05f9a0b --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints_private_aws.go @@ -0,0 +1,164 @@ +/* +TiDB Cloud Serverless Open API + +TiDB Cloud Serverless Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package branch + +import ( + "encoding/json" +) + +// checks if the BranchEndpointsPrivateAWS type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &BranchEndpointsPrivateAWS{} + +// BranchEndpointsPrivateAWS Message for AWS Private Link Service. +type BranchEndpointsPrivateAWS struct { + // Output Only. Service Name for Private Link Service. + ServiceName *string `json:"serviceName,omitempty"` + // Output Only. Availability Zone for Private Link Service. + AvailabilityZone []string `json:"availabilityZone,omitempty"` +} + +// NewBranchEndpointsPrivateAWS instantiates a new BranchEndpointsPrivateAWS object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewBranchEndpointsPrivateAWS() *BranchEndpointsPrivateAWS { + this := BranchEndpointsPrivateAWS{} + return &this +} + +// NewBranchEndpointsPrivateAWSWithDefaults instantiates a new BranchEndpointsPrivateAWS object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewBranchEndpointsPrivateAWSWithDefaults() *BranchEndpointsPrivateAWS { + this := BranchEndpointsPrivateAWS{} + return &this +} + +// GetServiceName returns the ServiceName field value if set, zero value otherwise. +func (o *BranchEndpointsPrivateAWS) GetServiceName() string { + if o == nil || IsNil(o.ServiceName) { + var ret string + return ret + } + return *o.ServiceName +} + +// GetServiceNameOk returns a tuple with the ServiceName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BranchEndpointsPrivateAWS) GetServiceNameOk() (*string, bool) { + if o == nil || IsNil(o.ServiceName) { + return nil, false + } + return o.ServiceName, true +} + +// HasServiceName returns a boolean if a field has been set. +func (o *BranchEndpointsPrivateAWS) HasServiceName() bool { + if o != nil && !IsNil(o.ServiceName) { + return true + } + + return false +} + +// SetServiceName gets a reference to the given string and assigns it to the ServiceName field. +func (o *BranchEndpointsPrivateAWS) SetServiceName(v string) { + o.ServiceName = &v +} + +// GetAvailabilityZone returns the AvailabilityZone field value if set, zero value otherwise. +func (o *BranchEndpointsPrivateAWS) GetAvailabilityZone() []string { + if o == nil || IsNil(o.AvailabilityZone) { + var ret []string + return ret + } + return o.AvailabilityZone +} + +// GetAvailabilityZoneOk returns a tuple with the AvailabilityZone field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BranchEndpointsPrivateAWS) GetAvailabilityZoneOk() ([]string, bool) { + if o == nil || IsNil(o.AvailabilityZone) { + return nil, false + } + return o.AvailabilityZone, true +} + +// HasAvailabilityZone returns a boolean if a field has been set. +func (o *BranchEndpointsPrivateAWS) HasAvailabilityZone() bool { + if o != nil && !IsNil(o.AvailabilityZone) { + return true + } + + return false +} + +// SetAvailabilityZone gets a reference to the given []string and assigns it to the AvailabilityZone field. +func (o *BranchEndpointsPrivateAWS) SetAvailabilityZone(v []string) { + o.AvailabilityZone = v +} + +func (o BranchEndpointsPrivateAWS) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o BranchEndpointsPrivateAWS) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.ServiceName) { + toSerialize["serviceName"] = o.ServiceName + } + if !IsNil(o.AvailabilityZone) { + toSerialize["availabilityZone"] = o.AvailabilityZone + } + return toSerialize, nil +} + +type NullableBranchEndpointsPrivateAWS struct { + value *BranchEndpointsPrivateAWS + isSet bool +} + +func (v NullableBranchEndpointsPrivateAWS) Get() *BranchEndpointsPrivateAWS { + return v.value +} + +func (v *NullableBranchEndpointsPrivateAWS) Set(val *BranchEndpointsPrivateAWS) { + v.value = val + v.isSet = true +} + +func (v NullableBranchEndpointsPrivateAWS) IsSet() bool { + return v.isSet +} + +func (v *NullableBranchEndpointsPrivateAWS) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBranchEndpointsPrivateAWS(val *BranchEndpointsPrivateAWS) *NullableBranchEndpointsPrivateAWS { + return &NullableBranchEndpointsPrivateAWS{value: val, isSet: true} +} + +func (v NullableBranchEndpointsPrivateAWS) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBranchEndpointsPrivateAWS) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints_private_gcp.go b/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints_private_gcp.go new file mode 100644 index 00000000..1d1ba3d5 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints_private_gcp.go @@ -0,0 +1,127 @@ +/* +TiDB Cloud Serverless Open API + +TiDB Cloud Serverless Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package branch + +import ( + "encoding/json" +) + +// checks if the BranchEndpointsPrivateGCP type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &BranchEndpointsPrivateGCP{} + +// BranchEndpointsPrivateGCP Message for GCP Private Link Service. +type BranchEndpointsPrivateGCP struct { + // Output Only. Target Service Account for Private Link Service. + ServiceAttachmentName *string `json:"serviceAttachmentName,omitempty"` +} + +// NewBranchEndpointsPrivateGCP instantiates a new BranchEndpointsPrivateGCP object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewBranchEndpointsPrivateGCP() *BranchEndpointsPrivateGCP { + this := BranchEndpointsPrivateGCP{} + return &this +} + +// NewBranchEndpointsPrivateGCPWithDefaults instantiates a new BranchEndpointsPrivateGCP object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewBranchEndpointsPrivateGCPWithDefaults() *BranchEndpointsPrivateGCP { + this := BranchEndpointsPrivateGCP{} + return &this +} + +// GetServiceAttachmentName returns the ServiceAttachmentName field value if set, zero value otherwise. +func (o *BranchEndpointsPrivateGCP) GetServiceAttachmentName() string { + if o == nil || IsNil(o.ServiceAttachmentName) { + var ret string + return ret + } + return *o.ServiceAttachmentName +} + +// GetServiceAttachmentNameOk returns a tuple with the ServiceAttachmentName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BranchEndpointsPrivateGCP) GetServiceAttachmentNameOk() (*string, bool) { + if o == nil || IsNil(o.ServiceAttachmentName) { + return nil, false + } + return o.ServiceAttachmentName, true +} + +// HasServiceAttachmentName returns a boolean if a field has been set. +func (o *BranchEndpointsPrivateGCP) HasServiceAttachmentName() bool { + if o != nil && !IsNil(o.ServiceAttachmentName) { + return true + } + + return false +} + +// SetServiceAttachmentName gets a reference to the given string and assigns it to the ServiceAttachmentName field. +func (o *BranchEndpointsPrivateGCP) SetServiceAttachmentName(v string) { + o.ServiceAttachmentName = &v +} + +func (o BranchEndpointsPrivateGCP) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o BranchEndpointsPrivateGCP) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.ServiceAttachmentName) { + toSerialize["serviceAttachmentName"] = o.ServiceAttachmentName + } + return toSerialize, nil +} + +type NullableBranchEndpointsPrivateGCP struct { + value *BranchEndpointsPrivateGCP + isSet bool +} + +func (v NullableBranchEndpointsPrivateGCP) Get() *BranchEndpointsPrivateGCP { + return v.value +} + +func (v *NullableBranchEndpointsPrivateGCP) Set(val *BranchEndpointsPrivateGCP) { + v.value = val + v.isSet = true +} + +func (v NullableBranchEndpointsPrivateGCP) IsSet() bool { + return v.isSet +} + +func (v *NullableBranchEndpointsPrivateGCP) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBranchEndpointsPrivateGCP(val *BranchEndpointsPrivateGCP) *NullableBranchEndpointsPrivateGCP { + return &NullableBranchEndpointsPrivateGCP{value: val, isSet: true} +} + +func (v NullableBranchEndpointsPrivateGCP) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBranchEndpointsPrivateGCP) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints_public.go b/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints_public.go new file mode 100644 index 00000000..815ce12e --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_endpoints_public.go @@ -0,0 +1,198 @@ +/* +TiDB Cloud Serverless Open API + +TiDB Cloud Serverless Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package branch + +import ( + "encoding/json" +) + +// checks if the BranchEndpointsPublic type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &BranchEndpointsPublic{} + +// BranchEndpointsPublic Message for Public Endpoint for this branch. +type BranchEndpointsPublic struct { + Host *string `json:"host,omitempty"` + Port *int32 `json:"port,omitempty"` + Disabled *bool `json:"disabled,omitempty"` +} + +// NewBranchEndpointsPublic instantiates a new BranchEndpointsPublic object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewBranchEndpointsPublic() *BranchEndpointsPublic { + this := BranchEndpointsPublic{} + return &this +} + +// NewBranchEndpointsPublicWithDefaults instantiates a new BranchEndpointsPublic object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewBranchEndpointsPublicWithDefaults() *BranchEndpointsPublic { + this := BranchEndpointsPublic{} + return &this +} + +// GetHost returns the Host field value if set, zero value otherwise. +func (o *BranchEndpointsPublic) GetHost() string { + if o == nil || IsNil(o.Host) { + var ret string + return ret + } + return *o.Host +} + +// GetHostOk returns a tuple with the Host field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BranchEndpointsPublic) GetHostOk() (*string, bool) { + if o == nil || IsNil(o.Host) { + return nil, false + } + return o.Host, true +} + +// HasHost returns a boolean if a field has been set. +func (o *BranchEndpointsPublic) HasHost() bool { + if o != nil && !IsNil(o.Host) { + return true + } + + return false +} + +// SetHost gets a reference to the given string and assigns it to the Host field. +func (o *BranchEndpointsPublic) SetHost(v string) { + o.Host = &v +} + +// GetPort returns the Port field value if set, zero value otherwise. +func (o *BranchEndpointsPublic) GetPort() int32 { + if o == nil || IsNil(o.Port) { + var ret int32 + return ret + } + return *o.Port +} + +// GetPortOk returns a tuple with the Port field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BranchEndpointsPublic) GetPortOk() (*int32, bool) { + if o == nil || IsNil(o.Port) { + return nil, false + } + return o.Port, true +} + +// HasPort returns a boolean if a field has been set. +func (o *BranchEndpointsPublic) HasPort() bool { + if o != nil && !IsNil(o.Port) { + return true + } + + return false +} + +// SetPort gets a reference to the given int32 and assigns it to the Port field. +func (o *BranchEndpointsPublic) SetPort(v int32) { + o.Port = &v +} + +// GetDisabled returns the Disabled field value if set, zero value otherwise. +func (o *BranchEndpointsPublic) GetDisabled() bool { + if o == nil || IsNil(o.Disabled) { + var ret bool + return ret + } + return *o.Disabled +} + +// GetDisabledOk returns a tuple with the Disabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BranchEndpointsPublic) GetDisabledOk() (*bool, bool) { + if o == nil || IsNil(o.Disabled) { + return nil, false + } + return o.Disabled, true +} + +// HasDisabled returns a boolean if a field has been set. +func (o *BranchEndpointsPublic) HasDisabled() bool { + if o != nil && !IsNil(o.Disabled) { + return true + } + + return false +} + +// SetDisabled gets a reference to the given bool and assigns it to the Disabled field. +func (o *BranchEndpointsPublic) SetDisabled(v bool) { + o.Disabled = &v +} + +func (o BranchEndpointsPublic) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o BranchEndpointsPublic) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Host) { + toSerialize["host"] = o.Host + } + if !IsNil(o.Port) { + toSerialize["port"] = o.Port + } + if !IsNil(o.Disabled) { + toSerialize["disabled"] = o.Disabled + } + return toSerialize, nil +} + +type NullableBranchEndpointsPublic struct { + value *BranchEndpointsPublic + isSet bool +} + +func (v NullableBranchEndpointsPublic) Get() *BranchEndpointsPublic { + return v.value +} + +func (v *NullableBranchEndpointsPublic) Set(val *BranchEndpointsPublic) { + v.value = val + v.isSet = true +} + +func (v NullableBranchEndpointsPublic) IsSet() bool { + return v.isSet +} + +func (v *NullableBranchEndpointsPublic) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBranchEndpointsPublic(val *BranchEndpointsPublic) *NullableBranchEndpointsPublic { + return &NullableBranchEndpointsPublic{value: val, isSet: true} +} + +func (v NullableBranchEndpointsPublic) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBranchEndpointsPublic) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_state.go b/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_state.go new file mode 100644 index 00000000..9f0de626 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_state.go @@ -0,0 +1,115 @@ +/* +TiDB Cloud Serverless Open API + +TiDB Cloud Serverless Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package branch + +import ( + "encoding/json" + "fmt" +) + +// BranchState Output Only. Branch State. - CREATING: The branch is being created. - ACTIVE: The branch is active and running. - DELETED: The branch is being deleted. - MAINTENANCE: The branch is under maintenance. +type BranchState string + +// List of Branch.State +const ( + BRANCHSTATE_CREATING BranchState = "CREATING" + BRANCHSTATE_ACTIVE BranchState = "ACTIVE" + BRANCHSTATE_DELETED BranchState = "DELETED" + BRANCHSTATE_MAINTENANCE BranchState = "MAINTENANCE" +) + +// All allowed values of BranchState enum +var AllowedBranchStateEnumValues = []BranchState{ + "CREATING", + "ACTIVE", + "DELETED", + "MAINTENANCE", +} + +func (v *BranchState) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := BranchState(value) + for _, existing := range AllowedBranchStateEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid BranchState", value) +} + +// NewBranchStateFromValue returns a pointer to a valid BranchState +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewBranchStateFromValue(v string) (*BranchState, error) { + ev := BranchState(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for BranchState: valid values are %v", v, AllowedBranchStateEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v BranchState) IsValid() bool { + for _, existing := range AllowedBranchStateEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to Branch.State value +func (v BranchState) Ptr() *BranchState { + return &v +} + +type NullableBranchState struct { + value *BranchState + isSet bool +} + +func (v NullableBranchState) Get() *BranchState { + return v.value +} + +func (v *NullableBranchState) Set(val *BranchState) { + v.value = val + v.isSet = true +} + +func (v NullableBranchState) IsSet() bool { + return v.isSet +} + +func (v *NullableBranchState) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBranchState(val *BranchState) *NullableBranchState { + return &NullableBranchState{value: val, isSet: true} +} + +func (v NullableBranchState) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBranchState) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_usage.go b/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_usage.go new file mode 100644 index 00000000..d6ccdb22 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_usage.go @@ -0,0 +1,201 @@ +/* +TiDB Cloud Serverless Open API + +TiDB Cloud Serverless Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package branch + +import ( + "encoding/json" +) + +// checks if the BranchUsage type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &BranchUsage{} + +// BranchUsage Message for usage metrics for this cluster. +type BranchUsage struct { + // Output Only. The latest value of Request Unit Metric for this cluster. + RequestUnit *string `json:"requestUnit,omitempty"` + // Output Only. The latest value of Row Storage Metric for this cluster. + RowStorage *float64 `json:"rowStorage,omitempty"` + // Output Only. The latest value of Columnar Storage Metric for this cluster. + ColumnarStorage *float64 `json:"columnarStorage,omitempty"` +} + +// NewBranchUsage instantiates a new BranchUsage object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewBranchUsage() *BranchUsage { + this := BranchUsage{} + return &this +} + +// NewBranchUsageWithDefaults instantiates a new BranchUsage object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewBranchUsageWithDefaults() *BranchUsage { + this := BranchUsage{} + return &this +} + +// GetRequestUnit returns the RequestUnit field value if set, zero value otherwise. +func (o *BranchUsage) GetRequestUnit() string { + if o == nil || IsNil(o.RequestUnit) { + var ret string + return ret + } + return *o.RequestUnit +} + +// GetRequestUnitOk returns a tuple with the RequestUnit field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BranchUsage) GetRequestUnitOk() (*string, bool) { + if o == nil || IsNil(o.RequestUnit) { + return nil, false + } + return o.RequestUnit, true +} + +// HasRequestUnit returns a boolean if a field has been set. +func (o *BranchUsage) HasRequestUnit() bool { + if o != nil && !IsNil(o.RequestUnit) { + return true + } + + return false +} + +// SetRequestUnit gets a reference to the given string and assigns it to the RequestUnit field. +func (o *BranchUsage) SetRequestUnit(v string) { + o.RequestUnit = &v +} + +// GetRowStorage returns the RowStorage field value if set, zero value otherwise. +func (o *BranchUsage) GetRowStorage() float64 { + if o == nil || IsNil(o.RowStorage) { + var ret float64 + return ret + } + return *o.RowStorage +} + +// GetRowStorageOk returns a tuple with the RowStorage field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BranchUsage) GetRowStorageOk() (*float64, bool) { + if o == nil || IsNil(o.RowStorage) { + return nil, false + } + return o.RowStorage, true +} + +// HasRowStorage returns a boolean if a field has been set. +func (o *BranchUsage) HasRowStorage() bool { + if o != nil && !IsNil(o.RowStorage) { + return true + } + + return false +} + +// SetRowStorage gets a reference to the given float64 and assigns it to the RowStorage field. +func (o *BranchUsage) SetRowStorage(v float64) { + o.RowStorage = &v +} + +// GetColumnarStorage returns the ColumnarStorage field value if set, zero value otherwise. +func (o *BranchUsage) GetColumnarStorage() float64 { + if o == nil || IsNil(o.ColumnarStorage) { + var ret float64 + return ret + } + return *o.ColumnarStorage +} + +// GetColumnarStorageOk returns a tuple with the ColumnarStorage field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BranchUsage) GetColumnarStorageOk() (*float64, bool) { + if o == nil || IsNil(o.ColumnarStorage) { + return nil, false + } + return o.ColumnarStorage, true +} + +// HasColumnarStorage returns a boolean if a field has been set. +func (o *BranchUsage) HasColumnarStorage() bool { + if o != nil && !IsNil(o.ColumnarStorage) { + return true + } + + return false +} + +// SetColumnarStorage gets a reference to the given float64 and assigns it to the ColumnarStorage field. +func (o *BranchUsage) SetColumnarStorage(v float64) { + o.ColumnarStorage = &v +} + +func (o BranchUsage) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o BranchUsage) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.RequestUnit) { + toSerialize["requestUnit"] = o.RequestUnit + } + if !IsNil(o.RowStorage) { + toSerialize["rowStorage"] = o.RowStorage + } + if !IsNil(o.ColumnarStorage) { + toSerialize["columnarStorage"] = o.ColumnarStorage + } + return toSerialize, nil +} + +type NullableBranchUsage struct { + value *BranchUsage + isSet bool +} + +func (v NullableBranchUsage) Get() *BranchUsage { + return v.value +} + +func (v *NullableBranchUsage) Set(val *BranchUsage) { + v.value = val + v.isSet = true +} + +func (v NullableBranchUsage) IsSet() bool { + return v.isSet +} + +func (v *NullableBranchUsage) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBranchUsage(val *BranchUsage) *NullableBranchUsage { + return &NullableBranchUsage{value: val, isSet: true} +} + +func (v NullableBranchUsage) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBranchUsage) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_view.go b/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_view.go new file mode 100644 index 00000000..0d40e86a --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/model_branch_view.go @@ -0,0 +1,111 @@ +/* +TiDB Cloud Serverless Open API + +TiDB Cloud Serverless Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package branch + +import ( + "encoding/json" + "fmt" +) + +// BranchView View on branch. Pass this enum to control which subsets of fields to get. - BASIC: Basic response contains basic information for a branch. - FULL: FULL response contains all detailed information for a branch. +type BranchView string + +// List of BranchView +const ( + BRANCHVIEW_BASIC BranchView = "BASIC" + BRANCHVIEW_FULL BranchView = "FULL" +) + +// All allowed values of BranchView enum +var AllowedBranchViewEnumValues = []BranchView{ + "BASIC", + "FULL", +} + +func (v *BranchView) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := BranchView(value) + for _, existing := range AllowedBranchViewEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid BranchView", value) +} + +// NewBranchViewFromValue returns a pointer to a valid BranchView +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewBranchViewFromValue(v string) (*BranchView, error) { + ev := BranchView(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for BranchView: valid values are %v", v, AllowedBranchViewEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v BranchView) IsValid() bool { + for _, existing := range AllowedBranchViewEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to BranchView value +func (v BranchView) Ptr() *BranchView { + return &v +} + +type NullableBranchView struct { + value *BranchView + isSet bool +} + +func (v NullableBranchView) Get() *BranchView { + return v.value +} + +func (v *NullableBranchView) Set(val *BranchView) { + v.value = val + v.isSet = true +} + +func (v NullableBranchView) IsSet() bool { + return v.isSet +} + +func (v *NullableBranchView) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBranchView(val *BranchView) *NullableBranchView { + return &NullableBranchView{value: val, isSet: true} +} + +func (v NullableBranchView) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBranchView) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/model_list_branches_response.go b/pkg/tidbcloud/v1beta1/serverless/branch/model_list_branches_response.go new file mode 100644 index 00000000..a4c75207 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/model_list_branches_response.go @@ -0,0 +1,199 @@ +/* +TiDB Cloud Serverless Open API + +TiDB Cloud Serverless Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package branch + +import ( + "encoding/json" +) + +// checks if the ListBranchesResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ListBranchesResponse{} + +// ListBranchesResponse struct for ListBranchesResponse +type ListBranchesResponse struct { + Branches []Branch `json:"branches,omitempty"` + // A token identifying a page of results the server should return. + NextPageToken *string `json:"nextPageToken,omitempty"` + TotalSize *int64 `json:"totalSize,omitempty"` +} + +// NewListBranchesResponse instantiates a new ListBranchesResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewListBranchesResponse() *ListBranchesResponse { + this := ListBranchesResponse{} + return &this +} + +// NewListBranchesResponseWithDefaults instantiates a new ListBranchesResponse object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewListBranchesResponseWithDefaults() *ListBranchesResponse { + this := ListBranchesResponse{} + return &this +} + +// GetBranches returns the Branches field value if set, zero value otherwise. +func (o *ListBranchesResponse) GetBranches() []Branch { + if o == nil || IsNil(o.Branches) { + var ret []Branch + return ret + } + return o.Branches +} + +// GetBranchesOk returns a tuple with the Branches field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListBranchesResponse) GetBranchesOk() ([]Branch, bool) { + if o == nil || IsNil(o.Branches) { + return nil, false + } + return o.Branches, true +} + +// HasBranches returns a boolean if a field has been set. +func (o *ListBranchesResponse) HasBranches() bool { + if o != nil && !IsNil(o.Branches) { + return true + } + + return false +} + +// SetBranches gets a reference to the given []Branch and assigns it to the Branches field. +func (o *ListBranchesResponse) SetBranches(v []Branch) { + o.Branches = v +} + +// GetNextPageToken returns the NextPageToken field value if set, zero value otherwise. +func (o *ListBranchesResponse) GetNextPageToken() string { + if o == nil || IsNil(o.NextPageToken) { + var ret string + return ret + } + return *o.NextPageToken +} + +// GetNextPageTokenOk returns a tuple with the NextPageToken field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListBranchesResponse) GetNextPageTokenOk() (*string, bool) { + if o == nil || IsNil(o.NextPageToken) { + return nil, false + } + return o.NextPageToken, true +} + +// HasNextPageToken returns a boolean if a field has been set. +func (o *ListBranchesResponse) HasNextPageToken() bool { + if o != nil && !IsNil(o.NextPageToken) { + return true + } + + return false +} + +// SetNextPageToken gets a reference to the given string and assigns it to the NextPageToken field. +func (o *ListBranchesResponse) SetNextPageToken(v string) { + o.NextPageToken = &v +} + +// GetTotalSize returns the TotalSize field value if set, zero value otherwise. +func (o *ListBranchesResponse) GetTotalSize() int64 { + if o == nil || IsNil(o.TotalSize) { + var ret int64 + return ret + } + return *o.TotalSize +} + +// GetTotalSizeOk returns a tuple with the TotalSize field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListBranchesResponse) GetTotalSizeOk() (*int64, bool) { + if o == nil || IsNil(o.TotalSize) { + return nil, false + } + return o.TotalSize, true +} + +// HasTotalSize returns a boolean if a field has been set. +func (o *ListBranchesResponse) HasTotalSize() bool { + if o != nil && !IsNil(o.TotalSize) { + return true + } + + return false +} + +// SetTotalSize gets a reference to the given int64 and assigns it to the TotalSize field. +func (o *ListBranchesResponse) SetTotalSize(v int64) { + o.TotalSize = &v +} + +func (o ListBranchesResponse) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ListBranchesResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Branches) { + toSerialize["branches"] = o.Branches + } + if !IsNil(o.NextPageToken) { + toSerialize["nextPageToken"] = o.NextPageToken + } + if !IsNil(o.TotalSize) { + toSerialize["totalSize"] = o.TotalSize + } + return toSerialize, nil +} + +type NullableListBranchesResponse struct { + value *ListBranchesResponse + isSet bool +} + +func (v NullableListBranchesResponse) Get() *ListBranchesResponse { + return v.value +} + +func (v *NullableListBranchesResponse) Set(val *ListBranchesResponse) { + v.value = val + v.isSet = true +} + +func (v NullableListBranchesResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableListBranchesResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableListBranchesResponse(val *ListBranchesResponse) *NullableListBranchesResponse { + return &NullableListBranchesResponse{value: val, isSet: true} +} + +func (v NullableListBranchesResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableListBranchesResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/model_status.go b/pkg/tidbcloud/v1beta1/serverless/branch/model_status.go new file mode 100644 index 00000000..a121f0fe --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/model_status.go @@ -0,0 +1,198 @@ +/* +TiDB Cloud Serverless Open API + +TiDB Cloud Serverless Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package branch + +import ( + "encoding/json" +) + +// checks if the Status type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Status{} + +// Status struct for Status +type Status struct { + Code *int32 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Details []Any `json:"details,omitempty"` +} + +// NewStatus instantiates a new Status object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewStatus() *Status { + this := Status{} + return &this +} + +// NewStatusWithDefaults instantiates a new Status object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewStatusWithDefaults() *Status { + this := Status{} + return &this +} + +// GetCode returns the Code field value if set, zero value otherwise. +func (o *Status) GetCode() int32 { + if o == nil || IsNil(o.Code) { + var ret int32 + return ret + } + return *o.Code +} + +// GetCodeOk returns a tuple with the Code field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Status) GetCodeOk() (*int32, bool) { + if o == nil || IsNil(o.Code) { + return nil, false + } + return o.Code, true +} + +// HasCode returns a boolean if a field has been set. +func (o *Status) HasCode() bool { + if o != nil && !IsNil(o.Code) { + return true + } + + return false +} + +// SetCode gets a reference to the given int32 and assigns it to the Code field. +func (o *Status) SetCode(v int32) { + o.Code = &v +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *Status) GetMessage() string { + if o == nil || IsNil(o.Message) { + var ret string + return ret + } + return *o.Message +} + +// GetMessageOk returns a tuple with the Message field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Status) GetMessageOk() (*string, bool) { + if o == nil || IsNil(o.Message) { + return nil, false + } + return o.Message, true +} + +// HasMessage returns a boolean if a field has been set. +func (o *Status) HasMessage() bool { + if o != nil && !IsNil(o.Message) { + return true + } + + return false +} + +// SetMessage gets a reference to the given string and assigns it to the Message field. +func (o *Status) SetMessage(v string) { + o.Message = &v +} + +// GetDetails returns the Details field value if set, zero value otherwise. +func (o *Status) GetDetails() []Any { + if o == nil || IsNil(o.Details) { + var ret []Any + return ret + } + return o.Details +} + +// GetDetailsOk returns a tuple with the Details field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Status) GetDetailsOk() ([]Any, bool) { + if o == nil || IsNil(o.Details) { + return nil, false + } + return o.Details, true +} + +// HasDetails returns a boolean if a field has been set. +func (o *Status) HasDetails() bool { + if o != nil && !IsNil(o.Details) { + return true + } + + return false +} + +// SetDetails gets a reference to the given []Any and assigns it to the Details field. +func (o *Status) SetDetails(v []Any) { + o.Details = v +} + +func (o Status) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Status) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Code) { + toSerialize["code"] = o.Code + } + if !IsNil(o.Message) { + toSerialize["message"] = o.Message + } + if !IsNil(o.Details) { + toSerialize["details"] = o.Details + } + return toSerialize, nil +} + +type NullableStatus struct { + value *Status + isSet bool +} + +func (v NullableStatus) Get() *Status { + return v.value +} + +func (v *NullableStatus) Set(val *Status) { + v.value = val + v.isSet = true +} + +func (v NullableStatus) IsSet() bool { + return v.isSet +} + +func (v *NullableStatus) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableStatus(val *Status) *NullableStatus { + return &NullableStatus{value: val, isSet: true} +} + +func (v NullableStatus) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableStatus) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/response.go b/pkg/tidbcloud/v1beta1/serverless/branch/response.go new file mode 100644 index 00000000..492202d0 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/response.go @@ -0,0 +1,47 @@ +/* +TiDB Cloud Serverless Open API + +TiDB Cloud Serverless Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package branch + +import ( + "net/http" +) + +// APIResponse stores the API response returned by the server. +type APIResponse struct { + *http.Response `json:"-"` + Message string `json:"message,omitempty"` + // Operation is the name of the OpenAPI operation. + Operation string `json:"operation,omitempty"` + // RequestURL is the request URL. This value is always available, even if the + // embedded *http.Response is nil. + RequestURL string `json:"url,omitempty"` + // Method is the HTTP method used for the request. This value is always + // available, even if the embedded *http.Response is nil. + Method string `json:"method,omitempty"` + // Payload holds the contents of the response body (which may be nil or empty). + // This is provided here as the raw response.Body() reader will have already + // been drained. + Payload []byte `json:"-"` +} + +// NewAPIResponse returns a new APIResponse object. +func NewAPIResponse(r *http.Response) *APIResponse { + + response := &APIResponse{Response: r} + return response +} + +// NewAPIResponseWithError returns a new APIResponse object with the provided error message. +func NewAPIResponseWithError(errorMessage string) *APIResponse { + + response := &APIResponse{Message: errorMessage} + return response +} diff --git a/pkg/tidbcloud/v1beta1/serverless/branch/utils.go b/pkg/tidbcloud/v1beta1/serverless/branch/utils.go new file mode 100644 index 00000000..32eb894d --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/branch/utils.go @@ -0,0 +1,361 @@ +/* +TiDB Cloud Serverless Open API + +TiDB Cloud Serverless Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package branch + +import ( + "bytes" + "encoding/json" + "fmt" + "reflect" + "time" +) + +// PtrBool is a helper routine that returns a pointer to given boolean value. +func PtrBool(v bool) *bool { return &v } + +// PtrInt is a helper routine that returns a pointer to given integer value. +func PtrInt(v int) *int { return &v } + +// PtrInt32 is a helper routine that returns a pointer to given integer value. +func PtrInt32(v int32) *int32 { return &v } + +// PtrInt64 is a helper routine that returns a pointer to given integer value. +func PtrInt64(v int64) *int64 { return &v } + +// PtrFloat32 is a helper routine that returns a pointer to given float value. +func PtrFloat32(v float32) *float32 { return &v } + +// PtrFloat64 is a helper routine that returns a pointer to given float value. +func PtrFloat64(v float64) *float64 { return &v } + +// PtrString is a helper routine that returns a pointer to given string value. +func PtrString(v string) *string { return &v } + +// PtrTime is helper routine that returns a pointer to given Time value. +func PtrTime(v time.Time) *time.Time { return &v } + +type NullableBool struct { + value *bool + isSet bool +} + +func (v NullableBool) Get() *bool { + return v.value +} + +func (v *NullableBool) Set(val *bool) { + v.value = val + v.isSet = true +} + +func (v NullableBool) IsSet() bool { + return v.isSet +} + +func (v *NullableBool) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBool(val *bool) *NullableBool { + return &NullableBool{value: val, isSet: true} +} + +func (v NullableBool) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBool) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt struct { + value *int + isSet bool +} + +func (v NullableInt) Get() *int { + return v.value +} + +func (v *NullableInt) Set(val *int) { + v.value = val + v.isSet = true +} + +func (v NullableInt) IsSet() bool { + return v.isSet +} + +func (v *NullableInt) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt(val *int) *NullableInt { + return &NullableInt{value: val, isSet: true} +} + +func (v NullableInt) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt32 struct { + value *int32 + isSet bool +} + +func (v NullableInt32) Get() *int32 { + return v.value +} + +func (v *NullableInt32) Set(val *int32) { + v.value = val + v.isSet = true +} + +func (v NullableInt32) IsSet() bool { + return v.isSet +} + +func (v *NullableInt32) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt32(val *int32) *NullableInt32 { + return &NullableInt32{value: val, isSet: true} +} + +func (v NullableInt32) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt32) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt64 struct { + value *int64 + isSet bool +} + +func (v NullableInt64) Get() *int64 { + return v.value +} + +func (v *NullableInt64) Set(val *int64) { + v.value = val + v.isSet = true +} + +func (v NullableInt64) IsSet() bool { + return v.isSet +} + +func (v *NullableInt64) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt64(val *int64) *NullableInt64 { + return &NullableInt64{value: val, isSet: true} +} + +func (v NullableInt64) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt64) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableFloat32 struct { + value *float32 + isSet bool +} + +func (v NullableFloat32) Get() *float32 { + return v.value +} + +func (v *NullableFloat32) Set(val *float32) { + v.value = val + v.isSet = true +} + +func (v NullableFloat32) IsSet() bool { + return v.isSet +} + +func (v *NullableFloat32) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableFloat32(val *float32) *NullableFloat32 { + return &NullableFloat32{value: val, isSet: true} +} + +func (v NullableFloat32) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableFloat32) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableFloat64 struct { + value *float64 + isSet bool +} + +func (v NullableFloat64) Get() *float64 { + return v.value +} + +func (v *NullableFloat64) Set(val *float64) { + v.value = val + v.isSet = true +} + +func (v NullableFloat64) IsSet() bool { + return v.isSet +} + +func (v *NullableFloat64) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableFloat64(val *float64) *NullableFloat64 { + return &NullableFloat64{value: val, isSet: true} +} + +func (v NullableFloat64) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableFloat64) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableString struct { + value *string + isSet bool +} + +func (v NullableString) Get() *string { + return v.value +} + +func (v *NullableString) Set(val *string) { + v.value = val + v.isSet = true +} + +func (v NullableString) IsSet() bool { + return v.isSet +} + +func (v *NullableString) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableString(val *string) *NullableString { + return &NullableString{value: val, isSet: true} +} + +func (v NullableString) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableString) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableTime struct { + value *time.Time + isSet bool +} + +func (v NullableTime) Get() *time.Time { + return v.value +} + +func (v *NullableTime) Set(val *time.Time) { + v.value = val + v.isSet = true +} + +func (v NullableTime) IsSet() bool { + return v.isSet +} + +func (v *NullableTime) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableTime(val *time.Time) *NullableTime { + return &NullableTime{value: val, isSet: true} +} + +func (v NullableTime) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableTime) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +// IsNil checks if an input is nil +func IsNil(i interface{}) bool { + if i == nil { + return true + } + switch reflect.TypeOf(i).Kind() { + case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.UnsafePointer, reflect.Interface, reflect.Slice: + return reflect.ValueOf(i).IsNil() + case reflect.Array: + return reflect.ValueOf(i).IsZero() + } + return false +} + +type MappedNullable interface { + ToMap() (map[string]interface{}, error) +} + +// A wrapper for strict JSON decoding +func newStrictDecoder(data []byte) *json.Decoder { + dec := json.NewDecoder(bytes.NewBuffer(data)) + dec.DisallowUnknownFields() + return dec +} + +// Prevent trying to import "fmt" +func reportError(format string, a ...interface{}) error { + return fmt.Errorf(format, a...) +} \ No newline at end of file From dc9977d5355415cf18a29d66e3b6e06b97c78e8d Mon Sep 17 00:00:00 2001 From: zhangyangyu Date: Fri, 30 Aug 2024 01:23:07 +0800 Subject: [PATCH 2/4] add rm --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 08b6fa52..afc11621 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,7 @@ addcopy: ## Add copyright to all files generate-v1beta1-client: install-openapi-generator## Generate v1beta1 client go install github.com/go-swagger/go-swagger/cmd/swagger@latest @echo "==> Generating serverless branch client" + rm -rf pkg/tidbcloud/v1beta1/serverless/branch cd tools/openapi-generator && npx openapi-generator-cli generate --additional-properties=withGoMod=false,enumClassPrefix=true --global-property=apiTests=false,apiDocs=false,modelDocs=fasle,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/branch.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/branch --package-name branch @echo "==> Generating serverless client" swagger generate client -f pkg/tidbcloud/v1beta1/serverless/serverless.swagger.json -A tidbcloud-serverless -t pkg/tidbcloud/v1beta1/serverless @@ -55,6 +56,7 @@ generate-v1beta1-client: install-openapi-generator## Generate v1beta1 client @echo "==> Generating serverless import client" swagger generate client -f pkg/tidbcloud/v1beta1/serverless_import/import.swagger.json -A tidbcloud-serverless -t pkg/tidbcloud/v1beta1/serverless_import @echo "==> Generating serverless export client" + rm -rf pkg/tidbcloud/v1beta1/serverless/export cd tools/openapi-generator && npx openapi-generator-cli generate --additional-properties=withGoMod=false,enumClassPrefix=true --global-property=apiTests=false,apiDocs=false,modelDocs=fasle,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/export.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/export --package-name export @echo "==> Generating iam client" swagger generate client -f pkg/tidbcloud/v1beta1/iam/iam.swagger.json -A tidbcloud-serverless -t pkg/tidbcloud/v1beta1/iam From e51b02799826300796271d1f1de3e58302df5b73 Mon Sep 17 00:00:00 2001 From: zhangyangyu Date: Fri, 30 Aug 2024 10:50:15 +0800 Subject: [PATCH 3/4] fix --- internal/cli/serverless/branch/list_test.go | 14 +++++++------- internal/service/cloud/logic.go | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/cli/serverless/branch/list_test.go b/internal/cli/serverless/branch/list_test.go index 4c0058ce..ec3a5b40 100644 --- a/internal/cli/serverless/branch/list_test.go +++ b/internal/cli/serverless/branch/list_test.go @@ -37,13 +37,13 @@ const listResultStr = `{ { "branchId": "bran-wscjvwen2jajdjiy7hawcebxke", "clusterId": "10202848322613926203", - "createTime": "2023-12-12T10:17:15.000Z", + "createTime": "2023-12-12T10:17:15Z", "createdBy": "apikey-MCTGR3Jv", "displayName": "t", "name": "clusters/10202848322613926203/branches/bran-wscjvwen2jajdjiy7hawcebxke", "parentId": "10202848322613926203", "state": "ACTIVE", - "updateTime": "2023-12-12T10:18:24.000Z" + "updateTime": "2023-12-12T10:18:24Z" } ], "totalSize": 1 @@ -55,24 +55,24 @@ const listResultMultiPageStr = `{ { "branchId": "bran-wscjvwen2jajdjiy7hawcebxke", "clusterId": "10202848322613926203", - "createTime": "2023-12-12T10:17:15.000Z", + "createTime": "2023-12-12T10:17:15Z", "createdBy": "apikey-MCTGR3Jv", "displayName": "t", "name": "clusters/10202848322613926203/branches/bran-wscjvwen2jajdjiy7hawcebxke", "parentId": "10202848322613926203", "state": "ACTIVE", - "updateTime": "2023-12-12T10:18:24.000Z" + "updateTime": "2023-12-12T10:18:24Z" }, { "branchId": "bran-wscjvwen2jajdjiy7hawcebxke", "clusterId": "10202848322613926203", - "createTime": "2023-12-12T10:17:15.000Z", + "createTime": "2023-12-12T10:17:15Z", "createdBy": "apikey-MCTGR3Jv", "displayName": "t", "name": "clusters/10202848322613926203/branches/bran-wscjvwen2jajdjiy7hawcebxke", "parentId": "10202848322613926203", "state": "ACTIVE", - "updateTime": "2023-12-12T10:18:24.000Z" + "updateTime": "2023-12-12T10:18:24Z" } ], "totalSize": 2 @@ -166,7 +166,7 @@ func (suite *ListBranchesSuite) TestListBranchesWithMultiPages() { body.NextPageToken = &pageToken clusterID := "12345" - suite.mockClient.On("ListBranches", ctx, clusterID, &pageSize, nil).Return(body, nil) + suite.mockClient.On("ListBranches", ctx, clusterID, &pageSize, (*string)(nil)).Return(body, nil) body2 := &branch.ListBranchesResponse{} err = json.Unmarshal([]byte(strings.ReplaceAll(listResultStr, `"totalSize": 1`, `"totalSize": 2`)), body2) diff --git a/internal/service/cloud/logic.go b/internal/service/cloud/logic.go index 7491d17f..bc8cacb4 100644 --- a/internal/service/cloud/logic.go +++ b/internal/service/cloud/logic.go @@ -659,7 +659,7 @@ func RetrieveBranches(ctx context.Context, cID string, pageSize int64, d TiDBClo // loop to get all branches for { pageToken = branches.NextPageToken - if pageToken != nil && *pageToken == "" { + if pageToken == nil || *pageToken == "" { break } branches, err = d.ListBranches(ctx, cID, &pageSizeInt32, pageToken) From 90340d04d8281ffac6ab72735a9d1c92745b8066 Mon Sep 17 00:00:00 2001 From: zhangyangyu Date: Fri, 30 Aug 2024 10:52:28 +0800 Subject: [PATCH 4/4] 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