From 4147f851d8349daaed3486145eb276cafa530479 Mon Sep 17 00:00:00 2001 From: Xiang Zhang Date: Wed, 4 Sep 2024 21:28:25 +0800 Subject: [PATCH 1/3] openapi generator cluster (#224) --- Makefile | 19 +- docs/generate_doc/ticloud_auth_login.md | 2 +- .../generate_doc/ticloud_serverless_update.md | 3 - internal/cli/serverless/create.go | 67 +- internal/cli/serverless/create_test.go | 53 +- internal/cli/serverless/delete.go | 11 +- internal/cli/serverless/delete_test.go | 15 +- internal/cli/serverless/describe.go | 11 +- internal/cli/serverless/describe_test.go | 13 +- internal/cli/serverless/list.go | 19 +- internal/cli/serverless/list_test.go | 48 +- internal/cli/serverless/region.go | 11 +- internal/cli/serverless/shell.go | 12 +- internal/cli/serverless/spending_limit.go | 21 +- .../cli/serverless/spending_limit_test.go | 22 +- internal/cli/serverless/sqluser/create.go | 7 +- .../cli/serverless/sqluser/create_test.go | 24 +- internal/cli/serverless/sqluser/update.go | 2 +- .../cli/serverless/sqluser/update_test.go | 14 +- internal/cli/serverless/update.go | 48 +- internal/cli/serverless/update_test.go | 30 +- internal/flag/flag.go | 87 +- internal/mock/api_client.go | 180 ++-- internal/service/cloud/api_client.go | 82 +- internal/service/cloud/logic.go | 34 +- ...service_change_root_password_parameters.go | 168 ---- ..._service_change_root_password_responses.go | 246 ----- .../serverless_service_client.go | 336 ------- ...rless_service_create_cluster_parameters.go | 153 --- ...erless_service_create_cluster_responses.go | 187 ---- ...rless_service_delete_cluster_parameters.go | 151 --- ...erless_service_delete_cluster_responses.go | 187 ---- ...rverless_service_get_cluster_parameters.go | 202 ---- ...erverless_service_get_cluster_responses.go | 187 ---- ...erless_service_list_clusters_parameters.go | 268 ------ ...verless_service_list_clusters_responses.go | 187 ---- ...verless_service_list_regions_parameters.go | 128 --- ...rverless_service_list_regions_responses.go | 187 ---- ...rvice_partial_update_cluster_parameters.go | 168 ---- ...ervice_partial_update_cluster_responses.go | 859 ----------------- .../client/tidbcloud_serverless_client.go | 112 --- ...less.swagger.json => cluster.swagger.json} | 494 +++++----- .../v1beta1/serverless/cluster/.gitignore | 24 + .../cluster/.openapi-generator-ignore | 23 + .../cluster/.openapi-generator/FILES | 33 + .../cluster/.openapi-generator/VERSION | 1 + .../v1beta1/serverless/cluster/.travis.yml | 8 + .../v1beta1/serverless/cluster/README.md | 140 +++ .../serverless/cluster/api/openapi.yaml | 909 ++++++++++++++++++ .../cluster/api_serverless_service.go | 875 +++++++++++++++++ .../v1beta1/serverless/cluster/client.go | 651 +++++++++++++ .../serverless/cluster/configuration.go | 214 +++++ .../v1beta1/serverless/cluster/git_push.sh | 57 ++ .../cluster/model_cluster_spending_limit.go | 125 +++ .../model_commonv1beta1_cluster_state.go | 132 +++ .../cluster/model_commonv1beta1_region.go | 283 ++++++ .../cluster/model_endpoints_private.go | 234 +++++ .../cluster/model_endpoints_public.go | 199 ++++ .../cluster/model_googlerpc_status.go | 199 ++++ .../serverless/cluster/model_private_aws.go | 162 ++++ .../serverless/cluster/model_private_gcp.go | 125 +++ .../serverless/cluster/model_protobuf_any.go | 154 +++ ...el_required__the_cluster_to_be_updated_.go | 273 ++++++ ...rless_service_change_root_password_body.go | 157 +++ .../model_serverlessv1beta1_cluster_view.go | 110 +++ ...cloud_open_apiserverlessv1beta1_cluster.go | 742 ++++++++++++++ ...erverlessv1beta1_list_clusters_response.go | 199 ++++ ...serverlessv1beta1_list_regions_response.go | 125 +++ ...v1beta1_cluster_automated_backup_policy.go | 162 ++++ ...model_v1beta1_cluster_encryption_config.go | 125 +++ .../model_v1beta1_cluster_endpoints.go | 162 ++++ .../cluster/model_v1beta1_cluster_usage.go | 199 ++++ ..._cluster_request_partial_update_cluster.go | 342 +++++++ .../model_v1beta1_region_cloud_provider.go | 112 +++ ...ess_service_partial_update_cluster_body.go | 193 ++++ .../v1beta1/serverless/cluster/response.go | 47 + .../v1beta1/serverless/cluster/utils.go | 361 +++++++ .../models/cluster_spending_limit.go | 50 - .../serverless/models/cluster_usage.go | 105 -- .../models/commonv1beta1_cluster_state.go | 147 --- .../serverless/models/commonv1beta1_region.go | 169 ---- .../serverless/models/endpoints_private.go | 197 ---- .../serverless/models/endpoints_public.go | 91 -- .../serverless/models/googlerpc_status.go | 127 --- .../serverless/models/private_a_w_s.go | 88 -- .../serverless/models/private_g_c_p.go | 71 -- .../v1beta1/serverless/models/protobuf_any.go | 127 --- .../models/serverlessv1beta1_cluster_view.go | 85 -- ...cloud_open_apiserverlessv1beta1_cluster.go | 596 ------------ ..._apiserverlessv1beta1_cluster_endpoints.go | 161 ---- ...open_apiserverlessv1beta1_cluster_state.go | 101 -- ...erverlessv1beta1_list_clusters_response.go | 127 --- ...serverlessv1beta1_list_regions_response.go | 121 --- ..._cloud_open_apiserverlessv1beta1_region.go | 145 --- .../v1beta1_change_root_password_response.go | 11 - ...v1beta1_cluster_automated_backup_policy.go | 53 - .../v1beta1_cluster_encryption_config.go | 50 - .../models/v1beta1_cluster_endpoints.go | 161 ---- .../models/v1beta1_cluster_usage.go | 105 -- .../serverless/models/v1beta1_cluster_view.go | 85 -- .../models/v1beta1_region_cloud_provider.go | 90 -- 101 files changed, 8499 insertions(+), 7476 deletions(-) delete mode 100644 pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_change_root_password_parameters.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_change_root_password_responses.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_client.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_create_cluster_parameters.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_create_cluster_responses.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_delete_cluster_parameters.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_delete_cluster_responses.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_get_cluster_parameters.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_get_cluster_responses.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_list_clusters_parameters.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_list_clusters_responses.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_list_regions_parameters.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_list_regions_responses.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_partial_update_cluster_parameters.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_partial_update_cluster_responses.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/client/tidbcloud_serverless_client.go rename pkg/tidbcloud/v1beta1/serverless/{serverless.swagger.json => cluster.swagger.json} (58%) create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/.gitignore create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/.openapi-generator-ignore create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/.openapi-generator/FILES create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/.openapi-generator/VERSION create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/.travis.yml create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/README.md create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/api/openapi.yaml create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/api_serverless_service.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/client.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/configuration.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/git_push.sh create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_cluster_spending_limit.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_commonv1beta1_cluster_state.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_commonv1beta1_region.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_endpoints_private.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_endpoints_public.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_googlerpc_status.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_private_aws.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_private_gcp.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_protobuf_any.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_required__the_cluster_to_be_updated_.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_serverless_service_change_root_password_body.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_serverlessv1beta1_cluster_view.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_cluster.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_list_clusters_response.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_list_regions_response.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_cluster_automated_backup_policy.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_cluster_encryption_config.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_cluster_endpoints.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_cluster_usage.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_partial_update_cluster_request_partial_update_cluster.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_region_cloud_provider.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_serverless_service_partial_update_cluster_body.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/response.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/utils.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/cluster_spending_limit.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/cluster_usage.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/commonv1beta1_cluster_state.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/commonv1beta1_region.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/endpoints_private.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/endpoints_public.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/googlerpc_status.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/private_a_w_s.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/private_g_c_p.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/protobuf_any.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/serverlessv1beta1_cluster_view.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_cluster.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_cluster_endpoints.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_cluster_state.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_list_clusters_response.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_list_regions_response.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_region.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/v1beta1_change_root_password_response.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_automated_backup_policy.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_encryption_config.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_endpoints.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_usage.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_view.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/models/v1beta1_region_cloud_provider.go diff --git a/Makefile b/Makefile index 7c50212f..cb864e3f 100644 --- a/Makefile +++ b/Makefile @@ -48,19 +48,20 @@ 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 - @echo "==> Generating serverless br client" - swagger generate client -f pkg/tidbcloud/v1beta1/serverless_br/serverless-br.swagger.json -A tidbcloud-serverless -t pkg/tidbcloud/v1beta1/serverless_br - @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 + cd tools/openapi-generator && npx openapi-generator-cli generate --additional-properties=withGoMod=false,enumClassPrefix=true --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/branch.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/branch --package-name branch + @echo "==> Generating serverless cluster client" + rm -rf pkg/tidbcloud/v1beta1/serverless/cluster + cd tools/openapi-generator && npx openapi-generator-cli generate --additional-properties=withGoMod=false,enumClassPrefix=true --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/cluster.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/cluster --package-name cluster --skip-validate-spec @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 + cd tools/openapi-generator && npx openapi-generator-cli generate --additional-properties=withGoMod=false,enumClassPrefix=true --global-property=apiTests=false,apiDocs=false,modelDocs=false,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" rm -rf pkg/tidbcloud/v1beta1/iam - 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/iam.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/iam --package-name iam + cd tools/openapi-generator && npx openapi-generator-cli generate --additional-properties=withGoMod=false,enumClassPrefix=true --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/v1beta1/iam.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/iam --package-name iam + @echo "==> Generating serverless br client" + swagger generate client -f pkg/tidbcloud/v1beta1/serverless_br/serverless-br.swagger.json -A tidbcloud-serverless -t pkg/tidbcloud/v1beta1/serverless_br + @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 go fmt ./pkg/... .PHONY: install-openapi-generator diff --git a/docs/generate_doc/ticloud_auth_login.md b/docs/generate_doc/ticloud_auth_login.md index 1a266c11..376273ac 100644 --- a/docs/generate_doc/ticloud_auth_login.md +++ b/docs/generate_doc/ticloud_auth_login.md @@ -9,7 +9,7 @@ ticloud auth login [flags] ### Examples ``` - To log into TiDB Cloud:: + To log into TiDB Cloud: $ ticloud auth login ``` diff --git a/docs/generate_doc/ticloud_serverless_update.md b/docs/generate_doc/ticloud_serverless_update.md index 0517ea05..27033d43 100644 --- a/docs/generate_doc/ticloud_serverless_update.md +++ b/docs/generate_doc/ticloud_serverless_update.md @@ -22,9 +22,6 @@ ticloud serverless update [flags] ### Options ``` - --annotations string The annotations of the cluster to be added or updated. - Interactive example: {"annotation1":"value1","annotation2":"value2"}. - NonInteractive example: "{\"annotation1\":\"value1\",\"annotation2\":\"value2\"}". -c, --cluster-id string The ID of the cluster to be updated. --disable-public-endpoint Disable the public endpoint of the cluster. -n, --display-name string The new displayName of the cluster to be updated. diff --git a/internal/cli/serverless/create.go b/internal/cli/serverless/create.go index 5de3d969..064c5f12 100644 --- a/internal/cli/serverless/create.go +++ b/internal/cli/serverless/create.go @@ -28,8 +28,7 @@ import ( "tidbcloud-cli/internal/telemetry" "tidbcloud-cli/internal/ui" "tidbcloud-cli/internal/util" - serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" - serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" "github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2/terminal" @@ -51,7 +50,7 @@ const ( ) type CreateOpts struct { - serverlessProviders []*serverlessModel.Commonv1beta1Region + serverlessProviders []cluster.Commonv1beta1Region interactive bool } @@ -133,16 +132,16 @@ func CreateCmd(h *internal.Helper) *cobra.Command { } // interactive mode - regions, err := d.ListProviderRegions(serverlessApi.NewServerlessServiceListRegionsParams().WithContext(ctx)) + regions, err := d.ListProviderRegions(ctx) if err != nil { return errors.Trace(err) } - opts.serverlessProviders = regions.Payload.Regions + opts.serverlessProviders = regions.Regions // distinct cloud providers providers := hashset.New() for _, provider := range opts.serverlessProviders { - providers.Add(string(*provider.Provider)) + providers.Add(string(*provider.CloudProvider)) } cloudProvider, err = GetProvider(providers) if err != nil { @@ -152,11 +151,11 @@ func CreateCmd(h *internal.Helper) *cobra.Command { // filter out regions for the selected cloud provider regionSet := hashset.New() for _, provider := range opts.serverlessProviders { - if string(*provider.Provider) == cloudProvider { + if string(*provider.CloudProvider) == cloudProvider { regionSet.Add(cloud.Region{ Name: *provider.Name, - DisplayName: provider.DisplayName, - Provider: string(*provider.Provider), + DisplayName: *provider.DisplayName, + Provider: string(*provider.CloudProvider), }) } } @@ -258,37 +257,37 @@ func CreateCmd(h *internal.Helper) *cobra.Command { cmd.Annotations[telemetry.ProjectID] = projectID - v1Cluster := &serverlessModel.TidbCloudOpenApiserverlessv1beta1Cluster{ - DisplayName: &clusterName, - Region: &serverlessModel.Commonv1beta1Region{ + v1Cluster := &cluster.TidbCloudOpenApiserverlessv1beta1Cluster{ + DisplayName: clusterName, + Region: cluster.Commonv1beta1Region{ Name: ®ion, }, } // optional fields if projectID != "" { - v1Cluster.Labels = map[string]string{"tidb.cloud/project": projectID} + v1Cluster.Labels = &map[string]string{"tidb.cloud/project": projectID} } if spendingLimitMonthly != 0 { - v1Cluster.SpendingLimit = &serverlessModel.ClusterSpendingLimit{ - Monthly: spendingLimitMonthly, + v1Cluster.SpendingLimit = &cluster.ClusterSpendingLimit{ + Monthly: &spendingLimitMonthly, } } if encryption { - v1Cluster.EncryptionConfig = &serverlessModel.V1beta1ClusterEncryptionConfig{ - EnhancedEncryptionEnabled: encryption, + v1Cluster.EncryptionConfig = &cluster.V1beta1ClusterEncryptionConfig{ + EnhancedEncryptionEnabled: &encryption, } } if publicEndpointDisabled { - v1Cluster.Endpoints = &serverlessModel.TidbCloudOpenApiserverlessv1beta1ClusterEndpoints{ - Public: &serverlessModel.EndpointsPublic{ - Disabled: publicEndpointDisabled, + v1Cluster.Endpoints = &cluster.V1beta1ClusterEndpoints{ + Public: &cluster.EndpointsPublic{ + Disabled: &publicEndpointDisabled, }, } } if h.IOStreams.CanPrompt { - err := CreateAndSpinnerWait(ctx, d, v1Cluster, h) + err := CreateAndSpinnerWait(ctx, h, d, v1Cluster) if err != nil { return errors.Trace(err) } @@ -312,13 +311,12 @@ func CreateCmd(h *internal.Helper) *cobra.Command { return createCmd } -func CreateAndWaitReady(ctx context.Context, h *internal.Helper, d cloud.TiDBCloudClient, v1Cluster *serverlessModel.TidbCloudOpenApiserverlessv1beta1Cluster) error { - createClusterResult, err := d.CreateCluster(serverlessApi.NewServerlessServiceCreateClusterParams(). - WithCluster(v1Cluster).WithContext(ctx)) +func CreateAndWaitReady(ctx context.Context, h *internal.Helper, d cloud.TiDBCloudClient, v1Cluster *cluster.TidbCloudOpenApiserverlessv1beta1Cluster) error { + createClusterResult, err := d.CreateCluster(ctx, v1Cluster) if err != nil { return errors.Trace(err) } - newClusterID := createClusterResult.GetPayload().ClusterID + newClusterID := *createClusterResult.ClusterId fmt.Fprintln(h.IOStreams.Out, "... Waiting for cluster to be ready") ticker := time.NewTicker(WaitInterval) @@ -329,13 +327,11 @@ func CreateAndWaitReady(ctx context.Context, h *internal.Helper, d cloud.TiDBClo case <-timer: return errors.New(fmt.Sprintf("Timeout waiting for cluster %s to be ready, please check status on dashboard.", newClusterID)) case <-ticker.C: - clusterResult, err := d.GetCluster(serverlessApi.NewServerlessServiceGetClusterParams(). - WithClusterID(newClusterID).WithContext(ctx)) + clusterResult, err := d.GetCluster(ctx, newClusterID) if err != nil { return errors.Trace(err) } - s := *clusterResult.GetPayload().State - if s == "ACTIVE" { + if *clusterResult.State == cluster.COMMONV1BETA1CLUSTERSTATE_ACTIVE { fmt.Fprint(h.IOStreams.Out, color.GreenString("Cluster %s is ready.", newClusterID)) return nil } @@ -343,15 +339,14 @@ func CreateAndWaitReady(ctx context.Context, h *internal.Helper, d cloud.TiDBClo } } -func CreateAndSpinnerWait(ctx context.Context, d cloud.TiDBCloudClient, v1Cluster *serverlessModel.TidbCloudOpenApiserverlessv1beta1Cluster, h *internal.Helper) error { +func CreateAndSpinnerWait(ctx context.Context, h *internal.Helper, d cloud.TiDBCloudClient, v1Cluster *cluster.TidbCloudOpenApiserverlessv1beta1Cluster) error { // use spinner to indicate that the cluster is being created task := func() tea.Msg { - createClusterResult, err := d.CreateCluster(serverlessApi.NewServerlessServiceCreateClusterParams(). - WithCluster(v1Cluster).WithContext(ctx)) + createClusterResult, err := d.CreateCluster(ctx, v1Cluster) if err != nil { return errors.Trace(err) } - newClusterID := createClusterResult.GetPayload().ClusterID + newClusterID := *createClusterResult.ClusterId ticker := time.NewTicker(WaitInterval) defer ticker.Stop() @@ -361,13 +356,11 @@ func CreateAndSpinnerWait(ctx context.Context, d cloud.TiDBCloudClient, v1Cluste case <-timer: return ui.Result(fmt.Sprintf("Timeout waiting for cluster %s to be ready, please check status on dashboard.", newClusterID)) case <-ticker.C: - clusterResult, err := d.GetCluster(serverlessApi.NewServerlessServiceGetClusterParams(). - WithClusterID(newClusterID).WithContext(ctx)) + clusterResult, err := d.GetCluster(ctx, newClusterID) if err != nil { return errors.Trace(err) } - s := *clusterResult.GetPayload().State - if s == "ACTIVE" { + if *clusterResult.State == cluster.COMMONV1BETA1CLUSTERSTATE_ACTIVE { return ui.Result(fmt.Sprintf("Cluster %s is ready.", newClusterID)) } case <-ctx.Done(): diff --git a/internal/cli/serverless/create_test.go b/internal/cli/serverless/create_test.go index defc39ae..a9e590ac 100644 --- a/internal/cli/serverless/create_test.go +++ b/internal/cli/serverless/create_test.go @@ -25,8 +25,7 @@ import ( "tidbcloud-cli/internal/iostream" "tidbcloud-cli/internal/mock" "tidbcloud-cli/internal/service/cloud" - serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" - serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -62,31 +61,23 @@ func (suite *CreateClusterSuite) TestCreateClusterArgs() { clusterID := "12345" clusterName := "test" regionName := "regions/aws-us-west-1" - v1Cluster := &serverlessModel.TidbCloudOpenApiserverlessv1beta1Cluster{ - DisplayName: &clusterName, - Region: &serverlessModel.Commonv1beta1Region{ + v1Cluster := &cluster.TidbCloudOpenApiserverlessv1beta1Cluster{ + DisplayName: clusterName, + Region: cluster.Commonv1beta1Region{ Name: ®ionName, }, - Labels: map[string]string{"tidb.cloud/project": projectID}, + Labels: &map[string]string{"tidb.cloud/project": projectID}, } - body := &serverlessModel.TidbCloudOpenApiserverlessv1beta1Cluster{} + body := &cluster.TidbCloudOpenApiserverlessv1beta1Cluster{} err := json.Unmarshal([]byte(getClusterResultStr), body) assert.Nil(err) - res := &serverlessApi.ServerlessServiceGetClusterOK{ - Payload: body, - } - suite.mockClient.On("CreateCluster", serverlessApi.NewServerlessServiceCreateClusterParams(). - WithCluster(v1Cluster).WithContext(ctx)). - Return(&serverlessApi.ServerlessServiceCreateClusterOK{ - Payload: &serverlessModel.TidbCloudOpenApiserverlessv1beta1Cluster{ - ClusterID: clusterID, - }, + suite.mockClient.On("CreateCluster", ctx, v1Cluster). + Return(&cluster.TidbCloudOpenApiserverlessv1beta1Cluster{ + ClusterId: &clusterID, }, nil) - suite.mockClient.On("GetCluster", serverlessApi.NewServerlessServiceGetClusterParams(). - WithClusterID(clusterID).WithContext(ctx)). - Return(res, nil) + suite.mockClient.On("GetCluster", ctx, clusterID).Return(body, nil) tests := []struct { name string @@ -134,30 +125,22 @@ func (suite *CreateClusterSuite) TestCreateClusterWithoutProject() { clusterName := "test" regionName := "regions/aws-us-west-1" - v1ClusterWithoutProject := &serverlessModel.TidbCloudOpenApiserverlessv1beta1Cluster{ - DisplayName: &clusterName, - Region: &serverlessModel.Commonv1beta1Region{ + v1ClusterWithoutProject := &cluster.TidbCloudOpenApiserverlessv1beta1Cluster{ + DisplayName: clusterName, + Region: cluster.Commonv1beta1Region{ Name: ®ionName, }, } - body := &serverlessModel.TidbCloudOpenApiserverlessv1beta1Cluster{} + body := &cluster.TidbCloudOpenApiserverlessv1beta1Cluster{} err := json.Unmarshal([]byte(getClusterResultStr), body) assert.Nil(err) - res := &serverlessApi.ServerlessServiceGetClusterOK{ - Payload: body, - } - suite.mockClient.On("CreateCluster", serverlessApi.NewServerlessServiceCreateClusterParams(). - WithCluster(v1ClusterWithoutProject).WithContext(ctx)). - Return(&serverlessApi.ServerlessServiceCreateClusterOK{ - Payload: &serverlessModel.TidbCloudOpenApiserverlessv1beta1Cluster{ - ClusterID: clusterID, - }, + suite.mockClient.On("CreateCluster", ctx, v1ClusterWithoutProject). + Return(&cluster.TidbCloudOpenApiserverlessv1beta1Cluster{ + ClusterId: &clusterID, }, nil) - suite.mockClient.On("GetCluster", serverlessApi.NewServerlessServiceGetClusterParams(). - WithClusterID(clusterID).WithContext(ctx)). - Return(res, nil) + suite.mockClient.On("GetCluster", ctx, clusterID).Return(body, nil) tests := []struct { name string diff --git a/internal/cli/serverless/delete.go b/internal/cli/serverless/delete.go index f558fbeb..72f234ce 100644 --- a/internal/cli/serverless/delete.go +++ b/internal/cli/serverless/delete.go @@ -23,7 +23,7 @@ import ( "tidbcloud-cli/internal/service/cloud" "tidbcloud-cli/internal/telemetry" "tidbcloud-cli/internal/util" - serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" "github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2/terminal" @@ -103,11 +103,11 @@ func DeleteCmd(h *internal.Helper) *cobra.Command { } projectID := project.ID - cluster, err := cloud.GetSelectedCluster(ctx, projectID, h.QueryPageSize, d) + c, err := cloud.GetSelectedCluster(ctx, projectID, h.QueryPageSize, d) if err != nil { return err } - clusterID = cluster.ID + clusterID = c.ID } else { // non-interactive mode doesn't need projectID cID, err := cmd.Flags().GetString(flag.ClusterID) @@ -143,12 +143,11 @@ func DeleteCmd(h *internal.Helper) *cobra.Command { } } - params := serverlessApi.NewServerlessServiceDeleteClusterParams().WithClusterID(clusterID).WithContext(cmd.Context()) - cluster, err := d.DeleteCluster(params) + c, err := d.DeleteCluster(ctx, clusterID) if err != nil { return errors.Trace(err) } - if *cluster.Payload.State == "DELETING" || *cluster.Payload.State == "DELETED" { + if *c.State == cluster.COMMONV1BETA1CLUSTERSTATE_DELETING || *c.State == cluster.COMMONV1BETA1CLUSTERSTATE_DELETED { fmt.Fprintln(h.IOStreams.Out, color.GreenString(fmt.Sprintf("cluster %s deleted", clusterID))) return nil } else { diff --git a/internal/cli/serverless/delete_test.go b/internal/cli/serverless/delete_test.go index 095f93df..9233caba 100644 --- a/internal/cli/serverless/delete_test.go +++ b/internal/cli/serverless/delete_test.go @@ -25,8 +25,7 @@ import ( "tidbcloud-cli/internal/iostream" "tidbcloud-cli/internal/mock" "tidbcloud-cli/internal/service/cloud" - serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" - serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -60,13 +59,11 @@ func (suite *DeleteClusterSuite) TestDeleteClusterArgs() { clusterID := "12345" state := "DELETING" - suite.mockClient.On("DeleteCluster", serverlessApi.NewServerlessServiceDeleteClusterParams(). - WithClusterID(clusterID).WithContext(ctx)). - Return(&serverlessApi.ServerlessServiceDeleteClusterOK{ - Payload: &serverlessModel.TidbCloudOpenApiserverlessv1beta1Cluster{ - State: (*serverlessModel.Commonv1beta1ClusterState)(&state), - }, - }, nil) + suite.mockClient.On("DeleteCluster", ctx, clusterID). + Return( + &cluster.TidbCloudOpenApiserverlessv1beta1Cluster{ + State: (*cluster.Commonv1beta1ClusterState)(&state), + }, nil) tests := []struct { name string diff --git a/internal/cli/serverless/describe.go b/internal/cli/serverless/describe.go index 3db6771b..cc4aa8a2 100644 --- a/internal/cli/serverless/describe.go +++ b/internal/cli/serverless/describe.go @@ -23,7 +23,6 @@ import ( "tidbcloud-cli/internal/output" "tidbcloud-cli/internal/service/cloud" "tidbcloud-cli/internal/telemetry" - serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" "github.com/juju/errors" "github.com/spf13/cobra" @@ -97,11 +96,11 @@ func DescribeCmd(h *internal.Helper) *cobra.Command { } projectID := project.ID - cluster, err := cloud.GetSelectedCluster(ctx, projectID, h.QueryPageSize, d) + c, err := cloud.GetSelectedCluster(ctx, projectID, h.QueryPageSize, d) if err != nil { return err } - clusterID = cluster.ID + clusterID = c.ID } else { // non-interactive mode does not need projectID cID, err := cmd.Flags().GetString(flag.ClusterID) @@ -111,14 +110,12 @@ func DescribeCmd(h *internal.Helper) *cobra.Command { clusterID = cID } - params := serverlessApi.NewServerlessServiceGetClusterParams().WithClusterID(clusterID).WithContext(cmd.Context()) - - cluster, err := d.GetCluster(params) + c, err := d.GetCluster(ctx, clusterID) if err != nil { return errors.Trace(err) } - err = output.PrintJson(h.IOStreams.Out, cluster.Payload) + err = output.PrintJson(h.IOStreams.Out, c) return errors.Trace(err) }, } diff --git a/internal/cli/serverless/describe_test.go b/internal/cli/serverless/describe_test.go index 68a5ac8b..13adb077 100644 --- a/internal/cli/serverless/describe_test.go +++ b/internal/cli/serverless/describe_test.go @@ -25,8 +25,7 @@ import ( "tidbcloud-cli/internal/iostream" "tidbcloud-cli/internal/mock" "tidbcloud-cli/internal/service/cloud" - serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" - serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -107,16 +106,12 @@ func (suite *DescribeClusterSuite) TestDescribeClusterArgs() { assert := require.New(suite.T()) ctx := context.Background() - body := &serverlessModel.TidbCloudOpenApiserverlessv1beta1Cluster{} + body := &cluster.TidbCloudOpenApiserverlessv1beta1Cluster{} err := json.Unmarshal([]byte(getClusterResultStr), body) assert.Nil(err) - result := &serverlessApi.ServerlessServiceGetClusterOK{ - Payload: body, - } + clusterID := "12345" - suite.mockClient.On("GetCluster", serverlessApi.NewServerlessServiceGetClusterParams(). - WithClusterID(clusterID).WithContext(ctx)). - Return(result, nil) + suite.mockClient.On("GetCluster", ctx, clusterID).Return(body, nil) tests := []struct { name string diff --git a/internal/cli/serverless/list.go b/internal/cli/serverless/list.go index 3fd70b8b..c8abcf57 100644 --- a/internal/cli/serverless/list.go +++ b/internal/cli/serverless/list.go @@ -16,6 +16,7 @@ package serverless import ( "fmt" + "time" "tidbcloud-cli/internal" "tidbcloud-cli/internal/config" @@ -23,7 +24,7 @@ import ( "tidbcloud-cli/internal/output" "tidbcloud-cli/internal/service/cloud" "tidbcloud-cli/internal/telemetry" - serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" "github.com/juju/errors" "github.com/spf13/cobra" @@ -109,9 +110,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 := &serverlessModel.TidbCloudOpenApiserverlessv1beta1ListClustersResponse{ + res := &cluster.TidbCloudOpenApiserverlessv1beta1ListClustersResponse{ Clusters: items, - TotalSize: total, + TotalSize: &total, } err := output.PrintJson(h.IOStreams.Out, res) if err != nil { @@ -131,13 +132,13 @@ func ListCmd(h *internal.Helper) *cobra.Command { var rows []output.Row for _, item := range items { rows = append(rows, output.Row{ - item.ClusterID, - *item.DisplayName, + *item.ClusterId, + item.DisplayName, string(*item.State), - item.Version, - string(*item.Region.Provider), - item.Region.DisplayName, - item.CreateTime.String(), + *item.Version, + string(*item.Region.CloudProvider), + *item.Region.DisplayName, + item.CreateTime.Format(time.RFC3339), }) } diff --git a/internal/cli/serverless/list_test.go b/internal/cli/serverless/list_test.go index d161d513..8b606126 100644 --- a/internal/cli/serverless/list_test.go +++ b/internal/cli/serverless/list_test.go @@ -27,8 +27,7 @@ import ( "tidbcloud-cli/internal/iostream" "tidbcloud-cli/internal/mock" "tidbcloud-cli/internal/service/cloud" - serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" - serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -38,7 +37,7 @@ const listResultStr = `{ "clusters": [ { "clusterId": "3779024", - "createTime": "2023-07-04T01:56:12.000Z", + "createTime": "2023-07-04T01:56:12Z", "createdBy": "yuhang.shi@pingcap.com", "displayName": "Cluster0", "endpoints": { @@ -68,7 +67,7 @@ const listResultStr = `{ "provider": "AWS" }, "state": "ACTIVE", - "updateTime": "2023-08-03T09:08:07.753Z", + "updateTime": "2023-08-03T09:08:07Z", "userPrefix": "4FNu72xBpLXjFnC", "version": "v6.6.0" } @@ -81,7 +80,7 @@ const listResultMultiPageStr = `{ "clusters": [ { "clusterId": "3779024", - "createTime": "2023-07-04T01:56:12.000Z", + "createTime": "2023-07-04T01:56:12Z", "createdBy": "yuhang.shi@pingcap.com", "displayName": "Cluster0", "endpoints": { @@ -111,13 +110,13 @@ const listResultMultiPageStr = `{ "provider": "AWS" }, "state": "ACTIVE", - "updateTime": "2023-08-03T09:08:07.753Z", + "updateTime": "2023-08-03T09:08:07Z", "userPrefix": "4FNu72xBpLXjFnC", "version": "v6.6.0" }, { "clusterId": "3779024", - "createTime": "2023-07-04T01:56:12.000Z", + "createTime": "2023-07-04T01:56:12Z", "createdBy": "yuhang.shi@pingcap.com", "displayName": "Cluster0", "endpoints": { @@ -147,7 +146,7 @@ const listResultMultiPageStr = `{ "provider": "AWS" }, "state": "ACTIVE", - "updateTime": "2023-08-03T09:08:07.753Z", + "updateTime": "2023-08-03T09:08:07Z", "userPrefix": "4FNu72xBpLXjFnC", "version": "v6.6.0" } @@ -182,18 +181,14 @@ func (suite *ListClusterSuite) TestListClusterArgs() { assert := require.New(suite.T()) ctx := context.Background() - body := &serverlessModel.TidbCloudOpenApiserverlessv1beta1ListClustersResponse{} + body := &cluster.TidbCloudOpenApiserverlessv1beta1ListClustersResponse{} err := json.Unmarshal([]byte(listResultStr), body) assert.Nil(err) - result := &serverlessApi.ServerlessServiceListClustersOK{ - Payload: body, - } + projectID := "12345" pageSize := int32(suite.h.QueryPageSize) filter := fmt.Sprintf("projectId=%s", projectID) - suite.mockClient.On("ListClustersOfProject", serverlessApi.NewServerlessServiceListClustersParams(). - WithPageSize(&pageSize).WithFilter(&filter).WithContext(ctx)). - Return(result, nil) + suite.mockClient.On("ListClusters", ctx, &filter, &pageSize, (*string)(nil), (*string)(nil), (*int32)(nil)).Return(body, nil) tests := []struct { name string @@ -245,30 +240,21 @@ func (suite *ListClusterSuite) TestListClusterWithMultiPages() { suite.h.QueryPageSize = 1 pageSize := int32(suite.h.QueryPageSize) pageToken := "2" - body := &serverlessModel.TidbCloudOpenApiserverlessv1beta1ListClustersResponse{} + body := &cluster.TidbCloudOpenApiserverlessv1beta1ListClustersResponse{} err := json.Unmarshal([]byte(strings.ReplaceAll(listResultStr, `"totalSize": 1`, `"totalSize": 2`)), body) assert.Nil(err) - body.NextPageToken = pageToken - result := &serverlessApi.ServerlessServiceListClustersOK{ - Payload: body, - } + body.NextPageToken = &pageToken + projectID := "12345" filter := fmt.Sprintf("projectId=%s", projectID) - suite.mockClient.On("ListClustersOfProject", serverlessApi.NewServerlessServiceListClustersParams(). - WithPageSize(&pageSize).WithFilter(&filter).WithContext(ctx)). - Return(result, nil) + suite.mockClient.On("ListClusters", ctx, &filter, &pageSize, (*string)(nil), (*string)(nil), (*int32)(nil)).Return(body, nil) - body2 := &serverlessModel.TidbCloudOpenApiserverlessv1beta1ListClustersResponse{} + body2 := &cluster.TidbCloudOpenApiserverlessv1beta1ListClustersResponse{} err = json.Unmarshal([]byte(strings.ReplaceAll(listResultStr, `"totalSize": 1`, `"totalSize": 2`)), body2) assert.Nil(err) - result2 := &serverlessApi.ServerlessServiceListClustersOK{ - Payload: body2, - } - suite.mockClient.On("ListClustersOfProject", serverlessApi.NewServerlessServiceListClustersParams(). - WithPageToken(&pageToken).WithPageSize(&pageSize).WithFilter(&filter).WithContext(ctx)). - Return(result2, nil) - cmd := ListCmd(suite.h) + suite.mockClient.On("ListClusters", ctx, &filter, &pageSize, &pageToken, (*string)(nil), (*int32)(nil)).Return(body2, nil) + cmd := ListCmd(suite.h) tests := []struct { name string args []string diff --git a/internal/cli/serverless/region.go b/internal/cli/serverless/region.go index 58d412bd..886d0ed2 100644 --- a/internal/cli/serverless/region.go +++ b/internal/cli/serverless/region.go @@ -22,7 +22,6 @@ import ( "tidbcloud-cli/internal" "tidbcloud-cli/internal/config" - serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" "github.com/juju/errors" "github.com/spf13/cobra" @@ -47,13 +46,13 @@ func RegionCmd(h *internal.Helper) *cobra.Command { return errors.Trace(err) } - regions, err := d.ListProviderRegions(serverlessApi.NewServerlessServiceListRegionsParams().WithContext(cmd.Context())) + regions, err := d.ListProviderRegions(cmd.Context()) if err != nil { return errors.Trace(err) } if format == output.JsonFormat || !h.IOStreams.CanPrompt { - err = output.PrintJson(h.IOStreams.Out, regions.Payload.Regions) + err = output.PrintJson(h.IOStreams.Out, regions.Regions) if err != nil { return errors.Trace(err) } @@ -65,11 +64,11 @@ func RegionCmd(h *internal.Helper) *cobra.Command { } var rows []output.Row - for _, item := range regions.Payload.Regions { + for _, item := range regions.Regions { rows = append(rows, output.Row{ *item.Name, - item.DisplayName, - string(*item.Provider), + *item.DisplayName, + string(*item.CloudProvider), }) } err = output.PrintHumanTable(h.IOStreams.Out, columns, rows) diff --git a/internal/cli/serverless/shell.go b/internal/cli/serverless/shell.go index c0d36439..9810be36 100644 --- a/internal/cli/serverless/shell.go +++ b/internal/cli/serverless/shell.go @@ -23,7 +23,6 @@ import ( "tidbcloud-cli/internal/flag" "tidbcloud-cli/internal/service/cloud" "tidbcloud-cli/internal/util" - serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" "github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2/terminal" @@ -169,16 +168,15 @@ The connection forces the [ANSI SQL mode](https://dev.mysql.com/doc/refman/8.0/e } var host, name, port string - params := serverlessApi.NewServerlessServiceGetClusterParams().WithClusterID(clusterID).WithContext(ctx) - cluster, err := d.GetCluster(params) + cluster, err := d.GetCluster(ctx, clusterID) if err != nil { return errors.Trace(err) } - host = cluster.Payload.Endpoints.Public.Host - name = *cluster.Payload.DisplayName - port = strconv.Itoa(int(cluster.Payload.Endpoints.Public.Port)) + host = *cluster.Endpoints.Public.Host + name = cluster.DisplayName + port = strconv.Itoa(int(*cluster.Endpoints.Public.Port)) if userName == "" { - userName = cluster.Payload.UserPrefix + ".root" + userName = *cluster.UserPrefix + ".root" fmt.Fprintln(h.IOStreams.Out, color.GreenString("Current user: ")+color.HiGreenString(userName)) } diff --git a/internal/cli/serverless/spending_limit.go b/internal/cli/serverless/spending_limit.go index 5000c724..9e1dc8db 100644 --- a/internal/cli/serverless/spending_limit.go +++ b/internal/cli/serverless/spending_limit.go @@ -24,8 +24,7 @@ import ( "tidbcloud-cli/internal/service/cloud" "tidbcloud-cli/internal/ui" "tidbcloud-cli/internal/util" - serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" - serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" "github.com/charmbracelet/bubbles/textinput" tea "github.com/charmbracelet/bubbletea" @@ -105,11 +104,11 @@ func SpendingLimitCmd(h *internal.Helper) *cobra.Command { return err } - cluster, err := cloud.GetSelectedCluster(ctx, project.ID, h.QueryPageSize, d) + c, err := cloud.GetSelectedCluster(ctx, project.ID, h.QueryPageSize, d) if err != nil { return err } - clusterID = cluster.ID + clusterID = c.ID field, err := cloud.GetSpendingLimitField(spendingLimitFields) if err != nil { @@ -146,16 +145,14 @@ func SpendingLimitCmd(h *internal.Helper) *cobra.Command { return errors.Errorf("invalid monthly spending limit %d", monthly) } - body := &serverlessApi.ServerlessServicePartialUpdateClusterBody{ - Cluster: &serverlessApi.ServerlessServicePartialUpdateClusterParamsBodyCluster{ - SpendingLimit: &serverlessModel.ClusterSpendingLimit{}, + body := &cluster.V1beta1ServerlessServicePartialUpdateClusterBody{ + Cluster: &cluster.RequiredTheClusterToBeUpdated{ + SpendingLimit: &cluster.ClusterSpendingLimit{}, }, } - body.UpdateMask = &SpendingLimitMonthlyMask - body.Cluster.SpendingLimit.Monthly = monthly - params := serverlessApi.NewServerlessServicePartialUpdateClusterParams().WithClusterClusterID(clusterID). - WithBody(*body).WithContext(ctx) - _, err = d.PartialUpdateCluster(params) + body.UpdateMask = SpendingLimitMonthlyMask + body.Cluster.SpendingLimit.Monthly = &monthly + _, err = d.PartialUpdateCluster(ctx, clusterID, body) if err != nil { return errors.Trace(err) } diff --git a/internal/cli/serverless/spending_limit_test.go b/internal/cli/serverless/spending_limit_test.go index b5aae506..d26c7954 100644 --- a/internal/cli/serverless/spending_limit_test.go +++ b/internal/cli/serverless/spending_limit_test.go @@ -25,8 +25,7 @@ import ( "tidbcloud-cli/internal/iostream" "tidbcloud-cli/internal/mock" "tidbcloud-cli/internal/service/cloud" - serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" - serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -59,20 +58,15 @@ func (suite *SpendingLimitSuite) TestSetSpendingLimit() { ctx := context.Background() clusterID := "0" - monthly := 10 - cluster := &serverlessApi.ServerlessServicePartialUpdateClusterParamsBodyCluster{ - SpendingLimit: &serverlessModel.ClusterSpendingLimit{ - Monthly: int32(monthly), + var monthly int32 = 10 + body := &cluster.V1beta1ServerlessServicePartialUpdateClusterBody{ + Cluster: &cluster.RequiredTheClusterToBeUpdated{ + SpendingLimit: &cluster.ClusterSpendingLimit{}, }, } - body := serverlessApi.ServerlessServicePartialUpdateClusterBody{ - Cluster: cluster, - UpdateMask: &SpendingLimitMonthlyMask, - } - - suite.mockClient.On("PartialUpdateCluster", serverlessApi.NewServerlessServicePartialUpdateClusterParams(). - WithClusterClusterID(clusterID).WithBody(body).WithContext(ctx)). - Return(&serverlessApi.ServerlessServicePartialUpdateClusterOK{}, nil) + body.UpdateMask = SpendingLimitMonthlyMask + body.Cluster.SpendingLimit.Monthly = &monthly + suite.mockClient.On("PartialUpdateCluster", ctx, clusterID, body).Return(&cluster.TidbCloudOpenApiserverlessv1beta1Cluster{}, nil) tests := []struct { name string diff --git a/internal/cli/serverless/sqluser/create.go b/internal/cli/serverless/sqluser/create.go index 3e6accdc..128e2792 100644 --- a/internal/cli/serverless/sqluser/create.go +++ b/internal/cli/serverless/sqluser/create.go @@ -29,7 +29,6 @@ import ( "tidbcloud-cli/internal/util" "tidbcloud-cli/pkg/tidbcloud/v1beta1/iam" - serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" "github.com/charmbracelet/bubbles/textinput" tea "github.com/charmbracelet/bubbletea" @@ -263,14 +262,12 @@ func initialCreateInputModel(userPrefix string) ui.TextInputModel { } func getUserPrefix(ctx context.Context, d cloud.TiDBCloudClient, clusterID string) (string, error) { - params := serverlessApi.NewServerlessServiceGetClusterParams().WithClusterID(clusterID).WithContext(ctx) - - cluster, err := d.GetCluster(params) + cluster, err := d.GetCluster(ctx, clusterID) if err != nil { return "", errors.Trace(err) } - return cluster.Payload.UserPrefix, nil + return *cluster.UserPrefix, nil } func getBuiltinRoleAndCustomRoles(roles []string) (*string, []string, error) { diff --git a/internal/cli/serverless/sqluser/create_test.go b/internal/cli/serverless/sqluser/create_test.go index 45905cd1..ed6c3d93 100644 --- a/internal/cli/serverless/sqluser/create_test.go +++ b/internal/cli/serverless/sqluser/create_test.go @@ -29,8 +29,7 @@ import ( "tidbcloud-cli/internal/service/cloud" "tidbcloud-cli/internal/util" "tidbcloud-cli/pkg/tidbcloud/v1beta1/iam" - serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" - serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" "github.com/juju/errors" "github.com/stretchr/testify/require" @@ -45,8 +44,14 @@ const getSQLUserResultStr = `{ }` const getClusterResultStr = `{ - "clusterID": "12345", - "userPrefix": "4TGJD6zA3Nn2333" + "clusterId": "12345", + "userPrefix": "4TGJD6zA3Nn2333", + "displayName": "test", + "region": { + "displayName": "Singapore (ap-southeast-1)", + "name": "regions/aws-ap-southeast-1", + "provider": "aws" + } }` type CreateSQLUserSuite struct { @@ -102,15 +107,10 @@ func (suite *CreateSQLUserSuite) TestCreateSQLUserArgs() { suite.mockClient.On("CreateSQLUser", ctx, clusterID, createSQLUserBody). Return(result, nil) - clusterBody := &serverlessModel.TidbCloudOpenApiserverlessv1beta1Cluster{} - err = json.Unmarshal([]byte(getClusterResultStr), clusterBody) + res := &cluster.TidbCloudOpenApiserverlessv1beta1Cluster{} + err = json.Unmarshal([]byte(getClusterResultStr), res) assert.Nil(err) - res := &serverlessApi.ServerlessServiceGetClusterOK{ - Payload: clusterBody, - } - suite.mockClient.On("GetCluster", serverlessApi.NewServerlessServiceGetClusterParams(). - WithClusterID(clusterID).WithContext(ctx)). - Return(res, nil) + suite.mockClient.On("GetCluster", ctx, clusterID).Return(res, nil) tests := []struct { name string diff --git a/internal/cli/serverless/sqluser/update.go b/internal/cli/serverless/sqluser/update.go index 060f80de..522d50fb 100644 --- a/internal/cli/serverless/sqluser/update.go +++ b/internal/cli/serverless/sqluser/update.go @@ -227,7 +227,7 @@ func UpdateCmd(h *internal.Helper) *cobra.Command { } if !util.IsNilOrEmpty(u.BuiltinRole) && !util.IsNilOrEmpty(addBuiltinRole) { return errors.New("built-in role already exists in the SQL user") - } else if util.IsNilOrEmpty(u.BuiltinRole) && !!util.IsNilOrEmpty(addBuiltinRole) { + } else if util.IsNilOrEmpty(u.BuiltinRole) && !util.IsNilOrEmpty(addBuiltinRole) { u.BuiltinRole = addBuiltinRole } u.CustomRoles = append(u.CustomRoles, addCustomRoles...) diff --git a/internal/cli/serverless/sqluser/update_test.go b/internal/cli/serverless/sqluser/update_test.go index 4e8c200a..acc5d365 100644 --- a/internal/cli/serverless/sqluser/update_test.go +++ b/internal/cli/serverless/sqluser/update_test.go @@ -29,8 +29,7 @@ import ( "tidbcloud-cli/internal/service/cloud" "tidbcloud-cli/internal/util" "tidbcloud-cli/pkg/tidbcloud/v1beta1/iam" - serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" - serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" "github.com/juju/errors" "github.com/stretchr/testify/require" @@ -81,15 +80,10 @@ func (suite *UpdateSQLUserSuite) TestUpdateSQLUserArgs() { suite.mockClient.On("GetSQLUser", ctx, clusterID, fullUserName). Return(result, nil) - clusterBody := &serverlessModel.TidbCloudOpenApiserverlessv1beta1Cluster{} - err = json.Unmarshal([]byte(getClusterResultStr), clusterBody) + res := &cluster.TidbCloudOpenApiserverlessv1beta1Cluster{} + err = json.Unmarshal([]byte(getClusterResultStr), res) assert.Nil(err) - res := &serverlessApi.ServerlessServiceGetClusterOK{ - Payload: clusterBody, - } - suite.mockClient.On("GetCluster", serverlessApi.NewServerlessServiceGetClusterParams(). - WithClusterID(clusterID).WithContext(ctx)). - Return(res, nil) + suite.mockClient.On("GetCluster", ctx, clusterID).Return(res, nil) updateBody := &iam.ApiUpdateSqlUserReq{ BuiltinRole: &builtinRole, diff --git a/internal/cli/serverless/update.go b/internal/cli/serverless/update.go index 9ef2c02f..625cefac 100644 --- a/internal/cli/serverless/update.go +++ b/internal/cli/serverless/update.go @@ -25,8 +25,7 @@ import ( "tidbcloud-cli/internal/telemetry" "tidbcloud-cli/internal/ui" "tidbcloud-cli/internal/util" - serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" - serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" "github.com/charmbracelet/bubbles/textinput" tea "github.com/charmbracelet/bubbletea" @@ -43,7 +42,6 @@ func (c UpdateOpts) NonInteractiveFlags() []string { return []string{ flag.ClusterID, flag.DisplayName, - flag.ServerlessAnnotations, flag.ServerlessLabels, flag.PublicEndpointDisabled, } @@ -53,7 +51,6 @@ type mutableField string const ( DisplayName mutableField = "displayName" - Annotations mutableField = "annotations" Labels mutableField = "labels" PublicEndpointDisabled mutableField = "endpoints.public.disabled" ) @@ -65,7 +62,6 @@ const ( var mutableFields = []string{ string(DisplayName), string(Labels), - string(Annotations), string(PublicEndpointDisabledHumanReadable), } @@ -102,8 +98,8 @@ func UpdateCmd(h *internal.Helper) *cobra.Command { if err != nil { return err } - cmd.MarkFlagsMutuallyExclusive(flag.DisplayName, flag.ServerlessAnnotations, flag.ServerlessLabels, flag.PublicEndpointDisabled) - cmd.MarkFlagsOneRequired(flag.DisplayName, flag.ServerlessAnnotations, flag.ServerlessLabels, flag.PublicEndpointDisabled) + cmd.MarkFlagsMutuallyExclusive(flag.DisplayName, flag.ServerlessLabels, flag.PublicEndpointDisabled) + cmd.MarkFlagsOneRequired(flag.DisplayName, flag.ServerlessLabels, flag.PublicEndpointDisabled) } return nil }, @@ -116,7 +112,8 @@ func UpdateCmd(h *internal.Helper) *cobra.Command { var clusterID string var fieldName string - var displayName, labels, annotations string + var displayName string + var labels string var publicEndpointDisabled bool if opts.interactive { cmd.Annotations[telemetry.InteractiveMode] = "true" @@ -158,8 +155,6 @@ func UpdateCmd(h *internal.Helper) *cobra.Command { switch fieldName { case string(DisplayName): displayName = fieldValue - case string(Annotations): - annotations = fieldValue case string(Labels): labels = fieldValue default: @@ -181,21 +176,17 @@ func UpdateCmd(h *internal.Helper) *cobra.Command { if err != nil { return errors.Trace(err) } - annotations, err = cmd.Flags().GetString(flag.ServerlessAnnotations) - if err != nil { - return errors.Trace(err) - } publicEndpointDisabled, err = cmd.Flags().GetBool(flag.PublicEndpointDisabled) if err != nil { return errors.Trace(err) } } - body := &serverlessApi.ServerlessServicePartialUpdateClusterBody{ - Cluster: &serverlessApi.ServerlessServicePartialUpdateClusterParamsBodyCluster{}, + body := &cluster.V1beta1ServerlessServicePartialUpdateClusterBody{ + Cluster: &cluster.RequiredTheClusterToBeUpdated{}, } if displayName != "" { - body.Cluster.DisplayName = displayName + body.Cluster.DisplayName = &displayName fieldName = string(DisplayName) } if labels != "" { @@ -203,30 +194,20 @@ func UpdateCmd(h *internal.Helper) *cobra.Command { if err != nil { return errors.Errorf("invalid labels %s", labels) } - body.Cluster.Labels = labelsMap + body.Cluster.Labels = &labelsMap fieldName = string(Labels) } - if annotations != "" { - annotationsMap, err := stringToMap(annotations) - if err != nil { - return errors.Errorf("invalid annotations %s", annotations) - } - body.Cluster.Annotations = annotationsMap - fieldName = string(Annotations) - } // if fieldName is PublicEndpointDisabled, means this field is changed in Interactive mode if cmd.Flags().Changed(flag.PublicEndpointDisabled) || fieldName == string(PublicEndpointDisabledHumanReadable) { - body.Cluster.Endpoints = &serverlessModel.TidbCloudOpenApiserverlessv1beta1ClusterEndpoints{ - Public: &serverlessModel.EndpointsPublic{ - Disabled: publicEndpointDisabled, + body.Cluster.Endpoints = &cluster.V1beta1ClusterEndpoints{ + Public: &cluster.EndpointsPublic{ + Disabled: &publicEndpointDisabled, }, } fieldName = string(PublicEndpointDisabled) } - body.UpdateMask = &fieldName - params := serverlessApi.NewServerlessServicePartialUpdateClusterParams().WithClusterClusterID(clusterID). - WithBody(*body).WithContext(ctx) - _, err = d.PartialUpdateCluster(params) + body.UpdateMask = fieldName + _, err = d.PartialUpdateCluster(ctx, clusterID, body) if err != nil { return errors.Trace(err) } @@ -238,7 +219,6 @@ func UpdateCmd(h *internal.Helper) *cobra.Command { updateCmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The ID of the cluster to be updated.") updateCmd.Flags().StringP(flag.DisplayName, flag.DisplayNameShort, "", "The new displayName of the cluster to be updated.") updateCmd.Flags().String(flag.ServerlessLabels, "", "The labels of the cluster to be added or updated.\nInteractive example: {\"label1\":\"value1\",\"label2\":\"value2\"}.\nNonInteractive example: \"{\\\"label1\\\":\\\"value1\\\",\\\"label2\\\":\\\"value2\\\"}\".") - updateCmd.Flags().String(flag.ServerlessAnnotations, "", "The annotations of the cluster to be added or updated.\nInteractive example: {\"annotation1\":\"value1\",\"annotation2\":\"value2\"}.\nNonInteractive example: \"{\\\"annotation1\\\":\\\"value1\\\",\\\"annotation2\\\":\\\"value2\\\"}\".") updateCmd.Flags().Bool(flag.PublicEndpointDisabled, false, "Disable the public endpoint of the cluster.") return updateCmd } diff --git a/internal/cli/serverless/update_test.go b/internal/cli/serverless/update_test.go index f913ab5d..bb972c98 100644 --- a/internal/cli/serverless/update_test.go +++ b/internal/cli/serverless/update_test.go @@ -26,7 +26,7 @@ import ( "tidbcloud-cli/internal/iostream" "tidbcloud-cli/internal/mock" "tidbcloud-cli/internal/service/cloud" - serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -59,19 +59,17 @@ func (suite *UpdateClusterSuite) TestUpdateClusterArgs() { ctx := context.Background() displayName := "update_name" - cluster := &serverlessApi.ServerlessServicePartialUpdateClusterParamsBodyCluster{ - DisplayName: displayName, + c := &cluster.RequiredTheClusterToBeUpdated{ + DisplayName: &displayName, } mask := "displayName" - body := serverlessApi.ServerlessServicePartialUpdateClusterBody{ - Cluster: cluster, - UpdateMask: &mask, + body := &cluster.V1beta1ServerlessServicePartialUpdateClusterBody{ + Cluster: c, + UpdateMask: mask, } clusterID := "12345" - suite.mockClient.On("PartialUpdateCluster", serverlessApi.NewServerlessServicePartialUpdateClusterParams(). - WithClusterClusterID(clusterID).WithBody(body).WithContext(ctx)). - Return(&serverlessApi.ServerlessServicePartialUpdateClusterOK{}, nil) + suite.mockClient.On("PartialUpdateCluster", ctx, clusterID, body).Return(&cluster.TidbCloudOpenApiserverlessv1beta1Cluster{}, nil) tests := []struct { name string @@ -115,17 +113,15 @@ func (suite *UpdateClusterSuite) TestUpdateLabels() { labelsMap := make(map[string]string) _ = json.Unmarshal([]byte(labels), &labelsMap) - cluster := &serverlessApi.ServerlessServicePartialUpdateClusterParamsBodyCluster{ - Labels: labelsMap, + c := &cluster.RequiredTheClusterToBeUpdated{ + Labels: &labelsMap, } - body := serverlessApi.ServerlessServicePartialUpdateClusterBody{ - Cluster: cluster, - UpdateMask: &mask, + body := &cluster.V1beta1ServerlessServicePartialUpdateClusterBody{ + Cluster: c, + UpdateMask: mask, } clusterID := "12345" - suite.mockClient.On("PartialUpdateCluster", serverlessApi.NewServerlessServicePartialUpdateClusterParams(). - WithClusterClusterID(clusterID).WithBody(body).WithContext(ctx)). - Return(&serverlessApi.ServerlessServicePartialUpdateClusterOK{}, nil) + suite.mockClient.On("PartialUpdateCluster", ctx, clusterID, body).Return(&cluster.TidbCloudOpenApiserverlessv1beta1Cluster{}, nil) tests := []struct { name string diff --git a/internal/flag/flag.go b/internal/flag/flag.go index be6ea94e..7b1fcfdd 100644 --- a/internal/flag/flag.go +++ b/internal/flag/flag.go @@ -15,50 +15,49 @@ package flag const ( - ClusterID string = "cluster-id" - ClusterIDShort string = "c" - LocalConcurrency string = "local.concurrency" - CSVBackslashEscape string = "csv.backslash-escape" - CSVDelimiter string = "csv.delimiter" - CSVSeparator string = "csv.separator" - CSVTrimLastSeparator string = "csv.trim-last-separator" - CSVNullValue string = "csv.null-value" - CSVSkipHeader string = "csv.skip-header" - DisplayName string = "display-name" - DisplayNameShort string = "n" - ClusterType string = "cluster-type" - BranchID string = "branch-id" - BranchIDShort string = "b" - Debug string = "debug" - DebugShort string = "D" - LocalFilePath string = "local.file-path" - Force string = "force" - ImportID string = "import-id" - NoColor string = "no-color" - Output string = "output" - OutputShort string = "o" - Password string = "password" - ProjectID string = "project-id" - ProjectIDShort string = "p" - ProfileName string = "profile-name" - Profile string = "profile" - ProfileShort string = "P" - PublicKey string = "public-key" - PrivateKey string = "private-key" - Query string = "query" - QueryShort string = "q" - Region string = "region" - RegionShort string = "r" - LocalTargetDatabase string = "local.target-database" - LocalTargetTable string = "local.target-table" - User string = "user" - UserShort string = "u" - SpendingLimitMonthly string = "spending-limit-monthly" - ServerlessLabels string = "labels" - ServerlessAnnotations string = "annotations" - Monthly string = "monthly" - BackupID string = "backup-id" - BackupTime string = "backup-time" + ClusterID string = "cluster-id" + ClusterIDShort string = "c" + LocalConcurrency string = "local.concurrency" + CSVBackslashEscape string = "csv.backslash-escape" + CSVDelimiter string = "csv.delimiter" + CSVSeparator string = "csv.separator" + CSVTrimLastSeparator string = "csv.trim-last-separator" + CSVNullValue string = "csv.null-value" + CSVSkipHeader string = "csv.skip-header" + DisplayName string = "display-name" + DisplayNameShort string = "n" + ClusterType string = "cluster-type" + BranchID string = "branch-id" + BranchIDShort string = "b" + Debug string = "debug" + DebugShort string = "D" + LocalFilePath string = "local.file-path" + Force string = "force" + ImportID string = "import-id" + NoColor string = "no-color" + Output string = "output" + OutputShort string = "o" + Password string = "password" + ProjectID string = "project-id" + ProjectIDShort string = "p" + ProfileName string = "profile-name" + Profile string = "profile" + ProfileShort string = "P" + PublicKey string = "public-key" + PrivateKey string = "private-key" + Query string = "query" + QueryShort string = "q" + Region string = "region" + RegionShort string = "r" + LocalTargetDatabase string = "local.target-database" + LocalTargetTable string = "local.target-table" + User string = "user" + UserShort string = "u" + SpendingLimitMonthly string = "spending-limit-monthly" + ServerlessLabels string = "labels" + Monthly string = "monthly" + BackupID string = "backup-id" + BackupTime string = "backup-time" // External storage S3URI string = "s3.uri" S3AccessKeyID string = "s3.access-key-id" diff --git a/internal/mock/api_client.go b/internal/mock/api_client.go index 5e4d5086..baca05b2 100644 --- a/internal/mock/api_client.go +++ b/internal/mock/api_client.go @@ -6,6 +6,8 @@ import ( branch "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/branch" backup_restore_service "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service" + cluster "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" + context "context" export "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/export" @@ -17,8 +19,6 @@ import ( mock "github.com/stretchr/testify/mock" operations "tidbcloud-cli/pkg/tidbcloud/pingchat/client/operations" - - serverless_service "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" ) // TiDBCloudClient is an autogenerated mock type for the TiDBCloudClient type @@ -234,36 +234,29 @@ func (_m *TiDBCloudClient) CreateBranch(ctx context.Context, clusterId string, b return r0, r1 } -// CreateCluster provides a mock function with given fields: params, opts -func (_m *TiDBCloudClient) CreateCluster(params *serverless_service.ServerlessServiceCreateClusterParams, opts ...serverless_service.ClientOption) (*serverless_service.ServerlessServiceCreateClusterOK, 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...) +// CreateCluster provides a mock function with given fields: ctx, body +func (_m *TiDBCloudClient) CreateCluster(ctx context.Context, body *cluster.TidbCloudOpenApiserverlessv1beta1Cluster) (*cluster.TidbCloudOpenApiserverlessv1beta1Cluster, error) { + ret := _m.Called(ctx, body) if len(ret) == 0 { panic("no return value specified for CreateCluster") } - var r0 *serverless_service.ServerlessServiceCreateClusterOK + var r0 *cluster.TidbCloudOpenApiserverlessv1beta1Cluster var r1 error - if rf, ok := ret.Get(0).(func(*serverless_service.ServerlessServiceCreateClusterParams, ...serverless_service.ClientOption) (*serverless_service.ServerlessServiceCreateClusterOK, error)); ok { - return rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, *cluster.TidbCloudOpenApiserverlessv1beta1Cluster) (*cluster.TidbCloudOpenApiserverlessv1beta1Cluster, error)); ok { + return rf(ctx, body) } - if rf, ok := ret.Get(0).(func(*serverless_service.ServerlessServiceCreateClusterParams, ...serverless_service.ClientOption) *serverless_service.ServerlessServiceCreateClusterOK); ok { - r0 = rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, *cluster.TidbCloudOpenApiserverlessv1beta1Cluster) *cluster.TidbCloudOpenApiserverlessv1beta1Cluster); ok { + r0 = rf(ctx, body) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*serverless_service.ServerlessServiceCreateClusterOK) + r0 = ret.Get(0).(*cluster.TidbCloudOpenApiserverlessv1beta1Cluster) } } - if rf, ok := ret.Get(1).(func(*serverless_service.ServerlessServiceCreateClusterParams, ...serverless_service.ClientOption) error); ok { - r1 = rf(params, opts...) + if rf, ok := ret.Get(1).(func(context.Context, *cluster.TidbCloudOpenApiserverlessv1beta1Cluster) error); ok { + r1 = rf(ctx, body) } else { r1 = ret.Error(1) } @@ -435,36 +428,29 @@ func (_m *TiDBCloudClient) DeleteBranch(ctx context.Context, clusterId string, b return r0, r1 } -// DeleteCluster provides a mock function with given fields: params, opts -func (_m *TiDBCloudClient) DeleteCluster(params *serverless_service.ServerlessServiceDeleteClusterParams, opts ...serverless_service.ClientOption) (*serverless_service.ServerlessServiceDeleteClusterOK, 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...) +// DeleteCluster provides a mock function with given fields: ctx, clusterId +func (_m *TiDBCloudClient) DeleteCluster(ctx context.Context, clusterId string) (*cluster.TidbCloudOpenApiserverlessv1beta1Cluster, error) { + ret := _m.Called(ctx, clusterId) if len(ret) == 0 { panic("no return value specified for DeleteCluster") } - var r0 *serverless_service.ServerlessServiceDeleteClusterOK + var r0 *cluster.TidbCloudOpenApiserverlessv1beta1Cluster var r1 error - if rf, ok := ret.Get(0).(func(*serverless_service.ServerlessServiceDeleteClusterParams, ...serverless_service.ClientOption) (*serverless_service.ServerlessServiceDeleteClusterOK, error)); ok { - return rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, string) (*cluster.TidbCloudOpenApiserverlessv1beta1Cluster, error)); ok { + return rf(ctx, clusterId) } - if rf, ok := ret.Get(0).(func(*serverless_service.ServerlessServiceDeleteClusterParams, ...serverless_service.ClientOption) *serverless_service.ServerlessServiceDeleteClusterOK); ok { - r0 = rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, string) *cluster.TidbCloudOpenApiserverlessv1beta1Cluster); ok { + r0 = rf(ctx, clusterId) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*serverless_service.ServerlessServiceDeleteClusterOK) + r0 = ret.Get(0).(*cluster.TidbCloudOpenApiserverlessv1beta1Cluster) } } - if rf, ok := ret.Get(1).(func(*serverless_service.ServerlessServiceDeleteClusterParams, ...serverless_service.ClientOption) error); ok { - r1 = rf(params, opts...) + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, clusterId) } else { r1 = ret.Error(1) } @@ -629,36 +615,29 @@ func (_m *TiDBCloudClient) GetBranch(ctx context.Context, clusterId string, bran return r0, r1 } -// GetCluster provides a mock function with given fields: params, opts -func (_m *TiDBCloudClient) GetCluster(params *serverless_service.ServerlessServiceGetClusterParams, opts ...serverless_service.ClientOption) (*serverless_service.ServerlessServiceGetClusterOK, 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...) +// GetCluster provides a mock function with given fields: ctx, clusterId +func (_m *TiDBCloudClient) GetCluster(ctx context.Context, clusterId string) (*cluster.TidbCloudOpenApiserverlessv1beta1Cluster, error) { + ret := _m.Called(ctx, clusterId) if len(ret) == 0 { panic("no return value specified for GetCluster") } - var r0 *serverless_service.ServerlessServiceGetClusterOK + var r0 *cluster.TidbCloudOpenApiserverlessv1beta1Cluster var r1 error - if rf, ok := ret.Get(0).(func(*serverless_service.ServerlessServiceGetClusterParams, ...serverless_service.ClientOption) (*serverless_service.ServerlessServiceGetClusterOK, error)); ok { - return rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, string) (*cluster.TidbCloudOpenApiserverlessv1beta1Cluster, error)); ok { + return rf(ctx, clusterId) } - if rf, ok := ret.Get(0).(func(*serverless_service.ServerlessServiceGetClusterParams, ...serverless_service.ClientOption) *serverless_service.ServerlessServiceGetClusterOK); ok { - r0 = rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, string) *cluster.TidbCloudOpenApiserverlessv1beta1Cluster); ok { + r0 = rf(ctx, clusterId) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*serverless_service.ServerlessServiceGetClusterOK) + r0 = ret.Get(0).(*cluster.TidbCloudOpenApiserverlessv1beta1Cluster) } } - if rf, ok := ret.Get(1).(func(*serverless_service.ServerlessServiceGetClusterParams, ...serverless_service.ClientOption) error); ok { - r1 = rf(params, opts...) + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, clusterId) } else { r1 = ret.Error(1) } @@ -830,36 +809,29 @@ func (_m *TiDBCloudClient) ListBranches(ctx context.Context, clusterId string, p return r0, r1 } -// ListClustersOfProject provides a mock function with given fields: params, opts -func (_m *TiDBCloudClient) ListClustersOfProject(params *serverless_service.ServerlessServiceListClustersParams, opts ...serverless_service.ClientOption) (*serverless_service.ServerlessServiceListClustersOK, 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...) +// ListClusters provides a mock function with given fields: ctx, filter, pageSize, pageToken, orderBy, skip +func (_m *TiDBCloudClient) ListClusters(ctx context.Context, filter *string, pageSize *int32, pageToken *string, orderBy *string, skip *int32) (*cluster.TidbCloudOpenApiserverlessv1beta1ListClustersResponse, error) { + ret := _m.Called(ctx, filter, pageSize, pageToken, orderBy, skip) if len(ret) == 0 { - panic("no return value specified for ListClustersOfProject") + panic("no return value specified for ListClusters") } - var r0 *serverless_service.ServerlessServiceListClustersOK + var r0 *cluster.TidbCloudOpenApiserverlessv1beta1ListClustersResponse var r1 error - if rf, ok := ret.Get(0).(func(*serverless_service.ServerlessServiceListClustersParams, ...serverless_service.ClientOption) (*serverless_service.ServerlessServiceListClustersOK, error)); ok { - return rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, *string, *int32, *string, *string, *int32) (*cluster.TidbCloudOpenApiserverlessv1beta1ListClustersResponse, error)); ok { + return rf(ctx, filter, pageSize, pageToken, orderBy, skip) } - if rf, ok := ret.Get(0).(func(*serverless_service.ServerlessServiceListClustersParams, ...serverless_service.ClientOption) *serverless_service.ServerlessServiceListClustersOK); ok { - r0 = rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, *string, *int32, *string, *string, *int32) *cluster.TidbCloudOpenApiserverlessv1beta1ListClustersResponse); ok { + r0 = rf(ctx, filter, pageSize, pageToken, orderBy, skip) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*serverless_service.ServerlessServiceListClustersOK) + r0 = ret.Get(0).(*cluster.TidbCloudOpenApiserverlessv1beta1ListClustersResponse) } } - if rf, ok := ret.Get(1).(func(*serverless_service.ServerlessServiceListClustersParams, ...serverless_service.ClientOption) error); ok { - r1 = rf(params, opts...) + if rf, ok := ret.Get(1).(func(context.Context, *string, *int32, *string, *string, *int32) error); ok { + r1 = rf(ctx, filter, pageSize, pageToken, orderBy, skip) } else { r1 = ret.Error(1) } @@ -964,36 +936,29 @@ func (_m *TiDBCloudClient) ListProjects(ctx context.Context, pageSize *int32, pa return r0, r1 } -// ListProviderRegions provides a mock function with given fields: params, opts -func (_m *TiDBCloudClient) ListProviderRegions(params *serverless_service.ServerlessServiceListRegionsParams, opts ...serverless_service.ClientOption) (*serverless_service.ServerlessServiceListRegionsOK, 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...) +// ListProviderRegions provides a mock function with given fields: ctx +func (_m *TiDBCloudClient) ListProviderRegions(ctx context.Context) (*cluster.TidbCloudOpenApiserverlessv1beta1ListRegionsResponse, error) { + ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for ListProviderRegions") } - var r0 *serverless_service.ServerlessServiceListRegionsOK + var r0 *cluster.TidbCloudOpenApiserverlessv1beta1ListRegionsResponse var r1 error - if rf, ok := ret.Get(0).(func(*serverless_service.ServerlessServiceListRegionsParams, ...serverless_service.ClientOption) (*serverless_service.ServerlessServiceListRegionsOK, error)); ok { - return rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context) (*cluster.TidbCloudOpenApiserverlessv1beta1ListRegionsResponse, error)); ok { + return rf(ctx) } - if rf, ok := ret.Get(0).(func(*serverless_service.ServerlessServiceListRegionsParams, ...serverless_service.ClientOption) *serverless_service.ServerlessServiceListRegionsOK); ok { - r0 = rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context) *cluster.TidbCloudOpenApiserverlessv1beta1ListRegionsResponse); ok { + r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*serverless_service.ServerlessServiceListRegionsOK) + r0 = ret.Get(0).(*cluster.TidbCloudOpenApiserverlessv1beta1ListRegionsResponse) } } - if rf, ok := ret.Get(1).(func(*serverless_service.ServerlessServiceListRegionsParams, ...serverless_service.ClientOption) error); ok { - r1 = rf(params, opts...) + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) } else { r1 = ret.Error(1) } @@ -1031,36 +996,29 @@ func (_m *TiDBCloudClient) ListSQLUsers(ctx context.Context, clusterID string, p return r0, r1 } -// PartialUpdateCluster provides a mock function with given fields: params, opts -func (_m *TiDBCloudClient) PartialUpdateCluster(params *serverless_service.ServerlessServicePartialUpdateClusterParams, opts ...serverless_service.ClientOption) (*serverless_service.ServerlessServicePartialUpdateClusterOK, 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...) +// PartialUpdateCluster provides a mock function with given fields: ctx, clusterId, body +func (_m *TiDBCloudClient) PartialUpdateCluster(ctx context.Context, clusterId string, body *cluster.V1beta1ServerlessServicePartialUpdateClusterBody) (*cluster.TidbCloudOpenApiserverlessv1beta1Cluster, error) { + ret := _m.Called(ctx, clusterId, body) if len(ret) == 0 { panic("no return value specified for PartialUpdateCluster") } - var r0 *serverless_service.ServerlessServicePartialUpdateClusterOK + var r0 *cluster.TidbCloudOpenApiserverlessv1beta1Cluster var r1 error - if rf, ok := ret.Get(0).(func(*serverless_service.ServerlessServicePartialUpdateClusterParams, ...serverless_service.ClientOption) (*serverless_service.ServerlessServicePartialUpdateClusterOK, error)); ok { - return rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, string, *cluster.V1beta1ServerlessServicePartialUpdateClusterBody) (*cluster.TidbCloudOpenApiserverlessv1beta1Cluster, error)); ok { + return rf(ctx, clusterId, body) } - if rf, ok := ret.Get(0).(func(*serverless_service.ServerlessServicePartialUpdateClusterParams, ...serverless_service.ClientOption) *serverless_service.ServerlessServicePartialUpdateClusterOK); ok { - r0 = rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, string, *cluster.V1beta1ServerlessServicePartialUpdateClusterBody) *cluster.TidbCloudOpenApiserverlessv1beta1Cluster); ok { + r0 = rf(ctx, clusterId, body) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*serverless_service.ServerlessServicePartialUpdateClusterOK) + r0 = ret.Get(0).(*cluster.TidbCloudOpenApiserverlessv1beta1Cluster) } } - if rf, ok := ret.Get(1).(func(*serverless_service.ServerlessServicePartialUpdateClusterParams, ...serverless_service.ClientOption) error); ok { - r1 = rf(params, opts...) + if rf, ok := ret.Get(1).(func(context.Context, string, *cluster.V1beta1ServerlessServicePartialUpdateClusterBody) error); ok { + r1 = rf(ctx, clusterId, body) } else { r1 = ret.Error(1) } diff --git a/internal/service/cloud/api_client.go b/internal/service/cloud/api_client.go index 97bb9a6d..3fe57016 100644 --- a/internal/service/cloud/api_client.go +++ b/internal/service/cloud/api_client.go @@ -30,8 +30,7 @@ import ( pingchatOp "tidbcloud-cli/pkg/tidbcloud/pingchat/client/operations" "tidbcloud-cli/pkg/tidbcloud/v1beta1/iam" "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" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" "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" @@ -46,23 +45,23 @@ import ( const ( DefaultApiUrl = "https://" + apiClient.DefaultHost - DefaultServerlessEndpoint = "https://" + serverlessClient.DefaultHost + DefaultServerlessEndpoint = "https://serverless.tidbapi.com" DefaultIAMEndpoint = "https://iam.tidbapi.com" userAgent = "User-Agent" ) type TiDBCloudClient interface { - CreateCluster(params *serverlessOp.ServerlessServiceCreateClusterParams, opts ...serverlessOp.ClientOption) (*serverlessOp.ServerlessServiceCreateClusterOK, error) + CreateCluster(ctx context.Context, body *cluster.TidbCloudOpenApiserverlessv1beta1Cluster) (*cluster.TidbCloudOpenApiserverlessv1beta1Cluster, error) - DeleteCluster(params *serverlessOp.ServerlessServiceDeleteClusterParams, opts ...serverlessOp.ClientOption) (*serverlessOp.ServerlessServiceDeleteClusterOK, error) + DeleteCluster(ctx context.Context, clusterId string) (*cluster.TidbCloudOpenApiserverlessv1beta1Cluster, error) - GetCluster(params *serverlessOp.ServerlessServiceGetClusterParams, opts ...serverlessOp.ClientOption) (*serverlessOp.ServerlessServiceGetClusterOK, error) + GetCluster(ctx context.Context, clusterId string) (*cluster.TidbCloudOpenApiserverlessv1beta1Cluster, error) - ListClustersOfProject(params *serverlessOp.ServerlessServiceListClustersParams, opts ...serverlessOp.ClientOption) (*serverlessOp.ServerlessServiceListClustersOK, error) + ListClusters(ctx context.Context, filter *string, pageSize *int32, pageToken *string, orderBy *string, skip *int32) (*cluster.TidbCloudOpenApiserverlessv1beta1ListClustersResponse, error) - PartialUpdateCluster(params *serverlessOp.ServerlessServicePartialUpdateClusterParams, opts ...serverlessOp.ClientOption) (*serverlessOp.ServerlessServicePartialUpdateClusterOK, error) + PartialUpdateCluster(ctx context.Context, clusterId string, body *cluster.V1beta1ServerlessServicePartialUpdateClusterBody) (*cluster.TidbCloudOpenApiserverlessv1beta1Cluster, error) - ListProviderRegions(params *serverlessOp.ServerlessServiceListRegionsParams, opts ...serverlessOp.ClientOption) (*serverlessOp.ServerlessServiceListRegionsOK, error) + ListProviderRegions(ctx context.Context) (*cluster.TidbCloudOpenApiserverlessv1beta1ListRegionsResponse, error) ListProjects(ctx context.Context, pageSize *int32, pageToken *string) (*iam.ApiListProjectsRsp, error) @@ -125,7 +124,7 @@ type ClientDelegate struct { ic *iam.APIClient bc *branch.APIClient pc *pingchatClient.TidbcloudPingchat - sc *serverlessClient.TidbcloudServerless + sc *cluster.APIClient brc *brClient.TidbcloudServerless sic *serverlessImportClient.TidbcloudServerless ec *export.APIClient @@ -165,28 +164,58 @@ func NewClientDelegateWithApiKey(publicKey string, privateKey string, apiUrl str }, nil } -func (d *ClientDelegate) CreateCluster(params *serverlessOp.ServerlessServiceCreateClusterParams, opts ...serverlessOp.ClientOption) (*serverlessOp.ServerlessServiceCreateClusterOK, error) { - return d.sc.ServerlessService.ServerlessServiceCreateCluster(params, opts...) +func (d *ClientDelegate) CreateCluster(ctx context.Context, body *cluster.TidbCloudOpenApiserverlessv1beta1Cluster) (*cluster.TidbCloudOpenApiserverlessv1beta1Cluster, error) { + r := d.sc.ServerlessServiceAPI.ServerlessServiceCreateCluster(ctx) + if body != nil { + r = r.Cluster(*body) + } + c, h, err := r.Execute() + return c, parseError(err, h) } -func (d *ClientDelegate) DeleteCluster(params *serverlessOp.ServerlessServiceDeleteClusterParams, opts ...serverlessOp.ClientOption) (*serverlessOp.ServerlessServiceDeleteClusterOK, error) { - return d.sc.ServerlessService.ServerlessServiceDeleteCluster(params, opts...) +func (d *ClientDelegate) DeleteCluster(ctx context.Context, clusterId string) (*cluster.TidbCloudOpenApiserverlessv1beta1Cluster, error) { + c, h, err := d.sc.ServerlessServiceAPI.ServerlessServiceDeleteCluster(ctx, clusterId).Execute() + return c, parseError(err, h) } -func (d *ClientDelegate) GetCluster(params *serverlessOp.ServerlessServiceGetClusterParams, opts ...serverlessOp.ClientOption) (*serverlessOp.ServerlessServiceGetClusterOK, error) { - return d.sc.ServerlessService.ServerlessServiceGetCluster(params, opts...) +func (d *ClientDelegate) GetCluster(ctx context.Context, clusterId string) (*cluster.TidbCloudOpenApiserverlessv1beta1Cluster, error) { + c, h, err := d.sc.ServerlessServiceAPI.ServerlessServiceGetCluster(ctx, clusterId).Execute() + return c, parseError(err, h) } -func (d *ClientDelegate) ListProviderRegions(params *serverlessOp.ServerlessServiceListRegionsParams, opts ...serverlessOp.ClientOption) (*serverlessOp.ServerlessServiceListRegionsOK, error) { - return d.sc.ServerlessService.ServerlessServiceListRegions(params, opts...) +func (d *ClientDelegate) ListProviderRegions(ctx context.Context) (*cluster.TidbCloudOpenApiserverlessv1beta1ListRegionsResponse, error) { + resp, h, err := d.sc.ServerlessServiceAPI.ServerlessServiceListRegions(ctx).Execute() + return resp, parseError(err, h) } -func (d *ClientDelegate) ListClustersOfProject(params *serverlessOp.ServerlessServiceListClustersParams, opts ...serverlessOp.ClientOption) (*serverlessOp.ServerlessServiceListClustersOK, error) { - return d.sc.ServerlessService.ServerlessServiceListClusters(params, opts...) +func (d *ClientDelegate) ListClusters(ctx context.Context, filter *string, pageSize *int32, pageToken *string, orderBy *string, skip *int32) (*cluster.TidbCloudOpenApiserverlessv1beta1ListClustersResponse, error) { + r := d.sc.ServerlessServiceAPI.ServerlessServiceListClusters(ctx) + if filter != nil { + r = r.Filter(*filter) + } + if pageSize != nil { + r = r.PageSize(*pageSize) + } + if pageToken != nil { + r = r.PageToken(*pageToken) + } + if orderBy != nil { + r = r.OrderBy(*orderBy) + } + if skip != nil { + r = r.Skip(*skip) + } + resp, h, err := r.Execute() + return resp, parseError(err, h) } -func (d *ClientDelegate) PartialUpdateCluster(params *serverlessOp.ServerlessServicePartialUpdateClusterParams, opts ...serverlessOp.ClientOption) (*serverlessOp.ServerlessServicePartialUpdateClusterOK, error) { - return d.sc.ServerlessService.ServerlessServicePartialUpdateCluster(params, opts...) +func (d *ClientDelegate) PartialUpdateCluster(ctx context.Context, clusterId string, body *cluster.V1beta1ServerlessServicePartialUpdateClusterBody) (*cluster.TidbCloudOpenApiserverlessv1beta1Cluster, error) { + r := d.sc.ServerlessServiceAPI.ServerlessServicePartialUpdateCluster(ctx, clusterId) + if body != nil { + r = r.Body(*body) + } + c, h, err := r.Execute() + return c, parseError(err, h) } func (d *ClientDelegate) ListProjects(ctx context.Context, pageSize *int32, pageToken *string) (*iam.ApiListProjectsRsp, error) { @@ -368,7 +397,7 @@ func (d *ClientDelegate) UpdateSQLUser(ctx context.Context, clusterID string, us return res, parseError(err, h) } -func NewApiClient(rt http.RoundTripper, apiUrl string, serverlessEndpoint string, iamEndpoint string) (*branch.APIClient, *serverlessClient.TidbcloudServerless, *pingchatClient.TidbcloudPingchat, *brClient.TidbcloudServerless, *serverlessImportClient.TidbcloudServerless, *export.APIClient, *iam.APIClient, error) { +func NewApiClient(rt http.RoundTripper, apiUrl string, serverlessEndpoint string, iamEndpoint string) (*branch.APIClient, *cluster.APIClient, *pingchatClient.TidbcloudPingchat, *brClient.TidbcloudServerless, *serverlessImportClient.TidbcloudServerless, *export.APIClient, *iam.APIClient, error) { httpclient := &http.Client{ Transport: rt, } @@ -386,7 +415,6 @@ 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) backRestoreTransport := httpTransport.NewWithClient(serverlessURL.Host, brClient.DefaultBasePath, []string{serverlessURL.Scheme}, httpclient) importTransport := httpTransport.NewWithClient(serverlessURL.Host, serverlessImportClient.DefaultBasePath, []string{serverlessURL.Scheme}, httpclient) @@ -398,6 +426,10 @@ func NewApiClient(rt http.RoundTripper, apiUrl string, serverlessEndpoint string } iamCfg.Host = iamURL.Host + clusterCfg := cluster.NewConfiguration() + clusterCfg.HTTPClient = httpclient + clusterCfg.Host = serverlessURL.Host + branchCfg := branch.NewConfiguration() branchCfg.HTTPClient = httpclient branchCfg.Host = serverlessURL.Host @@ -406,7 +438,7 @@ func NewApiClient(rt http.RoundTripper, apiUrl string, serverlessEndpoint string exportCfg.HTTPClient = httpclient exportCfg.Host = serverlessURL.Host - return branch.NewAPIClient(branchCfg), serverlessClient.New(serverlessTransport, strfmt.Default), + return branch.NewAPIClient(branchCfg), cluster.NewAPIClient(clusterCfg), pingchatClient.New(transport, strfmt.Default), brClient.New(backRestoreTransport, strfmt.Default), serverlessImportClient.New(importTransport, strfmt.Default), export.NewAPIClient(exportCfg), iam.NewAPIClient(iamCfg), nil diff --git a/internal/service/cloud/logic.go b/internal/service/cloud/logic.go index eedff243..3903f312 100644 --- a/internal/service/cloud/logic.go +++ b/internal/service/cloud/logic.go @@ -23,9 +23,8 @@ import ( "tidbcloud-cli/internal/util" "tidbcloud-cli/pkg/tidbcloud/v1beta1/iam" "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/branch" - serverlessApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/client/serverless_service" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/export" - serverlessModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models" brApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service" brModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/models" importApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_import/client/import_service" @@ -173,9 +172,9 @@ func GetSelectedCluster(ctx context.Context, projectID string, pageSize int64, c var items = make([]interface{}, 0, len(clusterItems)) for _, item := range clusterItems { items = append(items, &Cluster{ - ID: item.ClusterID, - DisplayName: *item.DisplayName, - UserPrefix: item.UserPrefix, + ID: *item.ClusterId, + DisplayName: item.DisplayName, + UserPrefix: *item.UserPrefix, }) } if len(items) == 0 { @@ -612,30 +611,31 @@ func RetrieveProjects(ctx context.Context, pageSize int64, d TiDBCloudClient) (i return int64(len(items)), items, nil } -func RetrieveClusters(ctx context.Context, pID string, pageSize int64, d TiDBCloudClient) (int64, []*serverlessModel.TidbCloudOpenApiserverlessv1beta1Cluster, error) { - params := serverlessApi.NewServerlessServiceListClustersParams().WithContext(ctx) +func RetrieveClusters(ctx context.Context, pID string, pageSize int64, d TiDBCloudClient) (int64, []cluster.TidbCloudOpenApiserverlessv1beta1Cluster, error) { + var items []cluster.TidbCloudOpenApiserverlessv1beta1Cluster + pageSizeInt32 := int32(pageSize) + var pageToken *string + var filter *string if pID != "" { projectFilter := fmt.Sprintf("projectId=%s", pID) - params.WithFilter(&projectFilter) + filter = &projectFilter } - pageSizeInt32 := int32(pageSize) - var pageToken string - var items []*serverlessModel.TidbCloudOpenApiserverlessv1beta1Cluster - clusters, err := d.ListClustersOfProject(params.WithPageSize(&pageSizeInt32)) + + clusters, err := d.ListClusters(ctx, filter, &pageSizeInt32, nil, nil, nil) if err != nil { return 0, nil, errors.Trace(err) } - items = append(items, clusters.Payload.Clusters...) + items = append(items, clusters.Clusters...) for { - pageToken = clusters.Payload.NextPageToken - if pageToken == "" { + pageToken = clusters.NextPageToken + if util.IsNilOrEmpty(pageToken) { break } - clusters, err = d.ListClustersOfProject(params.WithPageToken(&pageToken).WithPageSize(&pageSizeInt32)) + clusters, err = d.ListClusters(ctx, filter, &pageSizeInt32, pageToken, nil, nil) if err != nil { return 0, nil, errors.Trace(err) } - items = append(items, clusters.Payload.Clusters...) + items = append(items, clusters.Clusters...) } return int64(len(items)), items, nil } diff --git a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_change_root_password_parameters.go b/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_change_root_password_parameters.go deleted file mode 100644 index 31a063e0..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_change_root_password_parameters.go +++ /dev/null @@ -1,168 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package serverless_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" -) - -// NewServerlessServiceChangeRootPasswordParams creates a new ServerlessServiceChangeRootPasswordParams 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 NewServerlessServiceChangeRootPasswordParams() *ServerlessServiceChangeRootPasswordParams { - return &ServerlessServiceChangeRootPasswordParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewServerlessServiceChangeRootPasswordParamsWithTimeout creates a new ServerlessServiceChangeRootPasswordParams object -// with the ability to set a timeout on a request. -func NewServerlessServiceChangeRootPasswordParamsWithTimeout(timeout time.Duration) *ServerlessServiceChangeRootPasswordParams { - return &ServerlessServiceChangeRootPasswordParams{ - timeout: timeout, - } -} - -// NewServerlessServiceChangeRootPasswordParamsWithContext creates a new ServerlessServiceChangeRootPasswordParams object -// with the ability to set a context for a request. -func NewServerlessServiceChangeRootPasswordParamsWithContext(ctx context.Context) *ServerlessServiceChangeRootPasswordParams { - return &ServerlessServiceChangeRootPasswordParams{ - Context: ctx, - } -} - -// NewServerlessServiceChangeRootPasswordParamsWithHTTPClient creates a new ServerlessServiceChangeRootPasswordParams object -// with the ability to set a custom HTTPClient for a request. -func NewServerlessServiceChangeRootPasswordParamsWithHTTPClient(client *http.Client) *ServerlessServiceChangeRootPasswordParams { - return &ServerlessServiceChangeRootPasswordParams{ - HTTPClient: client, - } -} - -/* -ServerlessServiceChangeRootPasswordParams contains all the parameters to send to the API endpoint - - for the serverless service change root password operation. - - Typically these are written to a http.Request. -*/ -type ServerlessServiceChangeRootPasswordParams struct { - - // Body. - Body ServerlessServiceChangeRootPasswordBody - - /* ClusterID. - - Required. The ID of the cluster for which the password is to be changed. - */ - ClusterID string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the serverless service change root password params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ServerlessServiceChangeRootPasswordParams) WithDefaults() *ServerlessServiceChangeRootPasswordParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the serverless service change root password params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ServerlessServiceChangeRootPasswordParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the serverless service change root password params -func (o *ServerlessServiceChangeRootPasswordParams) WithTimeout(timeout time.Duration) *ServerlessServiceChangeRootPasswordParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the serverless service change root password params -func (o *ServerlessServiceChangeRootPasswordParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the serverless service change root password params -func (o *ServerlessServiceChangeRootPasswordParams) WithContext(ctx context.Context) *ServerlessServiceChangeRootPasswordParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the serverless service change root password params -func (o *ServerlessServiceChangeRootPasswordParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the serverless service change root password params -func (o *ServerlessServiceChangeRootPasswordParams) WithHTTPClient(client *http.Client) *ServerlessServiceChangeRootPasswordParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the serverless service change root password params -func (o *ServerlessServiceChangeRootPasswordParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithBody adds the body to the serverless service change root password params -func (o *ServerlessServiceChangeRootPasswordParams) WithBody(body ServerlessServiceChangeRootPasswordBody) *ServerlessServiceChangeRootPasswordParams { - o.SetBody(body) - return o -} - -// SetBody adds the body to the serverless service change root password params -func (o *ServerlessServiceChangeRootPasswordParams) SetBody(body ServerlessServiceChangeRootPasswordBody) { - o.Body = body -} - -// WithClusterID adds the clusterID to the serverless service change root password params -func (o *ServerlessServiceChangeRootPasswordParams) WithClusterID(clusterID string) *ServerlessServiceChangeRootPasswordParams { - o.SetClusterID(clusterID) - return o -} - -// SetClusterID adds the clusterId to the serverless service change root password params -func (o *ServerlessServiceChangeRootPasswordParams) SetClusterID(clusterID string) { - o.ClusterID = clusterID -} - -// WriteToRequest writes these params to a swagger request -func (o *ServerlessServiceChangeRootPasswordParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - if err := r.SetBodyParam(o.Body); 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/serverless/client/serverless_service/serverless_service_change_root_password_responses.go b/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_change_root_password_responses.go deleted file mode 100644 index 058325af..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_change_root_password_responses.go +++ /dev/null @@ -1,246 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package serverless_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" - "encoding/json" - "fmt" - "io" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models" -) - -// ServerlessServiceChangeRootPasswordReader is a Reader for the ServerlessServiceChangeRootPassword structure. -type ServerlessServiceChangeRootPasswordReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *ServerlessServiceChangeRootPasswordReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewServerlessServiceChangeRootPasswordOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - default: - result := NewServerlessServiceChangeRootPasswordDefault(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 - } -} - -// NewServerlessServiceChangeRootPasswordOK creates a ServerlessServiceChangeRootPasswordOK with default headers values -func NewServerlessServiceChangeRootPasswordOK() *ServerlessServiceChangeRootPasswordOK { - return &ServerlessServiceChangeRootPasswordOK{} -} - -/* -ServerlessServiceChangeRootPasswordOK describes a response with status code 200, with default header values. - -A successful response. -*/ -type ServerlessServiceChangeRootPasswordOK struct { - Payload models.V1beta1ChangeRootPasswordResponse -} - -// IsSuccess returns true when this serverless service change root password o k response has a 2xx status code -func (o *ServerlessServiceChangeRootPasswordOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this serverless service change root password o k response has a 3xx status code -func (o *ServerlessServiceChangeRootPasswordOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this serverless service change root password o k response has a 4xx status code -func (o *ServerlessServiceChangeRootPasswordOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this serverless service change root password o k response has a 5xx status code -func (o *ServerlessServiceChangeRootPasswordOK) IsServerError() bool { - return false -} - -// IsCode returns true when this serverless service change root password o k response a status code equal to that given -func (o *ServerlessServiceChangeRootPasswordOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the serverless service change root password o k response -func (o *ServerlessServiceChangeRootPasswordOK) Code() int { - return 200 -} - -func (o *ServerlessServiceChangeRootPasswordOK) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[PUT /clusters/{clusterId}/password][%d] serverlessServiceChangeRootPasswordOK %s", 200, payload) -} - -func (o *ServerlessServiceChangeRootPasswordOK) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[PUT /clusters/{clusterId}/password][%d] serverlessServiceChangeRootPasswordOK %s", 200, payload) -} - -func (o *ServerlessServiceChangeRootPasswordOK) GetPayload() models.V1beta1ChangeRootPasswordResponse { - return o.Payload -} - -func (o *ServerlessServiceChangeRootPasswordOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewServerlessServiceChangeRootPasswordDefault creates a ServerlessServiceChangeRootPasswordDefault with default headers values -func NewServerlessServiceChangeRootPasswordDefault(code int) *ServerlessServiceChangeRootPasswordDefault { - return &ServerlessServiceChangeRootPasswordDefault{ - _statusCode: code, - } -} - -/* -ServerlessServiceChangeRootPasswordDefault describes a response with status code -1, with default header values. - -An unexpected error response. -*/ -type ServerlessServiceChangeRootPasswordDefault struct { - _statusCode int - - Payload *models.GooglerpcStatus -} - -// IsSuccess returns true when this serverless service change root password default response has a 2xx status code -func (o *ServerlessServiceChangeRootPasswordDefault) IsSuccess() bool { - return o._statusCode/100 == 2 -} - -// IsRedirect returns true when this serverless service change root password default response has a 3xx status code -func (o *ServerlessServiceChangeRootPasswordDefault) IsRedirect() bool { - return o._statusCode/100 == 3 -} - -// IsClientError returns true when this serverless service change root password default response has a 4xx status code -func (o *ServerlessServiceChangeRootPasswordDefault) IsClientError() bool { - return o._statusCode/100 == 4 -} - -// IsServerError returns true when this serverless service change root password default response has a 5xx status code -func (o *ServerlessServiceChangeRootPasswordDefault) IsServerError() bool { - return o._statusCode/100 == 5 -} - -// IsCode returns true when this serverless service change root password default response a status code equal to that given -func (o *ServerlessServiceChangeRootPasswordDefault) IsCode(code int) bool { - return o._statusCode == code -} - -// Code gets the status code for the serverless service change root password default response -func (o *ServerlessServiceChangeRootPasswordDefault) Code() int { - return o._statusCode -} - -func (o *ServerlessServiceChangeRootPasswordDefault) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[PUT /clusters/{clusterId}/password][%d] ServerlessService_ChangeRootPassword default %s", o._statusCode, payload) -} - -func (o *ServerlessServiceChangeRootPasswordDefault) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[PUT /clusters/{clusterId}/password][%d] ServerlessService_ChangeRootPassword default %s", o._statusCode, payload) -} - -func (o *ServerlessServiceChangeRootPasswordDefault) GetPayload() *models.GooglerpcStatus { - return o.Payload -} - -func (o *ServerlessServiceChangeRootPasswordDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.GooglerpcStatus) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -/* -ServerlessServiceChangeRootPasswordBody Message for requesting to change the root password of a TiDB Serverless cluster. -swagger:model ServerlessServiceChangeRootPasswordBody -*/ -type ServerlessServiceChangeRootPasswordBody struct { - - // Required. The new root password for the cluster. - // Required: true - Password *string `json:"password"` -} - -// Validate validates this serverless service change root password body -func (o *ServerlessServiceChangeRootPasswordBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validatePassword(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *ServerlessServiceChangeRootPasswordBody) validatePassword(formats strfmt.Registry) error { - - if err := validate.Required("body"+"."+"password", "body", o.Password); err != nil { - return err - } - - return nil -} - -// ContextValidate validates this serverless service change root password body based on context it is used -func (o *ServerlessServiceChangeRootPasswordBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (o *ServerlessServiceChangeRootPasswordBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *ServerlessServiceChangeRootPasswordBody) UnmarshalBinary(b []byte) error { - var res ServerlessServiceChangeRootPasswordBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_client.go b/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_client.go deleted file mode 100644 index 81afe043..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_client.go +++ /dev/null @@ -1,336 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package serverless_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 serverless service API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { - return &Client{transport: transport, formats: formats} -} - -// New creates a new serverless 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 serverless 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 serverless 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 { - ServerlessServiceChangeRootPassword(params *ServerlessServiceChangeRootPasswordParams, opts ...ClientOption) (*ServerlessServiceChangeRootPasswordOK, error) - - ServerlessServiceCreateCluster(params *ServerlessServiceCreateClusterParams, opts ...ClientOption) (*ServerlessServiceCreateClusterOK, error) - - ServerlessServiceDeleteCluster(params *ServerlessServiceDeleteClusterParams, opts ...ClientOption) (*ServerlessServiceDeleteClusterOK, error) - - ServerlessServiceGetCluster(params *ServerlessServiceGetClusterParams, opts ...ClientOption) (*ServerlessServiceGetClusterOK, error) - - ServerlessServiceListClusters(params *ServerlessServiceListClustersParams, opts ...ClientOption) (*ServerlessServiceListClustersOK, error) - - ServerlessServiceListRegions(params *ServerlessServiceListRegionsParams, opts ...ClientOption) (*ServerlessServiceListRegionsOK, error) - - ServerlessServicePartialUpdateCluster(params *ServerlessServicePartialUpdateClusterParams, opts ...ClientOption) (*ServerlessServicePartialUpdateClusterOK, error) - - SetTransport(transport runtime.ClientTransport) -} - -/* -ServerlessServiceChangeRootPassword changes the root password of a specific ti d b serverless cluster -*/ -func (a *Client) ServerlessServiceChangeRootPassword(params *ServerlessServiceChangeRootPasswordParams, opts ...ClientOption) (*ServerlessServiceChangeRootPasswordOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewServerlessServiceChangeRootPasswordParams() - } - op := &runtime.ClientOperation{ - ID: "ServerlessService_ChangeRootPassword", - Method: "PUT", - PathPattern: "/clusters/{clusterId}/password", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &ServerlessServiceChangeRootPasswordReader{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.(*ServerlessServiceChangeRootPasswordOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*ServerlessServiceChangeRootPasswordDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) -} - -/* -ServerlessServiceCreateCluster creates a new ti d b serverless cluster -*/ -func (a *Client) ServerlessServiceCreateCluster(params *ServerlessServiceCreateClusterParams, opts ...ClientOption) (*ServerlessServiceCreateClusterOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewServerlessServiceCreateClusterParams() - } - op := &runtime.ClientOperation{ - ID: "ServerlessService_CreateCluster", - Method: "POST", - PathPattern: "/clusters", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &ServerlessServiceCreateClusterReader{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.(*ServerlessServiceCreateClusterOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*ServerlessServiceCreateClusterDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) -} - -/* -ServerlessServiceDeleteCluster deletes a specific ti d b serverless cluster -*/ -func (a *Client) ServerlessServiceDeleteCluster(params *ServerlessServiceDeleteClusterParams, opts ...ClientOption) (*ServerlessServiceDeleteClusterOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewServerlessServiceDeleteClusterParams() - } - op := &runtime.ClientOperation{ - ID: "ServerlessService_DeleteCluster", - Method: "DELETE", - PathPattern: "/clusters/{clusterId}", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &ServerlessServiceDeleteClusterReader{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.(*ServerlessServiceDeleteClusterOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*ServerlessServiceDeleteClusterDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) -} - -/* -ServerlessServiceGetCluster retrieves details of a specific ti d b serverless cluster -*/ -func (a *Client) ServerlessServiceGetCluster(params *ServerlessServiceGetClusterParams, opts ...ClientOption) (*ServerlessServiceGetClusterOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewServerlessServiceGetClusterParams() - } - op := &runtime.ClientOperation{ - ID: "ServerlessService_GetCluster", - Method: "GET", - PathPattern: "/clusters/{clusterId}", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &ServerlessServiceGetClusterReader{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.(*ServerlessServiceGetClusterOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*ServerlessServiceGetClusterDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) -} - -/* -ServerlessServiceListClusters provides a list of ti d b serverless clusters in a project -*/ -func (a *Client) ServerlessServiceListClusters(params *ServerlessServiceListClustersParams, opts ...ClientOption) (*ServerlessServiceListClustersOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewServerlessServiceListClustersParams() - } - op := &runtime.ClientOperation{ - ID: "ServerlessService_ListClusters", - Method: "GET", - PathPattern: "/clusters", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &ServerlessServiceListClustersReader{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.(*ServerlessServiceListClustersOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*ServerlessServiceListClustersDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) -} - -/* -ServerlessServiceListRegions provides a list of available regions for ti d b serverless clusters -*/ -func (a *Client) ServerlessServiceListRegions(params *ServerlessServiceListRegionsParams, opts ...ClientOption) (*ServerlessServiceListRegionsOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewServerlessServiceListRegionsParams() - } - op := &runtime.ClientOperation{ - ID: "ServerlessService_ListRegions", - Method: "GET", - PathPattern: "/regions", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &ServerlessServiceListRegionsReader{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.(*ServerlessServiceListRegionsOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*ServerlessServiceListRegionsDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) -} - -/* -ServerlessServicePartialUpdateCluster partiallies updates a specific ti d b serverless cluster -*/ -func (a *Client) ServerlessServicePartialUpdateCluster(params *ServerlessServicePartialUpdateClusterParams, opts ...ClientOption) (*ServerlessServicePartialUpdateClusterOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewServerlessServicePartialUpdateClusterParams() - } - op := &runtime.ClientOperation{ - ID: "ServerlessService_PartialUpdateCluster", - Method: "PATCH", - PathPattern: "/clusters/{cluster.clusterId}", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &ServerlessServicePartialUpdateClusterReader{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.(*ServerlessServicePartialUpdateClusterOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*ServerlessServicePartialUpdateClusterDefault) - 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/serverless/client/serverless_service/serverless_service_create_cluster_parameters.go b/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_create_cluster_parameters.go deleted file mode 100644 index 12c60eff..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_create_cluster_parameters.go +++ /dev/null @@ -1,153 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package serverless_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/serverless/models" -) - -// NewServerlessServiceCreateClusterParams creates a new ServerlessServiceCreateClusterParams 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 NewServerlessServiceCreateClusterParams() *ServerlessServiceCreateClusterParams { - return &ServerlessServiceCreateClusterParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewServerlessServiceCreateClusterParamsWithTimeout creates a new ServerlessServiceCreateClusterParams object -// with the ability to set a timeout on a request. -func NewServerlessServiceCreateClusterParamsWithTimeout(timeout time.Duration) *ServerlessServiceCreateClusterParams { - return &ServerlessServiceCreateClusterParams{ - timeout: timeout, - } -} - -// NewServerlessServiceCreateClusterParamsWithContext creates a new ServerlessServiceCreateClusterParams object -// with the ability to set a context for a request. -func NewServerlessServiceCreateClusterParamsWithContext(ctx context.Context) *ServerlessServiceCreateClusterParams { - return &ServerlessServiceCreateClusterParams{ - Context: ctx, - } -} - -// NewServerlessServiceCreateClusterParamsWithHTTPClient creates a new ServerlessServiceCreateClusterParams object -// with the ability to set a custom HTTPClient for a request. -func NewServerlessServiceCreateClusterParamsWithHTTPClient(client *http.Client) *ServerlessServiceCreateClusterParams { - return &ServerlessServiceCreateClusterParams{ - HTTPClient: client, - } -} - -/* -ServerlessServiceCreateClusterParams contains all the parameters to send to the API endpoint - - for the serverless service create cluster operation. - - Typically these are written to a http.Request. -*/ -type ServerlessServiceCreateClusterParams struct { - - /* Cluster. - - Required. The cluster to be created. - */ - Cluster *models.TidbCloudOpenApiserverlessv1beta1Cluster - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the serverless service create cluster params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ServerlessServiceCreateClusterParams) WithDefaults() *ServerlessServiceCreateClusterParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the serverless service create cluster params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ServerlessServiceCreateClusterParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the serverless service create cluster params -func (o *ServerlessServiceCreateClusterParams) WithTimeout(timeout time.Duration) *ServerlessServiceCreateClusterParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the serverless service create cluster params -func (o *ServerlessServiceCreateClusterParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the serverless service create cluster params -func (o *ServerlessServiceCreateClusterParams) WithContext(ctx context.Context) *ServerlessServiceCreateClusterParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the serverless service create cluster params -func (o *ServerlessServiceCreateClusterParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the serverless service create cluster params -func (o *ServerlessServiceCreateClusterParams) WithHTTPClient(client *http.Client) *ServerlessServiceCreateClusterParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the serverless service create cluster params -func (o *ServerlessServiceCreateClusterParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithCluster adds the cluster to the serverless service create cluster params -func (o *ServerlessServiceCreateClusterParams) WithCluster(cluster *models.TidbCloudOpenApiserverlessv1beta1Cluster) *ServerlessServiceCreateClusterParams { - o.SetCluster(cluster) - return o -} - -// SetCluster adds the cluster to the serverless service create cluster params -func (o *ServerlessServiceCreateClusterParams) SetCluster(cluster *models.TidbCloudOpenApiserverlessv1beta1Cluster) { - o.Cluster = cluster -} - -// WriteToRequest writes these params to a swagger request -func (o *ServerlessServiceCreateClusterParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - if o.Cluster != nil { - if err := r.SetBodyParam(o.Cluster); err != nil { - return err - } - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_create_cluster_responses.go b/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_create_cluster_responses.go deleted file mode 100644 index e5c65947..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_create_cluster_responses.go +++ /dev/null @@ -1,187 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package serverless_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/serverless/models" -) - -// ServerlessServiceCreateClusterReader is a Reader for the ServerlessServiceCreateCluster structure. -type ServerlessServiceCreateClusterReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *ServerlessServiceCreateClusterReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewServerlessServiceCreateClusterOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - default: - result := NewServerlessServiceCreateClusterDefault(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 - } -} - -// NewServerlessServiceCreateClusterOK creates a ServerlessServiceCreateClusterOK with default headers values -func NewServerlessServiceCreateClusterOK() *ServerlessServiceCreateClusterOK { - return &ServerlessServiceCreateClusterOK{} -} - -/* -ServerlessServiceCreateClusterOK describes a response with status code 200, with default header values. - -A successful response. -*/ -type ServerlessServiceCreateClusterOK struct { - Payload *models.TidbCloudOpenApiserverlessv1beta1Cluster -} - -// IsSuccess returns true when this serverless service create cluster o k response has a 2xx status code -func (o *ServerlessServiceCreateClusterOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this serverless service create cluster o k response has a 3xx status code -func (o *ServerlessServiceCreateClusterOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this serverless service create cluster o k response has a 4xx status code -func (o *ServerlessServiceCreateClusterOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this serverless service create cluster o k response has a 5xx status code -func (o *ServerlessServiceCreateClusterOK) IsServerError() bool { - return false -} - -// IsCode returns true when this serverless service create cluster o k response a status code equal to that given -func (o *ServerlessServiceCreateClusterOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the serverless service create cluster o k response -func (o *ServerlessServiceCreateClusterOK) Code() int { - return 200 -} - -func (o *ServerlessServiceCreateClusterOK) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[POST /clusters][%d] serverlessServiceCreateClusterOK %s", 200, payload) -} - -func (o *ServerlessServiceCreateClusterOK) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[POST /clusters][%d] serverlessServiceCreateClusterOK %s", 200, payload) -} - -func (o *ServerlessServiceCreateClusterOK) GetPayload() *models.TidbCloudOpenApiserverlessv1beta1Cluster { - return o.Payload -} - -func (o *ServerlessServiceCreateClusterOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.TidbCloudOpenApiserverlessv1beta1Cluster) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewServerlessServiceCreateClusterDefault creates a ServerlessServiceCreateClusterDefault with default headers values -func NewServerlessServiceCreateClusterDefault(code int) *ServerlessServiceCreateClusterDefault { - return &ServerlessServiceCreateClusterDefault{ - _statusCode: code, - } -} - -/* -ServerlessServiceCreateClusterDefault describes a response with status code -1, with default header values. - -An unexpected error response. -*/ -type ServerlessServiceCreateClusterDefault struct { - _statusCode int - - Payload *models.GooglerpcStatus -} - -// IsSuccess returns true when this serverless service create cluster default response has a 2xx status code -func (o *ServerlessServiceCreateClusterDefault) IsSuccess() bool { - return o._statusCode/100 == 2 -} - -// IsRedirect returns true when this serverless service create cluster default response has a 3xx status code -func (o *ServerlessServiceCreateClusterDefault) IsRedirect() bool { - return o._statusCode/100 == 3 -} - -// IsClientError returns true when this serverless service create cluster default response has a 4xx status code -func (o *ServerlessServiceCreateClusterDefault) IsClientError() bool { - return o._statusCode/100 == 4 -} - -// IsServerError returns true when this serverless service create cluster default response has a 5xx status code -func (o *ServerlessServiceCreateClusterDefault) IsServerError() bool { - return o._statusCode/100 == 5 -} - -// IsCode returns true when this serverless service create cluster default response a status code equal to that given -func (o *ServerlessServiceCreateClusterDefault) IsCode(code int) bool { - return o._statusCode == code -} - -// Code gets the status code for the serverless service create cluster default response -func (o *ServerlessServiceCreateClusterDefault) Code() int { - return o._statusCode -} - -func (o *ServerlessServiceCreateClusterDefault) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[POST /clusters][%d] ServerlessService_CreateCluster default %s", o._statusCode, payload) -} - -func (o *ServerlessServiceCreateClusterDefault) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[POST /clusters][%d] ServerlessService_CreateCluster default %s", o._statusCode, payload) -} - -func (o *ServerlessServiceCreateClusterDefault) GetPayload() *models.GooglerpcStatus { - return o.Payload -} - -func (o *ServerlessServiceCreateClusterDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.GooglerpcStatus) - - // 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/serverless/client/serverless_service/serverless_service_delete_cluster_parameters.go b/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_delete_cluster_parameters.go deleted file mode 100644 index a892c52e..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_delete_cluster_parameters.go +++ /dev/null @@ -1,151 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package serverless_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" -) - -// NewServerlessServiceDeleteClusterParams creates a new ServerlessServiceDeleteClusterParams 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 NewServerlessServiceDeleteClusterParams() *ServerlessServiceDeleteClusterParams { - return &ServerlessServiceDeleteClusterParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewServerlessServiceDeleteClusterParamsWithTimeout creates a new ServerlessServiceDeleteClusterParams object -// with the ability to set a timeout on a request. -func NewServerlessServiceDeleteClusterParamsWithTimeout(timeout time.Duration) *ServerlessServiceDeleteClusterParams { - return &ServerlessServiceDeleteClusterParams{ - timeout: timeout, - } -} - -// NewServerlessServiceDeleteClusterParamsWithContext creates a new ServerlessServiceDeleteClusterParams object -// with the ability to set a context for a request. -func NewServerlessServiceDeleteClusterParamsWithContext(ctx context.Context) *ServerlessServiceDeleteClusterParams { - return &ServerlessServiceDeleteClusterParams{ - Context: ctx, - } -} - -// NewServerlessServiceDeleteClusterParamsWithHTTPClient creates a new ServerlessServiceDeleteClusterParams object -// with the ability to set a custom HTTPClient for a request. -func NewServerlessServiceDeleteClusterParamsWithHTTPClient(client *http.Client) *ServerlessServiceDeleteClusterParams { - return &ServerlessServiceDeleteClusterParams{ - HTTPClient: client, - } -} - -/* -ServerlessServiceDeleteClusterParams contains all the parameters to send to the API endpoint - - for the serverless service delete cluster operation. - - Typically these are written to a http.Request. -*/ -type ServerlessServiceDeleteClusterParams struct { - - /* ClusterID. - - Required. The ID of the cluster to be deleted. - */ - ClusterID string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the serverless service delete cluster params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ServerlessServiceDeleteClusterParams) WithDefaults() *ServerlessServiceDeleteClusterParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the serverless service delete cluster params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ServerlessServiceDeleteClusterParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the serverless service delete cluster params -func (o *ServerlessServiceDeleteClusterParams) WithTimeout(timeout time.Duration) *ServerlessServiceDeleteClusterParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the serverless service delete cluster params -func (o *ServerlessServiceDeleteClusterParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the serverless service delete cluster params -func (o *ServerlessServiceDeleteClusterParams) WithContext(ctx context.Context) *ServerlessServiceDeleteClusterParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the serverless service delete cluster params -func (o *ServerlessServiceDeleteClusterParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the serverless service delete cluster params -func (o *ServerlessServiceDeleteClusterParams) WithHTTPClient(client *http.Client) *ServerlessServiceDeleteClusterParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the serverless service delete cluster params -func (o *ServerlessServiceDeleteClusterParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithClusterID adds the clusterID to the serverless service delete cluster params -func (o *ServerlessServiceDeleteClusterParams) WithClusterID(clusterID string) *ServerlessServiceDeleteClusterParams { - o.SetClusterID(clusterID) - return o -} - -// SetClusterID adds the clusterId to the serverless service delete cluster params -func (o *ServerlessServiceDeleteClusterParams) SetClusterID(clusterID string) { - o.ClusterID = clusterID -} - -// WriteToRequest writes these params to a swagger request -func (o *ServerlessServiceDeleteClusterParams) 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 len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_delete_cluster_responses.go b/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_delete_cluster_responses.go deleted file mode 100644 index e9cd9f1f..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_delete_cluster_responses.go +++ /dev/null @@ -1,187 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package serverless_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/serverless/models" -) - -// ServerlessServiceDeleteClusterReader is a Reader for the ServerlessServiceDeleteCluster structure. -type ServerlessServiceDeleteClusterReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *ServerlessServiceDeleteClusterReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewServerlessServiceDeleteClusterOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - default: - result := NewServerlessServiceDeleteClusterDefault(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 - } -} - -// NewServerlessServiceDeleteClusterOK creates a ServerlessServiceDeleteClusterOK with default headers values -func NewServerlessServiceDeleteClusterOK() *ServerlessServiceDeleteClusterOK { - return &ServerlessServiceDeleteClusterOK{} -} - -/* -ServerlessServiceDeleteClusterOK describes a response with status code 200, with default header values. - -A successful response. -*/ -type ServerlessServiceDeleteClusterOK struct { - Payload *models.TidbCloudOpenApiserverlessv1beta1Cluster -} - -// IsSuccess returns true when this serverless service delete cluster o k response has a 2xx status code -func (o *ServerlessServiceDeleteClusterOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this serverless service delete cluster o k response has a 3xx status code -func (o *ServerlessServiceDeleteClusterOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this serverless service delete cluster o k response has a 4xx status code -func (o *ServerlessServiceDeleteClusterOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this serverless service delete cluster o k response has a 5xx status code -func (o *ServerlessServiceDeleteClusterOK) IsServerError() bool { - return false -} - -// IsCode returns true when this serverless service delete cluster o k response a status code equal to that given -func (o *ServerlessServiceDeleteClusterOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the serverless service delete cluster o k response -func (o *ServerlessServiceDeleteClusterOK) Code() int { - return 200 -} - -func (o *ServerlessServiceDeleteClusterOK) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[DELETE /clusters/{clusterId}][%d] serverlessServiceDeleteClusterOK %s", 200, payload) -} - -func (o *ServerlessServiceDeleteClusterOK) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[DELETE /clusters/{clusterId}][%d] serverlessServiceDeleteClusterOK %s", 200, payload) -} - -func (o *ServerlessServiceDeleteClusterOK) GetPayload() *models.TidbCloudOpenApiserverlessv1beta1Cluster { - return o.Payload -} - -func (o *ServerlessServiceDeleteClusterOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.TidbCloudOpenApiserverlessv1beta1Cluster) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewServerlessServiceDeleteClusterDefault creates a ServerlessServiceDeleteClusterDefault with default headers values -func NewServerlessServiceDeleteClusterDefault(code int) *ServerlessServiceDeleteClusterDefault { - return &ServerlessServiceDeleteClusterDefault{ - _statusCode: code, - } -} - -/* -ServerlessServiceDeleteClusterDefault describes a response with status code -1, with default header values. - -An unexpected error response. -*/ -type ServerlessServiceDeleteClusterDefault struct { - _statusCode int - - Payload *models.GooglerpcStatus -} - -// IsSuccess returns true when this serverless service delete cluster default response has a 2xx status code -func (o *ServerlessServiceDeleteClusterDefault) IsSuccess() bool { - return o._statusCode/100 == 2 -} - -// IsRedirect returns true when this serverless service delete cluster default response has a 3xx status code -func (o *ServerlessServiceDeleteClusterDefault) IsRedirect() bool { - return o._statusCode/100 == 3 -} - -// IsClientError returns true when this serverless service delete cluster default response has a 4xx status code -func (o *ServerlessServiceDeleteClusterDefault) IsClientError() bool { - return o._statusCode/100 == 4 -} - -// IsServerError returns true when this serverless service delete cluster default response has a 5xx status code -func (o *ServerlessServiceDeleteClusterDefault) IsServerError() bool { - return o._statusCode/100 == 5 -} - -// IsCode returns true when this serverless service delete cluster default response a status code equal to that given -func (o *ServerlessServiceDeleteClusterDefault) IsCode(code int) bool { - return o._statusCode == code -} - -// Code gets the status code for the serverless service delete cluster default response -func (o *ServerlessServiceDeleteClusterDefault) Code() int { - return o._statusCode -} - -func (o *ServerlessServiceDeleteClusterDefault) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[DELETE /clusters/{clusterId}][%d] ServerlessService_DeleteCluster default %s", o._statusCode, payload) -} - -func (o *ServerlessServiceDeleteClusterDefault) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[DELETE /clusters/{clusterId}][%d] ServerlessService_DeleteCluster default %s", o._statusCode, payload) -} - -func (o *ServerlessServiceDeleteClusterDefault) GetPayload() *models.GooglerpcStatus { - return o.Payload -} - -func (o *ServerlessServiceDeleteClusterDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.GooglerpcStatus) - - // 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/serverless/client/serverless_service/serverless_service_get_cluster_parameters.go b/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_get_cluster_parameters.go deleted file mode 100644 index 33117048..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_get_cluster_parameters.go +++ /dev/null @@ -1,202 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package serverless_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" -) - -// NewServerlessServiceGetClusterParams creates a new ServerlessServiceGetClusterParams 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 NewServerlessServiceGetClusterParams() *ServerlessServiceGetClusterParams { - return &ServerlessServiceGetClusterParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewServerlessServiceGetClusterParamsWithTimeout creates a new ServerlessServiceGetClusterParams object -// with the ability to set a timeout on a request. -func NewServerlessServiceGetClusterParamsWithTimeout(timeout time.Duration) *ServerlessServiceGetClusterParams { - return &ServerlessServiceGetClusterParams{ - timeout: timeout, - } -} - -// NewServerlessServiceGetClusterParamsWithContext creates a new ServerlessServiceGetClusterParams object -// with the ability to set a context for a request. -func NewServerlessServiceGetClusterParamsWithContext(ctx context.Context) *ServerlessServiceGetClusterParams { - return &ServerlessServiceGetClusterParams{ - Context: ctx, - } -} - -// NewServerlessServiceGetClusterParamsWithHTTPClient creates a new ServerlessServiceGetClusterParams object -// with the ability to set a custom HTTPClient for a request. -func NewServerlessServiceGetClusterParamsWithHTTPClient(client *http.Client) *ServerlessServiceGetClusterParams { - return &ServerlessServiceGetClusterParams{ - HTTPClient: client, - } -} - -/* -ServerlessServiceGetClusterParams contains all the parameters to send to the API endpoint - - for the serverless service get cluster operation. - - Typically these are written to a http.Request. -*/ -type ServerlessServiceGetClusterParams struct { - - /* ClusterID. - - Required. The ID of the cluster to be retrieved. - */ - ClusterID string - - /* View. - - Optional. The level of detail to return for the cluster. - - - CLUSTER_VIEW_UNSPECIFIED: The server default is used if unspecified. - - BASIC: Only basic information about the cluster is returned. - - FULL: All details about the cluster are returned. - - Default: "CLUSTER_VIEW_UNSPECIFIED" - */ - View *string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the serverless service get cluster params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ServerlessServiceGetClusterParams) WithDefaults() *ServerlessServiceGetClusterParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the serverless service get cluster params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ServerlessServiceGetClusterParams) SetDefaults() { - var ( - viewDefault = string("CLUSTER_VIEW_UNSPECIFIED") - ) - - val := ServerlessServiceGetClusterParams{ - View: &viewDefault, - } - - val.timeout = o.timeout - val.Context = o.Context - val.HTTPClient = o.HTTPClient - *o = val -} - -// WithTimeout adds the timeout to the serverless service get cluster params -func (o *ServerlessServiceGetClusterParams) WithTimeout(timeout time.Duration) *ServerlessServiceGetClusterParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the serverless service get cluster params -func (o *ServerlessServiceGetClusterParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the serverless service get cluster params -func (o *ServerlessServiceGetClusterParams) WithContext(ctx context.Context) *ServerlessServiceGetClusterParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the serverless service get cluster params -func (o *ServerlessServiceGetClusterParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the serverless service get cluster params -func (o *ServerlessServiceGetClusterParams) WithHTTPClient(client *http.Client) *ServerlessServiceGetClusterParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the serverless service get cluster params -func (o *ServerlessServiceGetClusterParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithClusterID adds the clusterID to the serverless service get cluster params -func (o *ServerlessServiceGetClusterParams) WithClusterID(clusterID string) *ServerlessServiceGetClusterParams { - o.SetClusterID(clusterID) - return o -} - -// SetClusterID adds the clusterId to the serverless service get cluster params -func (o *ServerlessServiceGetClusterParams) SetClusterID(clusterID string) { - o.ClusterID = clusterID -} - -// WithView adds the view to the serverless service get cluster params -func (o *ServerlessServiceGetClusterParams) WithView(view *string) *ServerlessServiceGetClusterParams { - o.SetView(view) - return o -} - -// SetView adds the view to the serverless service get cluster params -func (o *ServerlessServiceGetClusterParams) SetView(view *string) { - o.View = view -} - -// WriteToRequest writes these params to a swagger request -func (o *ServerlessServiceGetClusterParams) 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.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/serverless/client/serverless_service/serverless_service_get_cluster_responses.go b/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_get_cluster_responses.go deleted file mode 100644 index 44be7d36..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_get_cluster_responses.go +++ /dev/null @@ -1,187 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package serverless_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/serverless/models" -) - -// ServerlessServiceGetClusterReader is a Reader for the ServerlessServiceGetCluster structure. -type ServerlessServiceGetClusterReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *ServerlessServiceGetClusterReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewServerlessServiceGetClusterOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - default: - result := NewServerlessServiceGetClusterDefault(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 - } -} - -// NewServerlessServiceGetClusterOK creates a ServerlessServiceGetClusterOK with default headers values -func NewServerlessServiceGetClusterOK() *ServerlessServiceGetClusterOK { - return &ServerlessServiceGetClusterOK{} -} - -/* -ServerlessServiceGetClusterOK describes a response with status code 200, with default header values. - -A successful response. -*/ -type ServerlessServiceGetClusterOK struct { - Payload *models.TidbCloudOpenApiserverlessv1beta1Cluster -} - -// IsSuccess returns true when this serverless service get cluster o k response has a 2xx status code -func (o *ServerlessServiceGetClusterOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this serverless service get cluster o k response has a 3xx status code -func (o *ServerlessServiceGetClusterOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this serverless service get cluster o k response has a 4xx status code -func (o *ServerlessServiceGetClusterOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this serverless service get cluster o k response has a 5xx status code -func (o *ServerlessServiceGetClusterOK) IsServerError() bool { - return false -} - -// IsCode returns true when this serverless service get cluster o k response a status code equal to that given -func (o *ServerlessServiceGetClusterOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the serverless service get cluster o k response -func (o *ServerlessServiceGetClusterOK) Code() int { - return 200 -} - -func (o *ServerlessServiceGetClusterOK) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /clusters/{clusterId}][%d] serverlessServiceGetClusterOK %s", 200, payload) -} - -func (o *ServerlessServiceGetClusterOK) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /clusters/{clusterId}][%d] serverlessServiceGetClusterOK %s", 200, payload) -} - -func (o *ServerlessServiceGetClusterOK) GetPayload() *models.TidbCloudOpenApiserverlessv1beta1Cluster { - return o.Payload -} - -func (o *ServerlessServiceGetClusterOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.TidbCloudOpenApiserverlessv1beta1Cluster) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewServerlessServiceGetClusterDefault creates a ServerlessServiceGetClusterDefault with default headers values -func NewServerlessServiceGetClusterDefault(code int) *ServerlessServiceGetClusterDefault { - return &ServerlessServiceGetClusterDefault{ - _statusCode: code, - } -} - -/* -ServerlessServiceGetClusterDefault describes a response with status code -1, with default header values. - -An unexpected error response. -*/ -type ServerlessServiceGetClusterDefault struct { - _statusCode int - - Payload *models.GooglerpcStatus -} - -// IsSuccess returns true when this serverless service get cluster default response has a 2xx status code -func (o *ServerlessServiceGetClusterDefault) IsSuccess() bool { - return o._statusCode/100 == 2 -} - -// IsRedirect returns true when this serverless service get cluster default response has a 3xx status code -func (o *ServerlessServiceGetClusterDefault) IsRedirect() bool { - return o._statusCode/100 == 3 -} - -// IsClientError returns true when this serverless service get cluster default response has a 4xx status code -func (o *ServerlessServiceGetClusterDefault) IsClientError() bool { - return o._statusCode/100 == 4 -} - -// IsServerError returns true when this serverless service get cluster default response has a 5xx status code -func (o *ServerlessServiceGetClusterDefault) IsServerError() bool { - return o._statusCode/100 == 5 -} - -// IsCode returns true when this serverless service get cluster default response a status code equal to that given -func (o *ServerlessServiceGetClusterDefault) IsCode(code int) bool { - return o._statusCode == code -} - -// Code gets the status code for the serverless service get cluster default response -func (o *ServerlessServiceGetClusterDefault) Code() int { - return o._statusCode -} - -func (o *ServerlessServiceGetClusterDefault) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /clusters/{clusterId}][%d] ServerlessService_GetCluster default %s", o._statusCode, payload) -} - -func (o *ServerlessServiceGetClusterDefault) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /clusters/{clusterId}][%d] ServerlessService_GetCluster default %s", o._statusCode, payload) -} - -func (o *ServerlessServiceGetClusterDefault) GetPayload() *models.GooglerpcStatus { - return o.Payload -} - -func (o *ServerlessServiceGetClusterDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.GooglerpcStatus) - - // 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/serverless/client/serverless_service/serverless_service_list_clusters_parameters.go b/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_list_clusters_parameters.go deleted file mode 100644 index 8e88b7f1..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_list_clusters_parameters.go +++ /dev/null @@ -1,268 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package serverless_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" -) - -// NewServerlessServiceListClustersParams creates a new ServerlessServiceListClustersParams 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 NewServerlessServiceListClustersParams() *ServerlessServiceListClustersParams { - return &ServerlessServiceListClustersParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewServerlessServiceListClustersParamsWithTimeout creates a new ServerlessServiceListClustersParams object -// with the ability to set a timeout on a request. -func NewServerlessServiceListClustersParamsWithTimeout(timeout time.Duration) *ServerlessServiceListClustersParams { - return &ServerlessServiceListClustersParams{ - timeout: timeout, - } -} - -// NewServerlessServiceListClustersParamsWithContext creates a new ServerlessServiceListClustersParams object -// with the ability to set a context for a request. -func NewServerlessServiceListClustersParamsWithContext(ctx context.Context) *ServerlessServiceListClustersParams { - return &ServerlessServiceListClustersParams{ - Context: ctx, - } -} - -// NewServerlessServiceListClustersParamsWithHTTPClient creates a new ServerlessServiceListClustersParams object -// with the ability to set a custom HTTPClient for a request. -func NewServerlessServiceListClustersParamsWithHTTPClient(client *http.Client) *ServerlessServiceListClustersParams { - return &ServerlessServiceListClustersParams{ - HTTPClient: client, - } -} - -/* -ServerlessServiceListClustersParams contains all the parameters to send to the API endpoint - - for the serverless service list clusters operation. - - Typically these are written to a http.Request. -*/ -type ServerlessServiceListClustersParams struct { - - /* Filter. - - Optional. The filter expression to filter clusters. - */ - Filter *string - - /* OrderBy. - - Optional. The order by expression for sorting clusters. - */ - OrderBy *string - - /* PageSize. - - Optional. The maximum number of clusters to return. - - Format: int32 - */ - PageSize *int32 - - /* PageToken. - - Optional. The page token from the previous response for pagination. - */ - PageToken *string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the serverless service list clusters params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ServerlessServiceListClustersParams) WithDefaults() *ServerlessServiceListClustersParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the serverless service list clusters params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ServerlessServiceListClustersParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the serverless service list clusters params -func (o *ServerlessServiceListClustersParams) WithTimeout(timeout time.Duration) *ServerlessServiceListClustersParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the serverless service list clusters params -func (o *ServerlessServiceListClustersParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the serverless service list clusters params -func (o *ServerlessServiceListClustersParams) WithContext(ctx context.Context) *ServerlessServiceListClustersParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the serverless service list clusters params -func (o *ServerlessServiceListClustersParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the serverless service list clusters params -func (o *ServerlessServiceListClustersParams) WithHTTPClient(client *http.Client) *ServerlessServiceListClustersParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the serverless service list clusters params -func (o *ServerlessServiceListClustersParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithFilter adds the filter to the serverless service list clusters params -func (o *ServerlessServiceListClustersParams) WithFilter(filter *string) *ServerlessServiceListClustersParams { - o.SetFilter(filter) - return o -} - -// SetFilter adds the filter to the serverless service list clusters params -func (o *ServerlessServiceListClustersParams) SetFilter(filter *string) { - o.Filter = filter -} - -// WithOrderBy adds the orderBy to the serverless service list clusters params -func (o *ServerlessServiceListClustersParams) WithOrderBy(orderBy *string) *ServerlessServiceListClustersParams { - o.SetOrderBy(orderBy) - return o -} - -// SetOrderBy adds the orderBy to the serverless service list clusters params -func (o *ServerlessServiceListClustersParams) SetOrderBy(orderBy *string) { - o.OrderBy = orderBy -} - -// WithPageSize adds the pageSize to the serverless service list clusters params -func (o *ServerlessServiceListClustersParams) WithPageSize(pageSize *int32) *ServerlessServiceListClustersParams { - o.SetPageSize(pageSize) - return o -} - -// SetPageSize adds the pageSize to the serverless service list clusters params -func (o *ServerlessServiceListClustersParams) SetPageSize(pageSize *int32) { - o.PageSize = pageSize -} - -// WithPageToken adds the pageToken to the serverless service list clusters params -func (o *ServerlessServiceListClustersParams) WithPageToken(pageToken *string) *ServerlessServiceListClustersParams { - o.SetPageToken(pageToken) - return o -} - -// SetPageToken adds the pageToken to the serverless service list clusters params -func (o *ServerlessServiceListClustersParams) SetPageToken(pageToken *string) { - o.PageToken = pageToken -} - -// WriteToRequest writes these params to a swagger request -func (o *ServerlessServiceListClustersParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - if o.Filter != nil { - - // query param filter - var qrFilter string - - if o.Filter != nil { - qrFilter = *o.Filter - } - qFilter := qrFilter - if qFilter != "" { - - if err := r.SetQueryParam("filter", qFilter); err != nil { - return err - } - } - } - - if o.OrderBy != nil { - - // query param orderBy - var qrOrderBy string - - if o.OrderBy != nil { - qrOrderBy = *o.OrderBy - } - qOrderBy := qrOrderBy - if qOrderBy != "" { - - if err := r.SetQueryParam("orderBy", qOrderBy); 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/serverless/client/serverless_service/serverless_service_list_clusters_responses.go b/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_list_clusters_responses.go deleted file mode 100644 index 2ce58cb1..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_list_clusters_responses.go +++ /dev/null @@ -1,187 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package serverless_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/serverless/models" -) - -// ServerlessServiceListClustersReader is a Reader for the ServerlessServiceListClusters structure. -type ServerlessServiceListClustersReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *ServerlessServiceListClustersReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewServerlessServiceListClustersOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - default: - result := NewServerlessServiceListClustersDefault(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 - } -} - -// NewServerlessServiceListClustersOK creates a ServerlessServiceListClustersOK with default headers values -func NewServerlessServiceListClustersOK() *ServerlessServiceListClustersOK { - return &ServerlessServiceListClustersOK{} -} - -/* -ServerlessServiceListClustersOK describes a response with status code 200, with default header values. - -A successful response. -*/ -type ServerlessServiceListClustersOK struct { - Payload *models.TidbCloudOpenApiserverlessv1beta1ListClustersResponse -} - -// IsSuccess returns true when this serverless service list clusters o k response has a 2xx status code -func (o *ServerlessServiceListClustersOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this serverless service list clusters o k response has a 3xx status code -func (o *ServerlessServiceListClustersOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this serverless service list clusters o k response has a 4xx status code -func (o *ServerlessServiceListClustersOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this serverless service list clusters o k response has a 5xx status code -func (o *ServerlessServiceListClustersOK) IsServerError() bool { - return false -} - -// IsCode returns true when this serverless service list clusters o k response a status code equal to that given -func (o *ServerlessServiceListClustersOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the serverless service list clusters o k response -func (o *ServerlessServiceListClustersOK) Code() int { - return 200 -} - -func (o *ServerlessServiceListClustersOK) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /clusters][%d] serverlessServiceListClustersOK %s", 200, payload) -} - -func (o *ServerlessServiceListClustersOK) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /clusters][%d] serverlessServiceListClustersOK %s", 200, payload) -} - -func (o *ServerlessServiceListClustersOK) GetPayload() *models.TidbCloudOpenApiserverlessv1beta1ListClustersResponse { - return o.Payload -} - -func (o *ServerlessServiceListClustersOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.TidbCloudOpenApiserverlessv1beta1ListClustersResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewServerlessServiceListClustersDefault creates a ServerlessServiceListClustersDefault with default headers values -func NewServerlessServiceListClustersDefault(code int) *ServerlessServiceListClustersDefault { - return &ServerlessServiceListClustersDefault{ - _statusCode: code, - } -} - -/* -ServerlessServiceListClustersDefault describes a response with status code -1, with default header values. - -An unexpected error response. -*/ -type ServerlessServiceListClustersDefault struct { - _statusCode int - - Payload *models.GooglerpcStatus -} - -// IsSuccess returns true when this serverless service list clusters default response has a 2xx status code -func (o *ServerlessServiceListClustersDefault) IsSuccess() bool { - return o._statusCode/100 == 2 -} - -// IsRedirect returns true when this serverless service list clusters default response has a 3xx status code -func (o *ServerlessServiceListClustersDefault) IsRedirect() bool { - return o._statusCode/100 == 3 -} - -// IsClientError returns true when this serverless service list clusters default response has a 4xx status code -func (o *ServerlessServiceListClustersDefault) IsClientError() bool { - return o._statusCode/100 == 4 -} - -// IsServerError returns true when this serverless service list clusters default response has a 5xx status code -func (o *ServerlessServiceListClustersDefault) IsServerError() bool { - return o._statusCode/100 == 5 -} - -// IsCode returns true when this serverless service list clusters default response a status code equal to that given -func (o *ServerlessServiceListClustersDefault) IsCode(code int) bool { - return o._statusCode == code -} - -// Code gets the status code for the serverless service list clusters default response -func (o *ServerlessServiceListClustersDefault) Code() int { - return o._statusCode -} - -func (o *ServerlessServiceListClustersDefault) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /clusters][%d] ServerlessService_ListClusters default %s", o._statusCode, payload) -} - -func (o *ServerlessServiceListClustersDefault) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /clusters][%d] ServerlessService_ListClusters default %s", o._statusCode, payload) -} - -func (o *ServerlessServiceListClustersDefault) GetPayload() *models.GooglerpcStatus { - return o.Payload -} - -func (o *ServerlessServiceListClustersDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.GooglerpcStatus) - - // 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/serverless/client/serverless_service/serverless_service_list_regions_parameters.go b/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_list_regions_parameters.go deleted file mode 100644 index 542591bd..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_list_regions_parameters.go +++ /dev/null @@ -1,128 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package serverless_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" -) - -// NewServerlessServiceListRegionsParams creates a new ServerlessServiceListRegionsParams 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 NewServerlessServiceListRegionsParams() *ServerlessServiceListRegionsParams { - return &ServerlessServiceListRegionsParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewServerlessServiceListRegionsParamsWithTimeout creates a new ServerlessServiceListRegionsParams object -// with the ability to set a timeout on a request. -func NewServerlessServiceListRegionsParamsWithTimeout(timeout time.Duration) *ServerlessServiceListRegionsParams { - return &ServerlessServiceListRegionsParams{ - timeout: timeout, - } -} - -// NewServerlessServiceListRegionsParamsWithContext creates a new ServerlessServiceListRegionsParams object -// with the ability to set a context for a request. -func NewServerlessServiceListRegionsParamsWithContext(ctx context.Context) *ServerlessServiceListRegionsParams { - return &ServerlessServiceListRegionsParams{ - Context: ctx, - } -} - -// NewServerlessServiceListRegionsParamsWithHTTPClient creates a new ServerlessServiceListRegionsParams object -// with the ability to set a custom HTTPClient for a request. -func NewServerlessServiceListRegionsParamsWithHTTPClient(client *http.Client) *ServerlessServiceListRegionsParams { - return &ServerlessServiceListRegionsParams{ - HTTPClient: client, - } -} - -/* -ServerlessServiceListRegionsParams contains all the parameters to send to the API endpoint - - for the serverless service list regions operation. - - Typically these are written to a http.Request. -*/ -type ServerlessServiceListRegionsParams struct { - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the serverless service list regions params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ServerlessServiceListRegionsParams) WithDefaults() *ServerlessServiceListRegionsParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the serverless service list regions params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ServerlessServiceListRegionsParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the serverless service list regions params -func (o *ServerlessServiceListRegionsParams) WithTimeout(timeout time.Duration) *ServerlessServiceListRegionsParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the serverless service list regions params -func (o *ServerlessServiceListRegionsParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the serverless service list regions params -func (o *ServerlessServiceListRegionsParams) WithContext(ctx context.Context) *ServerlessServiceListRegionsParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the serverless service list regions params -func (o *ServerlessServiceListRegionsParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the serverless service list regions params -func (o *ServerlessServiceListRegionsParams) WithHTTPClient(client *http.Client) *ServerlessServiceListRegionsParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the serverless service list regions params -func (o *ServerlessServiceListRegionsParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WriteToRequest writes these params to a swagger request -func (o *ServerlessServiceListRegionsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_list_regions_responses.go b/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_list_regions_responses.go deleted file mode 100644 index 3f8ae4d4..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_list_regions_responses.go +++ /dev/null @@ -1,187 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package serverless_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/serverless/models" -) - -// ServerlessServiceListRegionsReader is a Reader for the ServerlessServiceListRegions structure. -type ServerlessServiceListRegionsReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *ServerlessServiceListRegionsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewServerlessServiceListRegionsOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - default: - result := NewServerlessServiceListRegionsDefault(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 - } -} - -// NewServerlessServiceListRegionsOK creates a ServerlessServiceListRegionsOK with default headers values -func NewServerlessServiceListRegionsOK() *ServerlessServiceListRegionsOK { - return &ServerlessServiceListRegionsOK{} -} - -/* -ServerlessServiceListRegionsOK describes a response with status code 200, with default header values. - -A successful response. -*/ -type ServerlessServiceListRegionsOK struct { - Payload *models.TidbCloudOpenApiserverlessv1beta1ListRegionsResponse -} - -// IsSuccess returns true when this serverless service list regions o k response has a 2xx status code -func (o *ServerlessServiceListRegionsOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this serverless service list regions o k response has a 3xx status code -func (o *ServerlessServiceListRegionsOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this serverless service list regions o k response has a 4xx status code -func (o *ServerlessServiceListRegionsOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this serverless service list regions o k response has a 5xx status code -func (o *ServerlessServiceListRegionsOK) IsServerError() bool { - return false -} - -// IsCode returns true when this serverless service list regions o k response a status code equal to that given -func (o *ServerlessServiceListRegionsOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the serverless service list regions o k response -func (o *ServerlessServiceListRegionsOK) Code() int { - return 200 -} - -func (o *ServerlessServiceListRegionsOK) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /regions][%d] serverlessServiceListRegionsOK %s", 200, payload) -} - -func (o *ServerlessServiceListRegionsOK) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /regions][%d] serverlessServiceListRegionsOK %s", 200, payload) -} - -func (o *ServerlessServiceListRegionsOK) GetPayload() *models.TidbCloudOpenApiserverlessv1beta1ListRegionsResponse { - return o.Payload -} - -func (o *ServerlessServiceListRegionsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.TidbCloudOpenApiserverlessv1beta1ListRegionsResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewServerlessServiceListRegionsDefault creates a ServerlessServiceListRegionsDefault with default headers values -func NewServerlessServiceListRegionsDefault(code int) *ServerlessServiceListRegionsDefault { - return &ServerlessServiceListRegionsDefault{ - _statusCode: code, - } -} - -/* -ServerlessServiceListRegionsDefault describes a response with status code -1, with default header values. - -An unexpected error response. -*/ -type ServerlessServiceListRegionsDefault struct { - _statusCode int - - Payload *models.GooglerpcStatus -} - -// IsSuccess returns true when this serverless service list regions default response has a 2xx status code -func (o *ServerlessServiceListRegionsDefault) IsSuccess() bool { - return o._statusCode/100 == 2 -} - -// IsRedirect returns true when this serverless service list regions default response has a 3xx status code -func (o *ServerlessServiceListRegionsDefault) IsRedirect() bool { - return o._statusCode/100 == 3 -} - -// IsClientError returns true when this serverless service list regions default response has a 4xx status code -func (o *ServerlessServiceListRegionsDefault) IsClientError() bool { - return o._statusCode/100 == 4 -} - -// IsServerError returns true when this serverless service list regions default response has a 5xx status code -func (o *ServerlessServiceListRegionsDefault) IsServerError() bool { - return o._statusCode/100 == 5 -} - -// IsCode returns true when this serverless service list regions default response a status code equal to that given -func (o *ServerlessServiceListRegionsDefault) IsCode(code int) bool { - return o._statusCode == code -} - -// Code gets the status code for the serverless service list regions default response -func (o *ServerlessServiceListRegionsDefault) Code() int { - return o._statusCode -} - -func (o *ServerlessServiceListRegionsDefault) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /regions][%d] ServerlessService_ListRegions default %s", o._statusCode, payload) -} - -func (o *ServerlessServiceListRegionsDefault) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /regions][%d] ServerlessService_ListRegions default %s", o._statusCode, payload) -} - -func (o *ServerlessServiceListRegionsDefault) GetPayload() *models.GooglerpcStatus { - return o.Payload -} - -func (o *ServerlessServiceListRegionsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.GooglerpcStatus) - - // 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/serverless/client/serverless_service/serverless_service_partial_update_cluster_parameters.go b/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_partial_update_cluster_parameters.go deleted file mode 100644 index 0976a17c..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_partial_update_cluster_parameters.go +++ /dev/null @@ -1,168 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package serverless_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" -) - -// NewServerlessServicePartialUpdateClusterParams creates a new ServerlessServicePartialUpdateClusterParams 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 NewServerlessServicePartialUpdateClusterParams() *ServerlessServicePartialUpdateClusterParams { - return &ServerlessServicePartialUpdateClusterParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewServerlessServicePartialUpdateClusterParamsWithTimeout creates a new ServerlessServicePartialUpdateClusterParams object -// with the ability to set a timeout on a request. -func NewServerlessServicePartialUpdateClusterParamsWithTimeout(timeout time.Duration) *ServerlessServicePartialUpdateClusterParams { - return &ServerlessServicePartialUpdateClusterParams{ - timeout: timeout, - } -} - -// NewServerlessServicePartialUpdateClusterParamsWithContext creates a new ServerlessServicePartialUpdateClusterParams object -// with the ability to set a context for a request. -func NewServerlessServicePartialUpdateClusterParamsWithContext(ctx context.Context) *ServerlessServicePartialUpdateClusterParams { - return &ServerlessServicePartialUpdateClusterParams{ - Context: ctx, - } -} - -// NewServerlessServicePartialUpdateClusterParamsWithHTTPClient creates a new ServerlessServicePartialUpdateClusterParams object -// with the ability to set a custom HTTPClient for a request. -func NewServerlessServicePartialUpdateClusterParamsWithHTTPClient(client *http.Client) *ServerlessServicePartialUpdateClusterParams { - return &ServerlessServicePartialUpdateClusterParams{ - HTTPClient: client, - } -} - -/* -ServerlessServicePartialUpdateClusterParams contains all the parameters to send to the API endpoint - - for the serverless service partial update cluster operation. - - Typically these are written to a http.Request. -*/ -type ServerlessServicePartialUpdateClusterParams struct { - - // Body. - Body ServerlessServicePartialUpdateClusterBody - - /* ClusterClusterID. - - Output_only. The unique ID of the cluster. - */ - ClusterClusterID string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the serverless service partial update cluster params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ServerlessServicePartialUpdateClusterParams) WithDefaults() *ServerlessServicePartialUpdateClusterParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the serverless service partial update cluster params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ServerlessServicePartialUpdateClusterParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the serverless service partial update cluster params -func (o *ServerlessServicePartialUpdateClusterParams) WithTimeout(timeout time.Duration) *ServerlessServicePartialUpdateClusterParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the serverless service partial update cluster params -func (o *ServerlessServicePartialUpdateClusterParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the serverless service partial update cluster params -func (o *ServerlessServicePartialUpdateClusterParams) WithContext(ctx context.Context) *ServerlessServicePartialUpdateClusterParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the serverless service partial update cluster params -func (o *ServerlessServicePartialUpdateClusterParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the serverless service partial update cluster params -func (o *ServerlessServicePartialUpdateClusterParams) WithHTTPClient(client *http.Client) *ServerlessServicePartialUpdateClusterParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the serverless service partial update cluster params -func (o *ServerlessServicePartialUpdateClusterParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithBody adds the body to the serverless service partial update cluster params -func (o *ServerlessServicePartialUpdateClusterParams) WithBody(body ServerlessServicePartialUpdateClusterBody) *ServerlessServicePartialUpdateClusterParams { - o.SetBody(body) - return o -} - -// SetBody adds the body to the serverless service partial update cluster params -func (o *ServerlessServicePartialUpdateClusterParams) SetBody(body ServerlessServicePartialUpdateClusterBody) { - o.Body = body -} - -// WithClusterClusterID adds the clusterClusterID to the serverless service partial update cluster params -func (o *ServerlessServicePartialUpdateClusterParams) WithClusterClusterID(clusterClusterID string) *ServerlessServicePartialUpdateClusterParams { - o.SetClusterClusterID(clusterClusterID) - return o -} - -// SetClusterClusterID adds the clusterClusterId to the serverless service partial update cluster params -func (o *ServerlessServicePartialUpdateClusterParams) SetClusterClusterID(clusterClusterID string) { - o.ClusterClusterID = clusterClusterID -} - -// WriteToRequest writes these params to a swagger request -func (o *ServerlessServicePartialUpdateClusterParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - if err := r.SetBodyParam(o.Body); err != nil { - return err - } - - // path param cluster.clusterId - if err := r.SetPathParam("cluster.clusterId", o.ClusterClusterID); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_partial_update_cluster_responses.go b/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_partial_update_cluster_responses.go deleted file mode 100644 index 60efd9af..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/client/serverless_service/serverless_service_partial_update_cluster_responses.go +++ /dev/null @@ -1,859 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package serverless_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" - "encoding/json" - "fmt" - "io" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/models" -) - -// ServerlessServicePartialUpdateClusterReader is a Reader for the ServerlessServicePartialUpdateCluster structure. -type ServerlessServicePartialUpdateClusterReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *ServerlessServicePartialUpdateClusterReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewServerlessServicePartialUpdateClusterOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - default: - result := NewServerlessServicePartialUpdateClusterDefault(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 - } -} - -// NewServerlessServicePartialUpdateClusterOK creates a ServerlessServicePartialUpdateClusterOK with default headers values -func NewServerlessServicePartialUpdateClusterOK() *ServerlessServicePartialUpdateClusterOK { - return &ServerlessServicePartialUpdateClusterOK{} -} - -/* -ServerlessServicePartialUpdateClusterOK describes a response with status code 200, with default header values. - -A successful response. -*/ -type ServerlessServicePartialUpdateClusterOK struct { - Payload *models.TidbCloudOpenApiserverlessv1beta1Cluster -} - -// IsSuccess returns true when this serverless service partial update cluster o k response has a 2xx status code -func (o *ServerlessServicePartialUpdateClusterOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this serverless service partial update cluster o k response has a 3xx status code -func (o *ServerlessServicePartialUpdateClusterOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this serverless service partial update cluster o k response has a 4xx status code -func (o *ServerlessServicePartialUpdateClusterOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this serverless service partial update cluster o k response has a 5xx status code -func (o *ServerlessServicePartialUpdateClusterOK) IsServerError() bool { - return false -} - -// IsCode returns true when this serverless service partial update cluster o k response a status code equal to that given -func (o *ServerlessServicePartialUpdateClusterOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the serverless service partial update cluster o k response -func (o *ServerlessServicePartialUpdateClusterOK) Code() int { - return 200 -} - -func (o *ServerlessServicePartialUpdateClusterOK) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[PATCH /clusters/{cluster.clusterId}][%d] serverlessServicePartialUpdateClusterOK %s", 200, payload) -} - -func (o *ServerlessServicePartialUpdateClusterOK) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[PATCH /clusters/{cluster.clusterId}][%d] serverlessServicePartialUpdateClusterOK %s", 200, payload) -} - -func (o *ServerlessServicePartialUpdateClusterOK) GetPayload() *models.TidbCloudOpenApiserverlessv1beta1Cluster { - return o.Payload -} - -func (o *ServerlessServicePartialUpdateClusterOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.TidbCloudOpenApiserverlessv1beta1Cluster) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewServerlessServicePartialUpdateClusterDefault creates a ServerlessServicePartialUpdateClusterDefault with default headers values -func NewServerlessServicePartialUpdateClusterDefault(code int) *ServerlessServicePartialUpdateClusterDefault { - return &ServerlessServicePartialUpdateClusterDefault{ - _statusCode: code, - } -} - -/* -ServerlessServicePartialUpdateClusterDefault describes a response with status code -1, with default header values. - -An unexpected error response. -*/ -type ServerlessServicePartialUpdateClusterDefault struct { - _statusCode int - - Payload *models.GooglerpcStatus -} - -// IsSuccess returns true when this serverless service partial update cluster default response has a 2xx status code -func (o *ServerlessServicePartialUpdateClusterDefault) IsSuccess() bool { - return o._statusCode/100 == 2 -} - -// IsRedirect returns true when this serverless service partial update cluster default response has a 3xx status code -func (o *ServerlessServicePartialUpdateClusterDefault) IsRedirect() bool { - return o._statusCode/100 == 3 -} - -// IsClientError returns true when this serverless service partial update cluster default response has a 4xx status code -func (o *ServerlessServicePartialUpdateClusterDefault) IsClientError() bool { - return o._statusCode/100 == 4 -} - -// IsServerError returns true when this serverless service partial update cluster default response has a 5xx status code -func (o *ServerlessServicePartialUpdateClusterDefault) IsServerError() bool { - return o._statusCode/100 == 5 -} - -// IsCode returns true when this serverless service partial update cluster default response a status code equal to that given -func (o *ServerlessServicePartialUpdateClusterDefault) IsCode(code int) bool { - return o._statusCode == code -} - -// Code gets the status code for the serverless service partial update cluster default response -func (o *ServerlessServicePartialUpdateClusterDefault) Code() int { - return o._statusCode -} - -func (o *ServerlessServicePartialUpdateClusterDefault) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[PATCH /clusters/{cluster.clusterId}][%d] ServerlessService_PartialUpdateCluster default %s", o._statusCode, payload) -} - -func (o *ServerlessServicePartialUpdateClusterDefault) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[PATCH /clusters/{cluster.clusterId}][%d] ServerlessService_PartialUpdateCluster default %s", o._statusCode, payload) -} - -func (o *ServerlessServicePartialUpdateClusterDefault) GetPayload() *models.GooglerpcStatus { - return o.Payload -} - -func (o *ServerlessServicePartialUpdateClusterDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.GooglerpcStatus) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -/* -ServerlessServicePartialUpdateClusterBody Message for requesting a partial update on a TiDB Serverless cluster. -swagger:model ServerlessServicePartialUpdateClusterBody -*/ -type ServerlessServicePartialUpdateClusterBody struct { - - // cluster - Cluster *ServerlessServicePartialUpdateClusterParamsBodyCluster `json:"cluster,omitempty"` - - // Required. The update mask indicating which fields are to be updated. - // Required: true - UpdateMask *string `json:"updateMask"` -} - -// Validate validates this serverless service partial update cluster body -func (o *ServerlessServicePartialUpdateClusterBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateCluster(formats); err != nil { - res = append(res, err) - } - - if err := o.validateUpdateMask(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *ServerlessServicePartialUpdateClusterBody) validateCluster(formats strfmt.Registry) error { - if swag.IsZero(o.Cluster) { // not required - return nil - } - - if o.Cluster != nil { - if err := o.Cluster.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("body" + "." + "cluster") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("body" + "." + "cluster") - } - return err - } - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterBody) validateUpdateMask(formats strfmt.Registry) error { - - if err := validate.Required("body"+"."+"updateMask", "body", o.UpdateMask); err != nil { - return err - } - - return nil -} - -// ContextValidate validate this serverless service partial update cluster body based on the context it is used -func (o *ServerlessServicePartialUpdateClusterBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := o.contextValidateCluster(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *ServerlessServicePartialUpdateClusterBody) contextValidateCluster(ctx context.Context, formats strfmt.Registry) error { - - if o.Cluster != nil { - - if swag.IsZero(o.Cluster) { // not required - return nil - } - - if err := o.Cluster.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("body" + "." + "cluster") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("body" + "." + "cluster") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (o *ServerlessServicePartialUpdateClusterBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *ServerlessServicePartialUpdateClusterBody) UnmarshalBinary(b []byte) error { - var res ServerlessServicePartialUpdateClusterBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} - -/* -ServerlessServicePartialUpdateClusterParamsBodyCluster Required. The cluster to be updated. -// -// Required. The cluster to be updated. -swagger:model ServerlessServicePartialUpdateClusterParamsBodyCluster -*/ -type ServerlessServicePartialUpdateClusterParamsBodyCluster struct { - - // Optional. The annotations for the cluster. - // tidb.cloud/has-set-password. The annotation for whether the cluster has set password. - // tidb.cloud/available-features. The annotation for the available features of the cluster. - Annotations map[string]string `json:"annotations,omitempty"` - - // Optional. Automated backup policy to set on the cluster. - AutomatedBackupPolicy *models.V1beta1ClusterAutomatedBackupPolicy `json:"automatedBackupPolicy,omitempty"` - - // Output_only. Timestamp when the cluster was created. - // Read Only: true - // Format: date-time - CreateTime strfmt.DateTime `json:"createTime,omitempty"` - - // Output_only. The email of the creator of the cluster. - // Read Only: true - CreatedBy string `json:"createdBy,omitempty"` - - // Required. User friendly display name of the cluster. - DisplayName string `json:"displayName,omitempty"` - - // Optional. Encryption settings for the cluster. - EncryptionConfig *models.V1beta1ClusterEncryptionConfig `json:"encryptionConfig,omitempty"` - - // Optional. The endpoints for connecting to the cluster. - Endpoints *models.TidbCloudOpenApiserverlessv1beta1ClusterEndpoints `json:"endpoints,omitempty"` - - // Optional. The labels for the cluster. - // tidb.cloud/organization. The label for the cluster organization id. - // tidb.cloud/project. The label for the cluster project id. - Labels map[string]string `json:"labels,omitempty"` - - // Output_only. The unique name of the cluster. - // Read Only: true - Name string `json:"name,omitempty"` - - // Required. Region where the cluster will be created. - Region *models.Commonv1beta1Region `json:"region,omitempty"` - - // Optional. The spending limit for the cluster. - SpendingLimit *models.ClusterSpendingLimit `json:"spendingLimit,omitempty"` - - // Output_only. The current state of the cluster. - // Read Only: true - State *models.Commonv1beta1ClusterState `json:"state,omitempty"` - - // Output_only. Timestamp when the cluster was last updated. - // Read Only: true - // Format: date-time - UpdateTime strfmt.DateTime `json:"updateTime,omitempty"` - - // Output_only. Usage details of the cluster. - // Read Only: true - Usage *models.V1beta1ClusterUsage `json:"usage,omitempty"` - - // Output_only. The unique prefix in SQL user name. - // Read Only: true - UserPrefix string `json:"userPrefix,omitempty"` - - // Output_only. The TiDB version of the cluster. - // Read Only: true - Version string `json:"version,omitempty"` -} - -// Validate validates this serverless service partial update cluster params body cluster -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateAutomatedBackupPolicy(formats); err != nil { - res = append(res, err) - } - - if err := o.validateCreateTime(formats); err != nil { - res = append(res, err) - } - - if err := o.validateEncryptionConfig(formats); err != nil { - res = append(res, err) - } - - if err := o.validateEndpoints(formats); err != nil { - res = append(res, err) - } - - if err := o.validateRegion(formats); err != nil { - res = append(res, err) - } - - if err := o.validateSpendingLimit(formats); err != nil { - res = append(res, err) - } - - if err := o.validateState(formats); err != nil { - res = append(res, err) - } - - if err := o.validateUpdateTime(formats); err != nil { - res = append(res, err) - } - - if err := o.validateUsage(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) validateAutomatedBackupPolicy(formats strfmt.Registry) error { - if swag.IsZero(o.AutomatedBackupPolicy) { // not required - return nil - } - - if o.AutomatedBackupPolicy != nil { - if err := o.AutomatedBackupPolicy.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("body" + "." + "cluster" + "." + "automatedBackupPolicy") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("body" + "." + "cluster" + "." + "automatedBackupPolicy") - } - return err - } - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) validateCreateTime(formats strfmt.Registry) error { - if swag.IsZero(o.CreateTime) { // not required - return nil - } - - if err := validate.FormatOf("body"+"."+"cluster"+"."+"createTime", "body", "date-time", o.CreateTime.String(), formats); err != nil { - return err - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) validateEncryptionConfig(formats strfmt.Registry) error { - if swag.IsZero(o.EncryptionConfig) { // not required - return nil - } - - if o.EncryptionConfig != nil { - if err := o.EncryptionConfig.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("body" + "." + "cluster" + "." + "encryptionConfig") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("body" + "." + "cluster" + "." + "encryptionConfig") - } - return err - } - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) validateEndpoints(formats strfmt.Registry) error { - if swag.IsZero(o.Endpoints) { // not required - return nil - } - - if o.Endpoints != nil { - if err := o.Endpoints.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("body" + "." + "cluster" + "." + "endpoints") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("body" + "." + "cluster" + "." + "endpoints") - } - return err - } - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) validateRegion(formats strfmt.Registry) error { - if swag.IsZero(o.Region) { // not required - return nil - } - - if o.Region != nil { - if err := o.Region.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("body" + "." + "cluster" + "." + "region") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("body" + "." + "cluster" + "." + "region") - } - return err - } - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) validateSpendingLimit(formats strfmt.Registry) error { - if swag.IsZero(o.SpendingLimit) { // not required - return nil - } - - if o.SpendingLimit != nil { - if err := o.SpendingLimit.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("body" + "." + "cluster" + "." + "spendingLimit") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("body" + "." + "cluster" + "." + "spendingLimit") - } - return err - } - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) validateState(formats strfmt.Registry) error { - if swag.IsZero(o.State) { // not required - return nil - } - - if o.State != nil { - if err := o.State.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("body" + "." + "cluster" + "." + "state") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("body" + "." + "cluster" + "." + "state") - } - return err - } - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) validateUpdateTime(formats strfmt.Registry) error { - if swag.IsZero(o.UpdateTime) { // not required - return nil - } - - if err := validate.FormatOf("body"+"."+"cluster"+"."+"updateTime", "body", "date-time", o.UpdateTime.String(), formats); err != nil { - return err - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) validateUsage(formats strfmt.Registry) error { - if swag.IsZero(o.Usage) { // not required - return nil - } - - if o.Usage != nil { - if err := o.Usage.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("body" + "." + "cluster" + "." + "usage") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("body" + "." + "cluster" + "." + "usage") - } - return err - } - } - - return nil -} - -// ContextValidate validate this serverless service partial update cluster params body cluster based on the context it is used -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := o.contextValidateAutomatedBackupPolicy(ctx, formats); err != nil { - res = append(res, err) - } - - if err := o.contextValidateCreateTime(ctx, formats); err != nil { - res = append(res, err) - } - - if err := o.contextValidateCreatedBy(ctx, formats); err != nil { - res = append(res, err) - } - - if err := o.contextValidateEncryptionConfig(ctx, formats); err != nil { - res = append(res, err) - } - - if err := o.contextValidateEndpoints(ctx, formats); err != nil { - res = append(res, err) - } - - if err := o.contextValidateName(ctx, formats); err != nil { - res = append(res, err) - } - - if err := o.contextValidateRegion(ctx, formats); err != nil { - res = append(res, err) - } - - if err := o.contextValidateSpendingLimit(ctx, formats); err != nil { - res = append(res, err) - } - - if err := o.contextValidateState(ctx, formats); err != nil { - res = append(res, err) - } - - if err := o.contextValidateUpdateTime(ctx, formats); err != nil { - res = append(res, err) - } - - if err := o.contextValidateUsage(ctx, formats); err != nil { - res = append(res, err) - } - - if err := o.contextValidateUserPrefix(ctx, formats); err != nil { - res = append(res, err) - } - - if err := o.contextValidateVersion(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) contextValidateAutomatedBackupPolicy(ctx context.Context, formats strfmt.Registry) error { - - if o.AutomatedBackupPolicy != nil { - - if swag.IsZero(o.AutomatedBackupPolicy) { // not required - return nil - } - - if err := o.AutomatedBackupPolicy.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("body" + "." + "cluster" + "." + "automatedBackupPolicy") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("body" + "." + "cluster" + "." + "automatedBackupPolicy") - } - return err - } - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) contextValidateCreateTime(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "body"+"."+"cluster"+"."+"createTime", "body", strfmt.DateTime(o.CreateTime)); err != nil { - return err - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) contextValidateCreatedBy(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "body"+"."+"cluster"+"."+"createdBy", "body", string(o.CreatedBy)); err != nil { - return err - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) contextValidateEncryptionConfig(ctx context.Context, formats strfmt.Registry) error { - - if o.EncryptionConfig != nil { - - if swag.IsZero(o.EncryptionConfig) { // not required - return nil - } - - if err := o.EncryptionConfig.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("body" + "." + "cluster" + "." + "encryptionConfig") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("body" + "." + "cluster" + "." + "encryptionConfig") - } - return err - } - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) contextValidateEndpoints(ctx context.Context, formats strfmt.Registry) error { - - if o.Endpoints != nil { - - if swag.IsZero(o.Endpoints) { // not required - return nil - } - - if err := o.Endpoints.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("body" + "." + "cluster" + "." + "endpoints") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("body" + "." + "cluster" + "." + "endpoints") - } - return err - } - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) contextValidateName(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "body"+"."+"cluster"+"."+"name", "body", string(o.Name)); err != nil { - return err - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) contextValidateRegion(ctx context.Context, formats strfmt.Registry) error { - - if o.Region != nil { - - if swag.IsZero(o.Region) { // not required - return nil - } - - if err := o.Region.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("body" + "." + "cluster" + "." + "region") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("body" + "." + "cluster" + "." + "region") - } - return err - } - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) contextValidateSpendingLimit(ctx context.Context, formats strfmt.Registry) error { - - if o.SpendingLimit != nil { - - if swag.IsZero(o.SpendingLimit) { // not required - return nil - } - - if err := o.SpendingLimit.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("body" + "." + "cluster" + "." + "spendingLimit") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("body" + "." + "cluster" + "." + "spendingLimit") - } - return err - } - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) contextValidateState(ctx context.Context, formats strfmt.Registry) error { - - if o.State != nil { - - if swag.IsZero(o.State) { // not required - return nil - } - - if err := o.State.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("body" + "." + "cluster" + "." + "state") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("body" + "." + "cluster" + "." + "state") - } - return err - } - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) contextValidateUpdateTime(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "body"+"."+"cluster"+"."+"updateTime", "body", strfmt.DateTime(o.UpdateTime)); err != nil { - return err - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) contextValidateUsage(ctx context.Context, formats strfmt.Registry) error { - - if o.Usage != nil { - - if swag.IsZero(o.Usage) { // not required - return nil - } - - if err := o.Usage.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("body" + "." + "cluster" + "." + "usage") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("body" + "." + "cluster" + "." + "usage") - } - return err - } - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) contextValidateUserPrefix(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "body"+"."+"cluster"+"."+"userPrefix", "body", string(o.UserPrefix)); err != nil { - return err - } - - return nil -} - -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) contextValidateVersion(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "body"+"."+"cluster"+"."+"version", "body", string(o.Version)); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *ServerlessServicePartialUpdateClusterParamsBodyCluster) UnmarshalBinary(b []byte) error { - var res ServerlessServicePartialUpdateClusterParamsBodyCluster - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/client/tidbcloud_serverless_client.go b/pkg/tidbcloud/v1beta1/serverless/client/tidbcloud_serverless_client.go deleted file mode 100644 index 9467aa2c..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/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/serverless/client/serverless_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 = "/v1beta1" -) - -// 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.ServerlessService = serverless_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 { - ServerlessService serverless_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.ServerlessService.SetTransport(transport) -} diff --git a/pkg/tidbcloud/v1beta1/serverless/serverless.swagger.json b/pkg/tidbcloud/v1beta1/serverless/cluster.swagger.json similarity index 58% rename from pkg/tidbcloud/v1beta1/serverless/serverless.swagger.json rename to pkg/tidbcloud/v1beta1/serverless/cluster.swagger.json index 69dca0aa..4154773b 100644 --- a/pkg/tidbcloud/v1beta1/serverless/serverless.swagger.json +++ b/pkg/tidbcloud/v1beta1/serverless/cluster.swagger.json @@ -69,6 +69,14 @@ "in": "query", "required": false, "type": "string" + }, + { + "name": "skip", + "description": "The number of individual resources to skip before starting to return results.\nIf the skip value causes the cursor to move past the end of the collection,\nthe response will be 200 OK with an empty result set and no next_page_token.", + "in": "query", + "required": false, + "type": "integer", + "format": "int32" } ], "tags": [ @@ -111,10 +119,10 @@ ] } }, - "/clusters/{cluster.clusterId}": { - "patch": { - "summary": "Partially updates a specific TiDB Serverless cluster.", - "operationId": "ServerlessService_PartialUpdateCluster", + "/clusters/{clusterId}": { + "get": { + "summary": "Retrieves details of a specific TiDB Serverless cluster.", + "operationId": "ServerlessService_GetCluster", "responses": { "200": { "description": "A successful response.", @@ -131,129 +139,31 @@ }, "parameters": [ { - "name": "cluster.clusterId", - "description": "Output_only. The unique ID of the cluster.", + "name": "clusterId", + "description": "Required. The ID of the cluster to be retrieved.", "in": "path", "required": true, "type": "string" }, { - "name": "body", - "in": "body", - "required": true, - "schema": { - "type": "object", - "properties": { - "cluster": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "Output_only. The unique name of the cluster.", - "readOnly": true - }, - "displayName": { - "type": "string", - "description": "Required. User friendly display name of the cluster." - }, - "region": { - "$ref": "#/definitions/commonv1beta1Region", - "description": "Required. Region where the cluster will be created." - }, - "spendingLimit": { - "$ref": "#/definitions/ClusterSpendingLimit", - "description": "Optional. The spending limit for the cluster." - }, - "version": { - "type": "string", - "description": "Output_only. The TiDB version of the cluster.", - "readOnly": true - }, - "createdBy": { - "type": "string", - "description": "Output_only. The email of the creator of the cluster.", - "readOnly": true - }, - "automatedBackupPolicy": { - "$ref": "#/definitions/v1beta1ClusterAutomatedBackupPolicy", - "description": "Optional. Automated backup policy to set on the cluster." - }, - "userPrefix": { - "type": "string", - "description": "Output_only. The unique prefix in SQL user name.", - "readOnly": true - }, - "endpoints": { - "$ref": "#/definitions/tidb_cloud_open_apiserverlessv1beta1ClusterEndpoints", - "description": "Optional. The endpoints for connecting to the cluster." - }, - "state": { - "$ref": "#/definitions/commonv1beta1ClusterState", - "description": "Output_only. The current state of the cluster.", - "readOnly": true - }, - "usage": { - "$ref": "#/definitions/v1beta1ClusterUsage", - "description": "Output_only. Usage details of the cluster.", - "readOnly": true - }, - "encryptionConfig": { - "$ref": "#/definitions/v1beta1ClusterEncryptionConfig", - "description": "Optional. Encryption settings for the cluster." - }, - "labels": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "Optional. The labels for the cluster.\ntidb.cloud/organization. The label for the cluster organization id.\ntidb.cloud/project. The label for the cluster project id." - }, - "annotations": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "Optional. The annotations for the cluster.\ntidb.cloud/has-set-password. The annotation for whether the cluster has set password.\ntidb.cloud/available-features. The annotation for the available features of the cluster." - }, - "createTime": { - "type": "string", - "format": "date-time", - "description": "Output_only. Timestamp when the cluster was created.", - "readOnly": true - }, - "updateTime": { - "type": "string", - "format": "date-time", - "description": "Output_only. Timestamp when the cluster was last updated.", - "readOnly": true - } - }, - "description": "Required. The cluster to be updated.", - "title": "Required. The cluster to be updated." - }, - "updateMask": { - "type": "string", - "description": "Required. The update mask indicating which fields are to be updated." - } - }, - "description": "Message for requesting a partial update on a TiDB Serverless cluster.", - "required": [ - "displayName", - "region", - "updateMask" - ] - } + "name": "view", + "description": "Optional. The level of detail to return for the cluster.\n\n - BASIC: Only basic information about the cluster is returned.\n - FULL: All details about the cluster are returned.", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "BASIC", + "FULL" + ] } ], "tags": [ "ServerlessService" ] - } - }, - "/clusters/{clusterId}": { - "get": { - "summary": "Retrieves details of a specific TiDB Serverless cluster.", - "operationId": "ServerlessService_GetCluster", + }, + "delete": { + "summary": "Deletes a specific TiDB Serverless cluster.", + "operationId": "ServerlessService_DeleteCluster", "responses": { "200": { "description": "A successful response.", @@ -271,32 +181,21 @@ "parameters": [ { "name": "clusterId", - "description": "Required. The ID of the cluster to be retrieved.", + "description": "Required. The ID of the cluster to be deleted.", "in": "path", "required": true, "type": "string" - }, - { - "name": "view", - "description": "Optional. The level of detail to return for the cluster.\n\n - CLUSTER_VIEW_UNSPECIFIED: The server default is used if unspecified.\n - BASIC: Only basic information about the cluster is returned.\n - FULL: All details about the cluster are returned.", - "in": "query", - "required": false, - "type": "string", - "enum": [ - "CLUSTER_VIEW_UNSPECIFIED", - "BASIC", - "FULL" - ], - "default": "CLUSTER_VIEW_UNSPECIFIED" } ], "tags": [ "ServerlessService" ] - }, - "delete": { - "summary": "Deletes a specific TiDB Serverless cluster.", - "operationId": "ServerlessService_DeleteCluster", + } + }, + "/clusters/{cluster.clusterId}": { + "patch": { + "summary": "Partially updates a specific TiDB Serverless cluster.", + "operationId": "ServerlessService_PartialUpdateCluster", "responses": { "200": { "description": "A successful response.", @@ -313,11 +212,19 @@ }, "parameters": [ { - "name": "clusterId", - "description": "Required. The ID of the cluster to be deleted.", + "name": "cluster.clusterId", + "description": "Output_only. The unique ID of the cluster.", "in": "path", "required": true, "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1beta1ServerlessServicePartialUpdateClusterBody" + } } ], "tags": [ @@ -356,17 +263,7 @@ "in": "body", "required": true, "schema": { - "type": "object", - "properties": { - "password": { - "type": "string", - "description": "Required. The new root password for the cluster." - } - }, - "description": "Message for requesting to change the root password of a TiDB Serverless cluster.", - "required": [ - "password" - ] + "$ref": "#/definitions/ServerlessServiceChangeRootPasswordBody" } } ], @@ -426,12 +323,20 @@ "readOnly": true }, "aws": { - "$ref": "#/definitions/PrivateAWS", - "readOnly": true + "readOnly": true, + "allOf": [ + { + "$ref": "#/definitions/PrivateAWS" + } + ] }, "gcp": { - "$ref": "#/definitions/PrivateGCP", - "readOnly": true + "readOnly": true, + "allOf": [ + { + "$ref": "#/definitions/PrivateGCP" + } + ] } }, "description": "Message for private endpoint to securely connect to the cluster." @@ -487,10 +392,22 @@ }, "description": "Message for GCP Private Service information." }, + "ServerlessServiceChangeRootPasswordBody": { + "type": "object", + "properties": { + "password": { + "type": "string", + "description": "Required. The new root password for the cluster." + } + }, + "description": "Message for requesting to change the root password of a TiDB Serverless cluster.", + "required": [ + "password" + ] + }, "commonv1beta1ClusterState": { "type": "string", "enum": [ - "CLUSTER_STATE_UNSPECIFIED", "CREATING", "DELETING", "ACTIVE", @@ -498,16 +415,14 @@ "MAINTENANCE", "DELETED", "INACTIVE", - "UPDATING", + "UPGRADING", "IMPORTING", "MODIFYING", "PAUSING", "PAUSED", - "RESUMING", - "SCALING" + "RESUMING" ], - "default": "CLUSTER_STATE_UNSPECIFIED", - "description": "Enum for current state of a cluster.\n\n - CREATING: Cluster is being created.\n - DELETING: Cluster is being deleted.\n - ACTIVE: Cluster is active for use.\n - RESTORING: Cluster data is being restored.\n - MAINTENANCE: Cluster is under maintenance.\n - DELETED: Cluster has been deleted.\n - INACTIVE: Cluster is not active, but not being deleted.\n - UPDATING: Cluster is being updated.\nOnly for Dedicated Cluster.\n - IMPORTING: Cluster is being imported.\nOnly for Dedicated Cluster.\n - MODIFYING: Cluster is being modified.\nOnly for Dedicated Cluster.\n - PAUSING: Cluster is being paused.\nOnly for Dedicated Cluster.\n - PAUSED: Cluster is paused.\nOnly for Dedicated Cluster.\n - RESUMING: Cluster is resuming.\nOnly for Dedicated Cluster.\n - SCALING: Cluster is scaling.\nOnly for Dedicated Cluster.\nOnly for Mgmt Internal API." + "description": "Enum of possible states of a cluster.\n\n - CREATING: Cluster is being created.\n - DELETING: Cluster is being deleted.\n - ACTIVE: Cluster is active for use.\n - RESTORING: Cluster data is being restored.\n - MAINTENANCE: Cluster is under maintenance.\n - DELETED: Cluster has been deleted.\n - INACTIVE: Cluster is not active, but not being deleted.\n - UPGRADING: Cluster is being updated.\nOnly for Dedicated Cluster.\n - IMPORTING: Cluster is being imported.\nOnly for Dedicated Cluster.\n - MODIFYING: Cluster is being modified.\nOnly for Dedicated Cluster.\n - PAUSING: Cluster is being paused.\nOnly for Dedicated Cluster.\n - PAUSED: Cluster is paused.\nOnly for Dedicated Cluster.\n - RESUMING: Cluster is resuming.\nOnly for Dedicated Cluster." }, "commonv1beta1Region": { "type": "object", @@ -515,67 +430,78 @@ "name": { "type": "string", "example": "regions/aws-us-west-2", - "description": "Required. The unique name of the region.", + "title": "The unique name of the region.\nFormat: regions/{region_id}", "pattern": "^regions/(aws|gcp|azure)-(.+)$" }, - "displayName": { + "regionId": { "type": "string", - "description": "Output only. User-friendly display name of the region.", + "description": "Format: {cloud_provider}-{region_code}\nRegion code: us-west-2, asia-east1.", "readOnly": true }, - "provider": { - "$ref": "#/definitions/v1beta1RegionCloudProvider", - "description": "Output only. The cloud provider for the region.", + "cloudProvider": { + "description": "The cloud provider for the region.", + "readOnly": true, + "allOf": [ + { + "$ref": "#/definitions/v1beta1RegionCloudProvider" + } + ] + }, + "displayName": { + "type": "string", + "description": "User-friendly display name of the region.", "readOnly": true }, - "id": { + "provider": { "type": "string", - "example": "us-west-2", + "x-nullable": true, + "description": "Optional provider name for the region.\nOnly used for serverless cluster.\nDeprecated.", "readOnly": true } }, - "description": "Message for describing a region for deploying TiDB Serverless clusters.", - "required": [ - "name" - ] + "description": "A representation of a region for deploying TiDB clusters." }, "googlerpcStatus": { "type": "object", "properties": { "code": { "type": "integer", - "format": "int32" + "format": "int32", + "description": "The status code, which should be an enum value of\n[google.rpc.Code][google.rpc.Code]." }, "message": { - "type": "string" + "type": "string", + "description": "A developer-facing error message, which should be in English. Any\nuser-facing error message should be localized and sent in the\n[google.rpc.Status.details][google.rpc.Status.details] field, or localized\nby the client." }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" - } + }, + "description": "A list of messages that carry the error details. There is a common set of\nmessage types for APIs to use." } - } + }, + "description": "The `Status` type defines a logical error model that is suitable for\ndifferent programming environments, including REST APIs and RPC APIs. It is\nused by [gRPC](https://github.com/grpc). Each `Status` message contains\nthree pieces of data: error code, error message, and error details.\n\nYou can find out more about this error model and how to work with it in the\n[API Design Guide](https://cloud.google.com/apis/design/errors)." }, "protobufAny": { "type": "object", "properties": { "@type": { - "type": "string" + "type": "string", + "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." } }, - "additionalProperties": {} + "additionalProperties": {}, + "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" }, "serverlessv1beta1ClusterView": { "type": "string", "enum": [ - "CLUSTER_VIEW_UNSPECIFIED", "BASIC", "FULL" ], - "default": "CLUSTER_VIEW_UNSPECIFIED", - "description": "Enum for the different types of detail view to be returned for a TiDB Serverless cluster.\n\n - CLUSTER_VIEW_UNSPECIFIED: The server default is used if unspecified.\n - BASIC: Only basic information about the cluster is returned.\n - FULL: All details about the cluster are returned." + "description": "Enum for the different types of detail view to be returned for a TiDB Serverless cluster.\n\n - BASIC: Only basic information about the cluster is returned.\n - FULL: All details about the cluster are returned." }, "tidb_cloud_open_apiserverlessv1beta1Cluster": { "type": "object", @@ -595,12 +521,20 @@ "description": "Required. User friendly display name of the cluster." }, "region": { - "$ref": "#/definitions/commonv1beta1Region", - "description": "Required. Region where the cluster will be created." + "description": "Required. Region where the cluster will be created.", + "allOf": [ + { + "$ref": "#/definitions/commonv1beta1Region" + } + ] }, "spendingLimit": { - "$ref": "#/definitions/ClusterSpendingLimit", - "description": "Optional. The spending limit for the cluster." + "description": "Optional. The spending limit for the cluster.", + "allOf": [ + { + "$ref": "#/definitions/ClusterSpendingLimit" + } + ] }, "version": { "type": "string", @@ -613,8 +547,12 @@ "readOnly": true }, "automatedBackupPolicy": { - "$ref": "#/definitions/v1beta1ClusterAutomatedBackupPolicy", - "description": "Optional. Automated backup policy to set on the cluster." + "description": "Optional. Automated backup policy to set on the cluster.", + "allOf": [ + { + "$ref": "#/definitions/v1beta1ClusterAutomatedBackupPolicy" + } + ] }, "userPrefix": { "type": "string", @@ -622,22 +560,38 @@ "readOnly": true }, "endpoints": { - "$ref": "#/definitions/tidb_cloud_open_apiserverlessv1beta1ClusterEndpoints", - "description": "Optional. The endpoints for connecting to the cluster." + "description": "Optional. The endpoints for connecting to the cluster.", + "allOf": [ + { + "$ref": "#/definitions/v1beta1ClusterEndpoints" + } + ] }, "state": { - "$ref": "#/definitions/commonv1beta1ClusterState", "description": "Output_only. The current state of the cluster.", - "readOnly": true + "readOnly": true, + "allOf": [ + { + "$ref": "#/definitions/commonv1beta1ClusterState" + } + ] }, "usage": { - "$ref": "#/definitions/v1beta1ClusterUsage", "description": "Output_only. Usage details of the cluster.", - "readOnly": true + "readOnly": true, + "allOf": [ + { + "$ref": "#/definitions/v1beta1ClusterUsage" + } + ] }, "encryptionConfig": { - "$ref": "#/definitions/v1beta1ClusterEncryptionConfig", - "description": "Optional. Encryption settings for the cluster." + "description": "Optional. Encryption settings for the cluster.", + "allOf": [ + { + "$ref": "#/definitions/v1beta1ClusterEncryptionConfig" + } + ] }, "labels": { "type": "object", @@ -651,7 +605,8 @@ "additionalProperties": { "type": "string" }, - "description": "Optional. The annotations for the cluster.\ntidb.cloud/has-set-password. The annotation for whether the cluster has set password.\ntidb.cloud/available-features. The annotation for the available features of the cluster." + "description": "OUTPUT_ONLY. The annotations for the cluster.\ntidb.cloud/has-set-password. The annotation for whether the cluster has set password.\ntidb.cloud/available-features. The annotation for the available features of the cluster.", + "readOnly": true }, "createTime": { "type": "string", @@ -672,21 +627,6 @@ "region" ] }, - "tidb_cloud_open_apiserverlessv1beta1ClusterEndpoints": { - "type": "object", - "properties": { - "public": { - "$ref": "#/definitions/EndpointsPublic", - "description": "Optional. Public endpoint to connect to the cluster." - }, - "private": { - "$ref": "#/definitions/EndpointsPrivate", - "description": "Output_only. Private endpoint to securely connect to the cluster.", - "readOnly": true - } - }, - "description": "Message for endpoint information for connecting to a cluster." - }, "tidb_cloud_open_apiserverlessv1beta1ListClustersResponse": { "type": "object", "properties": { @@ -753,6 +693,29 @@ }, "description": "Message for encryption settings for a cluster." }, + "v1beta1ClusterEndpoints": { + "type": "object", + "properties": { + "public": { + "description": "Optional. Public endpoint to connect to the cluster.", + "allOf": [ + { + "$ref": "#/definitions/EndpointsPublic" + } + ] + }, + "private": { + "description": "Output_only. Private endpoint to securely connect to the cluster.", + "readOnly": true, + "allOf": [ + { + "$ref": "#/definitions/EndpointsPrivate" + } + ] + } + }, + "description": "Message for endpoint information for connecting to a cluster." + }, "v1beta1ClusterUsage": { "type": "object", "properties": { @@ -777,17 +740,116 @@ }, "description": "Message for usage statistics of a cluster." }, + "v1beta1PartialUpdateClusterRequestPartialUpdateCluster": { + "type": "object", + "properties": { + "clusterId": { + "type": "string", + "description": "Output_only. The unique ID of the cluster." + }, + "displayName": { + "type": "string", + "description": "Required. User friendly display name of the cluster." + }, + "spendingLimit": { + "description": "Optional. The spending limit for the cluster.", + "allOf": [ + { + "$ref": "#/definitions/ClusterSpendingLimit" + } + ] + }, + "automatedBackupPolicy": { + "description": "Optional. Automated backup policy to set on the cluster.", + "allOf": [ + { + "$ref": "#/definitions/v1beta1ClusterAutomatedBackupPolicy" + } + ] + }, + "endpoints": { + "description": "Optional. The endpoints for connecting to the cluster.", + "allOf": [ + { + "$ref": "#/definitions/v1beta1ClusterEndpoints" + } + ] + }, + "labels": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Optional. The labels for the cluster.\ntidb.cloud/organization. The label for the cluster organization id.\ntidb.cloud/project. The label for the cluster project id." + } + }, + "required": [ + "clusterId" + ] + }, "v1beta1RegionCloudProvider": { "type": "string", "enum": [ - "CLOUD_PROVIDER_UNSPECIFIED", - "AWS", - "GCP", - "AZURE" + "aws", + "gcp", + "azure" ], - "default": "CLOUD_PROVIDER_UNSPECIFIED", - "description": "- CLOUD_PROVIDER_UNSPECIFIED: Unspecified cloud provider.\n - AWS: Amazon Web Services.\n - GCP: Google Cloud Platform.\n - AZURE: Microsoft Azure.", - "title": "Enum for cloud providers for the region.\n@gotags: tag:\"replace\"" + "description": "Enum of cloud provider names.\n\n - aws: Amazon Web Services.\nbuf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE\n - gcp: Google Cloud Platform.\nbuf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE\n - azure: Microsoft Azure.\nbuf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE" + }, + "v1beta1ServerlessServicePartialUpdateClusterBody": { + "type": "object", + "properties": { + "cluster": { + "type": "object", + "properties": { + "displayName": { + "type": "string", + "description": "Required. User friendly display name of the cluster." + }, + "spendingLimit": { + "description": "Optional. The spending limit for the cluster.", + "allOf": [ + { + "$ref": "#/definitions/ClusterSpendingLimit" + } + ] + }, + "automatedBackupPolicy": { + "description": "Optional. Automated backup policy to set on the cluster.", + "allOf": [ + { + "$ref": "#/definitions/v1beta1ClusterAutomatedBackupPolicy" + } + ] + }, + "endpoints": { + "description": "Optional. The endpoints for connecting to the cluster.", + "allOf": [ + { + "$ref": "#/definitions/v1beta1ClusterEndpoints" + } + ] + }, + "labels": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Optional. The labels for the cluster.\ntidb.cloud/organization. The label for the cluster organization id.\ntidb.cloud/project. The label for the cluster project id." + } + }, + "description": "Required. The cluster to be updated.", + "title": "Required. The cluster to be updated." + }, + "updateMask": { + "type": "string", + "description": "Required. The update mask indicating which fields are to be updated." + } + }, + "description": "Message for requesting a partial update on a TiDB Serverless cluster.", + "required": [ + "updateMask" + ] } } } \ No newline at end of file diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/.gitignore b/pkg/tidbcloud/v1beta1/serverless/cluster/.gitignore new file mode 100644 index 00000000..daf913b1 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/.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/cluster/.openapi-generator-ignore b/pkg/tidbcloud/v1beta1/serverless/cluster/.openapi-generator-ignore new file mode 100644 index 00000000..7484ee59 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/.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/cluster/.openapi-generator/FILES b/pkg/tidbcloud/v1beta1/serverless/cluster/.openapi-generator/FILES new file mode 100644 index 00000000..070b78d3 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/.openapi-generator/FILES @@ -0,0 +1,33 @@ +.gitignore +.openapi-generator-ignore +.travis.yml +README.md +api/openapi.yaml +api_serverless_service.go +client.go +configuration.go +git_push.sh +model_cluster_spending_limit.go +model_commonv1beta1_cluster_state.go +model_commonv1beta1_region.go +model_endpoints_private.go +model_endpoints_public.go +model_googlerpc_status.go +model_private_aws.go +model_private_gcp.go +model_protobuf_any.go +model_required__the_cluster_to_be_updated_.go +model_serverless_service_change_root_password_body.go +model_serverlessv1beta1_cluster_view.go +model_tidb_cloud_open_apiserverlessv1beta1_cluster.go +model_tidb_cloud_open_apiserverlessv1beta1_list_clusters_response.go +model_tidb_cloud_open_apiserverlessv1beta1_list_regions_response.go +model_v1beta1_cluster_automated_backup_policy.go +model_v1beta1_cluster_encryption_config.go +model_v1beta1_cluster_endpoints.go +model_v1beta1_cluster_usage.go +model_v1beta1_partial_update_cluster_request_partial_update_cluster.go +model_v1beta1_region_cloud_provider.go +model_v1beta1_serverless_service_partial_update_cluster_body.go +response.go +utils.go diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/.openapi-generator/VERSION b/pkg/tidbcloud/v1beta1/serverless/cluster/.openapi-generator/VERSION new file mode 100644 index 00000000..09a6d308 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.8.0 diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/.travis.yml b/pkg/tidbcloud/v1beta1/serverless/cluster/.travis.yml new file mode 100644 index 00000000..f5cb2ce9 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/.travis.yml @@ -0,0 +1,8 @@ +language: go + +install: + - go get -d -v . + +script: + - go build -v ./ + diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/README.md b/pkg/tidbcloud/v1beta1/serverless/cluster/README.md new file mode 100644 index 00000000..3010b36a --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/README.md @@ -0,0 +1,140 @@ +# Go API client for cluster + +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 cluster "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 `cluster.ContextServerIndex` of type `int`. + +```go +ctx := context.WithValue(context.Background(), cluster.ContextServerIndex, 1) +``` + +### Templated Server URL + +Templated server URL is formatted using default variables from configuration or from context value `cluster.ContextServerVariables` of type `map[string]string`. + +```go +ctx := context.WithValue(context.Background(), cluster.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 `cluster.ContextOperationServerIndices` and `cluster.ContextOperationServerVariables` context maps. + +```go +ctx := context.WithValue(context.Background(), cluster.ContextOperationServerIndices, map[string]int{ + "{classname}Service.{nickname}": 2, +}) +ctx = context.WithValue(context.Background(), cluster.ContextOperationServerVariables, map[string]map[string]string{ + "{classname}Service.{nickname}": { + "port": "8443", + }, +}) +``` + +## Documentation for API Endpoints + +All URIs are relative to *https://serverless.tidbapi.com/v1beta1* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*ServerlessServiceAPI* | [**ServerlessServiceChangeRootPassword**](docs/ServerlessServiceAPI.md#serverlessservicechangerootpassword) | **Put** /clusters/{clusterId}/password | Changes the root password of a specific TiDB Serverless cluster. +*ServerlessServiceAPI* | [**ServerlessServiceCreateCluster**](docs/ServerlessServiceAPI.md#serverlessservicecreatecluster) | **Post** /clusters | Creates a new TiDB Serverless cluster. +*ServerlessServiceAPI* | [**ServerlessServiceDeleteCluster**](docs/ServerlessServiceAPI.md#serverlessservicedeletecluster) | **Delete** /clusters/{clusterId} | Deletes a specific TiDB Serverless cluster. +*ServerlessServiceAPI* | [**ServerlessServiceGetCluster**](docs/ServerlessServiceAPI.md#serverlessservicegetcluster) | **Get** /clusters/{clusterId} | Retrieves details of a specific TiDB Serverless cluster. +*ServerlessServiceAPI* | [**ServerlessServiceListClusters**](docs/ServerlessServiceAPI.md#serverlessservicelistclusters) | **Get** /clusters | Provides a list of TiDB Serverless clusters in a project. +*ServerlessServiceAPI* | [**ServerlessServiceListRegions**](docs/ServerlessServiceAPI.md#serverlessservicelistregions) | **Get** /regions | Provides a list of available regions for TiDB Serverless clusters. +*ServerlessServiceAPI* | [**ServerlessServicePartialUpdateCluster**](docs/ServerlessServiceAPI.md#serverlessservicepartialupdatecluster) | **Patch** /clusters/{cluster.clusterId} | Partially updates a specific TiDB Serverless cluster. + + +## Documentation For Models + + - [ClusterSpendingLimit](docs/ClusterSpendingLimit.md) + - [Commonv1beta1ClusterState](docs/Commonv1beta1ClusterState.md) + - [Commonv1beta1Region](docs/Commonv1beta1Region.md) + - [EndpointsPrivate](docs/EndpointsPrivate.md) + - [EndpointsPublic](docs/EndpointsPublic.md) + - [GooglerpcStatus](docs/GooglerpcStatus.md) + - [PrivateAWS](docs/PrivateAWS.md) + - [PrivateGCP](docs/PrivateGCP.md) + - [ProtobufAny](docs/ProtobufAny.md) + - [RequiredTheClusterToBeUpdated](docs/RequiredTheClusterToBeUpdated.md) + - [ServerlessServiceChangeRootPasswordBody](docs/ServerlessServiceChangeRootPasswordBody.md) + - [Serverlessv1beta1ClusterView](docs/Serverlessv1beta1ClusterView.md) + - [TidbCloudOpenApiserverlessv1beta1Cluster](docs/TidbCloudOpenApiserverlessv1beta1Cluster.md) + - [TidbCloudOpenApiserverlessv1beta1ListClustersResponse](docs/TidbCloudOpenApiserverlessv1beta1ListClustersResponse.md) + - [TidbCloudOpenApiserverlessv1beta1ListRegionsResponse](docs/TidbCloudOpenApiserverlessv1beta1ListRegionsResponse.md) + - [V1beta1ClusterAutomatedBackupPolicy](docs/V1beta1ClusterAutomatedBackupPolicy.md) + - [V1beta1ClusterEncryptionConfig](docs/V1beta1ClusterEncryptionConfig.md) + - [V1beta1ClusterEndpoints](docs/V1beta1ClusterEndpoints.md) + - [V1beta1ClusterUsage](docs/V1beta1ClusterUsage.md) + - [V1beta1PartialUpdateClusterRequestPartialUpdateCluster](docs/V1beta1PartialUpdateClusterRequestPartialUpdateCluster.md) + - [V1beta1RegionCloudProvider](docs/V1beta1RegionCloudProvider.md) + - [V1beta1ServerlessServicePartialUpdateClusterBody](docs/V1beta1ServerlessServicePartialUpdateClusterBody.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/cluster/api/openapi.yaml b/pkg/tidbcloud/v1beta1/serverless/cluster/api/openapi.yaml new file mode 100644 index 00000000..2b8b95ee --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/api/openapi.yaml @@ -0,0 +1,909 @@ +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/v1beta1 +tags: +- name: ServerlessService +paths: + /clusters: + get: + operationId: ServerlessService_ListClusters + parameters: + - description: Optional. The maximum number of clusters to return. + in: query + name: pageSize + schema: + format: int32 + type: integer + - description: Optional. The page token from the previous response for pagination. + in: query + name: pageToken + schema: + type: string + - description: Optional. The filter expression to filter clusters. + in: query + name: filter + schema: + type: string + - description: Optional. The order by expression for sorting clusters. + in: query + name: orderBy + schema: + type: string + - description: |- + The number of individual resources to skip before starting to return results. + If the skip value causes the cursor to move past the end of the collection, + the response will be 200 OK with an empty result set and no next_page_token. + in: query + name: skip + schema: + format: int32 + type: integer + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/tidb_cloud_open_apiserverlessv1beta1ListClustersResponse' + description: A successful response. + default: + content: + application/json: + schema: + $ref: '#/components/schemas/googlerpcStatus' + description: An unexpected error response. + summary: Provides a list of TiDB Serverless clusters in a project. + tags: + - ServerlessService + post: + operationId: ServerlessService_CreateCluster + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/tidb_cloud_open_apiserverlessv1beta1Cluster' + description: Required. The cluster to be created. + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/tidb_cloud_open_apiserverlessv1beta1Cluster' + description: A successful response. + default: + content: + application/json: + schema: + $ref: '#/components/schemas/googlerpcStatus' + description: An unexpected error response. + summary: Creates a new TiDB Serverless cluster. + tags: + - ServerlessService + x-codegen-request-body-name: cluster + /clusters/{clusterId}: + delete: + operationId: ServerlessService_DeleteCluster + parameters: + - description: Required. The ID of the cluster to be deleted. + in: path + name: clusterId + required: true + schema: + type: string + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/tidb_cloud_open_apiserverlessv1beta1Cluster' + description: A successful response. + default: + content: + application/json: + schema: + $ref: '#/components/schemas/googlerpcStatus' + description: An unexpected error response. + summary: Deletes a specific TiDB Serverless cluster. + tags: + - ServerlessService + get: + operationId: ServerlessService_GetCluster + parameters: + - description: Required. The ID of the cluster to be retrieved. + in: path + name: clusterId + required: true + schema: + type: string + - description: |- + Optional. The level of detail to return for the cluster. + + - BASIC: Only basic information about the cluster is returned. + - FULL: All details about the cluster are returned. + in: query + name: view + schema: + enum: + - BASIC + - FULL + type: string + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/tidb_cloud_open_apiserverlessv1beta1Cluster' + description: A successful response. + default: + content: + application/json: + schema: + $ref: '#/components/schemas/googlerpcStatus' + description: An unexpected error response. + summary: Retrieves details of a specific TiDB Serverless cluster. + tags: + - ServerlessService + /clusters/{cluster.clusterId}: + patch: + operationId: ServerlessService_PartialUpdateCluster + parameters: + - description: Output_only. The unique ID of the cluster. + in: path + name: cluster.clusterId + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/v1beta1ServerlessServicePartialUpdateClusterBody' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/tidb_cloud_open_apiserverlessv1beta1Cluster' + description: A successful response. + default: + content: + application/json: + schema: + $ref: '#/components/schemas/googlerpcStatus' + description: An unexpected error response. + summary: Partially updates a specific TiDB Serverless cluster. + tags: + - ServerlessService + x-codegen-request-body-name: body + /clusters/{clusterId}/password: + put: + operationId: ServerlessService_ChangeRootPassword + parameters: + - description: Required. The ID of the cluster for which the password is to + be changed. + in: path + name: clusterId + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ServerlessServiceChangeRootPasswordBody' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/v1beta1ChangeRootPasswordResponse' + description: A successful response. + default: + content: + application/json: + schema: + $ref: '#/components/schemas/googlerpcStatus' + description: An unexpected error response. + summary: Changes the root password of a specific TiDB Serverless cluster. + tags: + - ServerlessService + x-codegen-request-body-name: body + /regions: + get: + operationId: ServerlessService_ListRegions + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/tidb_cloud_open_apiserverlessv1beta1ListRegionsResponse' + description: A successful response. + default: + content: + application/json: + schema: + $ref: '#/components/schemas/googlerpcStatus' + description: An unexpected error response. + summary: Provides a list of available regions for TiDB Serverless clusters. + tags: + - ServerlessService +components: + schemas: + ClusterSpendingLimit: + description: Message for spending limit configuration. + properties: + monthly: + description: Optional. Maximum monthly spending limit in USD cents. + format: int32 + type: integer + type: object + EndpointsPrivate: + description: Message for private endpoint to securely connect to the cluster. + properties: + host: + description: Output_only. The hostname of the private endpoint. + readOnly: true + type: string + port: + description: Output_only. The port of the private endpoint. + format: int32 + readOnly: true + type: integer + aws: + allOf: + - $ref: '#/components/schemas/PrivateAWS' + type: object + gcp: + allOf: + - $ref: '#/components/schemas/PrivateGCP' + type: object + type: object + EndpointsPublic: + description: Message for public endpoint to connect to the cluster. + properties: + host: + description: Output_only. The hostname of the public endpoint. + readOnly: true + type: string + port: + description: Output_only. The port of the public endpoint. + format: int32 + readOnly: true + type: integer + disabled: + description: Optional. Whether the public endpoint is disabled. + type: boolean + type: object + PrivateAWS: + description: Message for AWS PrivateLink information. + properties: + serviceName: + description: Output_only. The AWS service name for private access. + readOnly: true + type: string + availabilityZone: + description: Output_only. The availability zones that the service is available + in. + items: + type: string + readOnly: true + type: array + type: object + PrivateGCP: + description: Message for GCP Private Service information. + properties: + serviceAttachmentName: + description: Output_only. The target GCP service attachment name for private + access. + readOnly: true + type: string + type: object + ServerlessServiceChangeRootPasswordBody: + description: Message for requesting to change the root password of a TiDB Serverless + cluster. + example: + password: password + properties: + password: + description: Required. The new root password for the cluster. + type: string + required: + - password + type: object + commonv1beta1ClusterState: + description: |- + Enum of possible states of a cluster. + + - CREATING: Cluster is being created. + - DELETING: Cluster is being deleted. + - ACTIVE: Cluster is active for use. + - RESTORING: Cluster data is being restored. + - MAINTENANCE: Cluster is under maintenance. + - DELETED: Cluster has been deleted. + - INACTIVE: Cluster is not active, but not being deleted. + - UPGRADING: Cluster is being updated. + Only for Dedicated Cluster. + - IMPORTING: Cluster is being imported. + Only for Dedicated Cluster. + - MODIFYING: Cluster is being modified. + Only for Dedicated Cluster. + - PAUSING: Cluster is being paused. + Only for Dedicated Cluster. + - PAUSED: Cluster is paused. + Only for Dedicated Cluster. + - RESUMING: Cluster is resuming. + Only for Dedicated Cluster. + enum: + - CREATING + - DELETING + - ACTIVE + - RESTORING + - MAINTENANCE + - DELETED + - INACTIVE + - UPGRADING + - IMPORTING + - MODIFYING + - PAUSING + - PAUSED + - RESUMING + type: string + commonv1beta1Region: + description: A representation of a region for deploying TiDB clusters. + example: + regionId: regionId + provider: provider + displayName: displayName + cloudProvider: "{}" + name: regions/aws-us-west-2 + properties: + name: + example: regions/aws-us-west-2 + pattern: ^regions/(aws|gcp|azure)-(.+)$ + title: |- + The unique name of the region. + Format: regions/{region_id} + type: string + regionId: + description: |- + Format: {cloud_provider}-{region_code} + Region code: us-west-2, asia-east1. + readOnly: true + type: string + cloudProvider: + allOf: + - $ref: '#/components/schemas/v1beta1RegionCloudProvider' + description: The cloud provider for the region. + type: object + displayName: + description: User-friendly display name of the region. + readOnly: true + type: string + provider: + description: |- + Optional provider name for the region. + Only used for serverless cluster. + Deprecated. + nullable: true + readOnly: true + type: string + type: object + googlerpcStatus: + description: |- + The `Status` type defines a logical error model that is suitable for + different programming environments, including REST APIs and RPC APIs. It is + used by [gRPC](https://github.com/grpc). Each `Status` message contains + three pieces of data: error code, error message, and error details. + + You can find out more about this error model and how to work with it in the + [API Design Guide](https://cloud.google.com/apis/design/errors). + example: + code: 6 + details: + - '@type': '@type' + - '@type': '@type' + message: message + properties: + code: + description: |- + The status code, which should be an enum value of + [google.rpc.Code][google.rpc.Code]. + format: int32 + type: integer + message: + description: |- + A developer-facing error message, which should be in English. Any + user-facing error message should be localized and sent in the + [google.rpc.Status.details][google.rpc.Status.details] field, or localized + by the client. + type: string + details: + description: |- + A list of messages that carry the error details. There is a common set of + message types for APIs to use. + items: + $ref: '#/components/schemas/protobufAny' + type: array + type: object + protobufAny: + additionalProperties: + type: object + description: |- + `Any` contains an arbitrary serialized protocol buffer message along with a + URL that describes the type of the serialized message. + + Protobuf library provides support to pack/unpack Any values in the form + of utility functions or additional generated methods of the Any type. + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + 'type.googleapis.com/full.type.name' as the type URL and the unpack + methods only use the fully qualified type name after the last '/' + in the type URL, for example "foo.bar.com/x/y.z" will yield type + name "y.z". + + JSON + ==== + The JSON representation of an `Any` value uses the regular + representation of the deserialized, embedded message, with an + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + representation, that representation will be embedded adding a field + `value` which holds the custom JSON in addition to the `@type` + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + example: + '@type': '@type' + properties: + '@type': + description: |- + A URL/resource name that uniquely identifies the type of the serialized + protocol buffer message. This string must contain at least + one "/" character. The last segment of the URL's path must represent + the fully qualified name of the type (as in + `path/google.protobuf.Duration`). The name should be in a canonical form + (e.g., leading "." is not accepted). + + In practice, teams usually precompile into the binary all types that they + expect it to use in the context of Any. However, for URLs which use the + scheme `http`, `https`, or no scheme, one can optionally set up a type + server that maps type URLs to message definitions as follows: + + * If no scheme is provided, `https` is assumed. + * An HTTP GET on the URL must yield a [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in the official + protobuf release, and it is not used for type URLs beginning with + type.googleapis.com. As of May 2023, there are no widely used type server + implementations and no plans to implement one. + + Schemes other than `http`, `https` (or the empty scheme) might be + used with implementation specific semantics. + type: string + type: object + serverlessv1beta1ClusterView: + description: |- + Enum for the different types of detail view to be returned for a TiDB Serverless cluster. + + - BASIC: Only basic information about the cluster is returned. + - FULL: All details about the cluster are returned. + enum: + - BASIC + - FULL + type: string + tidb_cloud_open_apiserverlessv1beta1Cluster: + description: Message for a serverless TiDB cluster resource. + example: + encryptionConfig: "{}" + endpoints: "{}" + automatedBackupPolicy: "{}" + displayName: displayName + usage: "{}" + annotations: + key: annotations + updateTime: 2000-01-23T04:56:07.000+00:00 + clusterId: clusterId + version: version + labels: + key: labels + spendingLimit: "{}" + createdBy: createdBy + createTime: 2000-01-23T04:56:07.000+00:00 + name: name + userPrefix: userPrefix + state: "{}" + region: "{}" + properties: + name: + description: Output_only. The unique name of the cluster. + readOnly: true + type: string + clusterId: + description: Output_only. The unique ID of the cluster. + readOnly: true + type: string + displayName: + description: Required. User friendly display name of the cluster. + type: string + region: + allOf: + - $ref: '#/components/schemas/commonv1beta1Region' + description: Required. Region where the cluster will be created. + type: object + spendingLimit: + allOf: + - $ref: '#/components/schemas/ClusterSpendingLimit' + description: Optional. The spending limit for the cluster. + type: object + version: + description: Output_only. The TiDB version of the cluster. + readOnly: true + type: string + createdBy: + description: Output_only. The email of the creator of the cluster. + readOnly: true + type: string + automatedBackupPolicy: + allOf: + - $ref: '#/components/schemas/v1beta1ClusterAutomatedBackupPolicy' + description: Optional. Automated backup policy to set on the cluster. + type: object + userPrefix: + description: Output_only. The unique prefix in SQL user name. + readOnly: true + type: string + endpoints: + allOf: + - $ref: '#/components/schemas/v1beta1ClusterEndpoints' + description: Optional. The endpoints for connecting to the cluster. + type: object + state: + allOf: + - $ref: '#/components/schemas/commonv1beta1ClusterState' + description: Output_only. The current state of the cluster. + type: object + usage: + allOf: + - $ref: '#/components/schemas/v1beta1ClusterUsage' + description: Output_only. Usage details of the cluster. + type: object + encryptionConfig: + allOf: + - $ref: '#/components/schemas/v1beta1ClusterEncryptionConfig' + description: Optional. Encryption settings for the cluster. + type: object + labels: + additionalProperties: + type: string + description: |- + Optional. The labels for the cluster. + tidb.cloud/organization. The label for the cluster organization id. + tidb.cloud/project. The label for the cluster project id. + type: object + annotations: + additionalProperties: + type: string + description: |- + OUTPUT_ONLY. The annotations for the cluster. + tidb.cloud/has-set-password. The annotation for whether the cluster has set password. + tidb.cloud/available-features. The annotation for the available features of the cluster. + readOnly: true + type: object + createTime: + description: Output_only. Timestamp when the cluster was created. + format: date-time + readOnly: true + type: string + updateTime: + description: Output_only. Timestamp when the cluster was last updated. + format: date-time + readOnly: true + type: string + required: + - displayName + - region + type: object + tidb_cloud_open_apiserverlessv1beta1ListClustersResponse: + description: Responses message to the request for listing of TiDB Serverless + clusters. + example: + totalSize: 0 + nextPageToken: nextPageToken + clusters: + - encryptionConfig: "{}" + endpoints: "{}" + automatedBackupPolicy: "{}" + displayName: displayName + usage: "{}" + annotations: + key: annotations + updateTime: 2000-01-23T04:56:07.000+00:00 + clusterId: clusterId + version: version + labels: + key: labels + spendingLimit: "{}" + createdBy: createdBy + createTime: 2000-01-23T04:56:07.000+00:00 + name: name + userPrefix: userPrefix + state: "{}" + region: "{}" + - encryptionConfig: "{}" + endpoints: "{}" + automatedBackupPolicy: "{}" + displayName: displayName + usage: "{}" + annotations: + key: annotations + updateTime: 2000-01-23T04:56:07.000+00:00 + clusterId: clusterId + version: version + labels: + key: labels + spendingLimit: "{}" + createdBy: createdBy + createTime: 2000-01-23T04:56:07.000+00:00 + name: name + userPrefix: userPrefix + state: "{}" + region: "{}" + properties: + clusters: + description: A list of clusters. + items: + $ref: '#/components/schemas/tidb_cloud_open_apiserverlessv1beta1Cluster' + type: array + nextPageToken: + description: Token provided to retrieve the next page of results. + type: string + totalSize: + description: Total number of available clusters. + format: int64 + type: integer + type: object + tidb_cloud_open_apiserverlessv1beta1ListRegionsResponse: + description: Responses message to the request for listing of available regions + in TiDB Serverless. + example: + regions: + - regionId: regionId + provider: provider + displayName: displayName + cloudProvider: "{}" + name: regions/aws-us-west-2 + - regionId: regionId + provider: provider + displayName: displayName + cloudProvider: "{}" + name: regions/aws-us-west-2 + properties: + regions: + description: A list of available regions. + items: + $ref: '#/components/schemas/commonv1beta1Region' + type: array + type: object + v1beta1ChangeRootPasswordResponse: + description: Responses message to the request for changing the root password + of a TiDB Serverless cluster. + type: object + v1beta1ClusterAutomatedBackupPolicy: + description: Message for automated backup configuration for a cluster. + properties: + startTime: + description: Optional. Cron expression for when automated backups should + start. + type: string + retentionDays: + description: Optional. Number of days to retain automated backups. + format: int32 + type: integer + type: object + v1beta1ClusterEncryptionConfig: + description: Message for encryption settings for a cluster. + properties: + enhancedEncryptionEnabled: + description: Optional. Whether enhanced encryption for cluster data is enabled. + type: boolean + type: object + v1beta1ClusterEndpoints: + description: Message for endpoint information for connecting to a cluster. + properties: + public: + allOf: + - $ref: '#/components/schemas/EndpointsPublic' + description: Optional. Public endpoint to connect to the cluster. + type: object + private: + allOf: + - $ref: '#/components/schemas/EndpointsPrivate' + description: Output_only. Private endpoint to securely connect to the cluster. + type: object + type: object + v1beta1ClusterUsage: + description: Message for usage statistics of a cluster. + properties: + requestUnit: + description: Output_only. The Request Units used in this month. + format: int64 + readOnly: true + type: string + rowBasedStorage: + description: Output_only. The storage used on row-based storage in bytes. + format: double + readOnly: true + type: number + columnarStorage: + description: Output_only. The storage used on column-based storage in bytes. + format: double + readOnly: true + type: number + type: object + v1beta1PartialUpdateClusterRequestPartialUpdateCluster: + properties: + clusterId: + description: Output_only. The unique ID of the cluster. + type: string + displayName: + description: Required. User friendly display name of the cluster. + type: string + spendingLimit: + allOf: + - $ref: '#/components/schemas/ClusterSpendingLimit' + description: Optional. The spending limit for the cluster. + type: object + automatedBackupPolicy: + allOf: + - $ref: '#/components/schemas/v1beta1ClusterAutomatedBackupPolicy' + description: Optional. Automated backup policy to set on the cluster. + type: object + endpoints: + allOf: + - $ref: '#/components/schemas/v1beta1ClusterEndpoints' + description: Optional. The endpoints for connecting to the cluster. + type: object + labels: + additionalProperties: + type: string + description: |- + Optional. The labels for the cluster. + tidb.cloud/organization. The label for the cluster organization id. + tidb.cloud/project. The label for the cluster project id. + type: object + required: + - clusterId + type: object + v1beta1RegionCloudProvider: + description: |- + Enum of cloud provider names. + + - aws: Amazon Web Services. + buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE + - gcp: Google Cloud Platform. + buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE + - azure: Microsoft Azure. + buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE + enum: + - aws + - gcp + - azure + type: string + v1beta1ServerlessServicePartialUpdateClusterBody: + description: Message for requesting a partial update on a TiDB Serverless cluster. + properties: + cluster: + $ref: '#/components/schemas/Required__The_cluster_to_be_updated_' + updateMask: + description: Required. The update mask indicating which fields are to be + updated. + type: string + required: + - updateMask + type: object + Required__The_cluster_to_be_updated_: + description: Required. The cluster to be updated. + properties: + displayName: + description: Required. User friendly display name of the cluster. + type: string + spendingLimit: + allOf: + - $ref: '#/components/schemas/ClusterSpendingLimit' + description: Optional. The spending limit for the cluster. + type: object + automatedBackupPolicy: + allOf: + - $ref: '#/components/schemas/v1beta1ClusterAutomatedBackupPolicy' + description: Optional. Automated backup policy to set on the cluster. + type: object + endpoints: + allOf: + - $ref: '#/components/schemas/v1beta1ClusterEndpoints' + description: Optional. The endpoints for connecting to the cluster. + type: object + labels: + additionalProperties: + type: string + description: |- + Optional. The labels for the cluster. + tidb.cloud/organization. The label for the cluster organization id. + tidb.cloud/project. The label for the cluster project id. + type: object + title: Required. The cluster to be updated. + type: object +x-original-swagger-version: "2.0" diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/api_serverless_service.go b/pkg/tidbcloud/v1beta1/serverless/cluster/api_serverless_service.go new file mode 100644 index 00000000..75539735 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/api_serverless_service.go @@ -0,0 +1,875 @@ +/* +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 cluster + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" + "strings" +) + +// ServerlessServiceAPIService ServerlessServiceAPI service +type ServerlessServiceAPIService service + +type ApiServerlessServiceChangeRootPasswordRequest struct { + ctx context.Context + ApiService *ServerlessServiceAPIService + clusterId string + body *ServerlessServiceChangeRootPasswordBody +} + +func (r ApiServerlessServiceChangeRootPasswordRequest) Body(body ServerlessServiceChangeRootPasswordBody) ApiServerlessServiceChangeRootPasswordRequest { + r.body = &body + return r +} + +func (r ApiServerlessServiceChangeRootPasswordRequest) Execute() (map[string]interface{}, *http.Response, error) { + return r.ApiService.ServerlessServiceChangeRootPasswordExecute(r) +} + +/* +ServerlessServiceChangeRootPassword Changes the root password of a specific TiDB Serverless cluster. + + @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 cluster for which the password is to be changed. + @return ApiServerlessServiceChangeRootPasswordRequest +*/ +func (a *ServerlessServiceAPIService) ServerlessServiceChangeRootPassword(ctx context.Context, clusterId string) ApiServerlessServiceChangeRootPasswordRequest { + return ApiServerlessServiceChangeRootPasswordRequest{ + ApiService: a, + ctx: ctx, + clusterId: clusterId, + } +} + +// Execute executes the request +// +// @return map[string]interface{} +func (a *ServerlessServiceAPIService) ServerlessServiceChangeRootPasswordExecute(r ApiServerlessServiceChangeRootPasswordRequest) (map[string]interface{}, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPut + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue map[string]interface{} + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ServerlessServiceAPIService.ServerlessServiceChangeRootPassword") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/clusters/{clusterId}/password" + 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.body == nil { + return localVarReturnValue, nil, reportError("body 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.body + 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 GooglerpcStatus + 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 ApiServerlessServiceCreateClusterRequest struct { + ctx context.Context + ApiService *ServerlessServiceAPIService + cluster *TidbCloudOpenApiserverlessv1beta1Cluster +} + +// Required. The cluster to be created. +func (r ApiServerlessServiceCreateClusterRequest) Cluster(cluster TidbCloudOpenApiserverlessv1beta1Cluster) ApiServerlessServiceCreateClusterRequest { + r.cluster = &cluster + return r +} + +func (r ApiServerlessServiceCreateClusterRequest) Execute() (*TidbCloudOpenApiserverlessv1beta1Cluster, *http.Response, error) { + return r.ApiService.ServerlessServiceCreateClusterExecute(r) +} + +/* +ServerlessServiceCreateCluster Creates a new TiDB Serverless cluster. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiServerlessServiceCreateClusterRequest +*/ +func (a *ServerlessServiceAPIService) ServerlessServiceCreateCluster(ctx context.Context) ApiServerlessServiceCreateClusterRequest { + return ApiServerlessServiceCreateClusterRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// +// @return TidbCloudOpenApiserverlessv1beta1Cluster +func (a *ServerlessServiceAPIService) ServerlessServiceCreateClusterExecute(r ApiServerlessServiceCreateClusterRequest) (*TidbCloudOpenApiserverlessv1beta1Cluster, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *TidbCloudOpenApiserverlessv1beta1Cluster + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ServerlessServiceAPIService.ServerlessServiceCreateCluster") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/clusters" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.cluster == nil { + return localVarReturnValue, nil, reportError("cluster 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.cluster + 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 GooglerpcStatus + 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 ApiServerlessServiceDeleteClusterRequest struct { + ctx context.Context + ApiService *ServerlessServiceAPIService + clusterId string +} + +func (r ApiServerlessServiceDeleteClusterRequest) Execute() (*TidbCloudOpenApiserverlessv1beta1Cluster, *http.Response, error) { + return r.ApiService.ServerlessServiceDeleteClusterExecute(r) +} + +/* +ServerlessServiceDeleteCluster Deletes a specific TiDB Serverless cluster. + + @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 cluster to be deleted. + @return ApiServerlessServiceDeleteClusterRequest +*/ +func (a *ServerlessServiceAPIService) ServerlessServiceDeleteCluster(ctx context.Context, clusterId string) ApiServerlessServiceDeleteClusterRequest { + return ApiServerlessServiceDeleteClusterRequest{ + ApiService: a, + ctx: ctx, + clusterId: clusterId, + } +} + +// Execute executes the request +// +// @return TidbCloudOpenApiserverlessv1beta1Cluster +func (a *ServerlessServiceAPIService) ServerlessServiceDeleteClusterExecute(r ApiServerlessServiceDeleteClusterRequest) (*TidbCloudOpenApiserverlessv1beta1Cluster, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *TidbCloudOpenApiserverlessv1beta1Cluster + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ServerlessServiceAPIService.ServerlessServiceDeleteCluster") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/clusters/{clusterId}" + localVarPath = strings.Replace(localVarPath, "{"+"clusterId"+"}", url.PathEscape(parameterValueToString(r.clusterId, "clusterId")), -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 GooglerpcStatus + 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 ApiServerlessServiceGetClusterRequest struct { + ctx context.Context + ApiService *ServerlessServiceAPIService + clusterId string + view *string +} + +// Optional. The level of detail to return for the cluster. - BASIC: Only basic information about the cluster is returned. - FULL: All details about the cluster are returned. +func (r ApiServerlessServiceGetClusterRequest) View(view string) ApiServerlessServiceGetClusterRequest { + r.view = &view + return r +} + +func (r ApiServerlessServiceGetClusterRequest) Execute() (*TidbCloudOpenApiserverlessv1beta1Cluster, *http.Response, error) { + return r.ApiService.ServerlessServiceGetClusterExecute(r) +} + +/* +ServerlessServiceGetCluster Retrieves details of a specific TiDB Serverless cluster. + + @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 cluster to be retrieved. + @return ApiServerlessServiceGetClusterRequest +*/ +func (a *ServerlessServiceAPIService) ServerlessServiceGetCluster(ctx context.Context, clusterId string) ApiServerlessServiceGetClusterRequest { + return ApiServerlessServiceGetClusterRequest{ + ApiService: a, + ctx: ctx, + clusterId: clusterId, + } +} + +// Execute executes the request +// +// @return TidbCloudOpenApiserverlessv1beta1Cluster +func (a *ServerlessServiceAPIService) ServerlessServiceGetClusterExecute(r ApiServerlessServiceGetClusterRequest) (*TidbCloudOpenApiserverlessv1beta1Cluster, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *TidbCloudOpenApiserverlessv1beta1Cluster + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ServerlessServiceAPIService.ServerlessServiceGetCluster") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/clusters/{clusterId}" + 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.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 GooglerpcStatus + 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 ApiServerlessServiceListClustersRequest struct { + ctx context.Context + ApiService *ServerlessServiceAPIService + pageSize *int32 + pageToken *string + filter *string + orderBy *string + skip *int32 +} + +// Optional. The maximum number of clusters to return. +func (r ApiServerlessServiceListClustersRequest) PageSize(pageSize int32) ApiServerlessServiceListClustersRequest { + r.pageSize = &pageSize + return r +} + +// Optional. The page token from the previous response for pagination. +func (r ApiServerlessServiceListClustersRequest) PageToken(pageToken string) ApiServerlessServiceListClustersRequest { + r.pageToken = &pageToken + return r +} + +// Optional. The filter expression to filter clusters. +func (r ApiServerlessServiceListClustersRequest) Filter(filter string) ApiServerlessServiceListClustersRequest { + r.filter = &filter + return r +} + +// Optional. The order by expression for sorting clusters. +func (r ApiServerlessServiceListClustersRequest) OrderBy(orderBy string) ApiServerlessServiceListClustersRequest { + r.orderBy = &orderBy + return r +} + +// The number of individual resources to skip before starting to return results. If the skip value causes the cursor to move past the end of the collection, the response will be 200 OK with an empty result set and no next_page_token. +func (r ApiServerlessServiceListClustersRequest) Skip(skip int32) ApiServerlessServiceListClustersRequest { + r.skip = &skip + return r +} + +func (r ApiServerlessServiceListClustersRequest) Execute() (*TidbCloudOpenApiserverlessv1beta1ListClustersResponse, *http.Response, error) { + return r.ApiService.ServerlessServiceListClustersExecute(r) +} + +/* +ServerlessServiceListClusters Provides a list of TiDB Serverless clusters in a project. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiServerlessServiceListClustersRequest +*/ +func (a *ServerlessServiceAPIService) ServerlessServiceListClusters(ctx context.Context) ApiServerlessServiceListClustersRequest { + return ApiServerlessServiceListClustersRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// +// @return TidbCloudOpenApiserverlessv1beta1ListClustersResponse +func (a *ServerlessServiceAPIService) ServerlessServiceListClustersExecute(r ApiServerlessServiceListClustersRequest) (*TidbCloudOpenApiserverlessv1beta1ListClustersResponse, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *TidbCloudOpenApiserverlessv1beta1ListClustersResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ServerlessServiceAPIService.ServerlessServiceListClusters") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/clusters" + + 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, "", "") + } + if r.filter != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "filter", r.filter, "", "") + } + if r.orderBy != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "orderBy", r.orderBy, "", "") + } + if r.skip != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "skip", r.skip, "", "") + } + // 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 GooglerpcStatus + 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 ApiServerlessServiceListRegionsRequest struct { + ctx context.Context + ApiService *ServerlessServiceAPIService +} + +func (r ApiServerlessServiceListRegionsRequest) Execute() (*TidbCloudOpenApiserverlessv1beta1ListRegionsResponse, *http.Response, error) { + return r.ApiService.ServerlessServiceListRegionsExecute(r) +} + +/* +ServerlessServiceListRegions Provides a list of available regions for TiDB Serverless clusters. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiServerlessServiceListRegionsRequest +*/ +func (a *ServerlessServiceAPIService) ServerlessServiceListRegions(ctx context.Context) ApiServerlessServiceListRegionsRequest { + return ApiServerlessServiceListRegionsRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// +// @return TidbCloudOpenApiserverlessv1beta1ListRegionsResponse +func (a *ServerlessServiceAPIService) ServerlessServiceListRegionsExecute(r ApiServerlessServiceListRegionsRequest) (*TidbCloudOpenApiserverlessv1beta1ListRegionsResponse, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *TidbCloudOpenApiserverlessv1beta1ListRegionsResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ServerlessServiceAPIService.ServerlessServiceListRegions") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/regions" + + 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 GooglerpcStatus + 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 ApiServerlessServicePartialUpdateClusterRequest struct { + ctx context.Context + ApiService *ServerlessServiceAPIService + clusterClusterId string + body *V1beta1ServerlessServicePartialUpdateClusterBody +} + +func (r ApiServerlessServicePartialUpdateClusterRequest) Body(body V1beta1ServerlessServicePartialUpdateClusterBody) ApiServerlessServicePartialUpdateClusterRequest { + r.body = &body + return r +} + +func (r ApiServerlessServicePartialUpdateClusterRequest) Execute() (*TidbCloudOpenApiserverlessv1beta1Cluster, *http.Response, error) { + return r.ApiService.ServerlessServicePartialUpdateClusterExecute(r) +} + +/* +ServerlessServicePartialUpdateCluster Partially updates a specific TiDB Serverless cluster. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param clusterClusterId Output_only. The unique ID of the cluster. + @return ApiServerlessServicePartialUpdateClusterRequest +*/ +func (a *ServerlessServiceAPIService) ServerlessServicePartialUpdateCluster(ctx context.Context, clusterClusterId string) ApiServerlessServicePartialUpdateClusterRequest { + return ApiServerlessServicePartialUpdateClusterRequest{ + ApiService: a, + ctx: ctx, + clusterClusterId: clusterClusterId, + } +} + +// Execute executes the request +// +// @return TidbCloudOpenApiserverlessv1beta1Cluster +func (a *ServerlessServiceAPIService) ServerlessServicePartialUpdateClusterExecute(r ApiServerlessServicePartialUpdateClusterRequest) (*TidbCloudOpenApiserverlessv1beta1Cluster, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPatch + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *TidbCloudOpenApiserverlessv1beta1Cluster + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ServerlessServiceAPIService.ServerlessServicePartialUpdateCluster") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/clusters/{cluster.clusterId}" + localVarPath = strings.Replace(localVarPath, "{"+"cluster.clusterId"+"}", url.PathEscape(parameterValueToString(r.clusterClusterId, "clusterClusterId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.body == nil { + return localVarReturnValue, nil, reportError("body 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.body + 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 GooglerpcStatus + 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/cluster/client.go b/pkg/tidbcloud/v1beta1/serverless/cluster/client.go new file mode 100644 index 00000000..f23cea49 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/client.go @@ -0,0 +1,651 @@ +/* +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 cluster + +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 + + ServerlessServiceAPI *ServerlessServiceAPIService +} + +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.ServerlessServiceAPI = (*ServerlessServiceAPIService)(&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 < lenIndValue; i++ { + var arrayValue = indValue.Index(i) + var keyPrefixForCollectionType = keyPrefix + if style == "deepObject" { + keyPrefixForCollectionType = keyPrefix + "[" + strconv.Itoa(i) + "]" + } + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefixForCollectionType, arrayValue.Interface(), style, collectionType) + } + return + + case reflect.Map: + var indValue = reflect.ValueOf(obj) + if indValue == reflect.ValueOf(nil) { + return + } + iter := indValue.MapRange() + for iter.Next() { + k, v := iter.Key(), iter.Value() + parameterAddToHeaderOrQuery(headerOrQueryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface(), style, collectionType) + } + return + + case reflect.Interface: + fallthrough + case reflect.Ptr: + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, v.Elem().Interface(), style, collectionType) + return + + case reflect.Int, reflect.Int8, reflect.Int16, + reflect.Int32, reflect.Int64: + value = strconv.FormatInt(v.Int(), 10) + case reflect.Uint, reflect.Uint8, reflect.Uint16, + reflect.Uint32, reflect.Uint64, reflect.Uintptr: + value = strconv.FormatUint(v.Uint(), 10) + case reflect.Float32, reflect.Float64: + value = strconv.FormatFloat(v.Float(), 'g', -1, 32) + case reflect.Bool: + value = strconv.FormatBool(v.Bool()) + case reflect.String: + value = v.String() + default: + value = v.Type().String() + " value" + } + } + + switch valuesMap := headerOrQueryParams.(type) { + case url.Values: + if collectionType == "csv" && valuesMap.Get(keyPrefix) != "" { + valuesMap.Set(keyPrefix, valuesMap.Get(keyPrefix)+","+value) + } else { + valuesMap.Add(keyPrefix, value) + } + break + case map[string]string: + valuesMap[keyPrefix] = value + break + } +} + +// helper for converting interface{} parameters to json strings +func parameterToJson(obj interface{}) (string, error) { + jsonBuf, err := json.Marshal(obj) + if err != nil { + return "", err + } + return string(jsonBuf), err +} + +// callAPI do the request. +func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { + if c.cfg.Debug { + dump, err := httputil.DumpRequestOut(request, true) + if err != nil { + return nil, err + } + log.Printf("\n%s\n", string(dump)) + } + + resp, err := c.cfg.HTTPClient.Do(request) + if err != nil { + return resp, err + } + + if c.cfg.Debug { + dump, err := httputil.DumpResponse(resp, true) + if err != nil { + return resp, err + } + log.Printf("\n%s\n", string(dump)) + } + return resp, err +} + +// Allow modification of underlying config for alternate implementations and testing +// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior +func (c *APIClient) GetConfig() *Configuration { + return c.cfg +} + +type formFile struct { + fileBytes []byte + fileName string + formFileName string +} + +// prepareRequest build the request +func (c *APIClient) prepareRequest( + ctx context.Context, + path string, method string, + postBody interface{}, + headerParams map[string]string, + queryParams url.Values, + formParams url.Values, + formFiles []formFile) (localVarRequest *http.Request, err error) { + + var body *bytes.Buffer + + // Detect postBody type and post. + if postBody != nil { + contentType := headerParams["Content-Type"] + if contentType == "" { + contentType = detectContentType(postBody) + headerParams["Content-Type"] = contentType + } + + body, err = setBody(postBody, contentType) + if err != nil { + return nil, err + } + } + + // add form parameters and file if available. + if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 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/cluster/configuration.go b/pkg/tidbcloud/v1beta1/serverless/cluster/configuration.go new file mode 100644 index 00000000..82ed0644 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/configuration.go @@ -0,0 +1,214 @@ +/* +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 cluster + +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/v1beta1", + 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/cluster/git_push.sh b/pkg/tidbcloud/v1beta1/serverless/cluster/git_push.sh new file mode 100644 index 00000000..f53a75d4 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/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/cluster/model_cluster_spending_limit.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_cluster_spending_limit.go new file mode 100644 index 00000000..0b72f4b0 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_cluster_spending_limit.go @@ -0,0 +1,125 @@ +/* +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 cluster + +import ( + "encoding/json" +) + +// checks if the ClusterSpendingLimit type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ClusterSpendingLimit{} + +// ClusterSpendingLimit Message for spending limit configuration. +type ClusterSpendingLimit struct { + // Optional. Maximum monthly spending limit in USD cents. + Monthly *int32 `json:"monthly,omitempty"` +} + +// NewClusterSpendingLimit instantiates a new ClusterSpendingLimit 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 NewClusterSpendingLimit() *ClusterSpendingLimit { + this := ClusterSpendingLimit{} + return &this +} + +// NewClusterSpendingLimitWithDefaults instantiates a new ClusterSpendingLimit 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 NewClusterSpendingLimitWithDefaults() *ClusterSpendingLimit { + this := ClusterSpendingLimit{} + return &this +} + +// GetMonthly returns the Monthly field value if set, zero value otherwise. +func (o *ClusterSpendingLimit) GetMonthly() int32 { + if o == nil || IsNil(o.Monthly) { + var ret int32 + return ret + } + return *o.Monthly +} + +// GetMonthlyOk returns a tuple with the Monthly field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ClusterSpendingLimit) GetMonthlyOk() (*int32, bool) { + if o == nil || IsNil(o.Monthly) { + return nil, false + } + return o.Monthly, true +} + +// HasMonthly returns a boolean if a field has been set. +func (o *ClusterSpendingLimit) HasMonthly() bool { + if o != nil && !IsNil(o.Monthly) { + return true + } + + return false +} + +// SetMonthly gets a reference to the given int32 and assigns it to the Monthly field. +func (o *ClusterSpendingLimit) SetMonthly(v int32) { + o.Monthly = &v +} + +func (o ClusterSpendingLimit) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ClusterSpendingLimit) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Monthly) { + toSerialize["monthly"] = o.Monthly + } + return toSerialize, nil +} + +type NullableClusterSpendingLimit struct { + value *ClusterSpendingLimit + isSet bool +} + +func (v NullableClusterSpendingLimit) Get() *ClusterSpendingLimit { + return v.value +} + +func (v *NullableClusterSpendingLimit) Set(val *ClusterSpendingLimit) { + v.value = val + v.isSet = true +} + +func (v NullableClusterSpendingLimit) IsSet() bool { + return v.isSet +} + +func (v *NullableClusterSpendingLimit) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableClusterSpendingLimit(val *ClusterSpendingLimit) *NullableClusterSpendingLimit { + return &NullableClusterSpendingLimit{value: val, isSet: true} +} + +func (v NullableClusterSpendingLimit) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableClusterSpendingLimit) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_commonv1beta1_cluster_state.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_commonv1beta1_cluster_state.go new file mode 100644 index 00000000..dde953cb --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_commonv1beta1_cluster_state.go @@ -0,0 +1,132 @@ +/* +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 cluster + +import ( + "encoding/json" + "fmt" +) + +// Commonv1beta1ClusterState Enum of possible states of a cluster. - CREATING: Cluster is being created. - DELETING: Cluster is being deleted. - ACTIVE: Cluster is active for use. - RESTORING: Cluster data is being restored. - MAINTENANCE: Cluster is under maintenance. - DELETED: Cluster has been deleted. - INACTIVE: Cluster is not active, but not being deleted. - UPGRADING: Cluster is being updated. Only for Dedicated Cluster. - IMPORTING: Cluster is being imported. Only for Dedicated Cluster. - MODIFYING: Cluster is being modified. Only for Dedicated Cluster. - PAUSING: Cluster is being paused. Only for Dedicated Cluster. - PAUSED: Cluster is paused. Only for Dedicated Cluster. - RESUMING: Cluster is resuming. Only for Dedicated Cluster. +type Commonv1beta1ClusterState string + +// List of commonv1beta1ClusterState +const ( + COMMONV1BETA1CLUSTERSTATE_CREATING Commonv1beta1ClusterState = "CREATING" + COMMONV1BETA1CLUSTERSTATE_DELETING Commonv1beta1ClusterState = "DELETING" + COMMONV1BETA1CLUSTERSTATE_ACTIVE Commonv1beta1ClusterState = "ACTIVE" + COMMONV1BETA1CLUSTERSTATE_RESTORING Commonv1beta1ClusterState = "RESTORING" + COMMONV1BETA1CLUSTERSTATE_MAINTENANCE Commonv1beta1ClusterState = "MAINTENANCE" + COMMONV1BETA1CLUSTERSTATE_DELETED Commonv1beta1ClusterState = "DELETED" + COMMONV1BETA1CLUSTERSTATE_INACTIVE Commonv1beta1ClusterState = "INACTIVE" + COMMONV1BETA1CLUSTERSTATE_UPGRADING Commonv1beta1ClusterState = "UPGRADING" + COMMONV1BETA1CLUSTERSTATE_IMPORTING Commonv1beta1ClusterState = "IMPORTING" + COMMONV1BETA1CLUSTERSTATE_MODIFYING Commonv1beta1ClusterState = "MODIFYING" + COMMONV1BETA1CLUSTERSTATE_PAUSING Commonv1beta1ClusterState = "PAUSING" + COMMONV1BETA1CLUSTERSTATE_PAUSED Commonv1beta1ClusterState = "PAUSED" + COMMONV1BETA1CLUSTERSTATE_RESUMING Commonv1beta1ClusterState = "RESUMING" +) + +// All allowed values of Commonv1beta1ClusterState enum +var AllowedCommonv1beta1ClusterStateEnumValues = []Commonv1beta1ClusterState{ + "CREATING", + "DELETING", + "ACTIVE", + "RESTORING", + "MAINTENANCE", + "DELETED", + "INACTIVE", + "UPGRADING", + "IMPORTING", + "MODIFYING", + "PAUSING", + "PAUSED", + "RESUMING", +} + +func (v *Commonv1beta1ClusterState) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := Commonv1beta1ClusterState(value) + for _, existing := range AllowedCommonv1beta1ClusterStateEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid Commonv1beta1ClusterState", value) +} + +// NewCommonv1beta1ClusterStateFromValue returns a pointer to a valid Commonv1beta1ClusterState +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewCommonv1beta1ClusterStateFromValue(v string) (*Commonv1beta1ClusterState, error) { + ev := Commonv1beta1ClusterState(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for Commonv1beta1ClusterState: valid values are %v", v, AllowedCommonv1beta1ClusterStateEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v Commonv1beta1ClusterState) IsValid() bool { + for _, existing := range AllowedCommonv1beta1ClusterStateEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to commonv1beta1ClusterState value +func (v Commonv1beta1ClusterState) Ptr() *Commonv1beta1ClusterState { + return &v +} + +type NullableCommonv1beta1ClusterState struct { + value *Commonv1beta1ClusterState + isSet bool +} + +func (v NullableCommonv1beta1ClusterState) Get() *Commonv1beta1ClusterState { + return v.value +} + +func (v *NullableCommonv1beta1ClusterState) Set(val *Commonv1beta1ClusterState) { + v.value = val + v.isSet = true +} + +func (v NullableCommonv1beta1ClusterState) IsSet() bool { + return v.isSet +} + +func (v *NullableCommonv1beta1ClusterState) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCommonv1beta1ClusterState(val *Commonv1beta1ClusterState) *NullableCommonv1beta1ClusterState { + return &NullableCommonv1beta1ClusterState{value: val, isSet: true} +} + +func (v NullableCommonv1beta1ClusterState) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCommonv1beta1ClusterState) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_commonv1beta1_region.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_commonv1beta1_region.go new file mode 100644 index 00000000..361ed4f6 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_commonv1beta1_region.go @@ -0,0 +1,283 @@ +/* +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 cluster + +import ( + "encoding/json" +) + +// checks if the Commonv1beta1Region type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Commonv1beta1Region{} + +// Commonv1beta1Region A representation of a region for deploying TiDB clusters. +type Commonv1beta1Region struct { + Name *string `json:"name,omitempty" validate:"regexp=^regions\\/(aws|gcp|azure)-(.+)$"` + // Format: {cloud_provider}-{region_code} Region code: us-west-2, asia-east1. + RegionId *string `json:"regionId,omitempty"` + // The cloud provider for the region. + CloudProvider *V1beta1RegionCloudProvider `json:"cloudProvider,omitempty"` + // User-friendly display name of the region. + DisplayName *string `json:"displayName,omitempty"` + // Optional provider name for the region. Only used for serverless cluster. Deprecated. + Provider NullableString `json:"provider,omitempty"` +} + +// NewCommonv1beta1Region instantiates a new Commonv1beta1Region 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 NewCommonv1beta1Region() *Commonv1beta1Region { + this := Commonv1beta1Region{} + return &this +} + +// NewCommonv1beta1RegionWithDefaults instantiates a new Commonv1beta1Region 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 NewCommonv1beta1RegionWithDefaults() *Commonv1beta1Region { + this := Commonv1beta1Region{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *Commonv1beta1Region) 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 *Commonv1beta1Region) 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 *Commonv1beta1Region) 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 *Commonv1beta1Region) SetName(v string) { + o.Name = &v +} + +// GetRegionId returns the RegionId field value if set, zero value otherwise. +func (o *Commonv1beta1Region) GetRegionId() string { + if o == nil || IsNil(o.RegionId) { + var ret string + return ret + } + return *o.RegionId +} + +// GetRegionIdOk returns a tuple with the RegionId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Commonv1beta1Region) GetRegionIdOk() (*string, bool) { + if o == nil || IsNil(o.RegionId) { + return nil, false + } + return o.RegionId, true +} + +// HasRegionId returns a boolean if a field has been set. +func (o *Commonv1beta1Region) HasRegionId() bool { + if o != nil && !IsNil(o.RegionId) { + return true + } + + return false +} + +// SetRegionId gets a reference to the given string and assigns it to the RegionId field. +func (o *Commonv1beta1Region) SetRegionId(v string) { + o.RegionId = &v +} + +// GetCloudProvider returns the CloudProvider field value if set, zero value otherwise. +func (o *Commonv1beta1Region) GetCloudProvider() V1beta1RegionCloudProvider { + if o == nil || IsNil(o.CloudProvider) { + var ret V1beta1RegionCloudProvider + return ret + } + return *o.CloudProvider +} + +// GetCloudProviderOk returns a tuple with the CloudProvider field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Commonv1beta1Region) GetCloudProviderOk() (*V1beta1RegionCloudProvider, bool) { + if o == nil || IsNil(o.CloudProvider) { + return nil, false + } + return o.CloudProvider, true +} + +// HasCloudProvider returns a boolean if a field has been set. +func (o *Commonv1beta1Region) HasCloudProvider() bool { + if o != nil && !IsNil(o.CloudProvider) { + return true + } + + return false +} + +// SetCloudProvider gets a reference to the given V1beta1RegionCloudProvider and assigns it to the CloudProvider field. +func (o *Commonv1beta1Region) SetCloudProvider(v V1beta1RegionCloudProvider) { + o.CloudProvider = &v +} + +// GetDisplayName returns the DisplayName field value if set, zero value otherwise. +func (o *Commonv1beta1Region) GetDisplayName() string { + if o == nil || IsNil(o.DisplayName) { + var ret string + return ret + } + return *o.DisplayName +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Commonv1beta1Region) GetDisplayNameOk() (*string, bool) { + if o == nil || IsNil(o.DisplayName) { + return nil, false + } + return o.DisplayName, true +} + +// HasDisplayName returns a boolean if a field has been set. +func (o *Commonv1beta1Region) HasDisplayName() bool { + if o != nil && !IsNil(o.DisplayName) { + return true + } + + return false +} + +// SetDisplayName gets a reference to the given string and assigns it to the DisplayName field. +func (o *Commonv1beta1Region) SetDisplayName(v string) { + o.DisplayName = &v +} + +// GetProvider returns the Provider field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *Commonv1beta1Region) GetProvider() string { + if o == nil || IsNil(o.Provider.Get()) { + var ret string + return ret + } + return *o.Provider.Get() +} + +// GetProviderOk returns a tuple with the Provider 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 *Commonv1beta1Region) GetProviderOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Provider.Get(), o.Provider.IsSet() +} + +// HasProvider returns a boolean if a field has been set. +func (o *Commonv1beta1Region) HasProvider() bool { + if o != nil && o.Provider.IsSet() { + return true + } + + return false +} + +// SetProvider gets a reference to the given NullableString and assigns it to the Provider field. +func (o *Commonv1beta1Region) SetProvider(v string) { + o.Provider.Set(&v) +} + +// SetProviderNil sets the value for Provider to be an explicit nil +func (o *Commonv1beta1Region) SetProviderNil() { + o.Provider.Set(nil) +} + +// UnsetProvider ensures that no value is present for Provider, not even an explicit nil +func (o *Commonv1beta1Region) UnsetProvider() { + o.Provider.Unset() +} + +func (o Commonv1beta1Region) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Commonv1beta1Region) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.RegionId) { + toSerialize["regionId"] = o.RegionId + } + if !IsNil(o.CloudProvider) { + toSerialize["cloudProvider"] = o.CloudProvider + } + if !IsNil(o.DisplayName) { + toSerialize["displayName"] = o.DisplayName + } + if o.Provider.IsSet() { + toSerialize["provider"] = o.Provider.Get() + } + return toSerialize, nil +} + +type NullableCommonv1beta1Region struct { + value *Commonv1beta1Region + isSet bool +} + +func (v NullableCommonv1beta1Region) Get() *Commonv1beta1Region { + return v.value +} + +func (v *NullableCommonv1beta1Region) Set(val *Commonv1beta1Region) { + v.value = val + v.isSet = true +} + +func (v NullableCommonv1beta1Region) IsSet() bool { + return v.isSet +} + +func (v *NullableCommonv1beta1Region) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCommonv1beta1Region(val *Commonv1beta1Region) *NullableCommonv1beta1Region { + return &NullableCommonv1beta1Region{value: val, isSet: true} +} + +func (v NullableCommonv1beta1Region) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCommonv1beta1Region) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_endpoints_private.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_endpoints_private.go new file mode 100644 index 00000000..3b5370d4 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_endpoints_private.go @@ -0,0 +1,234 @@ +/* +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 cluster + +import ( + "encoding/json" +) + +// checks if the EndpointsPrivate type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &EndpointsPrivate{} + +// EndpointsPrivate Message for private endpoint to securely connect to the cluster. +type EndpointsPrivate struct { + // Output_only. The hostname of the private endpoint. + Host *string `json:"host,omitempty"` + // Output_only. The port of the private endpoint. + Port *int32 `json:"port,omitempty"` + Aws *PrivateAWS `json:"aws,omitempty"` + Gcp *PrivateGCP `json:"gcp,omitempty"` +} + +// NewEndpointsPrivate instantiates a new EndpointsPrivate 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 NewEndpointsPrivate() *EndpointsPrivate { + this := EndpointsPrivate{} + return &this +} + +// NewEndpointsPrivateWithDefaults instantiates a new EndpointsPrivate 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 NewEndpointsPrivateWithDefaults() *EndpointsPrivate { + this := EndpointsPrivate{} + return &this +} + +// GetHost returns the Host field value if set, zero value otherwise. +func (o *EndpointsPrivate) 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 *EndpointsPrivate) 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 *EndpointsPrivate) 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 *EndpointsPrivate) SetHost(v string) { + o.Host = &v +} + +// GetPort returns the Port field value if set, zero value otherwise. +func (o *EndpointsPrivate) 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 *EndpointsPrivate) 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 *EndpointsPrivate) 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 *EndpointsPrivate) SetPort(v int32) { + o.Port = &v +} + +// GetAws returns the Aws field value if set, zero value otherwise. +func (o *EndpointsPrivate) GetAws() PrivateAWS { + if o == nil || IsNil(o.Aws) { + var ret PrivateAWS + 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 *EndpointsPrivate) GetAwsOk() (*PrivateAWS, 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 *EndpointsPrivate) HasAws() bool { + if o != nil && !IsNil(o.Aws) { + return true + } + + return false +} + +// SetAws gets a reference to the given PrivateAWS and assigns it to the Aws field. +func (o *EndpointsPrivate) SetAws(v PrivateAWS) { + o.Aws = &v +} + +// GetGcp returns the Gcp field value if set, zero value otherwise. +func (o *EndpointsPrivate) GetGcp() PrivateGCP { + if o == nil || IsNil(o.Gcp) { + var ret PrivateGCP + 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 *EndpointsPrivate) GetGcpOk() (*PrivateGCP, 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 *EndpointsPrivate) HasGcp() bool { + if o != nil && !IsNil(o.Gcp) { + return true + } + + return false +} + +// SetGcp gets a reference to the given PrivateGCP and assigns it to the Gcp field. +func (o *EndpointsPrivate) SetGcp(v PrivateGCP) { + o.Gcp = &v +} + +func (o EndpointsPrivate) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o EndpointsPrivate) 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 NullableEndpointsPrivate struct { + value *EndpointsPrivate + isSet bool +} + +func (v NullableEndpointsPrivate) Get() *EndpointsPrivate { + return v.value +} + +func (v *NullableEndpointsPrivate) Set(val *EndpointsPrivate) { + v.value = val + v.isSet = true +} + +func (v NullableEndpointsPrivate) IsSet() bool { + return v.isSet +} + +func (v *NullableEndpointsPrivate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableEndpointsPrivate(val *EndpointsPrivate) *NullableEndpointsPrivate { + return &NullableEndpointsPrivate{value: val, isSet: true} +} + +func (v NullableEndpointsPrivate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableEndpointsPrivate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_endpoints_public.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_endpoints_public.go new file mode 100644 index 00000000..76156878 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_endpoints_public.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 cluster + +import ( + "encoding/json" +) + +// checks if the EndpointsPublic type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &EndpointsPublic{} + +// EndpointsPublic Message for public endpoint to connect to the cluster. +type EndpointsPublic struct { + // Output_only. The hostname of the public endpoint. + Host *string `json:"host,omitempty"` + // Output_only. The port of the public endpoint. + Port *int32 `json:"port,omitempty"` + // Optional. Whether the public endpoint is disabled. + Disabled *bool `json:"disabled,omitempty"` +} + +// NewEndpointsPublic instantiates a new EndpointsPublic 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 NewEndpointsPublic() *EndpointsPublic { + this := EndpointsPublic{} + return &this +} + +// NewEndpointsPublicWithDefaults instantiates a new EndpointsPublic 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 NewEndpointsPublicWithDefaults() *EndpointsPublic { + this := EndpointsPublic{} + return &this +} + +// GetHost returns the Host field value if set, zero value otherwise. +func (o *EndpointsPublic) 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 *EndpointsPublic) 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 *EndpointsPublic) 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 *EndpointsPublic) SetHost(v string) { + o.Host = &v +} + +// GetPort returns the Port field value if set, zero value otherwise. +func (o *EndpointsPublic) 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 *EndpointsPublic) 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 *EndpointsPublic) 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 *EndpointsPublic) SetPort(v int32) { + o.Port = &v +} + +// GetDisabled returns the Disabled field value if set, zero value otherwise. +func (o *EndpointsPublic) 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 *EndpointsPublic) 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 *EndpointsPublic) 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 *EndpointsPublic) SetDisabled(v bool) { + o.Disabled = &v +} + +func (o EndpointsPublic) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o EndpointsPublic) 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 NullableEndpointsPublic struct { + value *EndpointsPublic + isSet bool +} + +func (v NullableEndpointsPublic) Get() *EndpointsPublic { + return v.value +} + +func (v *NullableEndpointsPublic) Set(val *EndpointsPublic) { + v.value = val + v.isSet = true +} + +func (v NullableEndpointsPublic) IsSet() bool { + return v.isSet +} + +func (v *NullableEndpointsPublic) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableEndpointsPublic(val *EndpointsPublic) *NullableEndpointsPublic { + return &NullableEndpointsPublic{value: val, isSet: true} +} + +func (v NullableEndpointsPublic) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableEndpointsPublic) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_googlerpc_status.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_googlerpc_status.go new file mode 100644 index 00000000..3560795a --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_googlerpc_status.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 cluster + +import ( + "encoding/json" +) + +// checks if the GooglerpcStatus type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GooglerpcStatus{} + +// GooglerpcStatus The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). +type GooglerpcStatus struct { + // The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. + Code *int32 `json:"code,omitempty"` + // A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. + Message *string `json:"message,omitempty"` + // A list of messages that carry the error details. There is a common set of message types for APIs to use. + Details []ProtobufAny `json:"details,omitempty"` +} + +// NewGooglerpcStatus instantiates a new GooglerpcStatus 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 NewGooglerpcStatus() *GooglerpcStatus { + this := GooglerpcStatus{} + return &this +} + +// NewGooglerpcStatusWithDefaults instantiates a new GooglerpcStatus 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 NewGooglerpcStatusWithDefaults() *GooglerpcStatus { + this := GooglerpcStatus{} + return &this +} + +// GetCode returns the Code field value if set, zero value otherwise. +func (o *GooglerpcStatus) 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 *GooglerpcStatus) 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 *GooglerpcStatus) 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 *GooglerpcStatus) SetCode(v int32) { + o.Code = &v +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *GooglerpcStatus) 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 *GooglerpcStatus) 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 *GooglerpcStatus) 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 *GooglerpcStatus) SetMessage(v string) { + o.Message = &v +} + +// GetDetails returns the Details field value if set, zero value otherwise. +func (o *GooglerpcStatus) GetDetails() []ProtobufAny { + if o == nil || IsNil(o.Details) { + var ret []ProtobufAny + 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 *GooglerpcStatus) GetDetailsOk() ([]ProtobufAny, 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 *GooglerpcStatus) HasDetails() bool { + if o != nil && !IsNil(o.Details) { + return true + } + + return false +} + +// SetDetails gets a reference to the given []ProtobufAny and assigns it to the Details field. +func (o *GooglerpcStatus) SetDetails(v []ProtobufAny) { + o.Details = v +} + +func (o GooglerpcStatus) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o GooglerpcStatus) 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 NullableGooglerpcStatus struct { + value *GooglerpcStatus + isSet bool +} + +func (v NullableGooglerpcStatus) Get() *GooglerpcStatus { + return v.value +} + +func (v *NullableGooglerpcStatus) Set(val *GooglerpcStatus) { + v.value = val + v.isSet = true +} + +func (v NullableGooglerpcStatus) IsSet() bool { + return v.isSet +} + +func (v *NullableGooglerpcStatus) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGooglerpcStatus(val *GooglerpcStatus) *NullableGooglerpcStatus { + return &NullableGooglerpcStatus{value: val, isSet: true} +} + +func (v NullableGooglerpcStatus) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGooglerpcStatus) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_private_aws.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_private_aws.go new file mode 100644 index 00000000..b364799f --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_private_aws.go @@ -0,0 +1,162 @@ +/* +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 cluster + +import ( + "encoding/json" +) + +// checks if the PrivateAWS type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PrivateAWS{} + +// PrivateAWS Message for AWS PrivateLink information. +type PrivateAWS struct { + // Output_only. The AWS service name for private access. + ServiceName *string `json:"serviceName,omitempty"` + // Output_only. The availability zones that the service is available in. + AvailabilityZone []string `json:"availabilityZone,omitempty"` +} + +// NewPrivateAWS instantiates a new PrivateAWS 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 NewPrivateAWS() *PrivateAWS { + this := PrivateAWS{} + return &this +} + +// NewPrivateAWSWithDefaults instantiates a new PrivateAWS 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 NewPrivateAWSWithDefaults() *PrivateAWS { + this := PrivateAWS{} + return &this +} + +// GetServiceName returns the ServiceName field value if set, zero value otherwise. +func (o *PrivateAWS) 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 *PrivateAWS) 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 *PrivateAWS) 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 *PrivateAWS) SetServiceName(v string) { + o.ServiceName = &v +} + +// GetAvailabilityZone returns the AvailabilityZone field value if set, zero value otherwise. +func (o *PrivateAWS) 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 *PrivateAWS) 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 *PrivateAWS) 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 *PrivateAWS) SetAvailabilityZone(v []string) { + o.AvailabilityZone = v +} + +func (o PrivateAWS) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o PrivateAWS) 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 NullablePrivateAWS struct { + value *PrivateAWS + isSet bool +} + +func (v NullablePrivateAWS) Get() *PrivateAWS { + return v.value +} + +func (v *NullablePrivateAWS) Set(val *PrivateAWS) { + v.value = val + v.isSet = true +} + +func (v NullablePrivateAWS) IsSet() bool { + return v.isSet +} + +func (v *NullablePrivateAWS) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePrivateAWS(val *PrivateAWS) *NullablePrivateAWS { + return &NullablePrivateAWS{value: val, isSet: true} +} + +func (v NullablePrivateAWS) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePrivateAWS) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_private_gcp.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_private_gcp.go new file mode 100644 index 00000000..d10d6a22 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_private_gcp.go @@ -0,0 +1,125 @@ +/* +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 cluster + +import ( + "encoding/json" +) + +// checks if the PrivateGCP type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PrivateGCP{} + +// PrivateGCP Message for GCP Private Service information. +type PrivateGCP struct { + // Output_only. The target GCP service attachment name for private access. + ServiceAttachmentName *string `json:"serviceAttachmentName,omitempty"` +} + +// NewPrivateGCP instantiates a new PrivateGCP 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 NewPrivateGCP() *PrivateGCP { + this := PrivateGCP{} + return &this +} + +// NewPrivateGCPWithDefaults instantiates a new PrivateGCP 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 NewPrivateGCPWithDefaults() *PrivateGCP { + this := PrivateGCP{} + return &this +} + +// GetServiceAttachmentName returns the ServiceAttachmentName field value if set, zero value otherwise. +func (o *PrivateGCP) 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 *PrivateGCP) 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 *PrivateGCP) 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 *PrivateGCP) SetServiceAttachmentName(v string) { + o.ServiceAttachmentName = &v +} + +func (o PrivateGCP) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o PrivateGCP) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.ServiceAttachmentName) { + toSerialize["serviceAttachmentName"] = o.ServiceAttachmentName + } + return toSerialize, nil +} + +type NullablePrivateGCP struct { + value *PrivateGCP + isSet bool +} + +func (v NullablePrivateGCP) Get() *PrivateGCP { + return v.value +} + +func (v *NullablePrivateGCP) Set(val *PrivateGCP) { + v.value = val + v.isSet = true +} + +func (v NullablePrivateGCP) IsSet() bool { + return v.isSet +} + +func (v *NullablePrivateGCP) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePrivateGCP(val *PrivateGCP) *NullablePrivateGCP { + return &NullablePrivateGCP{value: val, isSet: true} +} + +func (v NullablePrivateGCP) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePrivateGCP) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_protobuf_any.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_protobuf_any.go new file mode 100644 index 00000000..a1d92ff8 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_protobuf_any.go @@ -0,0 +1,154 @@ +/* +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 cluster + +import ( + "encoding/json" +) + +// checks if the ProtobufAny type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ProtobufAny{} + +// ProtobufAny `Any` contains an arbitrary serialized protocol buffer message along with a URL that describes the type of the serialized message. Protobuf library provides support to pack/unpack Any values in the form of utility functions or additional generated methods of the Any type. Example 1: Pack and unpack a message in C++. Foo foo = ...; Any any; any.PackFrom(foo); ... if (any.UnpackTo(&foo)) { ... } Example 2: Pack and unpack a message in Java. Foo foo = ...; Any any = Any.pack(foo); ... if (any.is(Foo.class)) { foo = any.unpack(Foo.class); } // or ... if (any.isSameTypeAs(Foo.getDefaultInstance())) { foo = any.unpack(Foo.getDefaultInstance()); } Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() any.Pack(foo) ... if any.Is(Foo.DESCRIPTOR): any.Unpack(foo) ... Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) if err != nil { ... } ... foo := &pb.Foo{} if err := any.UnmarshalTo(foo); err != nil { ... } The pack methods provided by protobuf library will by default use 'type.googleapis.com/full.type.name' as the type URL and the unpack methods only use the fully qualified type name after the last '/' in the type URL, for example \"foo.bar.com/x/y.z\" will yield type name \"y.z\". JSON ==== The JSON representation of an `Any` value uses the regular representation of the deserialized, embedded message, with an additional field `@type` which contains the type URL. Example: package google.profile; message Person { string first_name = 1; string last_name = 2; } { \"@type\": \"type.googleapis.com/google.profile.Person\", \"firstName\": , \"lastName\": } If the embedded message type is well-known and has a custom JSON representation, that representation will be embedded adding a field `value` which holds the custom JSON in addition to the `@type` field. Example (for message [google.protobuf.Duration][]): { \"@type\": \"type.googleapis.com/google.protobuf.Duration\", \"value\": \"1.212s\" } +type ProtobufAny struct { + // A URL/resource name that uniquely identifies the type of the serialized protocol buffer message. This string must contain at least one \"/\" character. The last segment of the URL's path must represent the fully qualified name of the type (as in `path/google.protobuf.Duration`). The name should be in a canonical form (e.g., leading \".\" is not accepted). In practice, teams usually precompile into the binary all types that they expect it to use in the context of Any. However, for URLs which use the scheme `http`, `https`, or no scheme, one can optionally set up a type server that maps type URLs to message definitions as follows: * If no scheme is provided, `https` is assumed. * An HTTP GET on the URL must yield a [google.protobuf.Type][] value in binary format, or produce an error. * Applications are allowed to cache lookup results based on the URL, or have them precompiled into a binary to avoid any lookup. Therefore, binary compatibility needs to be preserved on changes to types. (Use versioned type names to manage breaking changes.) Note: this functionality is not currently available in the official protobuf release, and it is not used for type URLs beginning with type.googleapis.com. As of May 2023, there are no widely used type server implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) might be used with implementation specific semantics. + Type *string `json:"@type,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _ProtobufAny ProtobufAny + +// NewProtobufAny instantiates a new ProtobufAny 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 NewProtobufAny() *ProtobufAny { + this := ProtobufAny{} + return &this +} + +// NewProtobufAnyWithDefaults instantiates a new ProtobufAny 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 NewProtobufAnyWithDefaults() *ProtobufAny { + this := ProtobufAny{} + return &this +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *ProtobufAny) 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 *ProtobufAny) 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 *ProtobufAny) 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 *ProtobufAny) SetType(v string) { + o.Type = &v +} + +func (o ProtobufAny) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ProtobufAny) 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 *ProtobufAny) UnmarshalJSON(data []byte) (err error) { + varProtobufAny := _ProtobufAny{} + + err = json.Unmarshal(data, &varProtobufAny) + + if err != nil { + return err + } + + *o = ProtobufAny(varProtobufAny) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "@type") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableProtobufAny struct { + value *ProtobufAny + isSet bool +} + +func (v NullableProtobufAny) Get() *ProtobufAny { + return v.value +} + +func (v *NullableProtobufAny) Set(val *ProtobufAny) { + v.value = val + v.isSet = true +} + +func (v NullableProtobufAny) IsSet() bool { + return v.isSet +} + +func (v *NullableProtobufAny) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableProtobufAny(val *ProtobufAny) *NullableProtobufAny { + return &NullableProtobufAny{value: val, isSet: true} +} + +func (v NullableProtobufAny) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableProtobufAny) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_required__the_cluster_to_be_updated_.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_required__the_cluster_to_be_updated_.go new file mode 100644 index 00000000..49c69ac5 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_required__the_cluster_to_be_updated_.go @@ -0,0 +1,273 @@ +/* +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 cluster + +import ( + "encoding/json" +) + +// checks if the RequiredTheClusterToBeUpdated type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &RequiredTheClusterToBeUpdated{} + +// RequiredTheClusterToBeUpdated Required. The cluster to be updated. +type RequiredTheClusterToBeUpdated struct { + // Required. User friendly display name of the cluster. + DisplayName *string `json:"displayName,omitempty"` + // Optional. The spending limit for the cluster. + SpendingLimit *ClusterSpendingLimit `json:"spendingLimit,omitempty"` + // Optional. Automated backup policy to set on the cluster. + AutomatedBackupPolicy *V1beta1ClusterAutomatedBackupPolicy `json:"automatedBackupPolicy,omitempty"` + // Optional. The endpoints for connecting to the cluster. + Endpoints *V1beta1ClusterEndpoints `json:"endpoints,omitempty"` + // Optional. The labels for the cluster. tidb.cloud/organization. The label for the cluster organization id. tidb.cloud/project. The label for the cluster project id. + Labels *map[string]string `json:"labels,omitempty"` +} + +// NewRequiredTheClusterToBeUpdated instantiates a new RequiredTheClusterToBeUpdated 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 NewRequiredTheClusterToBeUpdated() *RequiredTheClusterToBeUpdated { + this := RequiredTheClusterToBeUpdated{} + return &this +} + +// NewRequiredTheClusterToBeUpdatedWithDefaults instantiates a new RequiredTheClusterToBeUpdated 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 NewRequiredTheClusterToBeUpdatedWithDefaults() *RequiredTheClusterToBeUpdated { + this := RequiredTheClusterToBeUpdated{} + return &this +} + +// GetDisplayName returns the DisplayName field value if set, zero value otherwise. +func (o *RequiredTheClusterToBeUpdated) GetDisplayName() string { + if o == nil || IsNil(o.DisplayName) { + var ret string + return ret + } + return *o.DisplayName +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RequiredTheClusterToBeUpdated) GetDisplayNameOk() (*string, bool) { + if o == nil || IsNil(o.DisplayName) { + return nil, false + } + return o.DisplayName, true +} + +// HasDisplayName returns a boolean if a field has been set. +func (o *RequiredTheClusterToBeUpdated) HasDisplayName() bool { + if o != nil && !IsNil(o.DisplayName) { + return true + } + + return false +} + +// SetDisplayName gets a reference to the given string and assigns it to the DisplayName field. +func (o *RequiredTheClusterToBeUpdated) SetDisplayName(v string) { + o.DisplayName = &v +} + +// GetSpendingLimit returns the SpendingLimit field value if set, zero value otherwise. +func (o *RequiredTheClusterToBeUpdated) GetSpendingLimit() ClusterSpendingLimit { + if o == nil || IsNil(o.SpendingLimit) { + var ret ClusterSpendingLimit + return ret + } + return *o.SpendingLimit +} + +// GetSpendingLimitOk returns a tuple with the SpendingLimit field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RequiredTheClusterToBeUpdated) GetSpendingLimitOk() (*ClusterSpendingLimit, bool) { + if o == nil || IsNil(o.SpendingLimit) { + return nil, false + } + return o.SpendingLimit, true +} + +// HasSpendingLimit returns a boolean if a field has been set. +func (o *RequiredTheClusterToBeUpdated) HasSpendingLimit() bool { + if o != nil && !IsNil(o.SpendingLimit) { + return true + } + + return false +} + +// SetSpendingLimit gets a reference to the given ClusterSpendingLimit and assigns it to the SpendingLimit field. +func (o *RequiredTheClusterToBeUpdated) SetSpendingLimit(v ClusterSpendingLimit) { + o.SpendingLimit = &v +} + +// GetAutomatedBackupPolicy returns the AutomatedBackupPolicy field value if set, zero value otherwise. +func (o *RequiredTheClusterToBeUpdated) GetAutomatedBackupPolicy() V1beta1ClusterAutomatedBackupPolicy { + if o == nil || IsNil(o.AutomatedBackupPolicy) { + var ret V1beta1ClusterAutomatedBackupPolicy + return ret + } + return *o.AutomatedBackupPolicy +} + +// GetAutomatedBackupPolicyOk returns a tuple with the AutomatedBackupPolicy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RequiredTheClusterToBeUpdated) GetAutomatedBackupPolicyOk() (*V1beta1ClusterAutomatedBackupPolicy, bool) { + if o == nil || IsNil(o.AutomatedBackupPolicy) { + return nil, false + } + return o.AutomatedBackupPolicy, true +} + +// HasAutomatedBackupPolicy returns a boolean if a field has been set. +func (o *RequiredTheClusterToBeUpdated) HasAutomatedBackupPolicy() bool { + if o != nil && !IsNil(o.AutomatedBackupPolicy) { + return true + } + + return false +} + +// SetAutomatedBackupPolicy gets a reference to the given V1beta1ClusterAutomatedBackupPolicy and assigns it to the AutomatedBackupPolicy field. +func (o *RequiredTheClusterToBeUpdated) SetAutomatedBackupPolicy(v V1beta1ClusterAutomatedBackupPolicy) { + o.AutomatedBackupPolicy = &v +} + +// GetEndpoints returns the Endpoints field value if set, zero value otherwise. +func (o *RequiredTheClusterToBeUpdated) GetEndpoints() V1beta1ClusterEndpoints { + if o == nil || IsNil(o.Endpoints) { + var ret V1beta1ClusterEndpoints + 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 *RequiredTheClusterToBeUpdated) GetEndpointsOk() (*V1beta1ClusterEndpoints, 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 *RequiredTheClusterToBeUpdated) HasEndpoints() bool { + if o != nil && !IsNil(o.Endpoints) { + return true + } + + return false +} + +// SetEndpoints gets a reference to the given V1beta1ClusterEndpoints and assigns it to the Endpoints field. +func (o *RequiredTheClusterToBeUpdated) SetEndpoints(v V1beta1ClusterEndpoints) { + o.Endpoints = &v +} + +// GetLabels returns the Labels field value if set, zero value otherwise. +func (o *RequiredTheClusterToBeUpdated) GetLabels() map[string]string { + if o == nil || IsNil(o.Labels) { + var ret map[string]string + return ret + } + return *o.Labels +} + +// GetLabelsOk returns a tuple with the Labels field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RequiredTheClusterToBeUpdated) GetLabelsOk() (*map[string]string, bool) { + if o == nil || IsNil(o.Labels) { + return nil, false + } + return o.Labels, true +} + +// HasLabels returns a boolean if a field has been set. +func (o *RequiredTheClusterToBeUpdated) HasLabels() bool { + if o != nil && !IsNil(o.Labels) { + return true + } + + return false +} + +// SetLabels gets a reference to the given map[string]string and assigns it to the Labels field. +func (o *RequiredTheClusterToBeUpdated) SetLabels(v map[string]string) { + o.Labels = &v +} + +func (o RequiredTheClusterToBeUpdated) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o RequiredTheClusterToBeUpdated) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.DisplayName) { + toSerialize["displayName"] = o.DisplayName + } + if !IsNil(o.SpendingLimit) { + toSerialize["spendingLimit"] = o.SpendingLimit + } + if !IsNil(o.AutomatedBackupPolicy) { + toSerialize["automatedBackupPolicy"] = o.AutomatedBackupPolicy + } + if !IsNil(o.Endpoints) { + toSerialize["endpoints"] = o.Endpoints + } + if !IsNil(o.Labels) { + toSerialize["labels"] = o.Labels + } + return toSerialize, nil +} + +type NullableRequiredTheClusterToBeUpdated struct { + value *RequiredTheClusterToBeUpdated + isSet bool +} + +func (v NullableRequiredTheClusterToBeUpdated) Get() *RequiredTheClusterToBeUpdated { + return v.value +} + +func (v *NullableRequiredTheClusterToBeUpdated) Set(val *RequiredTheClusterToBeUpdated) { + v.value = val + v.isSet = true +} + +func (v NullableRequiredTheClusterToBeUpdated) IsSet() bool { + return v.isSet +} + +func (v *NullableRequiredTheClusterToBeUpdated) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRequiredTheClusterToBeUpdated(val *RequiredTheClusterToBeUpdated) *NullableRequiredTheClusterToBeUpdated { + return &NullableRequiredTheClusterToBeUpdated{value: val, isSet: true} +} + +func (v NullableRequiredTheClusterToBeUpdated) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRequiredTheClusterToBeUpdated) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_serverless_service_change_root_password_body.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_serverless_service_change_root_password_body.go new file mode 100644 index 00000000..f7016df6 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_serverless_service_change_root_password_body.go @@ -0,0 +1,157 @@ +/* +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 cluster + +import ( + "bytes" + "encoding/json" + "fmt" +) + +// checks if the ServerlessServiceChangeRootPasswordBody type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ServerlessServiceChangeRootPasswordBody{} + +// ServerlessServiceChangeRootPasswordBody Message for requesting to change the root password of a TiDB Serverless cluster. +type ServerlessServiceChangeRootPasswordBody struct { + // Required. The new root password for the cluster. + Password string `json:"password"` +} + +type _ServerlessServiceChangeRootPasswordBody ServerlessServiceChangeRootPasswordBody + +// NewServerlessServiceChangeRootPasswordBody instantiates a new ServerlessServiceChangeRootPasswordBody 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 NewServerlessServiceChangeRootPasswordBody(password string) *ServerlessServiceChangeRootPasswordBody { + this := ServerlessServiceChangeRootPasswordBody{} + this.Password = password + return &this +} + +// NewServerlessServiceChangeRootPasswordBodyWithDefaults instantiates a new ServerlessServiceChangeRootPasswordBody 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 NewServerlessServiceChangeRootPasswordBodyWithDefaults() *ServerlessServiceChangeRootPasswordBody { + this := ServerlessServiceChangeRootPasswordBody{} + return &this +} + +// GetPassword returns the Password field value +func (o *ServerlessServiceChangeRootPasswordBody) GetPassword() string { + if o == nil { + var ret string + return ret + } + + return o.Password +} + +// GetPasswordOk returns a tuple with the Password field value +// and a boolean to check if the value has been set. +func (o *ServerlessServiceChangeRootPasswordBody) GetPasswordOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Password, true +} + +// SetPassword sets field value +func (o *ServerlessServiceChangeRootPasswordBody) SetPassword(v string) { + o.Password = v +} + +func (o ServerlessServiceChangeRootPasswordBody) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ServerlessServiceChangeRootPasswordBody) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["password"] = o.Password + return toSerialize, nil +} + +func (o *ServerlessServiceChangeRootPasswordBody) 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{ + "password", + } + + 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) + } + } + + varServerlessServiceChangeRootPasswordBody := _ServerlessServiceChangeRootPasswordBody{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varServerlessServiceChangeRootPasswordBody) + + if err != nil { + return err + } + + *o = ServerlessServiceChangeRootPasswordBody(varServerlessServiceChangeRootPasswordBody) + + return err +} + +type NullableServerlessServiceChangeRootPasswordBody struct { + value *ServerlessServiceChangeRootPasswordBody + isSet bool +} + +func (v NullableServerlessServiceChangeRootPasswordBody) Get() *ServerlessServiceChangeRootPasswordBody { + return v.value +} + +func (v *NullableServerlessServiceChangeRootPasswordBody) Set(val *ServerlessServiceChangeRootPasswordBody) { + v.value = val + v.isSet = true +} + +func (v NullableServerlessServiceChangeRootPasswordBody) IsSet() bool { + return v.isSet +} + +func (v *NullableServerlessServiceChangeRootPasswordBody) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableServerlessServiceChangeRootPasswordBody(val *ServerlessServiceChangeRootPasswordBody) *NullableServerlessServiceChangeRootPasswordBody { + return &NullableServerlessServiceChangeRootPasswordBody{value: val, isSet: true} +} + +func (v NullableServerlessServiceChangeRootPasswordBody) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableServerlessServiceChangeRootPasswordBody) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_serverlessv1beta1_cluster_view.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_serverlessv1beta1_cluster_view.go new file mode 100644 index 00000000..78ff419a --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_serverlessv1beta1_cluster_view.go @@ -0,0 +1,110 @@ +/* +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 cluster + +import ( + "encoding/json" + "fmt" +) + +// Serverlessv1beta1ClusterView Enum for the different types of detail view to be returned for a TiDB Serverless cluster. - BASIC: Only basic information about the cluster is returned. - FULL: All details about the cluster are returned. +type Serverlessv1beta1ClusterView string + +// List of serverlessv1beta1ClusterView +const ( + SERVERLESSV1BETA1CLUSTERVIEW_BASIC Serverlessv1beta1ClusterView = "BASIC" + SERVERLESSV1BETA1CLUSTERVIEW_FULL Serverlessv1beta1ClusterView = "FULL" +) + +// All allowed values of Serverlessv1beta1ClusterView enum +var AllowedServerlessv1beta1ClusterViewEnumValues = []Serverlessv1beta1ClusterView{ + "BASIC", + "FULL", +} + +func (v *Serverlessv1beta1ClusterView) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := Serverlessv1beta1ClusterView(value) + for _, existing := range AllowedServerlessv1beta1ClusterViewEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid Serverlessv1beta1ClusterView", value) +} + +// NewServerlessv1beta1ClusterViewFromValue returns a pointer to a valid Serverlessv1beta1ClusterView +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewServerlessv1beta1ClusterViewFromValue(v string) (*Serverlessv1beta1ClusterView, error) { + ev := Serverlessv1beta1ClusterView(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for Serverlessv1beta1ClusterView: valid values are %v", v, AllowedServerlessv1beta1ClusterViewEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v Serverlessv1beta1ClusterView) IsValid() bool { + for _, existing := range AllowedServerlessv1beta1ClusterViewEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to serverlessv1beta1ClusterView value +func (v Serverlessv1beta1ClusterView) Ptr() *Serverlessv1beta1ClusterView { + return &v +} + +type NullableServerlessv1beta1ClusterView struct { + value *Serverlessv1beta1ClusterView + isSet bool +} + +func (v NullableServerlessv1beta1ClusterView) Get() *Serverlessv1beta1ClusterView { + return v.value +} + +func (v *NullableServerlessv1beta1ClusterView) Set(val *Serverlessv1beta1ClusterView) { + v.value = val + v.isSet = true +} + +func (v NullableServerlessv1beta1ClusterView) IsSet() bool { + return v.isSet +} + +func (v *NullableServerlessv1beta1ClusterView) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableServerlessv1beta1ClusterView(val *Serverlessv1beta1ClusterView) *NullableServerlessv1beta1ClusterView { + return &NullableServerlessv1beta1ClusterView{value: val, isSet: true} +} + +func (v NullableServerlessv1beta1ClusterView) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableServerlessv1beta1ClusterView) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_cluster.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_cluster.go new file mode 100644 index 00000000..18ab835b --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_cluster.go @@ -0,0 +1,742 @@ +/* +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 cluster + +import ( + "bytes" + "encoding/json" + "fmt" + "time" +) + +// checks if the TidbCloudOpenApiserverlessv1beta1Cluster type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &TidbCloudOpenApiserverlessv1beta1Cluster{} + +// TidbCloudOpenApiserverlessv1beta1Cluster Message for a serverless TiDB cluster resource. +type TidbCloudOpenApiserverlessv1beta1Cluster struct { + // Output_only. The unique name of the cluster. + Name *string `json:"name,omitempty"` + // Output_only. The unique ID of the cluster. + ClusterId *string `json:"clusterId,omitempty"` + // Required. User friendly display name of the cluster. + DisplayName string `json:"displayName"` + // Required. Region where the cluster will be created. + Region Commonv1beta1Region `json:"region"` + // Optional. The spending limit for the cluster. + SpendingLimit *ClusterSpendingLimit `json:"spendingLimit,omitempty"` + // Output_only. The TiDB version of the cluster. + Version *string `json:"version,omitempty"` + // Output_only. The email of the creator of the cluster. + CreatedBy *string `json:"createdBy,omitempty"` + // Optional. Automated backup policy to set on the cluster. + AutomatedBackupPolicy *V1beta1ClusterAutomatedBackupPolicy `json:"automatedBackupPolicy,omitempty"` + // Output_only. The unique prefix in SQL user name. + UserPrefix *string `json:"userPrefix,omitempty"` + // Optional. The endpoints for connecting to the cluster. + Endpoints *V1beta1ClusterEndpoints `json:"endpoints,omitempty"` + // Output_only. The current state of the cluster. + State *Commonv1beta1ClusterState `json:"state,omitempty"` + // Output_only. Usage details of the cluster. + Usage *V1beta1ClusterUsage `json:"usage,omitempty"` + // Optional. Encryption settings for the cluster. + EncryptionConfig *V1beta1ClusterEncryptionConfig `json:"encryptionConfig,omitempty"` + // Optional. The labels for the cluster. tidb.cloud/organization. The label for the cluster organization id. tidb.cloud/project. The label for the cluster project id. + Labels *map[string]string `json:"labels,omitempty"` + // OUTPUT_ONLY. The annotations for the cluster. tidb.cloud/has-set-password. The annotation for whether the cluster has set password. tidb.cloud/available-features. The annotation for the available features of the cluster. + Annotations *map[string]string `json:"annotations,omitempty"` + // Output_only. Timestamp when the cluster was created. + CreateTime *time.Time `json:"createTime,omitempty"` + // Output_only. Timestamp when the cluster was last updated. + UpdateTime *time.Time `json:"updateTime,omitempty"` +} + +type _TidbCloudOpenApiserverlessv1beta1Cluster TidbCloudOpenApiserverlessv1beta1Cluster + +// NewTidbCloudOpenApiserverlessv1beta1Cluster instantiates a new TidbCloudOpenApiserverlessv1beta1Cluster 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 NewTidbCloudOpenApiserverlessv1beta1Cluster(displayName string, region Commonv1beta1Region) *TidbCloudOpenApiserverlessv1beta1Cluster { + this := TidbCloudOpenApiserverlessv1beta1Cluster{} + this.DisplayName = displayName + this.Region = region + return &this +} + +// NewTidbCloudOpenApiserverlessv1beta1ClusterWithDefaults instantiates a new TidbCloudOpenApiserverlessv1beta1Cluster 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 NewTidbCloudOpenApiserverlessv1beta1ClusterWithDefaults() *TidbCloudOpenApiserverlessv1beta1Cluster { + this := TidbCloudOpenApiserverlessv1beta1Cluster{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) SetName(v string) { + o.Name = &v +} + +// GetClusterId returns the ClusterId field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) SetClusterId(v string) { + o.ClusterId = &v +} + +// GetDisplayName returns the DisplayName field value +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) GetDisplayNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.DisplayName, true +} + +// SetDisplayName sets field value +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) SetDisplayName(v string) { + o.DisplayName = v +} + +// GetRegion returns the Region field value +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetRegion() Commonv1beta1Region { + if o == nil { + var ret Commonv1beta1Region + return ret + } + + return o.Region +} + +// GetRegionOk returns a tuple with the Region field value +// and a boolean to check if the value has been set. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetRegionOk() (*Commonv1beta1Region, bool) { + if o == nil { + return nil, false + } + return &o.Region, true +} + +// SetRegion sets field value +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) SetRegion(v Commonv1beta1Region) { + o.Region = v +} + +// GetSpendingLimit returns the SpendingLimit field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetSpendingLimit() ClusterSpendingLimit { + if o == nil || IsNil(o.SpendingLimit) { + var ret ClusterSpendingLimit + return ret + } + return *o.SpendingLimit +} + +// GetSpendingLimitOk returns a tuple with the SpendingLimit field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetSpendingLimitOk() (*ClusterSpendingLimit, bool) { + if o == nil || IsNil(o.SpendingLimit) { + return nil, false + } + return o.SpendingLimit, true +} + +// HasSpendingLimit returns a boolean if a field has been set. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) HasSpendingLimit() bool { + if o != nil && !IsNil(o.SpendingLimit) { + return true + } + + return false +} + +// SetSpendingLimit gets a reference to the given ClusterSpendingLimit and assigns it to the SpendingLimit field. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) SetSpendingLimit(v ClusterSpendingLimit) { + o.SpendingLimit = &v +} + +// GetVersion returns the Version field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetVersion() string { + if o == nil || IsNil(o.Version) { + var ret string + return ret + } + return *o.Version +} + +// GetVersionOk returns a tuple with the Version field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetVersionOk() (*string, bool) { + if o == nil || IsNil(o.Version) { + return nil, false + } + return o.Version, true +} + +// HasVersion returns a boolean if a field has been set. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) HasVersion() bool { + if o != nil && !IsNil(o.Version) { + return true + } + + return false +} + +// SetVersion gets a reference to the given string and assigns it to the Version field. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) SetVersion(v string) { + o.Version = &v +} + +// GetCreatedBy returns the CreatedBy field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) SetCreatedBy(v string) { + o.CreatedBy = &v +} + +// GetAutomatedBackupPolicy returns the AutomatedBackupPolicy field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetAutomatedBackupPolicy() V1beta1ClusterAutomatedBackupPolicy { + if o == nil || IsNil(o.AutomatedBackupPolicy) { + var ret V1beta1ClusterAutomatedBackupPolicy + return ret + } + return *o.AutomatedBackupPolicy +} + +// GetAutomatedBackupPolicyOk returns a tuple with the AutomatedBackupPolicy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetAutomatedBackupPolicyOk() (*V1beta1ClusterAutomatedBackupPolicy, bool) { + if o == nil || IsNil(o.AutomatedBackupPolicy) { + return nil, false + } + return o.AutomatedBackupPolicy, true +} + +// HasAutomatedBackupPolicy returns a boolean if a field has been set. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) HasAutomatedBackupPolicy() bool { + if o != nil && !IsNil(o.AutomatedBackupPolicy) { + return true + } + + return false +} + +// SetAutomatedBackupPolicy gets a reference to the given V1beta1ClusterAutomatedBackupPolicy and assigns it to the AutomatedBackupPolicy field. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) SetAutomatedBackupPolicy(v V1beta1ClusterAutomatedBackupPolicy) { + o.AutomatedBackupPolicy = &v +} + +// GetUserPrefix returns the UserPrefix field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetUserPrefix() string { + if o == nil || IsNil(o.UserPrefix) { + var ret string + return ret + } + return *o.UserPrefix +} + +// GetUserPrefixOk returns a tuple with the UserPrefix field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetUserPrefixOk() (*string, bool) { + if o == nil || IsNil(o.UserPrefix) { + return nil, false + } + return o.UserPrefix, true +} + +// HasUserPrefix returns a boolean if a field has been set. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) HasUserPrefix() bool { + if o != nil && !IsNil(o.UserPrefix) { + return true + } + + return false +} + +// SetUserPrefix gets a reference to the given string and assigns it to the UserPrefix field. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) SetUserPrefix(v string) { + o.UserPrefix = &v +} + +// GetEndpoints returns the Endpoints field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetEndpoints() V1beta1ClusterEndpoints { + if o == nil || IsNil(o.Endpoints) { + var ret V1beta1ClusterEndpoints + 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 *TidbCloudOpenApiserverlessv1beta1Cluster) GetEndpointsOk() (*V1beta1ClusterEndpoints, 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 *TidbCloudOpenApiserverlessv1beta1Cluster) HasEndpoints() bool { + if o != nil && !IsNil(o.Endpoints) { + return true + } + + return false +} + +// SetEndpoints gets a reference to the given V1beta1ClusterEndpoints and assigns it to the Endpoints field. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) SetEndpoints(v V1beta1ClusterEndpoints) { + o.Endpoints = &v +} + +// GetState returns the State field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetState() Commonv1beta1ClusterState { + if o == nil || IsNil(o.State) { + var ret Commonv1beta1ClusterState + 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 *TidbCloudOpenApiserverlessv1beta1Cluster) GetStateOk() (*Commonv1beta1ClusterState, 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 *TidbCloudOpenApiserverlessv1beta1Cluster) HasState() bool { + if o != nil && !IsNil(o.State) { + return true + } + + return false +} + +// SetState gets a reference to the given Commonv1beta1ClusterState and assigns it to the State field. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) SetState(v Commonv1beta1ClusterState) { + o.State = &v +} + +// GetUsage returns the Usage field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetUsage() V1beta1ClusterUsage { + if o == nil || IsNil(o.Usage) { + var ret V1beta1ClusterUsage + 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 *TidbCloudOpenApiserverlessv1beta1Cluster) GetUsageOk() (*V1beta1ClusterUsage, 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 *TidbCloudOpenApiserverlessv1beta1Cluster) HasUsage() bool { + if o != nil && !IsNil(o.Usage) { + return true + } + + return false +} + +// SetUsage gets a reference to the given V1beta1ClusterUsage and assigns it to the Usage field. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) SetUsage(v V1beta1ClusterUsage) { + o.Usage = &v +} + +// GetEncryptionConfig returns the EncryptionConfig field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetEncryptionConfig() V1beta1ClusterEncryptionConfig { + if o == nil || IsNil(o.EncryptionConfig) { + var ret V1beta1ClusterEncryptionConfig + return ret + } + return *o.EncryptionConfig +} + +// GetEncryptionConfigOk returns a tuple with the EncryptionConfig field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetEncryptionConfigOk() (*V1beta1ClusterEncryptionConfig, bool) { + if o == nil || IsNil(o.EncryptionConfig) { + return nil, false + } + return o.EncryptionConfig, true +} + +// HasEncryptionConfig returns a boolean if a field has been set. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) HasEncryptionConfig() bool { + if o != nil && !IsNil(o.EncryptionConfig) { + return true + } + + return false +} + +// SetEncryptionConfig gets a reference to the given V1beta1ClusterEncryptionConfig and assigns it to the EncryptionConfig field. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) SetEncryptionConfig(v V1beta1ClusterEncryptionConfig) { + o.EncryptionConfig = &v +} + +// GetLabels returns the Labels field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetLabels() map[string]string { + if o == nil || IsNil(o.Labels) { + var ret map[string]string + return ret + } + return *o.Labels +} + +// GetLabelsOk returns a tuple with the Labels field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetLabelsOk() (*map[string]string, bool) { + if o == nil || IsNil(o.Labels) { + return nil, false + } + return o.Labels, true +} + +// HasLabels returns a boolean if a field has been set. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) HasLabels() bool { + if o != nil && !IsNil(o.Labels) { + return true + } + + return false +} + +// SetLabels gets a reference to the given map[string]string and assigns it to the Labels field. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) SetLabels(v map[string]string) { + o.Labels = &v +} + +// GetAnnotations returns the Annotations field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) SetAnnotations(v map[string]string) { + o.Annotations = &v +} + +// GetCreateTime returns the CreateTime field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) SetCreateTime(v time.Time) { + o.CreateTime = &v +} + +// GetUpdateTime returns the UpdateTime field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) SetUpdateTime(v time.Time) { + o.UpdateTime = &v +} + +func (o TidbCloudOpenApiserverlessv1beta1Cluster) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o TidbCloudOpenApiserverlessv1beta1Cluster) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.ClusterId) { + toSerialize["clusterId"] = o.ClusterId + } + toSerialize["displayName"] = o.DisplayName + toSerialize["region"] = o.Region + if !IsNil(o.SpendingLimit) { + toSerialize["spendingLimit"] = o.SpendingLimit + } + if !IsNil(o.Version) { + toSerialize["version"] = o.Version + } + if !IsNil(o.CreatedBy) { + toSerialize["createdBy"] = o.CreatedBy + } + if !IsNil(o.AutomatedBackupPolicy) { + toSerialize["automatedBackupPolicy"] = o.AutomatedBackupPolicy + } + if !IsNil(o.UserPrefix) { + toSerialize["userPrefix"] = o.UserPrefix + } + if !IsNil(o.Endpoints) { + toSerialize["endpoints"] = o.Endpoints + } + if !IsNil(o.State) { + toSerialize["state"] = o.State + } + if !IsNil(o.Usage) { + toSerialize["usage"] = o.Usage + } + if !IsNil(o.EncryptionConfig) { + toSerialize["encryptionConfig"] = o.EncryptionConfig + } + if !IsNil(o.Labels) { + toSerialize["labels"] = o.Labels + } + if !IsNil(o.Annotations) { + toSerialize["annotations"] = o.Annotations + } + if !IsNil(o.CreateTime) { + toSerialize["createTime"] = o.CreateTime + } + if !IsNil(o.UpdateTime) { + toSerialize["updateTime"] = o.UpdateTime + } + return toSerialize, nil +} + +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) 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", + "region", + } + + 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) + } + } + + varTidbCloudOpenApiserverlessv1beta1Cluster := _TidbCloudOpenApiserverlessv1beta1Cluster{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varTidbCloudOpenApiserverlessv1beta1Cluster) + + if err != nil { + return err + } + + *o = TidbCloudOpenApiserverlessv1beta1Cluster(varTidbCloudOpenApiserverlessv1beta1Cluster) + + return err +} + +type NullableTidbCloudOpenApiserverlessv1beta1Cluster struct { + value *TidbCloudOpenApiserverlessv1beta1Cluster + isSet bool +} + +func (v NullableTidbCloudOpenApiserverlessv1beta1Cluster) Get() *TidbCloudOpenApiserverlessv1beta1Cluster { + return v.value +} + +func (v *NullableTidbCloudOpenApiserverlessv1beta1Cluster) Set(val *TidbCloudOpenApiserverlessv1beta1Cluster) { + v.value = val + v.isSet = true +} + +func (v NullableTidbCloudOpenApiserverlessv1beta1Cluster) IsSet() bool { + return v.isSet +} + +func (v *NullableTidbCloudOpenApiserverlessv1beta1Cluster) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableTidbCloudOpenApiserverlessv1beta1Cluster(val *TidbCloudOpenApiserverlessv1beta1Cluster) *NullableTidbCloudOpenApiserverlessv1beta1Cluster { + return &NullableTidbCloudOpenApiserverlessv1beta1Cluster{value: val, isSet: true} +} + +func (v NullableTidbCloudOpenApiserverlessv1beta1Cluster) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableTidbCloudOpenApiserverlessv1beta1Cluster) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_list_clusters_response.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_list_clusters_response.go new file mode 100644 index 00000000..03d57483 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_list_clusters_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 cluster + +import ( + "encoding/json" +) + +// checks if the TidbCloudOpenApiserverlessv1beta1ListClustersResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &TidbCloudOpenApiserverlessv1beta1ListClustersResponse{} + +// TidbCloudOpenApiserverlessv1beta1ListClustersResponse Responses message to the request for listing of TiDB Serverless clusters. +type TidbCloudOpenApiserverlessv1beta1ListClustersResponse struct { + // A list of clusters. + Clusters []TidbCloudOpenApiserverlessv1beta1Cluster `json:"clusters,omitempty"` + // Token provided to retrieve the next page of results. + NextPageToken *string `json:"nextPageToken,omitempty"` + // Total number of available clusters. + TotalSize *int64 `json:"totalSize,omitempty"` +} + +// NewTidbCloudOpenApiserverlessv1beta1ListClustersResponse instantiates a new TidbCloudOpenApiserverlessv1beta1ListClustersResponse 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 NewTidbCloudOpenApiserverlessv1beta1ListClustersResponse() *TidbCloudOpenApiserverlessv1beta1ListClustersResponse { + this := TidbCloudOpenApiserverlessv1beta1ListClustersResponse{} + return &this +} + +// NewTidbCloudOpenApiserverlessv1beta1ListClustersResponseWithDefaults instantiates a new TidbCloudOpenApiserverlessv1beta1ListClustersResponse 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 NewTidbCloudOpenApiserverlessv1beta1ListClustersResponseWithDefaults() *TidbCloudOpenApiserverlessv1beta1ListClustersResponse { + this := TidbCloudOpenApiserverlessv1beta1ListClustersResponse{} + return &this +} + +// GetClusters returns the Clusters field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) GetClusters() []TidbCloudOpenApiserverlessv1beta1Cluster { + if o == nil || IsNil(o.Clusters) { + var ret []TidbCloudOpenApiserverlessv1beta1Cluster + return ret + } + return o.Clusters +} + +// GetClustersOk returns a tuple with the Clusters field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) GetClustersOk() ([]TidbCloudOpenApiserverlessv1beta1Cluster, bool) { + if o == nil || IsNil(o.Clusters) { + return nil, false + } + return o.Clusters, true +} + +// HasClusters returns a boolean if a field has been set. +func (o *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) HasClusters() bool { + if o != nil && !IsNil(o.Clusters) { + return true + } + + return false +} + +// SetClusters gets a reference to the given []TidbCloudOpenApiserverlessv1beta1Cluster and assigns it to the Clusters field. +func (o *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) SetClusters(v []TidbCloudOpenApiserverlessv1beta1Cluster) { + o.Clusters = v +} + +// GetNextPageToken returns the NextPageToken field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) 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 *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) 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 *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) 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 *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) SetNextPageToken(v string) { + o.NextPageToken = &v +} + +// GetTotalSize returns the TotalSize field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) 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 *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) 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 *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) 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 *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) SetTotalSize(v int64) { + o.TotalSize = &v +} + +func (o TidbCloudOpenApiserverlessv1beta1ListClustersResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o TidbCloudOpenApiserverlessv1beta1ListClustersResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Clusters) { + toSerialize["clusters"] = o.Clusters + } + if !IsNil(o.NextPageToken) { + toSerialize["nextPageToken"] = o.NextPageToken + } + if !IsNil(o.TotalSize) { + toSerialize["totalSize"] = o.TotalSize + } + return toSerialize, nil +} + +type NullableTidbCloudOpenApiserverlessv1beta1ListClustersResponse struct { + value *TidbCloudOpenApiserverlessv1beta1ListClustersResponse + isSet bool +} + +func (v NullableTidbCloudOpenApiserverlessv1beta1ListClustersResponse) Get() *TidbCloudOpenApiserverlessv1beta1ListClustersResponse { + return v.value +} + +func (v *NullableTidbCloudOpenApiserverlessv1beta1ListClustersResponse) Set(val *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) { + v.value = val + v.isSet = true +} + +func (v NullableTidbCloudOpenApiserverlessv1beta1ListClustersResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableTidbCloudOpenApiserverlessv1beta1ListClustersResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableTidbCloudOpenApiserverlessv1beta1ListClustersResponse(val *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) *NullableTidbCloudOpenApiserverlessv1beta1ListClustersResponse { + return &NullableTidbCloudOpenApiserverlessv1beta1ListClustersResponse{value: val, isSet: true} +} + +func (v NullableTidbCloudOpenApiserverlessv1beta1ListClustersResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableTidbCloudOpenApiserverlessv1beta1ListClustersResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_list_regions_response.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_list_regions_response.go new file mode 100644 index 00000000..db6d6afa --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_list_regions_response.go @@ -0,0 +1,125 @@ +/* +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 cluster + +import ( + "encoding/json" +) + +// checks if the TidbCloudOpenApiserverlessv1beta1ListRegionsResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &TidbCloudOpenApiserverlessv1beta1ListRegionsResponse{} + +// TidbCloudOpenApiserverlessv1beta1ListRegionsResponse Responses message to the request for listing of available regions in TiDB Serverless. +type TidbCloudOpenApiserverlessv1beta1ListRegionsResponse struct { + // A list of available regions. + Regions []Commonv1beta1Region `json:"regions,omitempty"` +} + +// NewTidbCloudOpenApiserverlessv1beta1ListRegionsResponse instantiates a new TidbCloudOpenApiserverlessv1beta1ListRegionsResponse 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 NewTidbCloudOpenApiserverlessv1beta1ListRegionsResponse() *TidbCloudOpenApiserverlessv1beta1ListRegionsResponse { + this := TidbCloudOpenApiserverlessv1beta1ListRegionsResponse{} + return &this +} + +// NewTidbCloudOpenApiserverlessv1beta1ListRegionsResponseWithDefaults instantiates a new TidbCloudOpenApiserverlessv1beta1ListRegionsResponse 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 NewTidbCloudOpenApiserverlessv1beta1ListRegionsResponseWithDefaults() *TidbCloudOpenApiserverlessv1beta1ListRegionsResponse { + this := TidbCloudOpenApiserverlessv1beta1ListRegionsResponse{} + return &this +} + +// GetRegions returns the Regions field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1ListRegionsResponse) GetRegions() []Commonv1beta1Region { + if o == nil || IsNil(o.Regions) { + var ret []Commonv1beta1Region + return ret + } + return o.Regions +} + +// GetRegionsOk returns a tuple with the Regions field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TidbCloudOpenApiserverlessv1beta1ListRegionsResponse) GetRegionsOk() ([]Commonv1beta1Region, bool) { + if o == nil || IsNil(o.Regions) { + return nil, false + } + return o.Regions, true +} + +// HasRegions returns a boolean if a field has been set. +func (o *TidbCloudOpenApiserverlessv1beta1ListRegionsResponse) HasRegions() bool { + if o != nil && !IsNil(o.Regions) { + return true + } + + return false +} + +// SetRegions gets a reference to the given []Commonv1beta1Region and assigns it to the Regions field. +func (o *TidbCloudOpenApiserverlessv1beta1ListRegionsResponse) SetRegions(v []Commonv1beta1Region) { + o.Regions = v +} + +func (o TidbCloudOpenApiserverlessv1beta1ListRegionsResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o TidbCloudOpenApiserverlessv1beta1ListRegionsResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Regions) { + toSerialize["regions"] = o.Regions + } + return toSerialize, nil +} + +type NullableTidbCloudOpenApiserverlessv1beta1ListRegionsResponse struct { + value *TidbCloudOpenApiserverlessv1beta1ListRegionsResponse + isSet bool +} + +func (v NullableTidbCloudOpenApiserverlessv1beta1ListRegionsResponse) Get() *TidbCloudOpenApiserverlessv1beta1ListRegionsResponse { + return v.value +} + +func (v *NullableTidbCloudOpenApiserverlessv1beta1ListRegionsResponse) Set(val *TidbCloudOpenApiserverlessv1beta1ListRegionsResponse) { + v.value = val + v.isSet = true +} + +func (v NullableTidbCloudOpenApiserverlessv1beta1ListRegionsResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableTidbCloudOpenApiserverlessv1beta1ListRegionsResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableTidbCloudOpenApiserverlessv1beta1ListRegionsResponse(val *TidbCloudOpenApiserverlessv1beta1ListRegionsResponse) *NullableTidbCloudOpenApiserverlessv1beta1ListRegionsResponse { + return &NullableTidbCloudOpenApiserverlessv1beta1ListRegionsResponse{value: val, isSet: true} +} + +func (v NullableTidbCloudOpenApiserverlessv1beta1ListRegionsResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableTidbCloudOpenApiserverlessv1beta1ListRegionsResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_cluster_automated_backup_policy.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_cluster_automated_backup_policy.go new file mode 100644 index 00000000..bfa2c09d --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_cluster_automated_backup_policy.go @@ -0,0 +1,162 @@ +/* +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 cluster + +import ( + "encoding/json" +) + +// checks if the V1beta1ClusterAutomatedBackupPolicy type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &V1beta1ClusterAutomatedBackupPolicy{} + +// V1beta1ClusterAutomatedBackupPolicy Message for automated backup configuration for a cluster. +type V1beta1ClusterAutomatedBackupPolicy struct { + // Optional. Cron expression for when automated backups should start. + StartTime *string `json:"startTime,omitempty"` + // Optional. Number of days to retain automated backups. + RetentionDays *int32 `json:"retentionDays,omitempty"` +} + +// NewV1beta1ClusterAutomatedBackupPolicy instantiates a new V1beta1ClusterAutomatedBackupPolicy 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 NewV1beta1ClusterAutomatedBackupPolicy() *V1beta1ClusterAutomatedBackupPolicy { + this := V1beta1ClusterAutomatedBackupPolicy{} + return &this +} + +// NewV1beta1ClusterAutomatedBackupPolicyWithDefaults instantiates a new V1beta1ClusterAutomatedBackupPolicy 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 NewV1beta1ClusterAutomatedBackupPolicyWithDefaults() *V1beta1ClusterAutomatedBackupPolicy { + this := V1beta1ClusterAutomatedBackupPolicy{} + return &this +} + +// GetStartTime returns the StartTime field value if set, zero value otherwise. +func (o *V1beta1ClusterAutomatedBackupPolicy) GetStartTime() string { + if o == nil || IsNil(o.StartTime) { + var ret string + return ret + } + return *o.StartTime +} + +// GetStartTimeOk returns a tuple with the StartTime field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *V1beta1ClusterAutomatedBackupPolicy) GetStartTimeOk() (*string, bool) { + if o == nil || IsNil(o.StartTime) { + return nil, false + } + return o.StartTime, true +} + +// HasStartTime returns a boolean if a field has been set. +func (o *V1beta1ClusterAutomatedBackupPolicy) HasStartTime() bool { + if o != nil && !IsNil(o.StartTime) { + return true + } + + return false +} + +// SetStartTime gets a reference to the given string and assigns it to the StartTime field. +func (o *V1beta1ClusterAutomatedBackupPolicy) SetStartTime(v string) { + o.StartTime = &v +} + +// GetRetentionDays returns the RetentionDays field value if set, zero value otherwise. +func (o *V1beta1ClusterAutomatedBackupPolicy) GetRetentionDays() int32 { + if o == nil || IsNil(o.RetentionDays) { + var ret int32 + return ret + } + return *o.RetentionDays +} + +// GetRetentionDaysOk returns a tuple with the RetentionDays field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *V1beta1ClusterAutomatedBackupPolicy) GetRetentionDaysOk() (*int32, bool) { + if o == nil || IsNil(o.RetentionDays) { + return nil, false + } + return o.RetentionDays, true +} + +// HasRetentionDays returns a boolean if a field has been set. +func (o *V1beta1ClusterAutomatedBackupPolicy) HasRetentionDays() bool { + if o != nil && !IsNil(o.RetentionDays) { + return true + } + + return false +} + +// SetRetentionDays gets a reference to the given int32 and assigns it to the RetentionDays field. +func (o *V1beta1ClusterAutomatedBackupPolicy) SetRetentionDays(v int32) { + o.RetentionDays = &v +} + +func (o V1beta1ClusterAutomatedBackupPolicy) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o V1beta1ClusterAutomatedBackupPolicy) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.StartTime) { + toSerialize["startTime"] = o.StartTime + } + if !IsNil(o.RetentionDays) { + toSerialize["retentionDays"] = o.RetentionDays + } + return toSerialize, nil +} + +type NullableV1beta1ClusterAutomatedBackupPolicy struct { + value *V1beta1ClusterAutomatedBackupPolicy + isSet bool +} + +func (v NullableV1beta1ClusterAutomatedBackupPolicy) Get() *V1beta1ClusterAutomatedBackupPolicy { + return v.value +} + +func (v *NullableV1beta1ClusterAutomatedBackupPolicy) Set(val *V1beta1ClusterAutomatedBackupPolicy) { + v.value = val + v.isSet = true +} + +func (v NullableV1beta1ClusterAutomatedBackupPolicy) IsSet() bool { + return v.isSet +} + +func (v *NullableV1beta1ClusterAutomatedBackupPolicy) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableV1beta1ClusterAutomatedBackupPolicy(val *V1beta1ClusterAutomatedBackupPolicy) *NullableV1beta1ClusterAutomatedBackupPolicy { + return &NullableV1beta1ClusterAutomatedBackupPolicy{value: val, isSet: true} +} + +func (v NullableV1beta1ClusterAutomatedBackupPolicy) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableV1beta1ClusterAutomatedBackupPolicy) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_cluster_encryption_config.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_cluster_encryption_config.go new file mode 100644 index 00000000..bfc87273 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_cluster_encryption_config.go @@ -0,0 +1,125 @@ +/* +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 cluster + +import ( + "encoding/json" +) + +// checks if the V1beta1ClusterEncryptionConfig type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &V1beta1ClusterEncryptionConfig{} + +// V1beta1ClusterEncryptionConfig Message for encryption settings for a cluster. +type V1beta1ClusterEncryptionConfig struct { + // Optional. Whether enhanced encryption for cluster data is enabled. + EnhancedEncryptionEnabled *bool `json:"enhancedEncryptionEnabled,omitempty"` +} + +// NewV1beta1ClusterEncryptionConfig instantiates a new V1beta1ClusterEncryptionConfig 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 NewV1beta1ClusterEncryptionConfig() *V1beta1ClusterEncryptionConfig { + this := V1beta1ClusterEncryptionConfig{} + return &this +} + +// NewV1beta1ClusterEncryptionConfigWithDefaults instantiates a new V1beta1ClusterEncryptionConfig 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 NewV1beta1ClusterEncryptionConfigWithDefaults() *V1beta1ClusterEncryptionConfig { + this := V1beta1ClusterEncryptionConfig{} + return &this +} + +// GetEnhancedEncryptionEnabled returns the EnhancedEncryptionEnabled field value if set, zero value otherwise. +func (o *V1beta1ClusterEncryptionConfig) GetEnhancedEncryptionEnabled() bool { + if o == nil || IsNil(o.EnhancedEncryptionEnabled) { + var ret bool + return ret + } + return *o.EnhancedEncryptionEnabled +} + +// GetEnhancedEncryptionEnabledOk returns a tuple with the EnhancedEncryptionEnabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *V1beta1ClusterEncryptionConfig) GetEnhancedEncryptionEnabledOk() (*bool, bool) { + if o == nil || IsNil(o.EnhancedEncryptionEnabled) { + return nil, false + } + return o.EnhancedEncryptionEnabled, true +} + +// HasEnhancedEncryptionEnabled returns a boolean if a field has been set. +func (o *V1beta1ClusterEncryptionConfig) HasEnhancedEncryptionEnabled() bool { + if o != nil && !IsNil(o.EnhancedEncryptionEnabled) { + return true + } + + return false +} + +// SetEnhancedEncryptionEnabled gets a reference to the given bool and assigns it to the EnhancedEncryptionEnabled field. +func (o *V1beta1ClusterEncryptionConfig) SetEnhancedEncryptionEnabled(v bool) { + o.EnhancedEncryptionEnabled = &v +} + +func (o V1beta1ClusterEncryptionConfig) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o V1beta1ClusterEncryptionConfig) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.EnhancedEncryptionEnabled) { + toSerialize["enhancedEncryptionEnabled"] = o.EnhancedEncryptionEnabled + } + return toSerialize, nil +} + +type NullableV1beta1ClusterEncryptionConfig struct { + value *V1beta1ClusterEncryptionConfig + isSet bool +} + +func (v NullableV1beta1ClusterEncryptionConfig) Get() *V1beta1ClusterEncryptionConfig { + return v.value +} + +func (v *NullableV1beta1ClusterEncryptionConfig) Set(val *V1beta1ClusterEncryptionConfig) { + v.value = val + v.isSet = true +} + +func (v NullableV1beta1ClusterEncryptionConfig) IsSet() bool { + return v.isSet +} + +func (v *NullableV1beta1ClusterEncryptionConfig) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableV1beta1ClusterEncryptionConfig(val *V1beta1ClusterEncryptionConfig) *NullableV1beta1ClusterEncryptionConfig { + return &NullableV1beta1ClusterEncryptionConfig{value: val, isSet: true} +} + +func (v NullableV1beta1ClusterEncryptionConfig) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableV1beta1ClusterEncryptionConfig) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_cluster_endpoints.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_cluster_endpoints.go new file mode 100644 index 00000000..7a4af32b --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_cluster_endpoints.go @@ -0,0 +1,162 @@ +/* +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 cluster + +import ( + "encoding/json" +) + +// checks if the V1beta1ClusterEndpoints type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &V1beta1ClusterEndpoints{} + +// V1beta1ClusterEndpoints Message for endpoint information for connecting to a cluster. +type V1beta1ClusterEndpoints struct { + // Optional. Public endpoint to connect to the cluster. + Public *EndpointsPublic `json:"public,omitempty"` + // Output_only. Private endpoint to securely connect to the cluster. + Private *EndpointsPrivate `json:"private,omitempty"` +} + +// NewV1beta1ClusterEndpoints instantiates a new V1beta1ClusterEndpoints 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 NewV1beta1ClusterEndpoints() *V1beta1ClusterEndpoints { + this := V1beta1ClusterEndpoints{} + return &this +} + +// NewV1beta1ClusterEndpointsWithDefaults instantiates a new V1beta1ClusterEndpoints 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 NewV1beta1ClusterEndpointsWithDefaults() *V1beta1ClusterEndpoints { + this := V1beta1ClusterEndpoints{} + return &this +} + +// GetPublic returns the Public field value if set, zero value otherwise. +func (o *V1beta1ClusterEndpoints) GetPublic() EndpointsPublic { + if o == nil || IsNil(o.Public) { + var ret EndpointsPublic + 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 *V1beta1ClusterEndpoints) GetPublicOk() (*EndpointsPublic, 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 *V1beta1ClusterEndpoints) HasPublic() bool { + if o != nil && !IsNil(o.Public) { + return true + } + + return false +} + +// SetPublic gets a reference to the given EndpointsPublic and assigns it to the Public field. +func (o *V1beta1ClusterEndpoints) SetPublic(v EndpointsPublic) { + o.Public = &v +} + +// GetPrivate returns the Private field value if set, zero value otherwise. +func (o *V1beta1ClusterEndpoints) GetPrivate() EndpointsPrivate { + if o == nil || IsNil(o.Private) { + var ret EndpointsPrivate + 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 *V1beta1ClusterEndpoints) GetPrivateOk() (*EndpointsPrivate, 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 *V1beta1ClusterEndpoints) HasPrivate() bool { + if o != nil && !IsNil(o.Private) { + return true + } + + return false +} + +// SetPrivate gets a reference to the given EndpointsPrivate and assigns it to the Private field. +func (o *V1beta1ClusterEndpoints) SetPrivate(v EndpointsPrivate) { + o.Private = &v +} + +func (o V1beta1ClusterEndpoints) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o V1beta1ClusterEndpoints) 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 NullableV1beta1ClusterEndpoints struct { + value *V1beta1ClusterEndpoints + isSet bool +} + +func (v NullableV1beta1ClusterEndpoints) Get() *V1beta1ClusterEndpoints { + return v.value +} + +func (v *NullableV1beta1ClusterEndpoints) Set(val *V1beta1ClusterEndpoints) { + v.value = val + v.isSet = true +} + +func (v NullableV1beta1ClusterEndpoints) IsSet() bool { + return v.isSet +} + +func (v *NullableV1beta1ClusterEndpoints) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableV1beta1ClusterEndpoints(val *V1beta1ClusterEndpoints) *NullableV1beta1ClusterEndpoints { + return &NullableV1beta1ClusterEndpoints{value: val, isSet: true} +} + +func (v NullableV1beta1ClusterEndpoints) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableV1beta1ClusterEndpoints) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_cluster_usage.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_cluster_usage.go new file mode 100644 index 00000000..b684e333 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_cluster_usage.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 cluster + +import ( + "encoding/json" +) + +// checks if the V1beta1ClusterUsage type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &V1beta1ClusterUsage{} + +// V1beta1ClusterUsage Message for usage statistics of a cluster. +type V1beta1ClusterUsage struct { + // Output_only. The Request Units used in this month. + RequestUnit *string `json:"requestUnit,omitempty"` + // Output_only. The storage used on row-based storage in bytes. + RowBasedStorage *float64 `json:"rowBasedStorage,omitempty"` + // Output_only. The storage used on column-based storage in bytes. + ColumnarStorage *float64 `json:"columnarStorage,omitempty"` +} + +// NewV1beta1ClusterUsage instantiates a new V1beta1ClusterUsage 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 NewV1beta1ClusterUsage() *V1beta1ClusterUsage { + this := V1beta1ClusterUsage{} + return &this +} + +// NewV1beta1ClusterUsageWithDefaults instantiates a new V1beta1ClusterUsage 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 NewV1beta1ClusterUsageWithDefaults() *V1beta1ClusterUsage { + this := V1beta1ClusterUsage{} + return &this +} + +// GetRequestUnit returns the RequestUnit field value if set, zero value otherwise. +func (o *V1beta1ClusterUsage) 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 *V1beta1ClusterUsage) 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 *V1beta1ClusterUsage) 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 *V1beta1ClusterUsage) SetRequestUnit(v string) { + o.RequestUnit = &v +} + +// GetRowBasedStorage returns the RowBasedStorage field value if set, zero value otherwise. +func (o *V1beta1ClusterUsage) GetRowBasedStorage() float64 { + if o == nil || IsNil(o.RowBasedStorage) { + var ret float64 + return ret + } + return *o.RowBasedStorage +} + +// GetRowBasedStorageOk returns a tuple with the RowBasedStorage field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *V1beta1ClusterUsage) GetRowBasedStorageOk() (*float64, bool) { + if o == nil || IsNil(o.RowBasedStorage) { + return nil, false + } + return o.RowBasedStorage, true +} + +// HasRowBasedStorage returns a boolean if a field has been set. +func (o *V1beta1ClusterUsage) HasRowBasedStorage() bool { + if o != nil && !IsNil(o.RowBasedStorage) { + return true + } + + return false +} + +// SetRowBasedStorage gets a reference to the given float64 and assigns it to the RowBasedStorage field. +func (o *V1beta1ClusterUsage) SetRowBasedStorage(v float64) { + o.RowBasedStorage = &v +} + +// GetColumnarStorage returns the ColumnarStorage field value if set, zero value otherwise. +func (o *V1beta1ClusterUsage) 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 *V1beta1ClusterUsage) 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 *V1beta1ClusterUsage) 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 *V1beta1ClusterUsage) SetColumnarStorage(v float64) { + o.ColumnarStorage = &v +} + +func (o V1beta1ClusterUsage) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o V1beta1ClusterUsage) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.RequestUnit) { + toSerialize["requestUnit"] = o.RequestUnit + } + if !IsNil(o.RowBasedStorage) { + toSerialize["rowBasedStorage"] = o.RowBasedStorage + } + if !IsNil(o.ColumnarStorage) { + toSerialize["columnarStorage"] = o.ColumnarStorage + } + return toSerialize, nil +} + +type NullableV1beta1ClusterUsage struct { + value *V1beta1ClusterUsage + isSet bool +} + +func (v NullableV1beta1ClusterUsage) Get() *V1beta1ClusterUsage { + return v.value +} + +func (v *NullableV1beta1ClusterUsage) Set(val *V1beta1ClusterUsage) { + v.value = val + v.isSet = true +} + +func (v NullableV1beta1ClusterUsage) IsSet() bool { + return v.isSet +} + +func (v *NullableV1beta1ClusterUsage) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableV1beta1ClusterUsage(val *V1beta1ClusterUsage) *NullableV1beta1ClusterUsage { + return &NullableV1beta1ClusterUsage{value: val, isSet: true} +} + +func (v NullableV1beta1ClusterUsage) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableV1beta1ClusterUsage) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_partial_update_cluster_request_partial_update_cluster.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_partial_update_cluster_request_partial_update_cluster.go new file mode 100644 index 00000000..1ba4c8e5 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_partial_update_cluster_request_partial_update_cluster.go @@ -0,0 +1,342 @@ +/* +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 cluster + +import ( + "bytes" + "encoding/json" + "fmt" +) + +// checks if the V1beta1PartialUpdateClusterRequestPartialUpdateCluster type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &V1beta1PartialUpdateClusterRequestPartialUpdateCluster{} + +// V1beta1PartialUpdateClusterRequestPartialUpdateCluster struct for V1beta1PartialUpdateClusterRequestPartialUpdateCluster +type V1beta1PartialUpdateClusterRequestPartialUpdateCluster struct { + // Output_only. The unique ID of the cluster. + ClusterId string `json:"clusterId"` + // Required. User friendly display name of the cluster. + DisplayName *string `json:"displayName,omitempty"` + // Optional. The spending limit for the cluster. + SpendingLimit *ClusterSpendingLimit `json:"spendingLimit,omitempty"` + // Optional. Automated backup policy to set on the cluster. + AutomatedBackupPolicy *V1beta1ClusterAutomatedBackupPolicy `json:"automatedBackupPolicy,omitempty"` + // Optional. The endpoints for connecting to the cluster. + Endpoints *V1beta1ClusterEndpoints `json:"endpoints,omitempty"` + // Optional. The labels for the cluster. tidb.cloud/organization. The label for the cluster organization id. tidb.cloud/project. The label for the cluster project id. + Labels *map[string]string `json:"labels,omitempty"` +} + +type _V1beta1PartialUpdateClusterRequestPartialUpdateCluster V1beta1PartialUpdateClusterRequestPartialUpdateCluster + +// NewV1beta1PartialUpdateClusterRequestPartialUpdateCluster instantiates a new V1beta1PartialUpdateClusterRequestPartialUpdateCluster 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 NewV1beta1PartialUpdateClusterRequestPartialUpdateCluster(clusterId string) *V1beta1PartialUpdateClusterRequestPartialUpdateCluster { + this := V1beta1PartialUpdateClusterRequestPartialUpdateCluster{} + this.ClusterId = clusterId + return &this +} + +// NewV1beta1PartialUpdateClusterRequestPartialUpdateClusterWithDefaults instantiates a new V1beta1PartialUpdateClusterRequestPartialUpdateCluster 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 NewV1beta1PartialUpdateClusterRequestPartialUpdateClusterWithDefaults() *V1beta1PartialUpdateClusterRequestPartialUpdateCluster { + this := V1beta1PartialUpdateClusterRequestPartialUpdateCluster{} + return &this +} + +// GetClusterId returns the ClusterId field value +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) GetClusterId() string { + if o == nil { + var ret string + return ret + } + + return o.ClusterId +} + +// GetClusterIdOk returns a tuple with the ClusterId field value +// and a boolean to check if the value has been set. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) GetClusterIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ClusterId, true +} + +// SetClusterId sets field value +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) SetClusterId(v string) { + o.ClusterId = v +} + +// GetDisplayName returns the DisplayName field value if set, zero value otherwise. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) GetDisplayName() string { + if o == nil || IsNil(o.DisplayName) { + var ret string + return ret + } + return *o.DisplayName +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) GetDisplayNameOk() (*string, bool) { + if o == nil || IsNil(o.DisplayName) { + return nil, false + } + return o.DisplayName, true +} + +// HasDisplayName returns a boolean if a field has been set. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) HasDisplayName() bool { + if o != nil && !IsNil(o.DisplayName) { + return true + } + + return false +} + +// SetDisplayName gets a reference to the given string and assigns it to the DisplayName field. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) SetDisplayName(v string) { + o.DisplayName = &v +} + +// GetSpendingLimit returns the SpendingLimit field value if set, zero value otherwise. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) GetSpendingLimit() ClusterSpendingLimit { + if o == nil || IsNil(o.SpendingLimit) { + var ret ClusterSpendingLimit + return ret + } + return *o.SpendingLimit +} + +// GetSpendingLimitOk returns a tuple with the SpendingLimit field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) GetSpendingLimitOk() (*ClusterSpendingLimit, bool) { + if o == nil || IsNil(o.SpendingLimit) { + return nil, false + } + return o.SpendingLimit, true +} + +// HasSpendingLimit returns a boolean if a field has been set. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) HasSpendingLimit() bool { + if o != nil && !IsNil(o.SpendingLimit) { + return true + } + + return false +} + +// SetSpendingLimit gets a reference to the given ClusterSpendingLimit and assigns it to the SpendingLimit field. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) SetSpendingLimit(v ClusterSpendingLimit) { + o.SpendingLimit = &v +} + +// GetAutomatedBackupPolicy returns the AutomatedBackupPolicy field value if set, zero value otherwise. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) GetAutomatedBackupPolicy() V1beta1ClusterAutomatedBackupPolicy { + if o == nil || IsNil(o.AutomatedBackupPolicy) { + var ret V1beta1ClusterAutomatedBackupPolicy + return ret + } + return *o.AutomatedBackupPolicy +} + +// GetAutomatedBackupPolicyOk returns a tuple with the AutomatedBackupPolicy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) GetAutomatedBackupPolicyOk() (*V1beta1ClusterAutomatedBackupPolicy, bool) { + if o == nil || IsNil(o.AutomatedBackupPolicy) { + return nil, false + } + return o.AutomatedBackupPolicy, true +} + +// HasAutomatedBackupPolicy returns a boolean if a field has been set. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) HasAutomatedBackupPolicy() bool { + if o != nil && !IsNil(o.AutomatedBackupPolicy) { + return true + } + + return false +} + +// SetAutomatedBackupPolicy gets a reference to the given V1beta1ClusterAutomatedBackupPolicy and assigns it to the AutomatedBackupPolicy field. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) SetAutomatedBackupPolicy(v V1beta1ClusterAutomatedBackupPolicy) { + o.AutomatedBackupPolicy = &v +} + +// GetEndpoints returns the Endpoints field value if set, zero value otherwise. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) GetEndpoints() V1beta1ClusterEndpoints { + if o == nil || IsNil(o.Endpoints) { + var ret V1beta1ClusterEndpoints + 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 *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) GetEndpointsOk() (*V1beta1ClusterEndpoints, 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 *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) HasEndpoints() bool { + if o != nil && !IsNil(o.Endpoints) { + return true + } + + return false +} + +// SetEndpoints gets a reference to the given V1beta1ClusterEndpoints and assigns it to the Endpoints field. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) SetEndpoints(v V1beta1ClusterEndpoints) { + o.Endpoints = &v +} + +// GetLabels returns the Labels field value if set, zero value otherwise. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) GetLabels() map[string]string { + if o == nil || IsNil(o.Labels) { + var ret map[string]string + return ret + } + return *o.Labels +} + +// GetLabelsOk returns a tuple with the Labels field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) GetLabelsOk() (*map[string]string, bool) { + if o == nil || IsNil(o.Labels) { + return nil, false + } + return o.Labels, true +} + +// HasLabels returns a boolean if a field has been set. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) HasLabels() bool { + if o != nil && !IsNil(o.Labels) { + return true + } + + return false +} + +// SetLabels gets a reference to the given map[string]string and assigns it to the Labels field. +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) SetLabels(v map[string]string) { + o.Labels = &v +} + +func (o V1beta1PartialUpdateClusterRequestPartialUpdateCluster) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o V1beta1PartialUpdateClusterRequestPartialUpdateCluster) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["clusterId"] = o.ClusterId + if !IsNil(o.DisplayName) { + toSerialize["displayName"] = o.DisplayName + } + if !IsNil(o.SpendingLimit) { + toSerialize["spendingLimit"] = o.SpendingLimit + } + if !IsNil(o.AutomatedBackupPolicy) { + toSerialize["automatedBackupPolicy"] = o.AutomatedBackupPolicy + } + if !IsNil(o.Endpoints) { + toSerialize["endpoints"] = o.Endpoints + } + if !IsNil(o.Labels) { + toSerialize["labels"] = o.Labels + } + return toSerialize, nil +} + +func (o *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) 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{ + "clusterId", + } + + 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) + } + } + + varV1beta1PartialUpdateClusterRequestPartialUpdateCluster := _V1beta1PartialUpdateClusterRequestPartialUpdateCluster{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varV1beta1PartialUpdateClusterRequestPartialUpdateCluster) + + if err != nil { + return err + } + + *o = V1beta1PartialUpdateClusterRequestPartialUpdateCluster(varV1beta1PartialUpdateClusterRequestPartialUpdateCluster) + + return err +} + +type NullableV1beta1PartialUpdateClusterRequestPartialUpdateCluster struct { + value *V1beta1PartialUpdateClusterRequestPartialUpdateCluster + isSet bool +} + +func (v NullableV1beta1PartialUpdateClusterRequestPartialUpdateCluster) Get() *V1beta1PartialUpdateClusterRequestPartialUpdateCluster { + return v.value +} + +func (v *NullableV1beta1PartialUpdateClusterRequestPartialUpdateCluster) Set(val *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) { + v.value = val + v.isSet = true +} + +func (v NullableV1beta1PartialUpdateClusterRequestPartialUpdateCluster) IsSet() bool { + return v.isSet +} + +func (v *NullableV1beta1PartialUpdateClusterRequestPartialUpdateCluster) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableV1beta1PartialUpdateClusterRequestPartialUpdateCluster(val *V1beta1PartialUpdateClusterRequestPartialUpdateCluster) *NullableV1beta1PartialUpdateClusterRequestPartialUpdateCluster { + return &NullableV1beta1PartialUpdateClusterRequestPartialUpdateCluster{value: val, isSet: true} +} + +func (v NullableV1beta1PartialUpdateClusterRequestPartialUpdateCluster) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableV1beta1PartialUpdateClusterRequestPartialUpdateCluster) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_region_cloud_provider.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_region_cloud_provider.go new file mode 100644 index 00000000..65830bd5 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_region_cloud_provider.go @@ -0,0 +1,112 @@ +/* +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 cluster + +import ( + "encoding/json" + "fmt" +) + +// V1beta1RegionCloudProvider Enum of cloud provider names. - aws: Amazon Web Services. buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE - gcp: Google Cloud Platform. buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE - azure: Microsoft Azure. buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE +type V1beta1RegionCloudProvider string + +// List of v1beta1RegionCloudProvider +const ( + V1BETA1REGIONCLOUDPROVIDER_AWS V1beta1RegionCloudProvider = "aws" + V1BETA1REGIONCLOUDPROVIDER_GCP V1beta1RegionCloudProvider = "gcp" + V1BETA1REGIONCLOUDPROVIDER_AZURE V1beta1RegionCloudProvider = "azure" +) + +// All allowed values of V1beta1RegionCloudProvider enum +var AllowedV1beta1RegionCloudProviderEnumValues = []V1beta1RegionCloudProvider{ + "aws", + "gcp", + "azure", +} + +func (v *V1beta1RegionCloudProvider) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := V1beta1RegionCloudProvider(value) + for _, existing := range AllowedV1beta1RegionCloudProviderEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid V1beta1RegionCloudProvider", value) +} + +// NewV1beta1RegionCloudProviderFromValue returns a pointer to a valid V1beta1RegionCloudProvider +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewV1beta1RegionCloudProviderFromValue(v string) (*V1beta1RegionCloudProvider, error) { + ev := V1beta1RegionCloudProvider(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for V1beta1RegionCloudProvider: valid values are %v", v, AllowedV1beta1RegionCloudProviderEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v V1beta1RegionCloudProvider) IsValid() bool { + for _, existing := range AllowedV1beta1RegionCloudProviderEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to v1beta1RegionCloudProvider value +func (v V1beta1RegionCloudProvider) Ptr() *V1beta1RegionCloudProvider { + return &v +} + +type NullableV1beta1RegionCloudProvider struct { + value *V1beta1RegionCloudProvider + isSet bool +} + +func (v NullableV1beta1RegionCloudProvider) Get() *V1beta1RegionCloudProvider { + return v.value +} + +func (v *NullableV1beta1RegionCloudProvider) Set(val *V1beta1RegionCloudProvider) { + v.value = val + v.isSet = true +} + +func (v NullableV1beta1RegionCloudProvider) IsSet() bool { + return v.isSet +} + +func (v *NullableV1beta1RegionCloudProvider) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableV1beta1RegionCloudProvider(val *V1beta1RegionCloudProvider) *NullableV1beta1RegionCloudProvider { + return &NullableV1beta1RegionCloudProvider{value: val, isSet: true} +} + +func (v NullableV1beta1RegionCloudProvider) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableV1beta1RegionCloudProvider) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_serverless_service_partial_update_cluster_body.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_serverless_service_partial_update_cluster_body.go new file mode 100644 index 00000000..a19c4e1f --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_v1beta1_serverless_service_partial_update_cluster_body.go @@ -0,0 +1,193 @@ +/* +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 cluster + +import ( + "bytes" + "encoding/json" + "fmt" +) + +// checks if the V1beta1ServerlessServicePartialUpdateClusterBody type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &V1beta1ServerlessServicePartialUpdateClusterBody{} + +// V1beta1ServerlessServicePartialUpdateClusterBody Message for requesting a partial update on a TiDB Serverless cluster. +type V1beta1ServerlessServicePartialUpdateClusterBody struct { + Cluster *RequiredTheClusterToBeUpdated `json:"cluster,omitempty"` + // Required. The update mask indicating which fields are to be updated. + UpdateMask string `json:"updateMask"` +} + +type _V1beta1ServerlessServicePartialUpdateClusterBody V1beta1ServerlessServicePartialUpdateClusterBody + +// NewV1beta1ServerlessServicePartialUpdateClusterBody instantiates a new V1beta1ServerlessServicePartialUpdateClusterBody 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 NewV1beta1ServerlessServicePartialUpdateClusterBody(updateMask string) *V1beta1ServerlessServicePartialUpdateClusterBody { + this := V1beta1ServerlessServicePartialUpdateClusterBody{} + this.UpdateMask = updateMask + return &this +} + +// NewV1beta1ServerlessServicePartialUpdateClusterBodyWithDefaults instantiates a new V1beta1ServerlessServicePartialUpdateClusterBody 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 NewV1beta1ServerlessServicePartialUpdateClusterBodyWithDefaults() *V1beta1ServerlessServicePartialUpdateClusterBody { + this := V1beta1ServerlessServicePartialUpdateClusterBody{} + return &this +} + +// GetCluster returns the Cluster field value if set, zero value otherwise. +func (o *V1beta1ServerlessServicePartialUpdateClusterBody) GetCluster() RequiredTheClusterToBeUpdated { + if o == nil || IsNil(o.Cluster) { + var ret RequiredTheClusterToBeUpdated + return ret + } + return *o.Cluster +} + +// GetClusterOk returns a tuple with the Cluster field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *V1beta1ServerlessServicePartialUpdateClusterBody) GetClusterOk() (*RequiredTheClusterToBeUpdated, bool) { + if o == nil || IsNil(o.Cluster) { + return nil, false + } + return o.Cluster, true +} + +// HasCluster returns a boolean if a field has been set. +func (o *V1beta1ServerlessServicePartialUpdateClusterBody) HasCluster() bool { + if o != nil && !IsNil(o.Cluster) { + return true + } + + return false +} + +// SetCluster gets a reference to the given RequiredTheClusterToBeUpdated and assigns it to the Cluster field. +func (o *V1beta1ServerlessServicePartialUpdateClusterBody) SetCluster(v RequiredTheClusterToBeUpdated) { + o.Cluster = &v +} + +// GetUpdateMask returns the UpdateMask field value +func (o *V1beta1ServerlessServicePartialUpdateClusterBody) GetUpdateMask() string { + if o == nil { + var ret string + return ret + } + + return o.UpdateMask +} + +// GetUpdateMaskOk returns a tuple with the UpdateMask field value +// and a boolean to check if the value has been set. +func (o *V1beta1ServerlessServicePartialUpdateClusterBody) GetUpdateMaskOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.UpdateMask, true +} + +// SetUpdateMask sets field value +func (o *V1beta1ServerlessServicePartialUpdateClusterBody) SetUpdateMask(v string) { + o.UpdateMask = v +} + +func (o V1beta1ServerlessServicePartialUpdateClusterBody) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o V1beta1ServerlessServicePartialUpdateClusterBody) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Cluster) { + toSerialize["cluster"] = o.Cluster + } + toSerialize["updateMask"] = o.UpdateMask + return toSerialize, nil +} + +func (o *V1beta1ServerlessServicePartialUpdateClusterBody) 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{ + "updateMask", + } + + 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) + } + } + + varV1beta1ServerlessServicePartialUpdateClusterBody := _V1beta1ServerlessServicePartialUpdateClusterBody{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varV1beta1ServerlessServicePartialUpdateClusterBody) + + if err != nil { + return err + } + + *o = V1beta1ServerlessServicePartialUpdateClusterBody(varV1beta1ServerlessServicePartialUpdateClusterBody) + + return err +} + +type NullableV1beta1ServerlessServicePartialUpdateClusterBody struct { + value *V1beta1ServerlessServicePartialUpdateClusterBody + isSet bool +} + +func (v NullableV1beta1ServerlessServicePartialUpdateClusterBody) Get() *V1beta1ServerlessServicePartialUpdateClusterBody { + return v.value +} + +func (v *NullableV1beta1ServerlessServicePartialUpdateClusterBody) Set(val *V1beta1ServerlessServicePartialUpdateClusterBody) { + v.value = val + v.isSet = true +} + +func (v NullableV1beta1ServerlessServicePartialUpdateClusterBody) IsSet() bool { + return v.isSet +} + +func (v *NullableV1beta1ServerlessServicePartialUpdateClusterBody) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableV1beta1ServerlessServicePartialUpdateClusterBody(val *V1beta1ServerlessServicePartialUpdateClusterBody) *NullableV1beta1ServerlessServicePartialUpdateClusterBody { + return &NullableV1beta1ServerlessServicePartialUpdateClusterBody{value: val, isSet: true} +} + +func (v NullableV1beta1ServerlessServicePartialUpdateClusterBody) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableV1beta1ServerlessServicePartialUpdateClusterBody) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/response.go b/pkg/tidbcloud/v1beta1/serverless/cluster/response.go new file mode 100644 index 00000000..cc6f1690 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/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 cluster + +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/cluster/utils.go b/pkg/tidbcloud/v1beta1/serverless/cluster/utils.go new file mode 100644 index 00000000..b9cd3a14 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/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 cluster + +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...) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/cluster_spending_limit.go b/pkg/tidbcloud/v1beta1/serverless/models/cluster_spending_limit.go deleted file mode 100644 index 945d8495..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/cluster_spending_limit.go +++ /dev/null @@ -1,50 +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/strfmt" - "github.com/go-openapi/swag" -) - -// ClusterSpendingLimit Message for spending limit configuration. -// -// swagger:model ClusterSpendingLimit -type ClusterSpendingLimit struct { - - // Optional. Maximum monthly spending limit in USD cents. - Monthly int32 `json:"monthly,omitempty"` -} - -// Validate validates this cluster spending limit -func (m *ClusterSpendingLimit) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this cluster spending limit based on context it is used -func (m *ClusterSpendingLimit) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *ClusterSpendingLimit) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ClusterSpendingLimit) UnmarshalBinary(b []byte) error { - var res ClusterSpendingLimit - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/cluster_usage.go b/pkg/tidbcloud/v1beta1/serverless/models/cluster_usage.go deleted file mode 100644 index dfa5a79d..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/cluster_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" -) - -// ClusterUsage Message for usage statistics of a cluster. -// -// swagger:model ClusterUsage -type ClusterUsage struct { - - // Output_only. The storage used on column-based storage in bytes. - // Read Only: true - ColumnarStorage float64 `json:"columnarStorage,omitempty"` - - // Output_only. The Request Units used in this month. - // Read Only: true - RequestUnit string `json:"requestUnit,omitempty"` - - // Output_only. The storage used on row-based storage in bytes. - // Read Only: true - RowBasedStorage float64 `json:"rowBasedStorage,omitempty"` -} - -// Validate validates this cluster usage -func (m *ClusterUsage) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validate this cluster usage based on the context it is used -func (m *ClusterUsage) 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.contextValidateRowBasedStorage(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ClusterUsage) 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 *ClusterUsage) 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 *ClusterUsage) contextValidateRowBasedStorage(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "rowBasedStorage", "body", float64(m.RowBasedStorage)); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *ClusterUsage) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ClusterUsage) UnmarshalBinary(b []byte) error { - var res ClusterUsage - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/commonv1beta1_cluster_state.go b/pkg/tidbcloud/v1beta1/serverless/models/commonv1beta1_cluster_state.go deleted file mode 100644 index c762445e..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/commonv1beta1_cluster_state.go +++ /dev/null @@ -1,147 +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" -) - -// Commonv1beta1ClusterState Enum for current state of a cluster. -// -// - CREATING: Cluster is being created. -// - DELETING: Cluster is being deleted. -// - ACTIVE: Cluster is active for use. -// - RESTORING: Cluster data is being restored. -// - MAINTENANCE: Cluster is under maintenance. -// - DELETED: Cluster has been deleted. -// - INACTIVE: Cluster is not active, but not being deleted. -// - UPDATING: Cluster is being updated. -// -// Only for Dedicated Cluster. -// - IMPORTING: Cluster is being imported. -// -// Only for Dedicated Cluster. -// - MODIFYING: Cluster is being modified. -// -// Only for Dedicated Cluster. -// - PAUSING: Cluster is being paused. -// -// Only for Dedicated Cluster. -// - PAUSED: Cluster is paused. -// -// Only for Dedicated Cluster. -// - RESUMING: Cluster is resuming. -// -// Only for Dedicated Cluster. -// - SCALING: Cluster is scaling. -// -// Only for Dedicated Cluster. -// Only for Mgmt Internal API. -// -// swagger:model commonv1beta1ClusterState -type Commonv1beta1ClusterState string - -func NewCommonv1beta1ClusterState(value Commonv1beta1ClusterState) *Commonv1beta1ClusterState { - return &value -} - -// Pointer returns a pointer to a freshly-allocated Commonv1beta1ClusterState. -func (m Commonv1beta1ClusterState) Pointer() *Commonv1beta1ClusterState { - return &m -} - -const ( - - // Commonv1beta1ClusterStateCLUSTERSTATEUNSPECIFIED captures enum value "CLUSTER_STATE_UNSPECIFIED" - Commonv1beta1ClusterStateCLUSTERSTATEUNSPECIFIED Commonv1beta1ClusterState = "CLUSTER_STATE_UNSPECIFIED" - - // Commonv1beta1ClusterStateCREATING captures enum value "CREATING" - Commonv1beta1ClusterStateCREATING Commonv1beta1ClusterState = "CREATING" - - // Commonv1beta1ClusterStateDELETING captures enum value "DELETING" - Commonv1beta1ClusterStateDELETING Commonv1beta1ClusterState = "DELETING" - - // Commonv1beta1ClusterStateACTIVE captures enum value "ACTIVE" - Commonv1beta1ClusterStateACTIVE Commonv1beta1ClusterState = "ACTIVE" - - // Commonv1beta1ClusterStateRESTORING captures enum value "RESTORING" - Commonv1beta1ClusterStateRESTORING Commonv1beta1ClusterState = "RESTORING" - - // Commonv1beta1ClusterStateMAINTENANCE captures enum value "MAINTENANCE" - Commonv1beta1ClusterStateMAINTENANCE Commonv1beta1ClusterState = "MAINTENANCE" - - // Commonv1beta1ClusterStateDELETED captures enum value "DELETED" - Commonv1beta1ClusterStateDELETED Commonv1beta1ClusterState = "DELETED" - - // Commonv1beta1ClusterStateINACTIVE captures enum value "INACTIVE" - Commonv1beta1ClusterStateINACTIVE Commonv1beta1ClusterState = "INACTIVE" - - // Commonv1beta1ClusterStateUPDATING captures enum value "UPDATING" - Commonv1beta1ClusterStateUPDATING Commonv1beta1ClusterState = "UPDATING" - - // Commonv1beta1ClusterStateIMPORTING captures enum value "IMPORTING" - Commonv1beta1ClusterStateIMPORTING Commonv1beta1ClusterState = "IMPORTING" - - // Commonv1beta1ClusterStateMODIFYING captures enum value "MODIFYING" - Commonv1beta1ClusterStateMODIFYING Commonv1beta1ClusterState = "MODIFYING" - - // Commonv1beta1ClusterStatePAUSING captures enum value "PAUSING" - Commonv1beta1ClusterStatePAUSING Commonv1beta1ClusterState = "PAUSING" - - // Commonv1beta1ClusterStatePAUSED captures enum value "PAUSED" - Commonv1beta1ClusterStatePAUSED Commonv1beta1ClusterState = "PAUSED" - - // Commonv1beta1ClusterStateRESUMING captures enum value "RESUMING" - Commonv1beta1ClusterStateRESUMING Commonv1beta1ClusterState = "RESUMING" - - // Commonv1beta1ClusterStateSCALING captures enum value "SCALING" - Commonv1beta1ClusterStateSCALING Commonv1beta1ClusterState = "SCALING" -) - -// for schema -var commonv1beta1ClusterStateEnum []interface{} - -func init() { - var res []Commonv1beta1ClusterState - if err := json.Unmarshal([]byte(`["CLUSTER_STATE_UNSPECIFIED","CREATING","DELETING","ACTIVE","RESTORING","MAINTENANCE","DELETED","INACTIVE","UPDATING","IMPORTING","MODIFYING","PAUSING","PAUSED","RESUMING","SCALING"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - commonv1beta1ClusterStateEnum = append(commonv1beta1ClusterStateEnum, v) - } -} - -func (m Commonv1beta1ClusterState) validateCommonv1beta1ClusterStateEnum(path, location string, value Commonv1beta1ClusterState) error { - if err := validate.EnumCase(path, location, value, commonv1beta1ClusterStateEnum, true); err != nil { - return err - } - return nil -} - -// Validate validates this commonv1beta1 cluster state -func (m Commonv1beta1ClusterState) Validate(formats strfmt.Registry) error { - var res []error - - // value enum - if err := m.validateCommonv1beta1ClusterStateEnum("", "body", m); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// ContextValidate validates this commonv1beta1 cluster state based on context it is used -func (m Commonv1beta1ClusterState) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/commonv1beta1_region.go b/pkg/tidbcloud/v1beta1/serverless/models/commonv1beta1_region.go deleted file mode 100644 index 6b251b0f..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/commonv1beta1_region.go +++ /dev/null @@ -1,169 +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" -) - -// Commonv1beta1Region Message for describing a region for deploying TiDB Serverless clusters. -// -// swagger:model commonv1beta1Region -type Commonv1beta1Region struct { - - // Output only. User-friendly display name of the region. - // Read Only: true - DisplayName string `json:"displayName,omitempty"` - - // id - // Example: us-west-2 - // Read Only: true - ID string `json:"id,omitempty"` - - // Required. The unique name of the region. - // Example: regions/aws-us-west-2 - // Required: true - // Pattern: ^regions/(aws|gcp|azure)-(.+)$ - Name *string `json:"name"` - - // Output only. The cloud provider for the region. - // Read Only: true - Provider *V1beta1RegionCloudProvider `json:"provider,omitempty"` -} - -// Validate validates this commonv1beta1 region -func (m *Commonv1beta1Region) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateName(formats); err != nil { - res = append(res, err) - } - - if err := m.validateProvider(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *Commonv1beta1Region) validateName(formats strfmt.Registry) error { - - if err := validate.Required("name", "body", m.Name); err != nil { - return err - } - - if err := validate.Pattern("name", "body", *m.Name, `^regions/(aws|gcp|azure)-(.+)$`); err != nil { - return err - } - - return nil -} - -func (m *Commonv1beta1Region) validateProvider(formats strfmt.Registry) error { - if swag.IsZero(m.Provider) { // not required - return nil - } - - if m.Provider != nil { - if err := m.Provider.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("provider") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("provider") - } - return err - } - } - - return nil -} - -// ContextValidate validate this commonv1beta1 region based on the context it is used -func (m *Commonv1beta1Region) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateDisplayName(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateID(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateProvider(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *Commonv1beta1Region) contextValidateDisplayName(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "displayName", "body", string(m.DisplayName)); err != nil { - return err - } - - return nil -} - -func (m *Commonv1beta1Region) contextValidateID(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "id", "body", string(m.ID)); err != nil { - return err - } - - return nil -} - -func (m *Commonv1beta1Region) contextValidateProvider(ctx context.Context, formats strfmt.Registry) error { - - if m.Provider != nil { - - if swag.IsZero(m.Provider) { // not required - return nil - } - - if err := m.Provider.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("provider") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("provider") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (m *Commonv1beta1Region) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *Commonv1beta1Region) UnmarshalBinary(b []byte) error { - var res Commonv1beta1Region - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/endpoints_private.go b/pkg/tidbcloud/v1beta1/serverless/models/endpoints_private.go deleted file mode 100644 index ece9a82b..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/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 to securely connect to the cluster. -// -// swagger:model EndpointsPrivate -type EndpointsPrivate struct { - - // aws - // Read Only: true - Aws *PrivateAWS `json:"aws,omitempty"` - - // gcp - // Read Only: true - Gcp *PrivateGCP `json:"gcp,omitempty"` - - // Output_only. The hostname of the private endpoint. - // Read Only: true - Host string `json:"host,omitempty"` - - // Output_only. The port of the private 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/serverless/models/endpoints_public.go b/pkg/tidbcloud/v1beta1/serverless/models/endpoints_public.go deleted file mode 100644 index fc0e0887..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/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 to connect to the cluster. -// -// swagger:model EndpointsPublic -type EndpointsPublic struct { - - // Optional. Whether the public endpoint is disabled. - Disabled bool `json:"disabled,omitempty"` - - // Output_only. The hostname of the public endpoint. - // Read Only: true - Host string `json:"host,omitempty"` - - // Output_only. The port of the 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/serverless/models/googlerpc_status.go b/pkg/tidbcloud/v1beta1/serverless/models/googlerpc_status.go deleted file mode 100644 index 2a3a4a98..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/googlerpc_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" -) - -// GooglerpcStatus googlerpc status -// -// swagger:model googlerpcStatus -type GooglerpcStatus struct { - - // code - Code int32 `json:"code,omitempty"` - - // details - Details []*ProtobufAny `json:"details"` - - // message - Message string `json:"message,omitempty"` -} - -// Validate validates this googlerpc status -func (m *GooglerpcStatus) 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 *GooglerpcStatus) 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 googlerpc status based on the context it is used -func (m *GooglerpcStatus) 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 *GooglerpcStatus) 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 *GooglerpcStatus) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *GooglerpcStatus) UnmarshalBinary(b []byte) error { - var res GooglerpcStatus - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/private_a_w_s.go b/pkg/tidbcloud/v1beta1/serverless/models/private_a_w_s.go deleted file mode 100644 index 0b271625..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/private_a_w_s.go +++ /dev/null @@ -1,88 +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 PrivateLink information. -// -// swagger:model PrivateAWS -type PrivateAWS struct { - - // Output_only. The availability zones that the service is available in. - // Read Only: true - AvailabilityZone []string `json:"availabilityZone"` - - // Output_only. The AWS service name for private access. - // 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/serverless/models/private_g_c_p.go b/pkg/tidbcloud/v1beta1/serverless/models/private_g_c_p.go deleted file mode 100644 index 31ef01b3..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/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 Service information. -// -// swagger:model PrivateGCP -type PrivateGCP struct { - - // Output_only. The target GCP service attachment name for private access. - // 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/serverless/models/protobuf_any.go b/pkg/tidbcloud/v1beta1/serverless/models/protobuf_any.go deleted file mode 100644 index f25b51ed..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/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/serverless/models/serverlessv1beta1_cluster_view.go b/pkg/tidbcloud/v1beta1/serverless/models/serverlessv1beta1_cluster_view.go deleted file mode 100644 index b689a849..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/serverlessv1beta1_cluster_view.go +++ /dev/null @@ -1,85 +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" -) - -// Serverlessv1beta1ClusterView Enum for the different types of detail view to be returned for a TiDB Serverless cluster. -// -// - CLUSTER_VIEW_UNSPECIFIED: The server default is used if unspecified. -// - BASIC: Only basic information about the cluster is returned. -// - FULL: All details about the cluster are returned. -// -// swagger:model serverlessv1beta1ClusterView -type Serverlessv1beta1ClusterView string - -func NewServerlessv1beta1ClusterView(value Serverlessv1beta1ClusterView) *Serverlessv1beta1ClusterView { - return &value -} - -// Pointer returns a pointer to a freshly-allocated Serverlessv1beta1ClusterView. -func (m Serverlessv1beta1ClusterView) Pointer() *Serverlessv1beta1ClusterView { - return &m -} - -const ( - - // Serverlessv1beta1ClusterViewCLUSTERVIEWUNSPECIFIED captures enum value "CLUSTER_VIEW_UNSPECIFIED" - Serverlessv1beta1ClusterViewCLUSTERVIEWUNSPECIFIED Serverlessv1beta1ClusterView = "CLUSTER_VIEW_UNSPECIFIED" - - // Serverlessv1beta1ClusterViewBASIC captures enum value "BASIC" - Serverlessv1beta1ClusterViewBASIC Serverlessv1beta1ClusterView = "BASIC" - - // Serverlessv1beta1ClusterViewFULL captures enum value "FULL" - Serverlessv1beta1ClusterViewFULL Serverlessv1beta1ClusterView = "FULL" -) - -// for schema -var serverlessv1beta1ClusterViewEnum []interface{} - -func init() { - var res []Serverlessv1beta1ClusterView - if err := json.Unmarshal([]byte(`["CLUSTER_VIEW_UNSPECIFIED","BASIC","FULL"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - serverlessv1beta1ClusterViewEnum = append(serverlessv1beta1ClusterViewEnum, v) - } -} - -func (m Serverlessv1beta1ClusterView) validateServerlessv1beta1ClusterViewEnum(path, location string, value Serverlessv1beta1ClusterView) error { - if err := validate.EnumCase(path, location, value, serverlessv1beta1ClusterViewEnum, true); err != nil { - return err - } - return nil -} - -// Validate validates this serverlessv1beta1 cluster view -func (m Serverlessv1beta1ClusterView) Validate(formats strfmt.Registry) error { - var res []error - - // value enum - if err := m.validateServerlessv1beta1ClusterViewEnum("", "body", m); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// ContextValidate validates this serverlessv1beta1 cluster view based on context it is used -func (m Serverlessv1beta1ClusterView) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_cluster.go b/pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_cluster.go deleted file mode 100644 index 9e99f658..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_cluster.go +++ /dev/null @@ -1,596 +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" -) - -// TidbCloudOpenApiserverlessv1beta1Cluster Message for a serverless TiDB cluster resource. -// -// swagger:model tidb_cloud_open_apiserverlessv1beta1Cluster -type TidbCloudOpenApiserverlessv1beta1Cluster struct { - - // Optional. The annotations for the cluster. - // tidb.cloud/has-set-password. The annotation for whether the cluster has set password. - // tidb.cloud/available-features. The annotation for the available features of the cluster. - Annotations map[string]string `json:"annotations,omitempty"` - - // Optional. Automated backup policy to set on the cluster. - AutomatedBackupPolicy *V1beta1ClusterAutomatedBackupPolicy `json:"automatedBackupPolicy,omitempty"` - - // Output_only. The unique ID of the cluster. - // Read Only: true - ClusterID string `json:"clusterId,omitempty"` - - // Output_only. Timestamp when the cluster was created. - // Read Only: true - // Format: date-time - CreateTime strfmt.DateTime `json:"createTime,omitempty"` - - // Output_only. The email of the creator of the cluster. - // Read Only: true - CreatedBy string `json:"createdBy,omitempty"` - - // Required. User friendly display name of the cluster. - // Required: true - DisplayName *string `json:"displayName"` - - // Optional. Encryption settings for the cluster. - EncryptionConfig *V1beta1ClusterEncryptionConfig `json:"encryptionConfig,omitempty"` - - // Optional. The endpoints for connecting to the cluster. - Endpoints *TidbCloudOpenApiserverlessv1beta1ClusterEndpoints `json:"endpoints,omitempty"` - - // Optional. The labels for the cluster. - // tidb.cloud/organization. The label for the cluster organization id. - // tidb.cloud/project. The label for the cluster project id. - Labels map[string]string `json:"labels,omitempty"` - - // Output_only. The unique name of the cluster. - // Read Only: true - Name string `json:"name,omitempty"` - - // Required. Region where the cluster will be created. - // Required: true - Region *Commonv1beta1Region `json:"region"` - - // Optional. The spending limit for the cluster. - SpendingLimit *ClusterSpendingLimit `json:"spendingLimit,omitempty"` - - // Output_only. The current state of the cluster. - // Read Only: true - State *Commonv1beta1ClusterState `json:"state,omitempty"` - - // Output_only. Timestamp when the cluster was last updated. - // Read Only: true - // Format: date-time - UpdateTime strfmt.DateTime `json:"updateTime,omitempty"` - - // Output_only. Usage details of the cluster. - // Read Only: true - Usage *V1beta1ClusterUsage `json:"usage,omitempty"` - - // Output_only. The unique prefix in SQL user name. - // Read Only: true - UserPrefix string `json:"userPrefix,omitempty"` - - // Output_only. The TiDB version of the cluster. - // Read Only: true - Version string `json:"version,omitempty"` -} - -// Validate validates this tidb cloud open apiserverlessv1beta1 cluster -func (m *TidbCloudOpenApiserverlessv1beta1Cluster) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateAutomatedBackupPolicy(formats); err != nil { - res = append(res, err) - } - - 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.validateEncryptionConfig(formats); err != nil { - res = append(res, err) - } - - if err := m.validateEndpoints(formats); err != nil { - res = append(res, err) - } - - if err := m.validateRegion(formats); err != nil { - res = append(res, err) - } - - if err := m.validateSpendingLimit(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 *TidbCloudOpenApiserverlessv1beta1Cluster) validateAutomatedBackupPolicy(formats strfmt.Registry) error { - if swag.IsZero(m.AutomatedBackupPolicy) { // not required - return nil - } - - if m.AutomatedBackupPolicy != nil { - if err := m.AutomatedBackupPolicy.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("automatedBackupPolicy") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("automatedBackupPolicy") - } - return err - } - } - - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) validateDisplayName(formats strfmt.Registry) error { - - if err := validate.Required("displayName", "body", m.DisplayName); err != nil { - return err - } - - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1Cluster) validateEncryptionConfig(formats strfmt.Registry) error { - if swag.IsZero(m.EncryptionConfig) { // not required - return nil - } - - if m.EncryptionConfig != nil { - if err := m.EncryptionConfig.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("encryptionConfig") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("encryptionConfig") - } - return err - } - } - - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) validateRegion(formats strfmt.Registry) error { - - if err := validate.Required("region", "body", m.Region); err != nil { - return err - } - - if m.Region != nil { - if err := m.Region.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("region") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("region") - } - return err - } - } - - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1Cluster) validateSpendingLimit(formats strfmt.Registry) error { - if swag.IsZero(m.SpendingLimit) { // not required - return nil - } - - if m.SpendingLimit != nil { - if err := m.SpendingLimit.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("spendingLimit") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("spendingLimit") - } - return err - } - } - - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1Cluster) validateState(formats strfmt.Registry) error { - if swag.IsZero(m.State) { // not required - return nil - } - - if m.State != 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 tidb cloud open apiserverlessv1beta1 cluster based on the context it is used -func (m *TidbCloudOpenApiserverlessv1beta1Cluster) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateAutomatedBackupPolicy(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.contextValidateEncryptionConfig(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.contextValidateRegion(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateSpendingLimit(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 err := m.contextValidateVersion(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1Cluster) contextValidateAutomatedBackupPolicy(ctx context.Context, formats strfmt.Registry) error { - - if m.AutomatedBackupPolicy != nil { - - if swag.IsZero(m.AutomatedBackupPolicy) { // not required - return nil - } - - if err := m.AutomatedBackupPolicy.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("automatedBackupPolicy") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("automatedBackupPolicy") - } - return err - } - } - - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) contextValidateEncryptionConfig(ctx context.Context, formats strfmt.Registry) error { - - if m.EncryptionConfig != nil { - - if swag.IsZero(m.EncryptionConfig) { // not required - return nil - } - - if err := m.EncryptionConfig.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("encryptionConfig") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("encryptionConfig") - } - return err - } - } - - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) contextValidateRegion(ctx context.Context, formats strfmt.Registry) error { - - if m.Region != nil { - - if err := m.Region.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("region") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("region") - } - return err - } - } - - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1Cluster) contextValidateSpendingLimit(ctx context.Context, formats strfmt.Registry) error { - - if m.SpendingLimit != nil { - - if swag.IsZero(m.SpendingLimit) { // not required - return nil - } - - if err := m.SpendingLimit.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("spendingLimit") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("spendingLimit") - } - return err - } - } - - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1Cluster) contextValidateState(ctx context.Context, formats strfmt.Registry) error { - - if m.State != nil { - - 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) 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 *TidbCloudOpenApiserverlessv1beta1Cluster) contextValidateUserPrefix(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "userPrefix", "body", string(m.UserPrefix)); err != nil { - return err - } - - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1Cluster) contextValidateVersion(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "version", "body", string(m.Version)); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *TidbCloudOpenApiserverlessv1beta1Cluster) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *TidbCloudOpenApiserverlessv1beta1Cluster) UnmarshalBinary(b []byte) error { - var res TidbCloudOpenApiserverlessv1beta1Cluster - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_cluster_endpoints.go b/pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_cluster_endpoints.go deleted file mode 100644 index b9b9ded7..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_cluster_endpoints.go +++ /dev/null @@ -1,161 +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" -) - -// TidbCloudOpenApiserverlessv1beta1ClusterEndpoints Message for endpoint information for connecting to a cluster. -// -// swagger:model tidb_cloud_open_apiserverlessv1beta1ClusterEndpoints -type TidbCloudOpenApiserverlessv1beta1ClusterEndpoints struct { - - // Output_only. Private endpoint to securely connect to the cluster. - // Read Only: true - Private *EndpointsPrivate `json:"private,omitempty"` - - // Optional. Public endpoint to connect to the cluster. - Public *EndpointsPublic `json:"public,omitempty"` -} - -// Validate validates this tidb cloud open apiserverlessv1beta1 cluster endpoints -func (m *TidbCloudOpenApiserverlessv1beta1ClusterEndpoints) 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 *TidbCloudOpenApiserverlessv1beta1ClusterEndpoints) 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 *TidbCloudOpenApiserverlessv1beta1ClusterEndpoints) 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 tidb cloud open apiserverlessv1beta1 cluster endpoints based on the context it is used -func (m *TidbCloudOpenApiserverlessv1beta1ClusterEndpoints) 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 *TidbCloudOpenApiserverlessv1beta1ClusterEndpoints) 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 *TidbCloudOpenApiserverlessv1beta1ClusterEndpoints) 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 *TidbCloudOpenApiserverlessv1beta1ClusterEndpoints) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *TidbCloudOpenApiserverlessv1beta1ClusterEndpoints) UnmarshalBinary(b []byte) error { - var res TidbCloudOpenApiserverlessv1beta1ClusterEndpoints - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_cluster_state.go b/pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_cluster_state.go deleted file mode 100644 index ea612887..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_cluster_state.go +++ /dev/null @@ -1,101 +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" -) - -// TidbCloudOpenApiserverlessv1beta1ClusterState Enum for current state of a cluster. -// -// - STATE_UNSPECIFIED: Unspecified state. -// - CREATING: Cluster is being created. -// - DELETING: Cluster is being deleted. -// - ACTIVE: Cluster is active for use. -// - RESTORING: Cluster data is being restored. -// - MAINTENANCE: Cluster is under maintenance. -// - DELETED: Cluster has been deleted. -// -// swagger:model tidb_cloud_open_apiserverlessv1beta1ClusterState -type TidbCloudOpenApiserverlessv1beta1ClusterState string - -func NewTidbCloudOpenApiserverlessv1beta1ClusterState(value TidbCloudOpenApiserverlessv1beta1ClusterState) *TidbCloudOpenApiserverlessv1beta1ClusterState { - return &value -} - -// Pointer returns a pointer to a freshly-allocated TidbCloudOpenApiserverlessv1beta1ClusterState. -func (m TidbCloudOpenApiserverlessv1beta1ClusterState) Pointer() *TidbCloudOpenApiserverlessv1beta1ClusterState { - return &m -} - -const ( - - // TidbCloudOpenApiserverlessv1beta1ClusterStateSTATEUNSPECIFIED captures enum value "STATE_UNSPECIFIED" - TidbCloudOpenApiserverlessv1beta1ClusterStateSTATEUNSPECIFIED TidbCloudOpenApiserverlessv1beta1ClusterState = "STATE_UNSPECIFIED" - - // TidbCloudOpenApiserverlessv1beta1ClusterStateCREATING captures enum value "CREATING" - TidbCloudOpenApiserverlessv1beta1ClusterStateCREATING TidbCloudOpenApiserverlessv1beta1ClusterState = "CREATING" - - // TidbCloudOpenApiserverlessv1beta1ClusterStateDELETING captures enum value "DELETING" - TidbCloudOpenApiserverlessv1beta1ClusterStateDELETING TidbCloudOpenApiserverlessv1beta1ClusterState = "DELETING" - - // TidbCloudOpenApiserverlessv1beta1ClusterStateACTIVE captures enum value "ACTIVE" - TidbCloudOpenApiserverlessv1beta1ClusterStateACTIVE TidbCloudOpenApiserverlessv1beta1ClusterState = "ACTIVE" - - // TidbCloudOpenApiserverlessv1beta1ClusterStateRESTORING captures enum value "RESTORING" - TidbCloudOpenApiserverlessv1beta1ClusterStateRESTORING TidbCloudOpenApiserverlessv1beta1ClusterState = "RESTORING" - - // TidbCloudOpenApiserverlessv1beta1ClusterStateMAINTENANCE captures enum value "MAINTENANCE" - TidbCloudOpenApiserverlessv1beta1ClusterStateMAINTENANCE TidbCloudOpenApiserverlessv1beta1ClusterState = "MAINTENANCE" - - // TidbCloudOpenApiserverlessv1beta1ClusterStateDELETED captures enum value "DELETED" - TidbCloudOpenApiserverlessv1beta1ClusterStateDELETED TidbCloudOpenApiserverlessv1beta1ClusterState = "DELETED" -) - -// for schema -var tidbCloudOpenApiserverlessv1beta1ClusterStateEnum []interface{} - -func init() { - var res []TidbCloudOpenApiserverlessv1beta1ClusterState - if err := json.Unmarshal([]byte(`["STATE_UNSPECIFIED","CREATING","DELETING","ACTIVE","RESTORING","MAINTENANCE","DELETED"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - tidbCloudOpenApiserverlessv1beta1ClusterStateEnum = append(tidbCloudOpenApiserverlessv1beta1ClusterStateEnum, v) - } -} - -func (m TidbCloudOpenApiserverlessv1beta1ClusterState) validateTidbCloudOpenApiserverlessv1beta1ClusterStateEnum(path, location string, value TidbCloudOpenApiserverlessv1beta1ClusterState) error { - if err := validate.EnumCase(path, location, value, tidbCloudOpenApiserverlessv1beta1ClusterStateEnum, true); err != nil { - return err - } - return nil -} - -// Validate validates this tidb cloud open apiserverlessv1beta1 cluster state -func (m TidbCloudOpenApiserverlessv1beta1ClusterState) Validate(formats strfmt.Registry) error { - var res []error - - // value enum - if err := m.validateTidbCloudOpenApiserverlessv1beta1ClusterStateEnum("", "body", m); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// ContextValidate validates this tidb cloud open apiserverlessv1beta1 cluster state based on context it is used -func (m TidbCloudOpenApiserverlessv1beta1ClusterState) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_list_clusters_response.go b/pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_list_clusters_response.go deleted file mode 100644 index 4c47bea6..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_list_clusters_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" -) - -// TidbCloudOpenApiserverlessv1beta1ListClustersResponse Responses message to the request for listing of TiDB Serverless clusters. -// -// swagger:model tidb_cloud_open_apiserverlessv1beta1ListClustersResponse -type TidbCloudOpenApiserverlessv1beta1ListClustersResponse struct { - - // A list of clusters. - Clusters []*TidbCloudOpenApiserverlessv1beta1Cluster `json:"clusters"` - - // Token provided to retrieve the next page of results. - NextPageToken string `json:"nextPageToken,omitempty"` - - // Total number of available clusters. - TotalSize int64 `json:"totalSize,omitempty"` -} - -// Validate validates this tidb cloud open apiserverlessv1beta1 list clusters response -func (m *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateClusters(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) validateClusters(formats strfmt.Registry) error { - if swag.IsZero(m.Clusters) { // not required - return nil - } - - for i := 0; i < len(m.Clusters); i++ { - if swag.IsZero(m.Clusters[i]) { // not required - continue - } - - if m.Clusters[i] != nil { - if err := m.Clusters[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("clusters" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("clusters" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// ContextValidate validate this tidb cloud open apiserverlessv1beta1 list clusters response based on the context it is used -func (m *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateClusters(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) contextValidateClusters(ctx context.Context, formats strfmt.Registry) error { - - for i := 0; i < len(m.Clusters); i++ { - - if m.Clusters[i] != nil { - - if swag.IsZero(m.Clusters[i]) { // not required - return nil - } - - if err := m.Clusters[i].ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("clusters" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("clusters" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// MarshalBinary interface implementation -func (m *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *TidbCloudOpenApiserverlessv1beta1ListClustersResponse) UnmarshalBinary(b []byte) error { - var res TidbCloudOpenApiserverlessv1beta1ListClustersResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_list_regions_response.go b/pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_list_regions_response.go deleted file mode 100644 index 46c79b5b..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_list_regions_response.go +++ /dev/null @@ -1,121 +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" -) - -// TidbCloudOpenApiserverlessv1beta1ListRegionsResponse Responses message to the request for listing of available regions in TiDB Serverless. -// -// swagger:model tidb_cloud_open_apiserverlessv1beta1ListRegionsResponse -type TidbCloudOpenApiserverlessv1beta1ListRegionsResponse struct { - - // A list of available regions. - Regions []*Commonv1beta1Region `json:"regions"` -} - -// Validate validates this tidb cloud open apiserverlessv1beta1 list regions response -func (m *TidbCloudOpenApiserverlessv1beta1ListRegionsResponse) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateRegions(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1ListRegionsResponse) validateRegions(formats strfmt.Registry) error { - if swag.IsZero(m.Regions) { // not required - return nil - } - - for i := 0; i < len(m.Regions); i++ { - if swag.IsZero(m.Regions[i]) { // not required - continue - } - - if m.Regions[i] != nil { - if err := m.Regions[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("regions" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("regions" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// ContextValidate validate this tidb cloud open apiserverlessv1beta1 list regions response based on the context it is used -func (m *TidbCloudOpenApiserverlessv1beta1ListRegionsResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateRegions(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1ListRegionsResponse) contextValidateRegions(ctx context.Context, formats strfmt.Registry) error { - - for i := 0; i < len(m.Regions); i++ { - - if m.Regions[i] != nil { - - if swag.IsZero(m.Regions[i]) { // not required - return nil - } - - if err := m.Regions[i].ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("regions" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("regions" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// MarshalBinary interface implementation -func (m *TidbCloudOpenApiserverlessv1beta1ListRegionsResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *TidbCloudOpenApiserverlessv1beta1ListRegionsResponse) UnmarshalBinary(b []byte) error { - var res TidbCloudOpenApiserverlessv1beta1ListRegionsResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_region.go b/pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_region.go deleted file mode 100644 index c505df40..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/tidb_cloud_open_apiserverlessv1beta1_region.go +++ /dev/null @@ -1,145 +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" -) - -// TidbCloudOpenApiserverlessv1beta1Region Message for describing a region for deploying TiDB Serverless clusters. -// -// swagger:model tidb_cloud_open_apiserverlessv1beta1Region -type TidbCloudOpenApiserverlessv1beta1Region struct { - - // Output_only. Immutable. User-friendly display name of the region. - // Read Only: true - DisplayName string `json:"displayName,omitempty"` - - // Required. Immutable. The unique name of the region. - // Required: true - Name *string `json:"name"` - - // Output_only. Immutable. The cloud provider for the region. - // Read Only: true - Provider *V1beta1RegionCloudProvider `json:"provider,omitempty"` -} - -// Validate validates this tidb cloud open apiserverlessv1beta1 region -func (m *TidbCloudOpenApiserverlessv1beta1Region) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateName(formats); err != nil { - res = append(res, err) - } - - if err := m.validateProvider(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1Region) validateName(formats strfmt.Registry) error { - - if err := validate.Required("name", "body", m.Name); err != nil { - return err - } - - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1Region) validateProvider(formats strfmt.Registry) error { - if swag.IsZero(m.Provider) { // not required - return nil - } - - if m.Provider != nil { - if err := m.Provider.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("provider") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("provider") - } - return err - } - } - - return nil -} - -// ContextValidate validate this tidb cloud open apiserverlessv1beta1 region based on the context it is used -func (m *TidbCloudOpenApiserverlessv1beta1Region) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateDisplayName(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateProvider(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1Region) contextValidateDisplayName(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "displayName", "body", string(m.DisplayName)); err != nil { - return err - } - - return nil -} - -func (m *TidbCloudOpenApiserverlessv1beta1Region) contextValidateProvider(ctx context.Context, formats strfmt.Registry) error { - - if m.Provider != nil { - - if swag.IsZero(m.Provider) { // not required - return nil - } - - if err := m.Provider.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("provider") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("provider") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (m *TidbCloudOpenApiserverlessv1beta1Region) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *TidbCloudOpenApiserverlessv1beta1Region) UnmarshalBinary(b []byte) error { - var res TidbCloudOpenApiserverlessv1beta1Region - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_change_root_password_response.go b/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_change_root_password_response.go deleted file mode 100644 index e6e60469..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_change_root_password_response.go +++ /dev/null @@ -1,11 +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 - -// V1beta1ChangeRootPasswordResponse Responses message to the request for changing the root password of a TiDB Serverless cluster. -// -// swagger:model v1beta1ChangeRootPasswordResponse -type V1beta1ChangeRootPasswordResponse interface{} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_automated_backup_policy.go b/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_automated_backup_policy.go deleted file mode 100644 index 8dd25ef2..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_automated_backup_policy.go +++ /dev/null @@ -1,53 +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/strfmt" - "github.com/go-openapi/swag" -) - -// V1beta1ClusterAutomatedBackupPolicy Message for automated backup configuration for a cluster. -// -// swagger:model v1beta1ClusterAutomatedBackupPolicy -type V1beta1ClusterAutomatedBackupPolicy struct { - - // Optional. Number of days to retain automated backups. - RetentionDays int32 `json:"retentionDays,omitempty"` - - // Optional. Cron expression for when automated backups should start. - StartTime string `json:"startTime,omitempty"` -} - -// Validate validates this v1beta1 cluster automated backup policy -func (m *V1beta1ClusterAutomatedBackupPolicy) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this v1beta1 cluster automated backup policy based on context it is used -func (m *V1beta1ClusterAutomatedBackupPolicy) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *V1beta1ClusterAutomatedBackupPolicy) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *V1beta1ClusterAutomatedBackupPolicy) UnmarshalBinary(b []byte) error { - var res V1beta1ClusterAutomatedBackupPolicy - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_encryption_config.go b/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_encryption_config.go deleted file mode 100644 index 487b5ac3..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_encryption_config.go +++ /dev/null @@ -1,50 +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/strfmt" - "github.com/go-openapi/swag" -) - -// V1beta1ClusterEncryptionConfig Message for encryption settings for a cluster. -// -// swagger:model v1beta1ClusterEncryptionConfig -type V1beta1ClusterEncryptionConfig struct { - - // Optional. Whether enhanced encryption for cluster data is enabled. - EnhancedEncryptionEnabled bool `json:"enhancedEncryptionEnabled,omitempty"` -} - -// Validate validates this v1beta1 cluster encryption config -func (m *V1beta1ClusterEncryptionConfig) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this v1beta1 cluster encryption config based on context it is used -func (m *V1beta1ClusterEncryptionConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *V1beta1ClusterEncryptionConfig) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *V1beta1ClusterEncryptionConfig) UnmarshalBinary(b []byte) error { - var res V1beta1ClusterEncryptionConfig - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_endpoints.go b/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_endpoints.go deleted file mode 100644 index a519337d..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_endpoints.go +++ /dev/null @@ -1,161 +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" -) - -// V1beta1ClusterEndpoints Message for endpoint information for connecting to a cluster. -// -// swagger:model v1beta1ClusterEndpoints -type V1beta1ClusterEndpoints struct { - - // Output_only. Private endpoint to securely connect to the cluster. - // Read Only: true - PrivateEndpoint *EndpointsPrivate `json:"privateEndpoint,omitempty"` - - // Optional. Public endpoint to connect to the cluster. - PublicEndpoint *EndpointsPublic `json:"publicEndpoint,omitempty"` -} - -// Validate validates this v1beta1 cluster endpoints -func (m *V1beta1ClusterEndpoints) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validatePrivateEndpoint(formats); err != nil { - res = append(res, err) - } - - if err := m.validatePublicEndpoint(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *V1beta1ClusterEndpoints) validatePrivateEndpoint(formats strfmt.Registry) error { - if swag.IsZero(m.PrivateEndpoint) { // not required - return nil - } - - if m.PrivateEndpoint != nil { - if err := m.PrivateEndpoint.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("privateEndpoint") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("privateEndpoint") - } - return err - } - } - - return nil -} - -func (m *V1beta1ClusterEndpoints) validatePublicEndpoint(formats strfmt.Registry) error { - if swag.IsZero(m.PublicEndpoint) { // not required - return nil - } - - if m.PublicEndpoint != nil { - if err := m.PublicEndpoint.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("publicEndpoint") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("publicEndpoint") - } - return err - } - } - - return nil -} - -// ContextValidate validate this v1beta1 cluster endpoints based on the context it is used -func (m *V1beta1ClusterEndpoints) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidatePrivateEndpoint(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidatePublicEndpoint(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *V1beta1ClusterEndpoints) contextValidatePrivateEndpoint(ctx context.Context, formats strfmt.Registry) error { - - if m.PrivateEndpoint != nil { - - if swag.IsZero(m.PrivateEndpoint) { // not required - return nil - } - - if err := m.PrivateEndpoint.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("privateEndpoint") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("privateEndpoint") - } - return err - } - } - - return nil -} - -func (m *V1beta1ClusterEndpoints) contextValidatePublicEndpoint(ctx context.Context, formats strfmt.Registry) error { - - if m.PublicEndpoint != nil { - - if swag.IsZero(m.PublicEndpoint) { // not required - return nil - } - - if err := m.PublicEndpoint.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("publicEndpoint") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("publicEndpoint") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (m *V1beta1ClusterEndpoints) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *V1beta1ClusterEndpoints) UnmarshalBinary(b []byte) error { - var res V1beta1ClusterEndpoints - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_usage.go b/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_usage.go deleted file mode 100644 index 68f30393..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_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" -) - -// V1beta1ClusterUsage Message for usage statistics of a cluster. -// -// swagger:model v1beta1ClusterUsage -type V1beta1ClusterUsage struct { - - // Output_only. The storage used on column-based storage in bytes. - // Read Only: true - ColumnarStorage float64 `json:"columnarStorage,omitempty"` - - // Output_only. The Request Units used in this month. - // Read Only: true - RequestUnit string `json:"requestUnit,omitempty"` - - // Output_only. The storage used on row-based storage in bytes. - // Read Only: true - RowBasedStorage float64 `json:"rowBasedStorage,omitempty"` -} - -// Validate validates this v1beta1 cluster usage -func (m *V1beta1ClusterUsage) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validate this v1beta1 cluster usage based on the context it is used -func (m *V1beta1ClusterUsage) 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.contextValidateRowBasedStorage(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *V1beta1ClusterUsage) 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 *V1beta1ClusterUsage) 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 *V1beta1ClusterUsage) contextValidateRowBasedStorage(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "rowBasedStorage", "body", float64(m.RowBasedStorage)); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *V1beta1ClusterUsage) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *V1beta1ClusterUsage) UnmarshalBinary(b []byte) error { - var res V1beta1ClusterUsage - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_view.go b/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_view.go deleted file mode 100644 index b902616b..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_cluster_view.go +++ /dev/null @@ -1,85 +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" -) - -// V1beta1ClusterView Enum for the different types of detail view to be returned for a TiDB Serverless cluster. -// -// - CLUSTER_VIEW_UNSPECIFIED: The server default is used if unspecified. -// - BASIC: Only basic information about the cluster is returned. -// - FULL: All details about the cluster are returned. -// -// swagger:model v1beta1ClusterView -type V1beta1ClusterView string - -func NewV1beta1ClusterView(value V1beta1ClusterView) *V1beta1ClusterView { - return &value -} - -// Pointer returns a pointer to a freshly-allocated V1beta1ClusterView. -func (m V1beta1ClusterView) Pointer() *V1beta1ClusterView { - return &m -} - -const ( - - // V1beta1ClusterViewCLUSTERVIEWUNSPECIFIED captures enum value "CLUSTER_VIEW_UNSPECIFIED" - V1beta1ClusterViewCLUSTERVIEWUNSPECIFIED V1beta1ClusterView = "CLUSTER_VIEW_UNSPECIFIED" - - // V1beta1ClusterViewBASIC captures enum value "BASIC" - V1beta1ClusterViewBASIC V1beta1ClusterView = "BASIC" - - // V1beta1ClusterViewFULL captures enum value "FULL" - V1beta1ClusterViewFULL V1beta1ClusterView = "FULL" -) - -// for schema -var v1beta1ClusterViewEnum []interface{} - -func init() { - var res []V1beta1ClusterView - if err := json.Unmarshal([]byte(`["CLUSTER_VIEW_UNSPECIFIED","BASIC","FULL"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - v1beta1ClusterViewEnum = append(v1beta1ClusterViewEnum, v) - } -} - -func (m V1beta1ClusterView) validateV1beta1ClusterViewEnum(path, location string, value V1beta1ClusterView) error { - if err := validate.EnumCase(path, location, value, v1beta1ClusterViewEnum, true); err != nil { - return err - } - return nil -} - -// Validate validates this v1beta1 cluster view -func (m V1beta1ClusterView) Validate(formats strfmt.Registry) error { - var res []error - - // value enum - if err := m.validateV1beta1ClusterViewEnum("", "body", m); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// ContextValidate validates this v1beta1 cluster view based on context it is used -func (m V1beta1ClusterView) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_region_cloud_provider.go b/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_region_cloud_provider.go deleted file mode 100644 index 9e0aa5f9..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/models/v1beta1_region_cloud_provider.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" -) - -// V1beta1RegionCloudProvider Enum for cloud providers for the region. -// @gotags: tag:"replace" -// -// - CLOUD_PROVIDER_UNSPECIFIED: Unspecified cloud provider. -// - AWS: Amazon Web Services. -// - GCP: Google Cloud Platform. -// - AZURE: Microsoft Azure. -// -// swagger:model v1beta1RegionCloudProvider -type V1beta1RegionCloudProvider string - -func NewV1beta1RegionCloudProvider(value V1beta1RegionCloudProvider) *V1beta1RegionCloudProvider { - return &value -} - -// Pointer returns a pointer to a freshly-allocated V1beta1RegionCloudProvider. -func (m V1beta1RegionCloudProvider) Pointer() *V1beta1RegionCloudProvider { - return &m -} - -const ( - - // V1beta1RegionCloudProviderCLOUDPROVIDERUNSPECIFIED captures enum value "CLOUD_PROVIDER_UNSPECIFIED" - V1beta1RegionCloudProviderCLOUDPROVIDERUNSPECIFIED V1beta1RegionCloudProvider = "CLOUD_PROVIDER_UNSPECIFIED" - - // V1beta1RegionCloudProviderAWS captures enum value "AWS" - V1beta1RegionCloudProviderAWS V1beta1RegionCloudProvider = "AWS" - - // V1beta1RegionCloudProviderGCP captures enum value "GCP" - V1beta1RegionCloudProviderGCP V1beta1RegionCloudProvider = "GCP" - - // V1beta1RegionCloudProviderAZURE captures enum value "AZURE" - V1beta1RegionCloudProviderAZURE V1beta1RegionCloudProvider = "AZURE" -) - -// for schema -var v1beta1RegionCloudProviderEnum []interface{} - -func init() { - var res []V1beta1RegionCloudProvider - if err := json.Unmarshal([]byte(`["CLOUD_PROVIDER_UNSPECIFIED","AWS","GCP","AZURE"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - v1beta1RegionCloudProviderEnum = append(v1beta1RegionCloudProviderEnum, v) - } -} - -func (m V1beta1RegionCloudProvider) validateV1beta1RegionCloudProviderEnum(path, location string, value V1beta1RegionCloudProvider) error { - if err := validate.EnumCase(path, location, value, v1beta1RegionCloudProviderEnum, true); err != nil { - return err - } - return nil -} - -// Validate validates this v1beta1 region cloud provider -func (m V1beta1RegionCloudProvider) Validate(formats strfmt.Registry) error { - var res []error - - // value enum - if err := m.validateV1beta1RegionCloudProviderEnum("", "body", m); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// ContextValidate validates this v1beta1 region cloud provider based on context it is used -func (m V1beta1RegionCloudProvider) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} From 9681f0367d7169dbbfb837ff24a2212e94061d3b Mon Sep 17 00:00:00 2001 From: shi yuhang <52435083+shiyuhang0@users.noreply.github.com> Date: Wed, 4 Sep 2024 21:34:31 +0800 Subject: [PATCH 2/3] Add export test (#228) --- internal/cli/serverless/export/cancel.go | 2 +- internal/cli/serverless/export/cancel_test.go | 113 +++++ internal/cli/serverless/export/create.go | 11 +- internal/cli/serverless/export/create_test.go | 434 ++++++++++++++++++ .../cli/serverless/export/describe_test.go | 151 ++++++ internal/cli/serverless/export/list_test.go | 239 ++++++++++ 6 files changed, 944 insertions(+), 6 deletions(-) create mode 100644 internal/cli/serverless/export/cancel_test.go create mode 100644 internal/cli/serverless/export/create_test.go create mode 100644 internal/cli/serverless/export/describe_test.go create mode 100644 internal/cli/serverless/export/list_test.go diff --git a/internal/cli/serverless/export/cancel.go b/internal/cli/serverless/export/cancel.go index df893443..98f3ad45 100644 --- a/internal/cli/serverless/export/cancel.go +++ b/internal/cli/serverless/export/cancel.go @@ -127,7 +127,7 @@ func CancelCmd(h *internal.Helper) *cobra.Command { if !force { if !h.IOStreams.CanPrompt { - return fmt.Errorf("the terminal doesn't support prompt, please run with --force to delete the branch") + return fmt.Errorf("the terminal doesn't support prompt, please run with --force to cancel the export") } confirmationMessage := fmt.Sprintf("%s %s %s", color.BlueString("Please type"), color.HiBlueString(confirmed), color.BlueString("to confirm:")) diff --git a/internal/cli/serverless/export/cancel_test.go b/internal/cli/serverless/export/cancel_test.go new file mode 100644 index 00000000..e8ee95e7 --- /dev/null +++ b/internal/cli/serverless/export/cancel_test.go @@ -0,0 +1,113 @@ +// Copyright 2024 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package export + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "os" + "testing" + + "tidbcloud-cli/internal" + "tidbcloud-cli/internal/iostream" + "tidbcloud-cli/internal/mock" + "tidbcloud-cli/internal/service/cloud" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/export" + + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" +) + +type CancelExportSuite struct { + suite.Suite + h *internal.Helper + mockClient *mock.TiDBCloudClient +} + +func (suite *CancelExportSuite) SetupTest() { + if err := os.Setenv("NO_COLOR", "true"); err != nil { + suite.T().Error(err) + } + + var pageSize int64 = 10 + suite.mockClient = new(mock.TiDBCloudClient) + suite.h = &internal.Helper{ + Client: func() (cloud.TiDBCloudClient, error) { + return suite.mockClient, nil + }, + QueryPageSize: pageSize, + IOStreams: iostream.Test(), + } +} + +func (suite *DescribeExportSuite) TestCancelExportArgs() { + assert := require.New(suite.T()) + ctx := context.Background() + + body := &export.Export{} + err := json.Unmarshal([]byte(getExportResp), body) + assert.Nil(err) + clusterId := "fake-cluster-id" + exportId := "fake-export-id" + suite.mockClient.On("CancelExport", ctx, clusterId, exportId).Return(body, nil) + + tests := []struct { + name string + args []string + err error + stdoutString string + stderrString string + }{ + { + name: "cancel export success", + args: []string{"-c", clusterId, "-e", exportId, "--force"}, + stdoutString: "export fake-export-id canceled\n", + }, + { + name: "cancel export without force", + args: []string{"-c", clusterId, "-e", exportId}, + err: fmt.Errorf("the terminal doesn't support prompt, please run with --force to cancel the export"), + }, + { + name: "cancel export without required cluster id", + args: []string{"-e", exportId}, + err: fmt.Errorf("required flag(s) \"cluster-id\" not set"), + }, + } + + for _, tt := range tests { + suite.T().Run(tt.name, func(t *testing.T) { + cmd := CancelCmd(suite.h) + cmd.SetContext(ctx) + suite.h.IOStreams.Out.(*bytes.Buffer).Reset() + suite.h.IOStreams.Err.(*bytes.Buffer).Reset() + cmd.SetArgs(tt.args) + err = cmd.Execute() + assert.Equal(tt.err, err) + + assert.Equal(tt.stdoutString, suite.h.IOStreams.Out.(*bytes.Buffer).String()) + assert.Equal(tt.stderrString, suite.h.IOStreams.Err.(*bytes.Buffer).String()) + if tt.err == nil { + suite.mockClient.AssertExpectations(suite.T()) + } + }) + } +} + +func TestCancelExportSuite(t *testing.T) { + suite.Run(t, new(CancelExportSuite)) +} diff --git a/internal/cli/serverless/export/create.go b/internal/cli/serverless/export/create.go index 3b93b668..521fb4f0 100644 --- a/internal/cli/serverless/export/create.go +++ b/internal/cli/serverless/export/create.go @@ -72,8 +72,9 @@ const ( CSVSeparatorDefaultValue = "," CSVDelimiterDefaultValue = "\"" CSVNullValueDefaultValue = "\\N" - CompressionDefaultValue = "GZIP" - ParquetCompressionDefaultValue = "ZSTD" + CSVSkipHeaderDefaultValue = false + CompressionDefaultValue = export.EXPORTCOMPRESSIONTYPEENUM_GZIP + ParquetCompressionDefaultValue = export.EXPORTPARQUETCOMPRESSIONTYPEENUM_ZSTD ) type CreateOpts struct { @@ -557,10 +558,10 @@ func CreateCmd(h *internal.Helper) *cobra.Command { // apply default values if strings.ToUpper(fileType) == string(FileTypePARQUET) { if parquetCompression == "" { - parquetCompression = ParquetCompressionDefaultValue + parquetCompression = string(ParquetCompressionDefaultValue) } } else if compression == "" { - compression = CompressionDefaultValue + compression = string(CompressionDefaultValue) } // build param to create export fileTypeEnum := export.ExportFileTypeEnum(strings.ToUpper(fileType)) @@ -668,7 +669,7 @@ func CreateCmd(h *internal.Helper) *cobra.Command { createCmd.Flags().String(flag.CSVDelimiter, CSVDelimiterDefaultValue, "Delimiter of string type variables in CSV files.") createCmd.Flags().String(flag.CSVSeparator, CSVSeparatorDefaultValue, "Separator of each value in CSV files.") createCmd.Flags().String(flag.CSVNullValue, CSVNullValueDefaultValue, "Representation of null values in CSV files.") - createCmd.Flags().Bool(flag.CSVSkipHeader, false, "Export CSV files of the tables without header.") + createCmd.Flags().Bool(flag.CSVSkipHeader, CSVSkipHeaderDefaultValue, "Export CSV files of the tables without header.") createCmd.Flags().String(flag.S3RoleArn, "", "The role arn of the S3. You only need to set one of the s3.role-arn and [s3.access-key-id, s3.secret-access-key].") createCmd.Flags().String(flag.GCSURI, "", "The GCS URI in gcs:/// format. Required when target type is GCS.") createCmd.Flags().String(flag.GCSServiceAccountKey, "", "The base64 encoded service account key of GCS.") diff --git a/internal/cli/serverless/export/create_test.go b/internal/cli/serverless/export/create_test.go new file mode 100644 index 00000000..fc824348 --- /dev/null +++ b/internal/cli/serverless/export/create_test.go @@ -0,0 +1,434 @@ +// Copyright 2024 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package export + +import ( + "bytes" + "context" + "errors" + "fmt" + "os" + "testing" + + "tidbcloud-cli/internal" + "tidbcloud-cli/internal/iostream" + "tidbcloud-cli/internal/mock" + "tidbcloud-cli/internal/service/cloud" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/export" + + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" +) + +type CreateExportSuite struct { + suite.Suite + h *internal.Helper + mockClient *mock.TiDBCloudClient +} + +func (suite *CreateExportSuite) SetupTest() { + if err := os.Setenv("NO_COLOR", "true"); err != nil { + suite.T().Error(err) + } + + var pageSize int64 = 10 + suite.mockClient = new(mock.TiDBCloudClient) + suite.h = &internal.Helper{ + Client: func() (cloud.TiDBCloudClient, error) { + return suite.mockClient, nil + }, + QueryPageSize: pageSize, + IOStreams: iostream.Test(), + } +} + +func (suite *CreateExportSuite) TestCreateExportToLocal() { + ctx := context.Background() + + clusterId := "fake-cluster-id" + exportId := "fake-export-id" + + suite.mockClient.On("CreateExport", ctx, clusterId, getDefaultCreateExportBody()). + Return(&export.Export{ + ExportId: &exportId, + }, nil) + + tests := []Test{ + { + name: "export all data to local with force", + args: []string{"-c", clusterId, "--force"}, + stdoutString: fmt.Sprintf("export %s is running now\n", exportId), + }, + { + name: "export all data to local without force", + args: []string{"-c", clusterId}, + err: errors.New("the terminal doesn't support prompt, please run with --force to create export"), + }, + } + suite.AssertTest(ctx, tests) +} + +func (suite *CreateExportSuite) TestCreateExportToS3WithRoleArn() { + ctx := context.Background() + + clusterId := "fake-cluster-id" + exportId := "fake-export-id" + targetType := export.EXPORTTARGETTYPEENUM_S3 + uri := "s3://fake-bucket/fake-prefix" + roleArn := "arn:aws:iam::123456789012:role/service-role/AmazonS3FullAccess" + + body := getDefaultCreateExportBody() + body.Target = &export.ExportTarget{ + Type: &targetType, + S3: &export.S3Target{ + Uri: &uri, + AuthType: export.EXPORTS3AUTHTYPEENUM_ROLE_ARN, + RoleArn: &roleArn, + }, + } + suite.mockClient.On("CreateExport", ctx, clusterId, body). + Return(&export.Export{ + ExportId: &exportId, + }, nil) + + tests := []Test{ + { + name: "export all data to s3 using role arn", + args: []string{"-c", clusterId, "--target-type", "S3", "--s3.uri", uri, "--s3.role-arn", roleArn, "--force"}, + stdoutString: fmt.Sprintf("export %s is running now\n", exportId), + }, + { + name: "export all data to s3 without uri", + args: []string{"-c", clusterId, "--target-type", "S3", "--s3.role-arn", roleArn, "--force"}, + err: errors.New("S3 URI is required when target type is S3"), + }, + { + name: "export all data to s3 without auth", + args: []string{"-c", clusterId, "--target-type", "S3", "--s3.uri", uri, "--force"}, + err: errors.New("missing S3 auth information, require either role arn or access key id and secret access key"), + }, + } + + suite.AssertTest(ctx, tests) +} + +func (suite *CreateExportSuite) TestCreateExportToS3WithAccessKey() { + ctx := context.Background() + + clusterId := "fake-cluster-id" + exportId := "fake-export-id" + targetType := export.EXPORTTARGETTYPEENUM_S3 + uri := "s3://fake-bucket/fake-prefix" + accessKeyId := "fake-id" + secretAccess := "fake-secret" + + body := getDefaultCreateExportBody() + body.Target = &export.ExportTarget{ + Type: &targetType, + S3: &export.S3Target{ + Uri: &uri, + AuthType: export.EXPORTS3AUTHTYPEENUM_ACCESS_KEY, + AccessKey: &export.S3TargetAccessKey{ + Id: accessKeyId, + Secret: secretAccess, + }, + }, + } + suite.mockClient.On("CreateExport", ctx, clusterId, body). + Return(&export.Export{ + ExportId: &exportId, + }, nil) + + tests := []Test{ + { + name: "export all data to s3 using access key", + args: []string{"-c", clusterId, "--target-type", "S3", "--s3.uri", uri, "--s3.access-key-id", accessKeyId, "--s3.secret-access-key", secretAccess, "--force"}, + stdoutString: fmt.Sprintf("export %s is running now\n", exportId), + }, + } + suite.AssertTest(ctx, tests) +} + +func (suite *CreateExportSuite) TestCreateExportToGCS() { + ctx := context.Background() + + clusterId := "fake-cluster-id" + exportId := "fake-export-id" + targetType := export.EXPORTTARGETTYPEENUM_GCS + uri := "s3://fake-bucket/fake-prefix" + serviceAccountKey := "fake-service-account-key" + + body := getDefaultCreateExportBody() + body.Target = &export.ExportTarget{ + Type: &targetType, + Gcs: &export.GCSTarget{ + Uri: uri, + AuthType: export.EXPORTGCSAUTHTYPEENUM_SERVICE_ACCOUNT_KEY, + ServiceAccountKey: &serviceAccountKey, + }, + } + suite.mockClient.On("CreateExport", ctx, clusterId, body). + Return(&export.Export{ + ExportId: &exportId, + }, nil) + + tests := []Test{ + { + name: "export all data to gcs", + args: []string{"-c", clusterId, "--target-type", "GCS", "--gcs.uri", uri, "--gcs.service-account-key", serviceAccountKey, "--force"}, + stdoutString: fmt.Sprintf("export %s is running now\n", exportId), + }, + { + name: "export all data to gcs without auth", + args: []string{"-c", clusterId, "--target-type", "GCS", "--gcs.uri", uri, "--force"}, + err: errors.New("GCS service account key is required when target type is GCS"), + }, + { + name: "export all data to gcs without uri", + args: []string{"-c", clusterId, "--target-type", "GCS", "--gcs.service-account-key", serviceAccountKey, "--force"}, + err: errors.New("GCS URI is required when target type is GCS"), + }, + } + suite.AssertTest(ctx, tests) +} + +func (suite *CreateExportSuite) TestCreateExportToAzure() { + ctx := context.Background() + + clusterId := "fake-cluster-id" + exportId := "fake-export-id" + targetType := export.EXPORTTARGETTYPEENUM_AZURE_BLOB + uri := "s3://fake-bucket/fake-prefix" + sasToken := "fake-sas-token" + + body := getDefaultCreateExportBody() + body.Target = &export.ExportTarget{ + Type: &targetType, + AzureBlob: &export.AzureBlobTarget{ + Uri: uri, + AuthType: export.EXPORTAZUREBLOBAUTHTYPEENUM_SAS_TOKEN, + SasToken: &sasToken, + }, + } + suite.mockClient.On("CreateExport", ctx, clusterId, body). + Return(&export.Export{ + ExportId: &exportId, + }, nil) + + tests := []Test{ + { + name: "export all data to azure blob", + args: []string{"-c", clusterId, "--target-type", "AZURE_BLOB", "--azblob.uri", uri, "--azblob.sas-token", sasToken, "--force"}, + stdoutString: fmt.Sprintf("export %s is running now\n", exportId), + }, + { + name: "export all data to azure blob without auth", + args: []string{"-c", clusterId, "--target-type", "AZURE_BLOB", "--azblob.uri", uri, "--force"}, + err: errors.New("Azure Blob SAS token is required when target type is AZURE_BLOB"), + }, + { + name: "export all data to azure blob without uri", + args: []string{"-c", clusterId, "--target-type", "AZURE_BLOB", "--azblob.sas-token", sasToken, "--force"}, + err: errors.New("Azure Blob URI is required when target type is AZURE_BLOB"), + }, + } + suite.AssertTest(ctx, tests) +} + +func (suite *CreateExportSuite) TestCreateExportWithSQLFile() { + ctx := context.Background() + + clusterId := "fake-cluster-id" + exportId := "fake-export-id" + fileType := export.EXPORTFILETYPEENUM_SQL + + body := getDefaultCreateExportBody() + body.ExportOptions.FileType = &fileType + body.ExportOptions.CsvFormat = nil + + suite.mockClient.On("CreateExport", ctx, clusterId, body). + Return(&export.Export{ + ExportId: &exportId, + }, nil) + + tests := []Test{ + { + name: "export all data to sql file", + args: []string{"-c", clusterId, "--file-type", "SQL", "--force"}, + stdoutString: fmt.Sprintf("export %s is running now\n", exportId), + }, + } + suite.AssertTest(ctx, tests) +} + +func (suite *CreateExportSuite) TestCreateExportWithParquetFile() { + ctx := context.Background() + + clusterId := "fake-cluster-id" + exportId := "fake-export-id" + fileType := export.EXPORTFILETYPEENUM_PARQUET + parquetCompression := export.EXPORTPARQUETCOMPRESSIONTYPEENUM_ZSTD + + body := getDefaultCreateExportBody() + body.ExportOptions.FileType = &fileType + body.ExportOptions.Compression = nil + body.ExportOptions.CsvFormat = nil + body.ExportOptions.ParquetFormat = &export.ExportOptionsParquetFormat{ + Compression: &parquetCompression, + } + + suite.mockClient.On("CreateExport", ctx, clusterId, body). + Return(&export.Export{ + ExportId: &exportId, + }, nil) + + tests := []Test{ + { + name: "export all data to parquet file", + args: []string{"-c", clusterId, "--file-type", "PARQUET", "--force"}, + stdoutString: fmt.Sprintf("export %s is running now\n", exportId), + }, + { + name: "export all data to parquet file with compression", + args: []string{"-c", clusterId, "--file-type", "PARQUET", "--compression", "GZIP", "--force"}, + err: errors.New("--compression is not supported when file type is parquet, please use --parquet.compression instead"), + }, + } + suite.AssertTest(ctx, tests) +} + +func (suite *CreateExportSuite) TestCreateExportWithSQLFilter() { + ctx := context.Background() + + clusterId := "fake-cluster-id" + exportId := "fake-export-id" + sql := "SELECT * FROM db.table WHERE column = 'value'" + + body := getDefaultCreateExportBody() + body.ExportOptions.Filter = &export.ExportOptionsFilter{ + Sql: &sql, + } + + suite.mockClient.On("CreateExport", ctx, clusterId, body). + Return(&export.Export{ + ExportId: &exportId, + }, nil) + + tests := []Test{ + { + name: "export data with sql filter", + args: []string{"-c", clusterId, "--sql", sql}, + stdoutString: fmt.Sprintf("export %s is running now\n", exportId), + }, + } + suite.AssertTest(ctx, tests) +} + +func (suite *CreateExportSuite) TestCreateExportWithTableFilter() { + ctx := context.Background() + + clusterId := "fake-cluster-id" + exportId := "fake-export-id" + where := "column = 'value'" + pattern1 := "db.t\\.able" + pattern2 := "db.table" + + body := getDefaultCreateExportBody() + body.ExportOptions.Filter = &export.ExportOptionsFilter{ + Table: &export.ExportOptionsFilterTable{ + Patterns: []string{pattern1, pattern2}, + Where: &where, + }, + } + + suite.mockClient.On("CreateExport", ctx, clusterId, body). + Return(&export.Export{ + ExportId: &exportId, + }, nil) + + tests := []Test{ + { + name: "export data with table filter", + args: []string{"-c", clusterId, "--where", where, "--filter", pattern1, "--filter", pattern2}, + stdoutString: fmt.Sprintf("export %s is running now\n", exportId), + }, + { + name: "export data with table filter2", + args: []string{"-c", clusterId, "--where", where, "--filter", fmt.Sprintf("%s,%s", pattern1, pattern2)}, + stdoutString: fmt.Sprintf("export %s is running now\n", exportId), + }, + } + suite.AssertTest(ctx, tests) +} + +func getDefaultCreateExportBody() *export.ExportServiceCreateExportBody { + defaultFileType := export.EXPORTFILETYPEENUM_CSV + defaultTargetType := export.EXPORTTARGETTYPEENUM_LOCAL + defaultCompression := export.EXPORTCOMPRESSIONTYPEENUM_GZIP + separatorDefaultValue := "," + delimiterDefaultValue := "\"" + nullValueDefaultValue := "\\N" + skipHeaderDefaultValue := false + return &export.ExportServiceCreateExportBody{ + ExportOptions: &export.ExportOptions{ + FileType: &defaultFileType, + Compression: &defaultCompression, + CsvFormat: &export.ExportOptionsCSVFormat{ + Separator: &separatorDefaultValue, + Delimiter: *export.NewNullableString(&delimiterDefaultValue), + NullValue: *export.NewNullableString(&nullValueDefaultValue), + SkipHeader: &skipHeaderDefaultValue, + }, + }, + Target: &export.ExportTarget{ + Type: &defaultTargetType, + }, + } +} + +func TestCreateExportSuite(t *testing.T) { + suite.Run(t, new(CreateExportSuite)) +} + +func (suite *CreateExportSuite) AssertTest(ctx context.Context, tests []Test) { + assert := require.New(suite.T()) + for _, tt := range tests { + suite.T().Run(tt.name, func(t *testing.T) { + cmd := CreateCmd(suite.h) + cmd.SetContext(ctx) + suite.h.IOStreams.Out.(*bytes.Buffer).Reset() + suite.h.IOStreams.Err.(*bytes.Buffer).Reset() + cmd.SetArgs(tt.args) + err := cmd.Execute() + if err != nil { + assert.Equal(tt.err.Error(), err.Error()) + } + + assert.Equal(tt.stdoutString, suite.h.IOStreams.Out.(*bytes.Buffer).String()) + assert.Equal(tt.stderrString, suite.h.IOStreams.Err.(*bytes.Buffer).String()) + if tt.err == nil { + suite.mockClient.AssertExpectations(suite.T()) + } + }) + } +} + +type Test struct { + name string + args []string + err error + stdoutString string + stderrString string +} diff --git a/internal/cli/serverless/export/describe_test.go b/internal/cli/serverless/export/describe_test.go new file mode 100644 index 00000000..5baa9e57 --- /dev/null +++ b/internal/cli/serverless/export/describe_test.go @@ -0,0 +1,151 @@ +// Copyright 2024 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package export + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "os" + "testing" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/export" + + "tidbcloud-cli/internal" + "tidbcloud-cli/internal/iostream" + "tidbcloud-cli/internal/mock" + "tidbcloud-cli/internal/service/cloud" + + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" +) + +const getExportResp = `{ + "clusterId": "fake-cluster-id", + "completeTime": "2024-09-02T11:31:13Z", + "createTime": "2024-09-02T11:31:01Z", + "createdBy": "apikey-MCTGR3Jv", + "displayName": "SNAPSHOT_2024-09-02T11:30:57Z", + "expireTime": "2024-09-04T11:31:13Z", + "exportId": "fake-export-id", + "exportOptions": { + "compression": "GZIP", + "csvFormat": { + "delimiter": "\"", + "nullValue": "\\N", + "separator": ",", + "skipHeader": false + }, + "database": "", + "fileType": "CSV", + "filter": { + "table": { + "patterns": [ + "test.t1" + ], + "where": "" + } + }, + "table": "" + }, + "name": "clusters/fake-cluster-id/exports/fake-export-id", + "snapshotTime": "2024-09-02T11:30:57.571Z", + "state": "SUCCEEDED", + "target": { + "type": "LOCAL" + }, + "updateTime": "2024-09-02T11:31:39Z" +} +` + +type DescribeExportSuite struct { + suite.Suite + h *internal.Helper + mockClient *mock.TiDBCloudClient +} + +func (suite *DescribeExportSuite) SetupTest() { + if err := os.Setenv("NO_COLOR", "true"); err != nil { + suite.T().Error(err) + } + + var pageSize int64 = 10 + suite.mockClient = new(mock.TiDBCloudClient) + suite.h = &internal.Helper{ + Client: func() (cloud.TiDBCloudClient, error) { + return suite.mockClient, nil + }, + QueryPageSize: pageSize, + IOStreams: iostream.Test(), + } +} + +func (suite *DescribeExportSuite) TestDescribeExportArgs() { + assert := require.New(suite.T()) + ctx := context.Background() + + body := &export.Export{} + err := json.Unmarshal([]byte(getExportResp), body) + assert.Nil(err) + clusterId := "fake-cluster-id" + exportId := "fake-export-id" + suite.mockClient.On("GetExport", ctx, clusterId, exportId).Return(body, nil) + + tests := []struct { + name string + args []string + err error + stdoutString string + stderrString string + }{ + { + name: "describe export success", + args: []string{"--cluster-id", clusterId, "--export-id", exportId}, + stdoutString: getExportResp, + }, + { + name: "describe export with shorthand flag", + args: []string{"-c", clusterId, "-e", exportId}, + stdoutString: getExportResp, + }, + { + name: "describe export without required cluster id", + args: []string{"-e", exportId}, + err: fmt.Errorf("required flag(s) \"cluster-id\" not set"), + }, + } + + for _, tt := range tests { + suite.T().Run(tt.name, func(t *testing.T) { + cmd := DescribeCmd(suite.h) + cmd.SetContext(ctx) + suite.h.IOStreams.Out.(*bytes.Buffer).Reset() + suite.h.IOStreams.Err.(*bytes.Buffer).Reset() + cmd.SetArgs(tt.args) + err = cmd.Execute() + assert.Equal(tt.err, err) + + assert.Equal(tt.stdoutString, suite.h.IOStreams.Out.(*bytes.Buffer).String()) + assert.Equal(tt.stderrString, suite.h.IOStreams.Err.(*bytes.Buffer).String()) + if tt.err == nil { + suite.mockClient.AssertExpectations(suite.T()) + } + }) + } +} + +func TestDescribeExportSuite(t *testing.T) { + suite.Run(t, new(DescribeExportSuite)) +} diff --git a/internal/cli/serverless/export/list_test.go b/internal/cli/serverless/export/list_test.go new file mode 100644 index 00000000..8364b2bc --- /dev/null +++ b/internal/cli/serverless/export/list_test.go @@ -0,0 +1,239 @@ +// Copyright 2024 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package export + +import ( + "bytes" + "context" + "encoding/json" + "os" + "strings" + "testing" + + "tidbcloud-cli/internal" + "tidbcloud-cli/internal/iostream" + "tidbcloud-cli/internal/mock" + "tidbcloud-cli/internal/service/cloud" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/export" + + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" +) + +const listResultStr = `{ + "exports": [ + { + "clusterId": "10289717998856001017", + "completeTime": "2024-09-04T04:45:41Z", + "createTime": "2024-09-04T04:45:27Z", + "createdBy": "apikey-MCTGR3Jv", + "displayName": "SNAPSHOT_2024-09-04T04:45:23Z", + "expireTime": "2024-09-06T04:45:41Z", + "exportId": "exp-q6j5hwy7vzhhfhlx3ilxqti3ay", + "exportOptions": { + "compression": "GZIP", + "database": "*", + "fileType": "SQL", + "table": "*" + }, + "name": "clusters/10289717998856001017/exports/exp-q6j5hwy7vzhhfhlx3ilxqti3ay", + "snapshotTime": "2024-09-04T04:45:23.189Z", + "state": "SUCCEEDED", + "target": { + "type": "LOCAL" + }, + "updateTime": "2024-09-04T04:46:44Z" + } + ], + "totalSize": 1 +} +` + +const listResultMultiPageStr = `{ + "exports": [ + { + "clusterId": "10289717998856001017", + "completeTime": "2024-09-04T04:45:41Z", + "createTime": "2024-09-04T04:45:27Z", + "createdBy": "apikey-MCTGR3Jv", + "displayName": "SNAPSHOT_2024-09-04T04:45:23Z", + "expireTime": "2024-09-06T04:45:41Z", + "exportId": "exp-q6j5hwy7vzhhfhlx3ilxqti3ay", + "exportOptions": { + "compression": "GZIP", + "database": "*", + "fileType": "SQL", + "table": "*" + }, + "name": "clusters/10289717998856001017/exports/exp-q6j5hwy7vzhhfhlx3ilxqti3ay", + "snapshotTime": "2024-09-04T04:45:23.189Z", + "state": "SUCCEEDED", + "target": { + "type": "LOCAL" + }, + "updateTime": "2024-09-04T04:46:44Z" + }, + { + "clusterId": "10289717998856001017", + "completeTime": "2024-09-04T04:45:41Z", + "createTime": "2024-09-04T04:45:27Z", + "createdBy": "apikey-MCTGR3Jv", + "displayName": "SNAPSHOT_2024-09-04T04:45:23Z", + "expireTime": "2024-09-06T04:45:41Z", + "exportId": "exp-q6j5hwy7vzhhfhlx3ilxqti3ay", + "exportOptions": { + "compression": "GZIP", + "database": "*", + "fileType": "SQL", + "table": "*" + }, + "name": "clusters/10289717998856001017/exports/exp-q6j5hwy7vzhhfhlx3ilxqti3ay", + "snapshotTime": "2024-09-04T04:45:23.189Z", + "state": "SUCCEEDED", + "target": { + "type": "LOCAL" + }, + "updateTime": "2024-09-04T04:46:44Z" + } + ], + "totalSize": 2 +} +` + +type ListExportsSuite struct { + suite.Suite + h *internal.Helper + mockClient *mock.TiDBCloudClient +} + +func (suite *ListExportsSuite) SetupTest() { + if err := os.Setenv("NO_COLOR", "true"); err != nil { + suite.T().Error(err) + } + + var pageSize int64 = 10 + suite.mockClient = new(mock.TiDBCloudClient) + suite.h = &internal.Helper{ + Client: func() (cloud.TiDBCloudClient, error) { + return suite.mockClient, nil + }, + QueryPageSize: pageSize, + IOStreams: iostream.Test(), + } +} + +func (suite *ListExportsSuite) TestListExportsArgs() { + assert := require.New(suite.T()) + pageSize := int32(suite.h.QueryPageSize) + orderBy := "create_time desc" + ctx := context.Background() + + body := &export.ListExportsResponse{} + err := json.Unmarshal([]byte(listResultStr), body) + assert.Nil(err) + clusterID := "fake-cluster-id" + suite.mockClient.On("ListExports", ctx, clusterID, &pageSize, (*string)(nil), &orderBy).Return(body, nil) + + tests := []struct { + name string + args []string + err error + stdoutString string + stderrString string + }{ + { + name: "list exports with default format(json when without tty)", + args: []string{"--cluster-id", clusterID}, + stdoutString: listResultStr, + }, + { + name: "list exports with output flag", + args: []string{"--cluster-id", clusterID, "-o", "json"}, + stdoutString: listResultStr, + }, + } + + for _, tt := range tests { + suite.T().Run(tt.name, func(t *testing.T) { + cmd := ListCmd(suite.h) + cmd.SetContext(ctx) + suite.h.IOStreams.Out.(*bytes.Buffer).Reset() + suite.h.IOStreams.Err.(*bytes.Buffer).Reset() + cmd.SetArgs(tt.args) + err = cmd.Execute() + assert.Equal(tt.err, err) + + assert.Equal(tt.stdoutString, suite.h.IOStreams.Out.(*bytes.Buffer).String()) + assert.Equal(tt.stderrString, suite.h.IOStreams.Err.(*bytes.Buffer).String()) + if tt.err == nil { + suite.mockClient.AssertExpectations(suite.T()) + } + }) + } +} + +func (suite *ListExportsSuite) TestListExportsWithMultiPages() { + assert := require.New(suite.T()) + ctx := context.Background() + // mock first page + pageSize := int32(suite.h.QueryPageSize) + pageToken := "2" + orderBy := "create_time desc" + body := &export.ListExportsResponse{} + err := json.Unmarshal([]byte(strings.ReplaceAll(listResultStr, `"totalSize": 1`, `"totalSize": 2`)), body) + assert.Nil(err) + body.NextPageToken = &pageToken + + clusterID := "fake-cluster-id" + suite.mockClient.On("ListExports", ctx, clusterID, &pageSize, (*string)(nil), &orderBy).Return(body, nil) + + body2 := &export.ListExportsResponse{} + err = json.Unmarshal([]byte(strings.ReplaceAll(listResultStr, `"totalSize": 1`, `"totalSize": 2`)), body2) + assert.Nil(err) + suite.mockClient.On("ListExports", ctx, clusterID, &pageSize, &pageToken, &orderBy).Return(body2, nil) + + cmd := ListCmd(suite.h) + tests := []struct { + name string + args []string + stdoutString string + stderrString string + }{ + { + name: "query with multi pages", + args: []string{"--cluster-id", clusterID, "--output", "json"}, + stdoutString: listResultMultiPageStr, + }, + } + + for _, tt := range tests { + suite.T().Run(tt.name, func(t *testing.T) { + cmd.SetContext(ctx) + suite.h.IOStreams.Out.(*bytes.Buffer).Reset() + suite.h.IOStreams.Err.(*bytes.Buffer).Reset() + cmd.SetArgs(tt.args) + err = cmd.Execute() + assert.Nil(err) + + assert.Equal(tt.stdoutString, suite.h.IOStreams.Out.(*bytes.Buffer).String()) + assert.Equal(tt.stderrString, suite.h.IOStreams.Err.(*bytes.Buffer).String()) + suite.mockClient.AssertExpectations(suite.T()) + }) + } +} + +func TestListExportSuite(t *testing.T) { + suite.Run(t, new(ListExportsSuite)) +} From bd7c1f24a616e711e6e3a2d96e60b3df37aa7f6f Mon Sep 17 00:00:00 2001 From: shi yuhang <52435083+shiyuhang0@users.noreply.github.com> Date: Wed, 4 Sep 2024 22:08:12 +0800 Subject: [PATCH 3/3] Openapi generator br (#229) --- Makefile | 3 +- internal/cli/serverless/backup/delete.go | 4 +- internal/cli/serverless/backup/delete_test.go | 7 +- internal/cli/serverless/backup/describe.go | 12 +- .../cli/serverless/backup/describe_test.go | 15 +- internal/cli/serverless/backup/list.go | 13 +- internal/cli/serverless/backup/list_test.go | 35 +- internal/cli/serverless/restore.go | 24 +- internal/cli/serverless/restore_test.go | 33 +- internal/mock/api_client.go | 118 ++-- internal/service/cloud/api_client.go | 56 +- internal/service/cloud/logic.go | 30 +- .../br.swagger.json} | 0 .../v1beta1/serverless/br/.gitignore | 24 + .../serverless/br/.openapi-generator-ignore | 23 + .../serverless/br/.openapi-generator/FILES | 19 + .../serverless/br/.openapi-generator/VERSION | 1 + .../v1beta1/serverless/br/.travis.yml | 8 + pkg/tidbcloud/v1beta1/serverless/br/README.md | 123 ++++ .../v1beta1/serverless/br/api/openapi.yaml | 236 +++++++ .../br/api_backup_restore_service.go | 497 +++++++++++++ pkg/tidbcloud/v1beta1/serverless/br/client.go | 651 ++++++++++++++++++ .../v1beta1/serverless/br/configuration.go | 214 ++++++ .../v1beta1/serverless/br/git_push.sh | 57 ++ .../serverless/br/model_protobuf_any.go | 153 ++++ .../br/model_restore_request_point_in_time.go | 161 +++++ .../br/model_restore_request_snapshot.go | 124 ++++ .../v1beta1/serverless/br/model_rpc_status.go | 196 ++++++ .../serverless/br/model_v1beta1_backup.go | 269 ++++++++ .../br/model_v1beta1_list_backups_response.go | 199 ++++++ .../br/model_v1beta1_restore_request.go | 160 +++++ .../br/model_v1beta1_restore_response.go | 156 +++++ .../v1beta1/serverless/br/response.go | 47 ++ pkg/tidbcloud/v1beta1/serverless/br/utils.go | 361 ++++++++++ .../backup_restore_service_client.go | 219 ------ ...estore_service_delete_backup_parameters.go | 151 ---- ...restore_service_delete_backup_responses.go | 187 ----- ...p_restore_service_get_backup_parameters.go | 151 ---- ...up_restore_service_get_backup_responses.go | 187 ----- ...restore_service_list_backups_parameters.go | 227 ------ ..._restore_service_list_backups_responses.go | 187 ----- ...ckup_restore_service_restore_parameters.go | 150 ---- ...ackup_restore_service_restore_responses.go | 187 ----- ...rvice_abort_multipart_upload_parameters.go | 205 ------ ...ervice_abort_multipart_upload_responses.go | 180 ----- .../import_service/import_service_client.go | 154 ----- ...ce_complete_multipart_upload_parameters.go | 205 ------ ...ice_complete_multipart_upload_responses.go | 180 ----- ..._service_generate_upload_url_parameters.go | 208 ------ ...t_service_generate_upload_url_responses.go | 182 ----- .../client/tidbcloud_serverless_client.go | 112 --- .../serverless_br/models/protobuf_any.go | 127 ---- .../models/restore_request_point_in_time.go | 77 --- .../models/restore_request_snapshot.go | 50 -- .../serverless_br/models/rpc_status.go | 127 ---- .../serverless_br/models/v1beta1_backup.go | 144 ---- .../v1beta1_generate_upload_url_response.go | 53 -- .../models/v1beta1_list_backups_response.go | 127 ---- .../models/v1beta1_restore_request.go | 160 ----- .../models/v1beta1_restore_response.go | 71 -- 60 files changed, 3837 insertions(+), 4200 deletions(-) rename pkg/tidbcloud/v1beta1/{serverless_br/serverless-br.swagger.json => serverless/br.swagger.json} (100%) create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/.gitignore create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/.openapi-generator-ignore create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/.openapi-generator/FILES create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/.openapi-generator/VERSION create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/.travis.yml create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/README.md create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/api/openapi.yaml create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/api_backup_restore_service.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/client.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/configuration.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/git_push.sh create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/model_protobuf_any.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/model_restore_request_point_in_time.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/model_restore_request_snapshot.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/model_rpc_status.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/model_v1beta1_backup.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/model_v1beta1_list_backups_response.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/model_v1beta1_restore_request.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/model_v1beta1_restore_response.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/response.go create mode 100644 pkg/tidbcloud/v1beta1/serverless/br/utils.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_client.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_delete_backup_parameters.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_delete_backup_responses.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_get_backup_parameters.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_get_backup_responses.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_list_backups_parameters.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_list_backups_responses.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_restore_parameters.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_restore_responses.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_abort_multipart_upload_parameters.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_abort_multipart_upload_responses.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_client.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_complete_multipart_upload_parameters.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_complete_multipart_upload_responses.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_generate_upload_url_parameters.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_generate_upload_url_responses.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/client/tidbcloud_serverless_client.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/models/protobuf_any.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/models/restore_request_point_in_time.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/models/restore_request_snapshot.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/models/rpc_status.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_backup.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_generate_upload_url_response.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_list_backups_response.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_restore_request.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_restore_response.go diff --git a/Makefile b/Makefile index cb864e3f..c95dc359 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,8 @@ generate-v1beta1-client: install-openapi-generator ## Generate v1beta1 client rm -rf pkg/tidbcloud/v1beta1/iam cd tools/openapi-generator && npx openapi-generator-cli generate --additional-properties=withGoMod=false,enumClassPrefix=true --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/v1beta1/iam.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/iam --package-name iam @echo "==> Generating serverless br client" - swagger generate client -f pkg/tidbcloud/v1beta1/serverless_br/serverless-br.swagger.json -A tidbcloud-serverless -t pkg/tidbcloud/v1beta1/serverless_br + rm -rf pkg/tidbcloud/v1beta1/serverless/br + cd tools/openapi-generator && npx openapi-generator-cli generate --additional-properties=withGoMod=false,enumClassPrefix=true --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/br.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/br --package-name br @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 go fmt ./pkg/... diff --git a/internal/cli/serverless/backup/delete.go b/internal/cli/serverless/backup/delete.go index b19f65a9..f143879f 100644 --- a/internal/cli/serverless/backup/delete.go +++ b/internal/cli/serverless/backup/delete.go @@ -22,7 +22,6 @@ import ( "tidbcloud-cli/internal/flag" "tidbcloud-cli/internal/service/cloud" "tidbcloud-cli/internal/util" - brApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service" "github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2/terminal" @@ -148,8 +147,7 @@ func DeleteCmd(h *internal.Helper) *cobra.Command { } } - params := brApi.NewBackupRestoreServiceDeleteBackupParams().WithBackupID(backupID).WithContext(ctx) - _, err = d.DeleteBackup(params) + _, err = d.DeleteBackup(ctx, backupID) if err != nil { return errors.Trace(err) } diff --git a/internal/cli/serverless/backup/delete_test.go b/internal/cli/serverless/backup/delete_test.go index a7cb5038..2c262a5c 100644 --- a/internal/cli/serverless/backup/delete_test.go +++ b/internal/cli/serverless/backup/delete_test.go @@ -25,7 +25,7 @@ import ( "tidbcloud-cli/internal/iostream" "tidbcloud-cli/internal/mock" "tidbcloud-cli/internal/service/cloud" - brApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/br" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -57,9 +57,8 @@ func (suite *DeleteBackupSuite) TestDeleteBackup() { ctx := context.Background() backupID := "289048" - suite.mockClient.On("DeleteBackup", brApi.NewBackupRestoreServiceDeleteBackupParams(). - WithBackupID(backupID).WithContext(ctx)). - Return(&brApi.BackupRestoreServiceDeleteBackupOK{}, nil) + suite.mockClient.On("DeleteBackup", ctx, backupID). + Return(&br.V1beta1Backup{}, nil) tests := []struct { name string diff --git a/internal/cli/serverless/backup/describe.go b/internal/cli/serverless/backup/describe.go index 8d1a2fba..88efe29e 100644 --- a/internal/cli/serverless/backup/describe.go +++ b/internal/cli/serverless/backup/describe.go @@ -17,17 +17,14 @@ package backup import ( "fmt" - "tidbcloud-cli/internal/output" - "tidbcloud-cli/internal" "tidbcloud-cli/internal/config" "tidbcloud-cli/internal/flag" + "tidbcloud-cli/internal/output" "tidbcloud-cli/internal/service/cloud" - brAPI "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service" - - "github.com/spf13/cobra" "github.com/juju/errors" + "github.com/spf13/cobra" ) type DescribeOpts struct { @@ -121,15 +118,14 @@ func DescribeCmd(h *internal.Helper) *cobra.Command { } } - params := brAPI.NewBackupRestoreServiceGetBackupParams().WithBackupID(backupID).WithContext(ctx) if err != nil { return errors.Trace(err) } - backup, err := d.GetBackup(params) + backup, err := d.GetBackup(ctx, backupID) if err != nil { return errors.Trace(err) } - err = output.PrintJson(h.IOStreams.Out, backup.Payload) + err = output.PrintJson(h.IOStreams.Out, backup) if err != nil { return errors.Trace(err) } diff --git a/internal/cli/serverless/backup/describe_test.go b/internal/cli/serverless/backup/describe_test.go index 6bbd2d45..0620247c 100644 --- a/internal/cli/serverless/backup/describe_test.go +++ b/internal/cli/serverless/backup/describe_test.go @@ -26,8 +26,7 @@ import ( "tidbcloud-cli/internal/iostream" "tidbcloud-cli/internal/mock" "tidbcloud-cli/internal/service/cloud" - brApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service" - brModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/br" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -36,7 +35,7 @@ import ( const getBackupResult = `{ "backupId": "289048", "clusterId": "10048930788495339885", - "createTime": "2023-12-15T07:00:00.000Z", + "createTime": "2023-12-15T07:00:00Z", "name": "backups/289048" } ` @@ -66,17 +65,13 @@ func (suite *DescribeBackupSuite) TestDescribeBackup() { assert := require.New(suite.T()) ctx := context.Background() - body := &brModel.V1beta1Backup{} + body := &br.V1beta1Backup{} err := json.Unmarshal([]byte(getBackupResult), body) assert.Nil(err) - result := &brApi.BackupRestoreServiceGetBackupOK{ - Payload: body, - } backupId := "289048" - suite.mockClient.On("GetBackup", brApi.NewBackupRestoreServiceGetBackupParams(). - WithBackupID(backupId).WithContext(ctx)). - Return(result, nil) + suite.mockClient.On("GetBackup", ctx, backupId). + Return(body, nil) tests := []struct { name string diff --git a/internal/cli/serverless/backup/list.go b/internal/cli/serverless/backup/list.go index 582fdf3a..3fe881c9 100644 --- a/internal/cli/serverless/backup/list.go +++ b/internal/cli/serverless/backup/list.go @@ -16,13 +16,14 @@ package backup import ( "fmt" + "time" "tidbcloud-cli/internal" "tidbcloud-cli/internal/config" "tidbcloud-cli/internal/flag" "tidbcloud-cli/internal/output" "tidbcloud-cli/internal/service/cloud" - brModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/br" "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 := &brModel.V1beta1ListBackupsResponse{ + res := &br.V1beta1ListBackupsResponse{ Backups: items, - TotalSize: total, + TotalSize: &total, } err := output.PrintJson(h.IOStreams.Out, res) if err != nil { @@ -144,9 +145,9 @@ func ListCmd(h *internal.Helper) *cobra.Command { var rows []output.Row for _, item := range items { rows = append(rows, output.Row{ - item.BackupID, - *item.ClusterID, - item.CreateTime.String(), + *item.BackupId, + item.ClusterId, + item.CreateTime.Format(time.RFC3339), }) } diff --git a/internal/cli/serverless/backup/list_test.go b/internal/cli/serverless/backup/list_test.go index 80eccb24..80aac888 100644 --- a/internal/cli/serverless/backup/list_test.go +++ b/internal/cli/serverless/backup/list_test.go @@ -26,8 +26,7 @@ import ( "tidbcloud-cli/internal/iostream" "tidbcloud-cli/internal/mock" "tidbcloud-cli/internal/service/cloud" - brApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service" - brModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/br" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -38,7 +37,7 @@ const listResultStr = `{ { "backupId": "289048", "clusterId": "10048930788495339885", - "createTime": "2023-12-15T07:00:00.000Z", + "createTime": "2023-12-15T07:00:00Z", "name": "backups/289048" } ], @@ -51,13 +50,13 @@ const listResultMultiPageStr = `{ { "backupId": "289048", "clusterId": "10048930788495339885", - "createTime": "2023-12-15T07:00:00.000Z", + "createTime": "2023-12-15T07:00:00Z", "name": "backups/289048" }, { "backupId": "289048", "clusterId": "10048930788495339885", - "createTime": "2023-12-15T07:00:00.000Z", + "createTime": "2023-12-15T07:00:00Z", "name": "backups/289048" } ], @@ -92,17 +91,13 @@ func (suite *ListBackupSuite) TestListBackups() { assert := require.New(suite.T()) ctx := context.Background() - body := &brModel.V1beta1ListBackupsResponse{} + body := &br.V1beta1ListBackupsResponse{} err := json.Unmarshal([]byte(listResultStr), body) assert.Nil(err) - result := &brApi.BackupRestoreServiceListBackupsOK{ - Payload: body, - } pageSize := int32(suite.pageSize) clusterID := "10048930788495339885" - suite.mockClient.On("ListBackups", brApi.NewBackupRestoreServiceListBackupsParams(). - WithClusterID(clusterID).WithPageSize(&pageSize).WithContext(ctx)). - Return(result, nil) + suite.mockClient.On("ListBackups", ctx, &clusterID, &pageSize, (*string)(nil)). + Return(body, nil) tests := []struct { name string @@ -156,20 +151,18 @@ func (suite *ListBackupSuite) TestListBackupsWithMultiPages() { pageToken := "2" clusterID := "10048930788495339885" - body := &brModel.V1beta1ListBackupsResponse{} + body := &br.V1beta1ListBackupsResponse{} err := json.Unmarshal([]byte(strings.ReplaceAll(listResultStr, `"total": 1`, `"total": 2`)), body) assert.Nil(err) - body.NextPageToken = pageToken - suite.mockClient.On("ListBackups", brApi.NewBackupRestoreServiceListBackupsParams(). - WithClusterID(clusterID).WithPageSize(&pageSize).WithContext(ctx)). - Return(&brApi.BackupRestoreServiceListBackupsOK{Payload: body}, nil) + body.NextPageToken = &pageToken + suite.mockClient.On("ListBackups", ctx, &clusterID, &pageSize, (*string)(nil)). + Return(body, nil) - body2 := &brModel.V1beta1ListBackupsResponse{} + body2 := &br.V1beta1ListBackupsResponse{} err = json.Unmarshal([]byte(strings.ReplaceAll(listResultStr, `"total": 1`, `"total": 2`)), body2) assert.Nil(err) - suite.mockClient.On("ListBackups", brApi.NewBackupRestoreServiceListBackupsParams(). - WithClusterID(clusterID).WithPageToken(&pageToken).WithPageSize(&pageSize).WithContext(ctx)). - Return(&brApi.BackupRestoreServiceListBackupsOK{Payload: body2}, nil) + suite.mockClient.On("ListBackups", ctx, &clusterID, &pageSize, &pageToken). + Return(body2, nil) tests := []struct { name string diff --git a/internal/cli/serverless/restore.go b/internal/cli/serverless/restore.go index d1cb38a8..ecd502a4 100644 --- a/internal/cli/serverless/restore.go +++ b/internal/cli/serverless/restore.go @@ -16,6 +16,7 @@ package serverless import ( "fmt" + "time" "tidbcloud-cli/internal" "tidbcloud-cli/internal/config" @@ -23,13 +24,11 @@ import ( "tidbcloud-cli/internal/service/cloud" "tidbcloud-cli/internal/ui" "tidbcloud-cli/internal/util" - brApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service" - brModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/br" "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" ) @@ -156,30 +155,29 @@ func RestoreCmd(h *internal.Helper) *cobra.Command { } } - params := brApi.NewBackupRestoreServiceRestoreParams().WithBody(&brModel.V1beta1RestoreRequest{}).WithContext(ctx) + body := &br.V1beta1RestoreRequest{} if backupID != "" { - params.Body.Snapshot = &brModel.RestoreRequestSnapshot{ - BackupID: backupID, + body.Snapshot = &br.RestoreRequestSnapshot{ + BackupId: &backupID, } } else { if backupTimeStr == "" { return errors.New("backup time is required in point-in-time mode") } - var backupTime strfmt.DateTime - backupTime, err = strfmt.ParseDateTime(backupTimeStr) + backupTime, err := time.Parse(time.RFC3339, backupTimeStr) if err != nil { return errors.New(fmt.Sprintf("invalid backup time %s. Please input the backup time with the 2006-01-02T15:04:05Z formate", backupTimeStr)) } - params.Body.PointInTime = &brModel.RestoreRequestPointInTime{ - ClusterID: clusterID, - BackupTime: backupTime, + body.PointInTime = &br.RestoreRequestPointInTime{ + ClusterId: &clusterID, + BackupTime: &backupTime, } } - resp, err := d.Restore(params) + resp, err := d.Restore(ctx, body) if err != nil { return errors.Trace(err) } - fmt.Fprintln(h.IOStreams.Out, color.GreenString(fmt.Sprintf("restore to clsuter %s, use \"ticloud serverless get -c %s\" to check the restore process", *resp.Payload.ClusterID, *resp.Payload.ClusterID))) + fmt.Fprintln(h.IOStreams.Out, color.GreenString(fmt.Sprintf("restore to clsuter %s, use \"ticloud serverless get -c %s\" to check the restore process", resp.ClusterId, resp.ClusterId))) return nil }, } diff --git a/internal/cli/serverless/restore_test.go b/internal/cli/serverless/restore_test.go index 7ee19c3b..bf7e3cc3 100644 --- a/internal/cli/serverless/restore_test.go +++ b/internal/cli/serverless/restore_test.go @@ -21,15 +21,14 @@ import ( "fmt" "os" "testing" + "time" "tidbcloud-cli/internal" "tidbcloud-cli/internal/iostream" "tidbcloud-cli/internal/mock" "tidbcloud-cli/internal/service/cloud" - brApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service" - brModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/models" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/br" - "github.com/go-openapi/strfmt" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" ) @@ -63,15 +62,13 @@ func (suite *RestoreClusterSuite) TestRestoreClusterSnapshot() { clusterID := "10048930788495339885" backupID := "289048" - body := &brModel.V1beta1RestoreRequest{ - Snapshot: &brModel.RestoreRequestSnapshot{ - BackupID: backupID, + body := &br.V1beta1RestoreRequest{ + Snapshot: &br.RestoreRequestSnapshot{ + BackupId: &backupID, }, } - suite.mockClient.On("Restore", brApi.NewBackupRestoreServiceRestoreParams(). - WithBody(body).WithContext(ctx)). - Return(&brApi.BackupRestoreServiceRestoreOK{Payload: &brModel.V1beta1RestoreResponse{ - ClusterID: &clusterID}}, nil) + suite.mockClient.On("Restore", ctx, body). + Return(&br.V1beta1RestoreResponse{ClusterId: clusterID}, nil) tests := []struct { name string @@ -113,18 +110,16 @@ func (suite *RestoreClusterSuite) TestRestoreClusterPointInTime() { clusterID := "10048930788495339885" backupTimeStr := "2023-12-15T07:00:00.000Z" - backupTime, err := strfmt.ParseDateTime(backupTimeStr) + backupTime, err := time.Parse(time.RFC3339, backupTimeStr) assert.Nil(err) - body := &brModel.V1beta1RestoreRequest{ - PointInTime: &brModel.RestoreRequestPointInTime{ - BackupTime: backupTime, - ClusterID: clusterID, + body := &br.V1beta1RestoreRequest{ + PointInTime: &br.RestoreRequestPointInTime{ + BackupTime: &backupTime, + ClusterId: &clusterID, }, } - suite.mockClient.On("Restore", brApi.NewBackupRestoreServiceRestoreParams(). - WithBody(body).WithContext(ctx)). - Return(&brApi.BackupRestoreServiceRestoreOK{Payload: &brModel.V1beta1RestoreResponse{ - ClusterID: &clusterID}}, nil) + suite.mockClient.On("Restore", ctx, body). + Return(&br.V1beta1RestoreResponse{ClusterId: clusterID}, nil) tests := []struct { name string diff --git a/internal/mock/api_client.go b/internal/mock/api_client.go index baca05b2..2453d1b1 100644 --- a/internal/mock/api_client.go +++ b/internal/mock/api_client.go @@ -3,8 +3,8 @@ package mock import ( + br "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/br" branch "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/branch" - backup_restore_service "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service" cluster "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" @@ -361,36 +361,29 @@ func (_m *TiDBCloudClient) CreateSQLUser(ctx context.Context, clusterID string, return r0, r1 } -// DeleteBackup provides a mock function with given fields: params, opts -func (_m *TiDBCloudClient) DeleteBackup(params *backup_restore_service.BackupRestoreServiceDeleteBackupParams, opts ...backup_restore_service.ClientOption) (*backup_restore_service.BackupRestoreServiceDeleteBackupOK, 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...) +// DeleteBackup provides a mock function with given fields: ctx, backupId +func (_m *TiDBCloudClient) DeleteBackup(ctx context.Context, backupId string) (*br.V1beta1Backup, error) { + ret := _m.Called(ctx, backupId) if len(ret) == 0 { panic("no return value specified for DeleteBackup") } - var r0 *backup_restore_service.BackupRestoreServiceDeleteBackupOK + var r0 *br.V1beta1Backup var r1 error - if rf, ok := ret.Get(0).(func(*backup_restore_service.BackupRestoreServiceDeleteBackupParams, ...backup_restore_service.ClientOption) (*backup_restore_service.BackupRestoreServiceDeleteBackupOK, error)); ok { - return rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, string) (*br.V1beta1Backup, error)); ok { + return rf(ctx, backupId) } - if rf, ok := ret.Get(0).(func(*backup_restore_service.BackupRestoreServiceDeleteBackupParams, ...backup_restore_service.ClientOption) *backup_restore_service.BackupRestoreServiceDeleteBackupOK); ok { - r0 = rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, string) *br.V1beta1Backup); ok { + r0 = rf(ctx, backupId) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*backup_restore_service.BackupRestoreServiceDeleteBackupOK) + r0 = ret.Get(0).(*br.V1beta1Backup) } } - if rf, ok := ret.Get(1).(func(*backup_restore_service.BackupRestoreServiceDeleteBackupParams, ...backup_restore_service.ClientOption) error); ok { - r1 = rf(params, opts...) + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, backupId) } else { r1 = ret.Error(1) } @@ -548,36 +541,29 @@ func (_m *TiDBCloudClient) DownloadExport(ctx context.Context, clusterId string, return r0, r1 } -// GetBackup provides a mock function with given fields: params, opts -func (_m *TiDBCloudClient) GetBackup(params *backup_restore_service.BackupRestoreServiceGetBackupParams, opts ...backup_restore_service.ClientOption) (*backup_restore_service.BackupRestoreServiceGetBackupOK, 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...) +// GetBackup provides a mock function with given fields: ctx, backupId +func (_m *TiDBCloudClient) GetBackup(ctx context.Context, backupId string) (*br.V1beta1Backup, error) { + ret := _m.Called(ctx, backupId) if len(ret) == 0 { panic("no return value specified for GetBackup") } - var r0 *backup_restore_service.BackupRestoreServiceGetBackupOK + var r0 *br.V1beta1Backup var r1 error - if rf, ok := ret.Get(0).(func(*backup_restore_service.BackupRestoreServiceGetBackupParams, ...backup_restore_service.ClientOption) (*backup_restore_service.BackupRestoreServiceGetBackupOK, error)); ok { - return rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, string) (*br.V1beta1Backup, error)); ok { + return rf(ctx, backupId) } - if rf, ok := ret.Get(0).(func(*backup_restore_service.BackupRestoreServiceGetBackupParams, ...backup_restore_service.ClientOption) *backup_restore_service.BackupRestoreServiceGetBackupOK); ok { - r0 = rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, string) *br.V1beta1Backup); ok { + r0 = rf(ctx, backupId) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*backup_restore_service.BackupRestoreServiceGetBackupOK) + r0 = ret.Get(0).(*br.V1beta1Backup) } } - if rf, ok := ret.Get(1).(func(*backup_restore_service.BackupRestoreServiceGetBackupParams, ...backup_restore_service.ClientOption) error); ok { - r1 = rf(params, opts...) + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, backupId) } else { r1 = ret.Error(1) } @@ -742,36 +728,29 @@ func (_m *TiDBCloudClient) GetSQLUser(ctx context.Context, clusterID string, use return r0, r1 } -// ListBackups provides a mock function with given fields: params, opts -func (_m *TiDBCloudClient) ListBackups(params *backup_restore_service.BackupRestoreServiceListBackupsParams, opts ...backup_restore_service.ClientOption) (*backup_restore_service.BackupRestoreServiceListBackupsOK, 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...) +// ListBackups provides a mock function with given fields: ctx, clusterId, pageSize, pageToken +func (_m *TiDBCloudClient) ListBackups(ctx context.Context, clusterId *string, pageSize *int32, pageToken *string) (*br.V1beta1ListBackupsResponse, error) { + ret := _m.Called(ctx, clusterId, pageSize, pageToken) if len(ret) == 0 { panic("no return value specified for ListBackups") } - var r0 *backup_restore_service.BackupRestoreServiceListBackupsOK + var r0 *br.V1beta1ListBackupsResponse var r1 error - if rf, ok := ret.Get(0).(func(*backup_restore_service.BackupRestoreServiceListBackupsParams, ...backup_restore_service.ClientOption) (*backup_restore_service.BackupRestoreServiceListBackupsOK, error)); ok { - return rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, *string, *int32, *string) (*br.V1beta1ListBackupsResponse, error)); ok { + return rf(ctx, clusterId, pageSize, pageToken) } - if rf, ok := ret.Get(0).(func(*backup_restore_service.BackupRestoreServiceListBackupsParams, ...backup_restore_service.ClientOption) *backup_restore_service.BackupRestoreServiceListBackupsOK); ok { - r0 = rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, *string, *int32, *string) *br.V1beta1ListBackupsResponse); ok { + r0 = rf(ctx, clusterId, pageSize, pageToken) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*backup_restore_service.BackupRestoreServiceListBackupsOK) + r0 = ret.Get(0).(*br.V1beta1ListBackupsResponse) } } - if rf, ok := ret.Get(1).(func(*backup_restore_service.BackupRestoreServiceListBackupsParams, ...backup_restore_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) } @@ -1026,36 +1005,29 @@ func (_m *TiDBCloudClient) PartialUpdateCluster(ctx context.Context, clusterId s return r0, r1 } -// Restore provides a mock function with given fields: params, opts -func (_m *TiDBCloudClient) Restore(params *backup_restore_service.BackupRestoreServiceRestoreParams, opts ...backup_restore_service.ClientOption) (*backup_restore_service.BackupRestoreServiceRestoreOK, 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...) +// Restore provides a mock function with given fields: ctx, body +func (_m *TiDBCloudClient) Restore(ctx context.Context, body *br.V1beta1RestoreRequest) (*br.V1beta1RestoreResponse, error) { + ret := _m.Called(ctx, body) if len(ret) == 0 { panic("no return value specified for Restore") } - var r0 *backup_restore_service.BackupRestoreServiceRestoreOK + var r0 *br.V1beta1RestoreResponse var r1 error - if rf, ok := ret.Get(0).(func(*backup_restore_service.BackupRestoreServiceRestoreParams, ...backup_restore_service.ClientOption) (*backup_restore_service.BackupRestoreServiceRestoreOK, error)); ok { - return rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, *br.V1beta1RestoreRequest) (*br.V1beta1RestoreResponse, error)); ok { + return rf(ctx, body) } - if rf, ok := ret.Get(0).(func(*backup_restore_service.BackupRestoreServiceRestoreParams, ...backup_restore_service.ClientOption) *backup_restore_service.BackupRestoreServiceRestoreOK); ok { - r0 = rf(params, opts...) + if rf, ok := ret.Get(0).(func(context.Context, *br.V1beta1RestoreRequest) *br.V1beta1RestoreResponse); ok { + r0 = rf(ctx, body) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*backup_restore_service.BackupRestoreServiceRestoreOK) + r0 = ret.Get(0).(*br.V1beta1RestoreResponse) } } - if rf, ok := ret.Get(1).(func(*backup_restore_service.BackupRestoreServiceRestoreParams, ...backup_restore_service.ClientOption) error); ok { - r1 = rf(params, opts...) + if rf, ok := ret.Get(1).(func(context.Context, *br.V1beta1RestoreRequest) error); ok { + r1 = rf(ctx, body) } else { r1 = ret.Error(1) } diff --git a/internal/service/cloud/api_client.go b/internal/service/cloud/api_client.go index 3fe57016..09ffb8ff 100644 --- a/internal/service/cloud/api_client.go +++ b/internal/service/cloud/api_client.go @@ -29,11 +29,10 @@ import ( pingchatClient "tidbcloud-cli/pkg/tidbcloud/pingchat/client" pingchatOp "tidbcloud-cli/pkg/tidbcloud/pingchat/client/operations" "tidbcloud-cli/pkg/tidbcloud/v1beta1/iam" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/br" "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/branch" "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" "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" serverlessImportOp "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_import/client/import_service" @@ -83,13 +82,13 @@ type TiDBCloudClient interface { Chat(params *pingchatOp.ChatParams, opts ...pingchatOp.ClientOption) (*pingchatOp.ChatOK, error) - DeleteBackup(params *brOp.BackupRestoreServiceDeleteBackupParams, opts ...brOp.ClientOption) (*brOp.BackupRestoreServiceDeleteBackupOK, error) + DeleteBackup(ctx context.Context, backupId string) (*br.V1beta1Backup, error) - GetBackup(params *brOp.BackupRestoreServiceGetBackupParams, opts ...brOp.ClientOption) (*brOp.BackupRestoreServiceGetBackupOK, error) + GetBackup(ctx context.Context, backupId string) (*br.V1beta1Backup, error) - ListBackups(params *brOp.BackupRestoreServiceListBackupsParams, opts ...brOp.ClientOption) (*brOp.BackupRestoreServiceListBackupsOK, error) + ListBackups(ctx context.Context, clusterId *string, pageSize *int32, pageToken *string) (*br.V1beta1ListBackupsResponse, error) - Restore(params *brOp.BackupRestoreServiceRestoreParams, opts ...brOp.ClientOption) (*brOp.BackupRestoreServiceRestoreOK, error) + Restore(ctx context.Context, body *br.V1beta1RestoreRequest) (*br.V1beta1RestoreResponse, error) StartUpload(params *serverlessImportOp.ImportServiceStartUploadParams, opts ...serverlessImportOp.ClientOption) (*serverlessImportOp.ImportServiceStartUploadOK, error) @@ -124,8 +123,8 @@ type ClientDelegate struct { ic *iam.APIClient bc *branch.APIClient pc *pingchatClient.TidbcloudPingchat + brc *br.APIClient sc *cluster.APIClient - brc *brClient.TidbcloudServerless sic *serverlessImportClient.TidbcloudServerless ec *export.APIClient } @@ -281,20 +280,38 @@ func (d *ClientDelegate) Chat(params *pingchatOp.ChatParams, opts ...pingchatOp. return d.pc.Operations.Chat(params, opts...) } -func (d *ClientDelegate) DeleteBackup(params *brOp.BackupRestoreServiceDeleteBackupParams, opts ...brOp.ClientOption) (*brOp.BackupRestoreServiceDeleteBackupOK, error) { - return d.brc.BackupRestoreService.BackupRestoreServiceDeleteBackup(params, opts...) +func (d *ClientDelegate) DeleteBackup(ctx context.Context, backupId string) (*br.V1beta1Backup, error) { + b, h, err := d.brc.BackupRestoreServiceAPI.BackupRestoreServiceDeleteBackup(ctx, backupId).Execute() + return b, parseError(err, h) } -func (d *ClientDelegate) GetBackup(params *brOp.BackupRestoreServiceGetBackupParams, opts ...brOp.ClientOption) (*brOp.BackupRestoreServiceGetBackupOK, error) { - return d.brc.BackupRestoreService.BackupRestoreServiceGetBackup(params, opts...) +func (d *ClientDelegate) GetBackup(ctx context.Context, backupId string) (*br.V1beta1Backup, error) { + b, h, err := d.brc.BackupRestoreServiceAPI.BackupRestoreServiceGetBackup(ctx, backupId).Execute() + return b, parseError(err, h) } -func (d *ClientDelegate) ListBackups(params *brOp.BackupRestoreServiceListBackupsParams, opts ...brOp.ClientOption) (*brOp.BackupRestoreServiceListBackupsOK, error) { - return d.brc.BackupRestoreService.BackupRestoreServiceListBackups(params, opts...) +func (d *ClientDelegate) ListBackups(ctx context.Context, clusterId *string, pageSize *int32, pageToken *string) (*br.V1beta1ListBackupsResponse, error) { + r := d.brc.BackupRestoreServiceAPI.BackupRestoreServiceListBackups(ctx) + if clusterId != nil { + r = r.ClusterId(*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) Restore(params *brOp.BackupRestoreServiceRestoreParams, opts ...brOp.ClientOption) (*brOp.BackupRestoreServiceRestoreOK, error) { - return d.brc.BackupRestoreService.BackupRestoreServiceRestore(params, opts...) +func (d *ClientDelegate) Restore(ctx context.Context, body *br.V1beta1RestoreRequest) (*br.V1beta1RestoreResponse, error) { + r := d.brc.BackupRestoreServiceAPI.BackupRestoreServiceRestore(ctx) + if body != nil { + r = r.Body(*body) + } + bs, h, err := r.Execute() + return bs, parseError(err, h) } func (d *ClientDelegate) StartUpload(params *serverlessImportOp.ImportServiceStartUploadParams, opts ...serverlessImportOp.ClientOption) (*serverlessImportOp.ImportServiceStartUploadOK, error) { @@ -397,7 +414,7 @@ func (d *ClientDelegate) UpdateSQLUser(ctx context.Context, clusterID string, us return res, parseError(err, h) } -func NewApiClient(rt http.RoundTripper, apiUrl string, serverlessEndpoint string, iamEndpoint string) (*branch.APIClient, *cluster.APIClient, *pingchatClient.TidbcloudPingchat, *brClient.TidbcloudServerless, *serverlessImportClient.TidbcloudServerless, *export.APIClient, *iam.APIClient, error) { +func NewApiClient(rt http.RoundTripper, apiUrl string, serverlessEndpoint string, iamEndpoint string) (*branch.APIClient, *cluster.APIClient, *pingchatClient.TidbcloudPingchat, *br.APIClient, *serverlessImportClient.TidbcloudServerless, *export.APIClient, *iam.APIClient, error) { httpclient := &http.Client{ Transport: rt, } @@ -415,7 +432,6 @@ func NewApiClient(rt http.RoundTripper, apiUrl string, serverlessEndpoint string return nil, nil, nil, nil, nil, nil, nil, err } - backRestoreTransport := httpTransport.NewWithClient(serverlessURL.Host, brClient.DefaultBasePath, []string{serverlessURL.Scheme}, httpclient) importTransport := httpTransport.NewWithClient(serverlessURL.Host, serverlessImportClient.DefaultBasePath, []string{serverlessURL.Scheme}, httpclient) iamCfg := iam.NewConfiguration() @@ -438,8 +454,12 @@ func NewApiClient(rt http.RoundTripper, apiUrl string, serverlessEndpoint string exportCfg.HTTPClient = httpclient exportCfg.Host = serverlessURL.Host + backupRestoreCfg := br.NewConfiguration() + backupRestoreCfg.HTTPClient = httpclient + backupRestoreCfg.Host = serverlessURL.Host + return branch.NewAPIClient(branchCfg), cluster.NewAPIClient(clusterCfg), - pingchatClient.New(transport, strfmt.Default), brClient.New(backRestoreTransport, strfmt.Default), + pingchatClient.New(transport, strfmt.Default), br.NewAPIClient(backupRestoreCfg), serverlessImportClient.New(importTransport, strfmt.Default), export.NewAPIClient(exportCfg), iam.NewAPIClient(iamCfg), nil } diff --git a/internal/service/cloud/logic.go b/internal/service/cloud/logic.go index 3903f312..c4053cda 100644 --- a/internal/service/cloud/logic.go +++ b/internal/service/cloud/logic.go @@ -18,6 +18,8 @@ import ( "context" "fmt" "slices" + "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/br" + "time" "tidbcloud-cli/internal/ui" "tidbcloud-cli/internal/util" @@ -25,13 +27,10 @@ import ( "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/branch" "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/cluster" "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/export" - brApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service" - brModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/models" importApi "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_import/client/import_service" importModel "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_import/models" tea "github.com/charmbracelet/bubbletea" - "github.com/go-openapi/strfmt" "github.com/juju/errors" ) @@ -66,7 +65,7 @@ type Region struct { type ServerlessBackup struct { ID string Name string - CreateTime strfmt.DateTime + CreateTime *time.Time } type Export struct { @@ -416,8 +415,8 @@ func GetSelectedServerlessBackup(ctx context.Context, clusterID string, pageSize var items = make([]interface{}, 0, len(backupItems)) for _, item := range backupItems { items = append(items, &ServerlessBackup{ - ID: item.BackupID, - Name: item.Name, + ID: *item.BackupId, + Name: *item.Name, CreateTime: item.CreateTime, }) } @@ -691,27 +690,26 @@ func RetrieveExports(ctx context.Context, cID string, pageSize int64, d TiDBClou return int64(len(items)), items, nil } -func RetrieveServerlessBackups(ctx context.Context, cID string, pageSize int32, d TiDBCloudClient) (int64, []*brModel.V1beta1Backup, error) { - var items []*brModel.V1beta1Backup - var pageToken string +func RetrieveServerlessBackups(ctx context.Context, cID string, pageSize int32, d TiDBCloudClient) (int64, []br.V1beta1Backup, error) { + var items []br.V1beta1Backup + var pageToken *string - params := brApi.NewBackupRestoreServiceListBackupsParams().WithClusterID(cID).WithContext(ctx) - backups, err := d.ListBackups(params.WithPageSize(&pageSize)) + backups, err := d.ListBackups(ctx, &cID, &pageSize, nil) if err != nil { return 0, nil, errors.Trace(err) } - items = append(items, backups.Payload.Backups...) + items = append(items, backups.Backups...) // loop to get all backups for { - pageToken = backups.Payload.NextPageToken - if pageToken == "" { + pageToken = backups.NextPageToken + if util.IsNilOrEmpty(pageToken) { break } - backups, err = d.ListBackups(params.WithPageSize(&pageSize).WithPageToken(&pageToken)) + backups, err = d.ListBackups(ctx, &cID, &pageSize, pageToken) if err != nil { return 0, nil, errors.Trace(err) } - items = append(items, backups.Payload.Backups...) + items = append(items, backups.Backups...) } return int64(len(items)), items, nil } diff --git a/pkg/tidbcloud/v1beta1/serverless_br/serverless-br.swagger.json b/pkg/tidbcloud/v1beta1/serverless/br.swagger.json similarity index 100% rename from pkg/tidbcloud/v1beta1/serverless_br/serverless-br.swagger.json rename to pkg/tidbcloud/v1beta1/serverless/br.swagger.json diff --git a/pkg/tidbcloud/v1beta1/serverless/br/.gitignore b/pkg/tidbcloud/v1beta1/serverless/br/.gitignore new file mode 100644 index 00000000..daf913b1 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/.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/br/.openapi-generator-ignore b/pkg/tidbcloud/v1beta1/serverless/br/.openapi-generator-ignore new file mode 100644 index 00000000..7484ee59 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/.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/br/.openapi-generator/FILES b/pkg/tidbcloud/v1beta1/serverless/br/.openapi-generator/FILES new file mode 100644 index 00000000..cfe1c0d7 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/.openapi-generator/FILES @@ -0,0 +1,19 @@ +.gitignore +.openapi-generator-ignore +.travis.yml +README.md +api/openapi.yaml +api_backup_restore_service.go +client.go +configuration.go +git_push.sh +model_protobuf_any.go +model_restore_request_point_in_time.go +model_restore_request_snapshot.go +model_rpc_status.go +model_v1beta1_backup.go +model_v1beta1_list_backups_response.go +model_v1beta1_restore_request.go +model_v1beta1_restore_response.go +response.go +utils.go diff --git a/pkg/tidbcloud/v1beta1/serverless/br/.openapi-generator/VERSION b/pkg/tidbcloud/v1beta1/serverless/br/.openapi-generator/VERSION new file mode 100644 index 00000000..09a6d308 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.8.0 diff --git a/pkg/tidbcloud/v1beta1/serverless/br/.travis.yml b/pkg/tidbcloud/v1beta1/serverless/br/.travis.yml new file mode 100644 index 00000000..f5cb2ce9 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/.travis.yml @@ -0,0 +1,8 @@ +language: go + +install: + - go get -d -v . + +script: + - go build -v ./ + diff --git a/pkg/tidbcloud/v1beta1/serverless/br/README.md b/pkg/tidbcloud/v1beta1/serverless/br/README.md new file mode 100644 index 00000000..378fc14a --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/README.md @@ -0,0 +1,123 @@ +# Go API client for br + +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 br "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 `br.ContextServerIndex` of type `int`. + +```go +ctx := context.WithValue(context.Background(), br.ContextServerIndex, 1) +``` + +### Templated Server URL + +Templated server URL is formatted using default variables from configuration or from context value `br.ContextServerVariables` of type `map[string]string`. + +```go +ctx := context.WithValue(context.Background(), br.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 `br.ContextOperationServerIndices` and `br.ContextOperationServerVariables` context maps. + +```go +ctx := context.WithValue(context.Background(), br.ContextOperationServerIndices, map[string]int{ + "{classname}Service.{nickname}": 2, +}) +ctx = context.WithValue(context.Background(), br.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 +------------ | ------------- | ------------- | ------------- +*BackupRestoreServiceAPI* | [**BackupRestoreServiceDeleteBackup**](docs/BackupRestoreServiceAPI.md#backuprestoreservicedeletebackup) | **Delete** /v1beta1/backups/{backupId} | Deletes a specific backup. +*BackupRestoreServiceAPI* | [**BackupRestoreServiceGetBackup**](docs/BackupRestoreServiceAPI.md#backuprestoreservicegetbackup) | **Get** /v1beta1/backups/{backupId} | Retrieves details of a specific backup. +*BackupRestoreServiceAPI* | [**BackupRestoreServiceListBackups**](docs/BackupRestoreServiceAPI.md#backuprestoreservicelistbackups) | **Get** /v1beta1/backups | Provides a list of backups. +*BackupRestoreServiceAPI* | [**BackupRestoreServiceRestore**](docs/BackupRestoreServiceAPI.md#backuprestoreservicerestore) | **Post** /v1beta1/clusters:restore | + + +## Documentation For Models + + - [ProtobufAny](docs/ProtobufAny.md) + - [RestoreRequestPointInTime](docs/RestoreRequestPointInTime.md) + - [RestoreRequestSnapshot](docs/RestoreRequestSnapshot.md) + - [RpcStatus](docs/RpcStatus.md) + - [V1beta1Backup](docs/V1beta1Backup.md) + - [V1beta1ListBackupsResponse](docs/V1beta1ListBackupsResponse.md) + - [V1beta1RestoreRequest](docs/V1beta1RestoreRequest.md) + - [V1beta1RestoreResponse](docs/V1beta1RestoreResponse.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/br/api/openapi.yaml b/pkg/tidbcloud/v1beta1/serverless/br/api/openapi.yaml new file mode 100644 index 00000000..d55acf10 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/api/openapi.yaml @@ -0,0 +1,236 @@ +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: BackupRestoreService +paths: + /v1beta1/backups: + get: + operationId: BackupRestoreService_ListBackups + parameters: + - description: Optional. The maximum number of clusters to return. + in: query + name: pageSize + schema: + format: int32 + type: integer + - description: Optional. The page token from the previous response for pagination. + in: query + name: pageToken + schema: + type: string + - description: Required. The cluster ID to list backups for. + in: query + name: clusterId + required: true + schema: + type: string + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/v1beta1ListBackupsResponse' + description: A successful response. + default: + content: + application/json: + schema: + $ref: '#/components/schemas/rpcStatus' + description: An unexpected error response. + summary: Provides a list of backups. + tags: + - BackupRestoreService + /v1beta1/backups/{backupId}: + delete: + operationId: BackupRestoreService_DeleteBackup + parameters: + - description: Required. The ID of the backup to be retrieved. + in: path + name: backupId + required: true + schema: + type: string + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/v1beta1Backup' + description: A successful response. + default: + content: + application/json: + schema: + $ref: '#/components/schemas/rpcStatus' + description: An unexpected error response. + summary: Deletes a specific backup. + tags: + - BackupRestoreService + get: + operationId: BackupRestoreService_GetBackup + parameters: + - description: Required. The ID of the backup to be retrieved. + in: path + name: backupId + required: true + schema: + type: string + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/v1beta1Backup' + description: A successful response. + default: + content: + application/json: + schema: + $ref: '#/components/schemas/rpcStatus' + description: An unexpected error response. + summary: Retrieves details of a specific backup. + tags: + - BackupRestoreService + /v1beta1/clusters:restore: + post: + operationId: BackupRestoreService_Restore + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/v1beta1RestoreRequest' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/v1beta1RestoreResponse' + description: A successful response. + default: + content: + application/json: + schema: + $ref: '#/components/schemas/rpcStatus' + description: An unexpected error response. + tags: + - BackupRestoreService + x-codegen-request-body-name: body +components: + schemas: + RestoreRequestPointInTime: + properties: + clusterId: + type: string + backupTime: + format: date-time + type: string + type: object + RestoreRequestSnapshot: + properties: + backupId: + type: string + type: object + protobufAny: + additionalProperties: + type: object + example: + '@type': '@type' + properties: + '@type': + type: string + type: object + rpcStatus: + example: + code: 6 + details: + - '@type': '@type' + - '@type': '@type' + message: message + properties: + code: + format: int32 + type: integer + message: + type: string + details: + items: + $ref: '#/components/schemas/protobufAny' + type: array + type: object + v1beta1Backup: + description: Message for backup resource. + example: + createTime: 2000-01-23T04:56:07.000+00:00 + backupId: backupId + name: name + clusterId: clusterId + properties: + name: + description: Output_only. The unique name of the backup. + readOnly: true + type: string + backupId: + description: Output_only. The unique ID of the backup. + readOnly: true + type: string + clusterId: + description: Required. The cluster ID that backup belong to. + type: string + createTime: + description: Output_only. Timestamp when the backup was created. + format: date-time + readOnly: true + type: string + required: + - clusterId + type: object + v1beta1ListBackupsResponse: + example: + totalSize: 0 + nextPageToken: nextPageToken + backups: + - createTime: 2000-01-23T04:56:07.000+00:00 + backupId: backupId + name: name + clusterId: clusterId + - createTime: 2000-01-23T04:56:07.000+00:00 + backupId: backupId + name: name + clusterId: clusterId + properties: + backups: + description: A list of clusters. + items: + $ref: '#/components/schemas/v1beta1Backup' + type: array + nextPageToken: + description: Token provided to retrieve the next page of results. + type: string + totalSize: + description: Total number of backups. + format: int64 + type: integer + type: object + v1beta1RestoreRequest: + properties: + snapshot: + $ref: '#/components/schemas/RestoreRequestSnapshot' + pointInTime: + $ref: '#/components/schemas/RestoreRequestPointInTime' + type: object + v1beta1RestoreResponse: + example: + clusterId: clusterId + properties: + clusterId: + type: string + required: + - clusterId + type: object +x-original-swagger-version: "2.0" diff --git a/pkg/tidbcloud/v1beta1/serverless/br/api_backup_restore_service.go b/pkg/tidbcloud/v1beta1/serverless/br/api_backup_restore_service.go new file mode 100644 index 00000000..df76245c --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/api_backup_restore_service.go @@ -0,0 +1,497 @@ +/* +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 br + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" + "strings" +) + +// BackupRestoreServiceAPIService BackupRestoreServiceAPI service +type BackupRestoreServiceAPIService service + +type ApiBackupRestoreServiceDeleteBackupRequest struct { + ctx context.Context + ApiService *BackupRestoreServiceAPIService + backupId string +} + +func (r ApiBackupRestoreServiceDeleteBackupRequest) Execute() (*V1beta1Backup, *http.Response, error) { + return r.ApiService.BackupRestoreServiceDeleteBackupExecute(r) +} + +/* +BackupRestoreServiceDeleteBackup Deletes a specific backup. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param backupId Required. The ID of the backup to be retrieved. + @return ApiBackupRestoreServiceDeleteBackupRequest +*/ +func (a *BackupRestoreServiceAPIService) BackupRestoreServiceDeleteBackup(ctx context.Context, backupId string) ApiBackupRestoreServiceDeleteBackupRequest { + return ApiBackupRestoreServiceDeleteBackupRequest{ + ApiService: a, + ctx: ctx, + backupId: backupId, + } +} + +// Execute executes the request +// +// @return V1beta1Backup +func (a *BackupRestoreServiceAPIService) BackupRestoreServiceDeleteBackupExecute(r ApiBackupRestoreServiceDeleteBackupRequest) (*V1beta1Backup, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *V1beta1Backup + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BackupRestoreServiceAPIService.BackupRestoreServiceDeleteBackup") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1beta1/backups/{backupId}" + localVarPath = strings.Replace(localVarPath, "{"+"backupId"+"}", url.PathEscape(parameterValueToString(r.backupId, "backupId")), -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 RpcStatus + 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 ApiBackupRestoreServiceGetBackupRequest struct { + ctx context.Context + ApiService *BackupRestoreServiceAPIService + backupId string +} + +func (r ApiBackupRestoreServiceGetBackupRequest) Execute() (*V1beta1Backup, *http.Response, error) { + return r.ApiService.BackupRestoreServiceGetBackupExecute(r) +} + +/* +BackupRestoreServiceGetBackup Retrieves details of a specific backup. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param backupId Required. The ID of the backup to be retrieved. + @return ApiBackupRestoreServiceGetBackupRequest +*/ +func (a *BackupRestoreServiceAPIService) BackupRestoreServiceGetBackup(ctx context.Context, backupId string) ApiBackupRestoreServiceGetBackupRequest { + return ApiBackupRestoreServiceGetBackupRequest{ + ApiService: a, + ctx: ctx, + backupId: backupId, + } +} + +// Execute executes the request +// +// @return V1beta1Backup +func (a *BackupRestoreServiceAPIService) BackupRestoreServiceGetBackupExecute(r ApiBackupRestoreServiceGetBackupRequest) (*V1beta1Backup, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *V1beta1Backup + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BackupRestoreServiceAPIService.BackupRestoreServiceGetBackup") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1beta1/backups/{backupId}" + localVarPath = strings.Replace(localVarPath, "{"+"backupId"+"}", url.PathEscape(parameterValueToString(r.backupId, "backupId")), -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 RpcStatus + 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 ApiBackupRestoreServiceListBackupsRequest struct { + ctx context.Context + ApiService *BackupRestoreServiceAPIService + clusterId *string + pageSize *int32 + pageToken *string +} + +// Required. The cluster ID to list backups for. +func (r ApiBackupRestoreServiceListBackupsRequest) ClusterId(clusterId string) ApiBackupRestoreServiceListBackupsRequest { + r.clusterId = &clusterId + return r +} + +// Optional. The maximum number of clusters to return. +func (r ApiBackupRestoreServiceListBackupsRequest) PageSize(pageSize int32) ApiBackupRestoreServiceListBackupsRequest { + r.pageSize = &pageSize + return r +} + +// Optional. The page token from the previous response for pagination. +func (r ApiBackupRestoreServiceListBackupsRequest) PageToken(pageToken string) ApiBackupRestoreServiceListBackupsRequest { + r.pageToken = &pageToken + return r +} + +func (r ApiBackupRestoreServiceListBackupsRequest) Execute() (*V1beta1ListBackupsResponse, *http.Response, error) { + return r.ApiService.BackupRestoreServiceListBackupsExecute(r) +} + +/* +BackupRestoreServiceListBackups Provides a list of backups. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiBackupRestoreServiceListBackupsRequest +*/ +func (a *BackupRestoreServiceAPIService) BackupRestoreServiceListBackups(ctx context.Context) ApiBackupRestoreServiceListBackupsRequest { + return ApiBackupRestoreServiceListBackupsRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// +// @return V1beta1ListBackupsResponse +func (a *BackupRestoreServiceAPIService) BackupRestoreServiceListBackupsExecute(r ApiBackupRestoreServiceListBackupsRequest) (*V1beta1ListBackupsResponse, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *V1beta1ListBackupsResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BackupRestoreServiceAPIService.BackupRestoreServiceListBackups") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1beta1/backups" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.clusterId == nil { + return localVarReturnValue, nil, reportError("clusterId is required and must be specified") + } + + if r.pageSize != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "pageSize", r.pageSize, "", "") + } + if r.pageToken != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "pageToken", r.pageToken, "", "") + } + parameterAddToHeaderOrQuery(localVarQueryParams, "clusterId", r.clusterId, "", "") + // 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 RpcStatus + 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 ApiBackupRestoreServiceRestoreRequest struct { + ctx context.Context + ApiService *BackupRestoreServiceAPIService + body *V1beta1RestoreRequest +} + +func (r ApiBackupRestoreServiceRestoreRequest) Body(body V1beta1RestoreRequest) ApiBackupRestoreServiceRestoreRequest { + r.body = &body + return r +} + +func (r ApiBackupRestoreServiceRestoreRequest) Execute() (*V1beta1RestoreResponse, *http.Response, error) { + return r.ApiService.BackupRestoreServiceRestoreExecute(r) +} + +/* +BackupRestoreServiceRestore Method for BackupRestoreServiceRestore + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiBackupRestoreServiceRestoreRequest +*/ +func (a *BackupRestoreServiceAPIService) BackupRestoreServiceRestore(ctx context.Context) ApiBackupRestoreServiceRestoreRequest { + return ApiBackupRestoreServiceRestoreRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// +// @return V1beta1RestoreResponse +func (a *BackupRestoreServiceAPIService) BackupRestoreServiceRestoreExecute(r ApiBackupRestoreServiceRestoreRequest) (*V1beta1RestoreResponse, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *V1beta1RestoreResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BackupRestoreServiceAPIService.BackupRestoreServiceRestore") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v1beta1/clusters:restore" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.body == nil { + return localVarReturnValue, nil, reportError("body 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.body + 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 RpcStatus + 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/br/client.go b/pkg/tidbcloud/v1beta1/serverless/br/client.go new file mode 100644 index 00000000..48fba9ed --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/client.go @@ -0,0 +1,651 @@ +/* +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 br + +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 + + BackupRestoreServiceAPI *BackupRestoreServiceAPIService +} + +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.BackupRestoreServiceAPI = (*BackupRestoreServiceAPIService)(&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 < lenIndValue; i++ { + var arrayValue = indValue.Index(i) + var keyPrefixForCollectionType = keyPrefix + if style == "deepObject" { + keyPrefixForCollectionType = keyPrefix + "[" + strconv.Itoa(i) + "]" + } + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefixForCollectionType, arrayValue.Interface(), style, collectionType) + } + return + + case reflect.Map: + var indValue = reflect.ValueOf(obj) + if indValue == reflect.ValueOf(nil) { + return + } + iter := indValue.MapRange() + for iter.Next() { + k, v := iter.Key(), iter.Value() + parameterAddToHeaderOrQuery(headerOrQueryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface(), style, collectionType) + } + return + + case reflect.Interface: + fallthrough + case reflect.Ptr: + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, v.Elem().Interface(), style, collectionType) + return + + case reflect.Int, reflect.Int8, reflect.Int16, + reflect.Int32, reflect.Int64: + value = strconv.FormatInt(v.Int(), 10) + case reflect.Uint, reflect.Uint8, reflect.Uint16, + reflect.Uint32, reflect.Uint64, reflect.Uintptr: + value = strconv.FormatUint(v.Uint(), 10) + case reflect.Float32, reflect.Float64: + value = strconv.FormatFloat(v.Float(), 'g', -1, 32) + case reflect.Bool: + value = strconv.FormatBool(v.Bool()) + case reflect.String: + value = v.String() + default: + value = v.Type().String() + " value" + } + } + + switch valuesMap := headerOrQueryParams.(type) { + case url.Values: + if collectionType == "csv" && valuesMap.Get(keyPrefix) != "" { + valuesMap.Set(keyPrefix, valuesMap.Get(keyPrefix)+","+value) + } else { + valuesMap.Add(keyPrefix, value) + } + break + case map[string]string: + valuesMap[keyPrefix] = value + break + } +} + +// helper for converting interface{} parameters to json strings +func parameterToJson(obj interface{}) (string, error) { + jsonBuf, err := json.Marshal(obj) + if err != nil { + return "", err + } + return string(jsonBuf), err +} + +// callAPI do the request. +func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { + if c.cfg.Debug { + dump, err := httputil.DumpRequestOut(request, true) + if err != nil { + return nil, err + } + log.Printf("\n%s\n", string(dump)) + } + + resp, err := c.cfg.HTTPClient.Do(request) + if err != nil { + return resp, err + } + + if c.cfg.Debug { + dump, err := httputil.DumpResponse(resp, true) + if err != nil { + return resp, err + } + log.Printf("\n%s\n", string(dump)) + } + return resp, err +} + +// Allow modification of underlying config for alternate implementations and testing +// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior +func (c *APIClient) GetConfig() *Configuration { + return c.cfg +} + +type formFile struct { + fileBytes []byte + fileName string + formFileName string +} + +// prepareRequest build the request +func (c *APIClient) prepareRequest( + ctx context.Context, + path string, method string, + postBody interface{}, + headerParams map[string]string, + queryParams url.Values, + formParams url.Values, + formFiles []formFile) (localVarRequest *http.Request, err error) { + + var body *bytes.Buffer + + // Detect postBody type and post. + if postBody != nil { + contentType := headerParams["Content-Type"] + if contentType == "" { + contentType = detectContentType(postBody) + headerParams["Content-Type"] = contentType + } + + body, err = setBody(postBody, contentType) + if err != nil { + return nil, err + } + } + + // add form parameters and file if available. + if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 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/br/configuration.go b/pkg/tidbcloud/v1beta1/serverless/br/configuration.go new file mode 100644 index 00000000..fd80c735 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/configuration.go @@ -0,0 +1,214 @@ +/* +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 br + +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/br/git_push.sh b/pkg/tidbcloud/v1beta1/serverless/br/git_push.sh new file mode 100644 index 00000000..f53a75d4 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/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/br/model_protobuf_any.go b/pkg/tidbcloud/v1beta1/serverless/br/model_protobuf_any.go new file mode 100644 index 00000000..7a150b5c --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/model_protobuf_any.go @@ -0,0 +1,153 @@ +/* +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 br + +import ( + "encoding/json" +) + +// checks if the ProtobufAny type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ProtobufAny{} + +// ProtobufAny struct for ProtobufAny +type ProtobufAny struct { + Type *string `json:"@type,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _ProtobufAny ProtobufAny + +// NewProtobufAny instantiates a new ProtobufAny 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 NewProtobufAny() *ProtobufAny { + this := ProtobufAny{} + return &this +} + +// NewProtobufAnyWithDefaults instantiates a new ProtobufAny 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 NewProtobufAnyWithDefaults() *ProtobufAny { + this := ProtobufAny{} + return &this +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *ProtobufAny) 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 *ProtobufAny) 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 *ProtobufAny) 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 *ProtobufAny) SetType(v string) { + o.Type = &v +} + +func (o ProtobufAny) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ProtobufAny) 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 *ProtobufAny) UnmarshalJSON(data []byte) (err error) { + varProtobufAny := _ProtobufAny{} + + err = json.Unmarshal(data, &varProtobufAny) + + if err != nil { + return err + } + + *o = ProtobufAny(varProtobufAny) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "@type") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableProtobufAny struct { + value *ProtobufAny + isSet bool +} + +func (v NullableProtobufAny) Get() *ProtobufAny { + return v.value +} + +func (v *NullableProtobufAny) Set(val *ProtobufAny) { + v.value = val + v.isSet = true +} + +func (v NullableProtobufAny) IsSet() bool { + return v.isSet +} + +func (v *NullableProtobufAny) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableProtobufAny(val *ProtobufAny) *NullableProtobufAny { + return &NullableProtobufAny{value: val, isSet: true} +} + +func (v NullableProtobufAny) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableProtobufAny) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/br/model_restore_request_point_in_time.go b/pkg/tidbcloud/v1beta1/serverless/br/model_restore_request_point_in_time.go new file mode 100644 index 00000000..b0f834f7 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/model_restore_request_point_in_time.go @@ -0,0 +1,161 @@ +/* +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 br + +import ( + "encoding/json" + "time" +) + +// checks if the RestoreRequestPointInTime type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &RestoreRequestPointInTime{} + +// RestoreRequestPointInTime struct for RestoreRequestPointInTime +type RestoreRequestPointInTime struct { + ClusterId *string `json:"clusterId,omitempty"` + BackupTime *time.Time `json:"backupTime,omitempty"` +} + +// NewRestoreRequestPointInTime instantiates a new RestoreRequestPointInTime 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 NewRestoreRequestPointInTime() *RestoreRequestPointInTime { + this := RestoreRequestPointInTime{} + return &this +} + +// NewRestoreRequestPointInTimeWithDefaults instantiates a new RestoreRequestPointInTime 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 NewRestoreRequestPointInTimeWithDefaults() *RestoreRequestPointInTime { + this := RestoreRequestPointInTime{} + return &this +} + +// GetClusterId returns the ClusterId field value if set, zero value otherwise. +func (o *RestoreRequestPointInTime) 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 *RestoreRequestPointInTime) 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 *RestoreRequestPointInTime) 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 *RestoreRequestPointInTime) SetClusterId(v string) { + o.ClusterId = &v +} + +// GetBackupTime returns the BackupTime field value if set, zero value otherwise. +func (o *RestoreRequestPointInTime) GetBackupTime() time.Time { + if o == nil || IsNil(o.BackupTime) { + var ret time.Time + return ret + } + return *o.BackupTime +} + +// GetBackupTimeOk returns a tuple with the BackupTime field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RestoreRequestPointInTime) GetBackupTimeOk() (*time.Time, bool) { + if o == nil || IsNil(o.BackupTime) { + return nil, false + } + return o.BackupTime, true +} + +// HasBackupTime returns a boolean if a field has been set. +func (o *RestoreRequestPointInTime) HasBackupTime() bool { + if o != nil && !IsNil(o.BackupTime) { + return true + } + + return false +} + +// SetBackupTime gets a reference to the given time.Time and assigns it to the BackupTime field. +func (o *RestoreRequestPointInTime) SetBackupTime(v time.Time) { + o.BackupTime = &v +} + +func (o RestoreRequestPointInTime) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o RestoreRequestPointInTime) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.ClusterId) { + toSerialize["clusterId"] = o.ClusterId + } + if !IsNil(o.BackupTime) { + toSerialize["backupTime"] = o.BackupTime + } + return toSerialize, nil +} + +type NullableRestoreRequestPointInTime struct { + value *RestoreRequestPointInTime + isSet bool +} + +func (v NullableRestoreRequestPointInTime) Get() *RestoreRequestPointInTime { + return v.value +} + +func (v *NullableRestoreRequestPointInTime) Set(val *RestoreRequestPointInTime) { + v.value = val + v.isSet = true +} + +func (v NullableRestoreRequestPointInTime) IsSet() bool { + return v.isSet +} + +func (v *NullableRestoreRequestPointInTime) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRestoreRequestPointInTime(val *RestoreRequestPointInTime) *NullableRestoreRequestPointInTime { + return &NullableRestoreRequestPointInTime{value: val, isSet: true} +} + +func (v NullableRestoreRequestPointInTime) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRestoreRequestPointInTime) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/br/model_restore_request_snapshot.go b/pkg/tidbcloud/v1beta1/serverless/br/model_restore_request_snapshot.go new file mode 100644 index 00000000..7c859b0b --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/model_restore_request_snapshot.go @@ -0,0 +1,124 @@ +/* +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 br + +import ( + "encoding/json" +) + +// checks if the RestoreRequestSnapshot type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &RestoreRequestSnapshot{} + +// RestoreRequestSnapshot struct for RestoreRequestSnapshot +type RestoreRequestSnapshot struct { + BackupId *string `json:"backupId,omitempty"` +} + +// NewRestoreRequestSnapshot instantiates a new RestoreRequestSnapshot 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 NewRestoreRequestSnapshot() *RestoreRequestSnapshot { + this := RestoreRequestSnapshot{} + return &this +} + +// NewRestoreRequestSnapshotWithDefaults instantiates a new RestoreRequestSnapshot 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 NewRestoreRequestSnapshotWithDefaults() *RestoreRequestSnapshot { + this := RestoreRequestSnapshot{} + return &this +} + +// GetBackupId returns the BackupId field value if set, zero value otherwise. +func (o *RestoreRequestSnapshot) GetBackupId() string { + if o == nil || IsNil(o.BackupId) { + var ret string + return ret + } + return *o.BackupId +} + +// GetBackupIdOk returns a tuple with the BackupId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RestoreRequestSnapshot) GetBackupIdOk() (*string, bool) { + if o == nil || IsNil(o.BackupId) { + return nil, false + } + return o.BackupId, true +} + +// HasBackupId returns a boolean if a field has been set. +func (o *RestoreRequestSnapshot) HasBackupId() bool { + if o != nil && !IsNil(o.BackupId) { + return true + } + + return false +} + +// SetBackupId gets a reference to the given string and assigns it to the BackupId field. +func (o *RestoreRequestSnapshot) SetBackupId(v string) { + o.BackupId = &v +} + +func (o RestoreRequestSnapshot) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o RestoreRequestSnapshot) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.BackupId) { + toSerialize["backupId"] = o.BackupId + } + return toSerialize, nil +} + +type NullableRestoreRequestSnapshot struct { + value *RestoreRequestSnapshot + isSet bool +} + +func (v NullableRestoreRequestSnapshot) Get() *RestoreRequestSnapshot { + return v.value +} + +func (v *NullableRestoreRequestSnapshot) Set(val *RestoreRequestSnapshot) { + v.value = val + v.isSet = true +} + +func (v NullableRestoreRequestSnapshot) IsSet() bool { + return v.isSet +} + +func (v *NullableRestoreRequestSnapshot) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRestoreRequestSnapshot(val *RestoreRequestSnapshot) *NullableRestoreRequestSnapshot { + return &NullableRestoreRequestSnapshot{value: val, isSet: true} +} + +func (v NullableRestoreRequestSnapshot) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRestoreRequestSnapshot) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/br/model_rpc_status.go b/pkg/tidbcloud/v1beta1/serverless/br/model_rpc_status.go new file mode 100644 index 00000000..300b93fc --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/model_rpc_status.go @@ -0,0 +1,196 @@ +/* +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 br + +import ( + "encoding/json" +) + +// checks if the RpcStatus type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &RpcStatus{} + +// RpcStatus struct for RpcStatus +type RpcStatus struct { + Code *int32 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Details []ProtobufAny `json:"details,omitempty"` +} + +// NewRpcStatus instantiates a new RpcStatus 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 NewRpcStatus() *RpcStatus { + this := RpcStatus{} + return &this +} + +// NewRpcStatusWithDefaults instantiates a new RpcStatus 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 NewRpcStatusWithDefaults() *RpcStatus { + this := RpcStatus{} + return &this +} + +// GetCode returns the Code field value if set, zero value otherwise. +func (o *RpcStatus) 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 *RpcStatus) 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 *RpcStatus) 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 *RpcStatus) SetCode(v int32) { + o.Code = &v +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *RpcStatus) 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 *RpcStatus) 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 *RpcStatus) 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 *RpcStatus) SetMessage(v string) { + o.Message = &v +} + +// GetDetails returns the Details field value if set, zero value otherwise. +func (o *RpcStatus) GetDetails() []ProtobufAny { + if o == nil || IsNil(o.Details) { + var ret []ProtobufAny + 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 *RpcStatus) GetDetailsOk() ([]ProtobufAny, 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 *RpcStatus) HasDetails() bool { + if o != nil && !IsNil(o.Details) { + return true + } + + return false +} + +// SetDetails gets a reference to the given []ProtobufAny and assigns it to the Details field. +func (o *RpcStatus) SetDetails(v []ProtobufAny) { + o.Details = v +} + +func (o RpcStatus) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o RpcStatus) 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 NullableRpcStatus struct { + value *RpcStatus + isSet bool +} + +func (v NullableRpcStatus) Get() *RpcStatus { + return v.value +} + +func (v *NullableRpcStatus) Set(val *RpcStatus) { + v.value = val + v.isSet = true +} + +func (v NullableRpcStatus) IsSet() bool { + return v.isSet +} + +func (v *NullableRpcStatus) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRpcStatus(val *RpcStatus) *NullableRpcStatus { + return &NullableRpcStatus{value: val, isSet: true} +} + +func (v NullableRpcStatus) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRpcStatus) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/br/model_v1beta1_backup.go b/pkg/tidbcloud/v1beta1/serverless/br/model_v1beta1_backup.go new file mode 100644 index 00000000..69bafeda --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/model_v1beta1_backup.go @@ -0,0 +1,269 @@ +/* +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 br + +import ( + "bytes" + "encoding/json" + "fmt" + "time" +) + +// checks if the V1beta1Backup type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &V1beta1Backup{} + +// V1beta1Backup Message for backup resource. +type V1beta1Backup struct { + // Output_only. The unique name of the backup. + Name *string `json:"name,omitempty"` + // Output_only. The unique ID of the backup. + BackupId *string `json:"backupId,omitempty"` + // Required. The cluster ID that backup belong to. + ClusterId string `json:"clusterId"` + // Output_only. Timestamp when the backup was created. + CreateTime *time.Time `json:"createTime,omitempty"` +} + +type _V1beta1Backup V1beta1Backup + +// NewV1beta1Backup instantiates a new V1beta1Backup 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 NewV1beta1Backup(clusterId string) *V1beta1Backup { + this := V1beta1Backup{} + this.ClusterId = clusterId + return &this +} + +// NewV1beta1BackupWithDefaults instantiates a new V1beta1Backup 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 NewV1beta1BackupWithDefaults() *V1beta1Backup { + this := V1beta1Backup{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *V1beta1Backup) 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 *V1beta1Backup) 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 *V1beta1Backup) 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 *V1beta1Backup) SetName(v string) { + o.Name = &v +} + +// GetBackupId returns the BackupId field value if set, zero value otherwise. +func (o *V1beta1Backup) GetBackupId() string { + if o == nil || IsNil(o.BackupId) { + var ret string + return ret + } + return *o.BackupId +} + +// GetBackupIdOk returns a tuple with the BackupId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *V1beta1Backup) GetBackupIdOk() (*string, bool) { + if o == nil || IsNil(o.BackupId) { + return nil, false + } + return o.BackupId, true +} + +// HasBackupId returns a boolean if a field has been set. +func (o *V1beta1Backup) HasBackupId() bool { + if o != nil && !IsNil(o.BackupId) { + return true + } + + return false +} + +// SetBackupId gets a reference to the given string and assigns it to the BackupId field. +func (o *V1beta1Backup) SetBackupId(v string) { + o.BackupId = &v +} + +// GetClusterId returns the ClusterId field value +func (o *V1beta1Backup) GetClusterId() string { + if o == nil { + var ret string + return ret + } + + return o.ClusterId +} + +// GetClusterIdOk returns a tuple with the ClusterId field value +// and a boolean to check if the value has been set. +func (o *V1beta1Backup) GetClusterIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ClusterId, true +} + +// SetClusterId sets field value +func (o *V1beta1Backup) SetClusterId(v string) { + o.ClusterId = v +} + +// GetCreateTime returns the CreateTime field value if set, zero value otherwise. +func (o *V1beta1Backup) 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 *V1beta1Backup) 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 *V1beta1Backup) 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 *V1beta1Backup) SetCreateTime(v time.Time) { + o.CreateTime = &v +} + +func (o V1beta1Backup) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o V1beta1Backup) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.BackupId) { + toSerialize["backupId"] = o.BackupId + } + toSerialize["clusterId"] = o.ClusterId + if !IsNil(o.CreateTime) { + toSerialize["createTime"] = o.CreateTime + } + return toSerialize, nil +} + +func (o *V1beta1Backup) 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{ + "clusterId", + } + + 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) + } + } + + varV1beta1Backup := _V1beta1Backup{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varV1beta1Backup) + + if err != nil { + return err + } + + *o = V1beta1Backup(varV1beta1Backup) + + return err +} + +type NullableV1beta1Backup struct { + value *V1beta1Backup + isSet bool +} + +func (v NullableV1beta1Backup) Get() *V1beta1Backup { + return v.value +} + +func (v *NullableV1beta1Backup) Set(val *V1beta1Backup) { + v.value = val + v.isSet = true +} + +func (v NullableV1beta1Backup) IsSet() bool { + return v.isSet +} + +func (v *NullableV1beta1Backup) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableV1beta1Backup(val *V1beta1Backup) *NullableV1beta1Backup { + return &NullableV1beta1Backup{value: val, isSet: true} +} + +func (v NullableV1beta1Backup) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableV1beta1Backup) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/br/model_v1beta1_list_backups_response.go b/pkg/tidbcloud/v1beta1/serverless/br/model_v1beta1_list_backups_response.go new file mode 100644 index 00000000..9d67b238 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/model_v1beta1_list_backups_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 br + +import ( + "encoding/json" +) + +// checks if the V1beta1ListBackupsResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &V1beta1ListBackupsResponse{} + +// V1beta1ListBackupsResponse struct for V1beta1ListBackupsResponse +type V1beta1ListBackupsResponse struct { + // A list of clusters. + Backups []V1beta1Backup `json:"backups,omitempty"` + // Token provided to retrieve the next page of results. + NextPageToken *string `json:"nextPageToken,omitempty"` + // Total number of backups. + TotalSize *int64 `json:"totalSize,omitempty"` +} + +// NewV1beta1ListBackupsResponse instantiates a new V1beta1ListBackupsResponse 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 NewV1beta1ListBackupsResponse() *V1beta1ListBackupsResponse { + this := V1beta1ListBackupsResponse{} + return &this +} + +// NewV1beta1ListBackupsResponseWithDefaults instantiates a new V1beta1ListBackupsResponse 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 NewV1beta1ListBackupsResponseWithDefaults() *V1beta1ListBackupsResponse { + this := V1beta1ListBackupsResponse{} + return &this +} + +// GetBackups returns the Backups field value if set, zero value otherwise. +func (o *V1beta1ListBackupsResponse) GetBackups() []V1beta1Backup { + if o == nil || IsNil(o.Backups) { + var ret []V1beta1Backup + return ret + } + return o.Backups +} + +// GetBackupsOk returns a tuple with the Backups field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *V1beta1ListBackupsResponse) GetBackupsOk() ([]V1beta1Backup, bool) { + if o == nil || IsNil(o.Backups) { + return nil, false + } + return o.Backups, true +} + +// HasBackups returns a boolean if a field has been set. +func (o *V1beta1ListBackupsResponse) HasBackups() bool { + if o != nil && !IsNil(o.Backups) { + return true + } + + return false +} + +// SetBackups gets a reference to the given []V1beta1Backup and assigns it to the Backups field. +func (o *V1beta1ListBackupsResponse) SetBackups(v []V1beta1Backup) { + o.Backups = v +} + +// GetNextPageToken returns the NextPageToken field value if set, zero value otherwise. +func (o *V1beta1ListBackupsResponse) 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 *V1beta1ListBackupsResponse) 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 *V1beta1ListBackupsResponse) 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 *V1beta1ListBackupsResponse) SetNextPageToken(v string) { + o.NextPageToken = &v +} + +// GetTotalSize returns the TotalSize field value if set, zero value otherwise. +func (o *V1beta1ListBackupsResponse) 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 *V1beta1ListBackupsResponse) 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 *V1beta1ListBackupsResponse) 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 *V1beta1ListBackupsResponse) SetTotalSize(v int64) { + o.TotalSize = &v +} + +func (o V1beta1ListBackupsResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o V1beta1ListBackupsResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Backups) { + toSerialize["backups"] = o.Backups + } + if !IsNil(o.NextPageToken) { + toSerialize["nextPageToken"] = o.NextPageToken + } + if !IsNil(o.TotalSize) { + toSerialize["totalSize"] = o.TotalSize + } + return toSerialize, nil +} + +type NullableV1beta1ListBackupsResponse struct { + value *V1beta1ListBackupsResponse + isSet bool +} + +func (v NullableV1beta1ListBackupsResponse) Get() *V1beta1ListBackupsResponse { + return v.value +} + +func (v *NullableV1beta1ListBackupsResponse) Set(val *V1beta1ListBackupsResponse) { + v.value = val + v.isSet = true +} + +func (v NullableV1beta1ListBackupsResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableV1beta1ListBackupsResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableV1beta1ListBackupsResponse(val *V1beta1ListBackupsResponse) *NullableV1beta1ListBackupsResponse { + return &NullableV1beta1ListBackupsResponse{value: val, isSet: true} +} + +func (v NullableV1beta1ListBackupsResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableV1beta1ListBackupsResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/br/model_v1beta1_restore_request.go b/pkg/tidbcloud/v1beta1/serverless/br/model_v1beta1_restore_request.go new file mode 100644 index 00000000..07027654 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/model_v1beta1_restore_request.go @@ -0,0 +1,160 @@ +/* +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 br + +import ( + "encoding/json" +) + +// checks if the V1beta1RestoreRequest type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &V1beta1RestoreRequest{} + +// V1beta1RestoreRequest struct for V1beta1RestoreRequest +type V1beta1RestoreRequest struct { + Snapshot *RestoreRequestSnapshot `json:"snapshot,omitempty"` + PointInTime *RestoreRequestPointInTime `json:"pointInTime,omitempty"` +} + +// NewV1beta1RestoreRequest instantiates a new V1beta1RestoreRequest 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 NewV1beta1RestoreRequest() *V1beta1RestoreRequest { + this := V1beta1RestoreRequest{} + return &this +} + +// NewV1beta1RestoreRequestWithDefaults instantiates a new V1beta1RestoreRequest 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 NewV1beta1RestoreRequestWithDefaults() *V1beta1RestoreRequest { + this := V1beta1RestoreRequest{} + return &this +} + +// GetSnapshot returns the Snapshot field value if set, zero value otherwise. +func (o *V1beta1RestoreRequest) GetSnapshot() RestoreRequestSnapshot { + if o == nil || IsNil(o.Snapshot) { + var ret RestoreRequestSnapshot + return ret + } + return *o.Snapshot +} + +// GetSnapshotOk returns a tuple with the Snapshot field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *V1beta1RestoreRequest) GetSnapshotOk() (*RestoreRequestSnapshot, bool) { + if o == nil || IsNil(o.Snapshot) { + return nil, false + } + return o.Snapshot, true +} + +// HasSnapshot returns a boolean if a field has been set. +func (o *V1beta1RestoreRequest) HasSnapshot() bool { + if o != nil && !IsNil(o.Snapshot) { + return true + } + + return false +} + +// SetSnapshot gets a reference to the given RestoreRequestSnapshot and assigns it to the Snapshot field. +func (o *V1beta1RestoreRequest) SetSnapshot(v RestoreRequestSnapshot) { + o.Snapshot = &v +} + +// GetPointInTime returns the PointInTime field value if set, zero value otherwise. +func (o *V1beta1RestoreRequest) GetPointInTime() RestoreRequestPointInTime { + if o == nil || IsNil(o.PointInTime) { + var ret RestoreRequestPointInTime + return ret + } + return *o.PointInTime +} + +// GetPointInTimeOk returns a tuple with the PointInTime field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *V1beta1RestoreRequest) GetPointInTimeOk() (*RestoreRequestPointInTime, bool) { + if o == nil || IsNil(o.PointInTime) { + return nil, false + } + return o.PointInTime, true +} + +// HasPointInTime returns a boolean if a field has been set. +func (o *V1beta1RestoreRequest) HasPointInTime() bool { + if o != nil && !IsNil(o.PointInTime) { + return true + } + + return false +} + +// SetPointInTime gets a reference to the given RestoreRequestPointInTime and assigns it to the PointInTime field. +func (o *V1beta1RestoreRequest) SetPointInTime(v RestoreRequestPointInTime) { + o.PointInTime = &v +} + +func (o V1beta1RestoreRequest) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o V1beta1RestoreRequest) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Snapshot) { + toSerialize["snapshot"] = o.Snapshot + } + if !IsNil(o.PointInTime) { + toSerialize["pointInTime"] = o.PointInTime + } + return toSerialize, nil +} + +type NullableV1beta1RestoreRequest struct { + value *V1beta1RestoreRequest + isSet bool +} + +func (v NullableV1beta1RestoreRequest) Get() *V1beta1RestoreRequest { + return v.value +} + +func (v *NullableV1beta1RestoreRequest) Set(val *V1beta1RestoreRequest) { + v.value = val + v.isSet = true +} + +func (v NullableV1beta1RestoreRequest) IsSet() bool { + return v.isSet +} + +func (v *NullableV1beta1RestoreRequest) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableV1beta1RestoreRequest(val *V1beta1RestoreRequest) *NullableV1beta1RestoreRequest { + return &NullableV1beta1RestoreRequest{value: val, isSet: true} +} + +func (v NullableV1beta1RestoreRequest) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableV1beta1RestoreRequest) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/br/model_v1beta1_restore_response.go b/pkg/tidbcloud/v1beta1/serverless/br/model_v1beta1_restore_response.go new file mode 100644 index 00000000..82b47558 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/model_v1beta1_restore_response.go @@ -0,0 +1,156 @@ +/* +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 br + +import ( + "bytes" + "encoding/json" + "fmt" +) + +// checks if the V1beta1RestoreResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &V1beta1RestoreResponse{} + +// V1beta1RestoreResponse struct for V1beta1RestoreResponse +type V1beta1RestoreResponse struct { + ClusterId string `json:"clusterId"` +} + +type _V1beta1RestoreResponse V1beta1RestoreResponse + +// NewV1beta1RestoreResponse instantiates a new V1beta1RestoreResponse 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 NewV1beta1RestoreResponse(clusterId string) *V1beta1RestoreResponse { + this := V1beta1RestoreResponse{} + this.ClusterId = clusterId + return &this +} + +// NewV1beta1RestoreResponseWithDefaults instantiates a new V1beta1RestoreResponse 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 NewV1beta1RestoreResponseWithDefaults() *V1beta1RestoreResponse { + this := V1beta1RestoreResponse{} + return &this +} + +// GetClusterId returns the ClusterId field value +func (o *V1beta1RestoreResponse) GetClusterId() string { + if o == nil { + var ret string + return ret + } + + return o.ClusterId +} + +// GetClusterIdOk returns a tuple with the ClusterId field value +// and a boolean to check if the value has been set. +func (o *V1beta1RestoreResponse) GetClusterIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ClusterId, true +} + +// SetClusterId sets field value +func (o *V1beta1RestoreResponse) SetClusterId(v string) { + o.ClusterId = v +} + +func (o V1beta1RestoreResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o V1beta1RestoreResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["clusterId"] = o.ClusterId + return toSerialize, nil +} + +func (o *V1beta1RestoreResponse) 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{ + "clusterId", + } + + 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) + } + } + + varV1beta1RestoreResponse := _V1beta1RestoreResponse{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varV1beta1RestoreResponse) + + if err != nil { + return err + } + + *o = V1beta1RestoreResponse(varV1beta1RestoreResponse) + + return err +} + +type NullableV1beta1RestoreResponse struct { + value *V1beta1RestoreResponse + isSet bool +} + +func (v NullableV1beta1RestoreResponse) Get() *V1beta1RestoreResponse { + return v.value +} + +func (v *NullableV1beta1RestoreResponse) Set(val *V1beta1RestoreResponse) { + v.value = val + v.isSet = true +} + +func (v NullableV1beta1RestoreResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableV1beta1RestoreResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableV1beta1RestoreResponse(val *V1beta1RestoreResponse) *NullableV1beta1RestoreResponse { + return &NullableV1beta1RestoreResponse{value: val, isSet: true} +} + +func (v NullableV1beta1RestoreResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableV1beta1RestoreResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/br/response.go b/pkg/tidbcloud/v1beta1/serverless/br/response.go new file mode 100644 index 00000000..4f562fee --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/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 br + +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/br/utils.go b/pkg/tidbcloud/v1beta1/serverless/br/utils.go new file mode 100644 index 00000000..958077c7 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/br/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 br + +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...) +} diff --git a/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_client.go b/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_client.go deleted file mode 100644 index 3c07e4b8..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_client.go +++ /dev/null @@ -1,219 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package backup_restore_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 backup restore service API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { - return &Client{transport: transport, formats: formats} -} - -// New creates a new backup restore 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 backup restore 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 backup restore 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 { - BackupRestoreServiceDeleteBackup(params *BackupRestoreServiceDeleteBackupParams, opts ...ClientOption) (*BackupRestoreServiceDeleteBackupOK, error) - - BackupRestoreServiceGetBackup(params *BackupRestoreServiceGetBackupParams, opts ...ClientOption) (*BackupRestoreServiceGetBackupOK, error) - - BackupRestoreServiceListBackups(params *BackupRestoreServiceListBackupsParams, opts ...ClientOption) (*BackupRestoreServiceListBackupsOK, error) - - BackupRestoreServiceRestore(params *BackupRestoreServiceRestoreParams, opts ...ClientOption) (*BackupRestoreServiceRestoreOK, error) - - SetTransport(transport runtime.ClientTransport) -} - -/* -BackupRestoreServiceDeleteBackup deletes a specific backup -*/ -func (a *Client) BackupRestoreServiceDeleteBackup(params *BackupRestoreServiceDeleteBackupParams, opts ...ClientOption) (*BackupRestoreServiceDeleteBackupOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewBackupRestoreServiceDeleteBackupParams() - } - op := &runtime.ClientOperation{ - ID: "BackupRestoreService_DeleteBackup", - Method: "DELETE", - PathPattern: "/v1beta1/backups/{backupId}", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &BackupRestoreServiceDeleteBackupReader{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.(*BackupRestoreServiceDeleteBackupOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*BackupRestoreServiceDeleteBackupDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) -} - -/* -BackupRestoreServiceGetBackup retrieves details of a specific backup -*/ -func (a *Client) BackupRestoreServiceGetBackup(params *BackupRestoreServiceGetBackupParams, opts ...ClientOption) (*BackupRestoreServiceGetBackupOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewBackupRestoreServiceGetBackupParams() - } - op := &runtime.ClientOperation{ - ID: "BackupRestoreService_GetBackup", - Method: "GET", - PathPattern: "/v1beta1/backups/{backupId}", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &BackupRestoreServiceGetBackupReader{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.(*BackupRestoreServiceGetBackupOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*BackupRestoreServiceGetBackupDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) -} - -/* -BackupRestoreServiceListBackups provides a list of backups -*/ -func (a *Client) BackupRestoreServiceListBackups(params *BackupRestoreServiceListBackupsParams, opts ...ClientOption) (*BackupRestoreServiceListBackupsOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewBackupRestoreServiceListBackupsParams() - } - op := &runtime.ClientOperation{ - ID: "BackupRestoreService_ListBackups", - Method: "GET", - PathPattern: "/v1beta1/backups", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &BackupRestoreServiceListBackupsReader{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.(*BackupRestoreServiceListBackupsOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*BackupRestoreServiceListBackupsDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) -} - -/* -BackupRestoreServiceRestore backup restore service restore API -*/ -func (a *Client) BackupRestoreServiceRestore(params *BackupRestoreServiceRestoreParams, opts ...ClientOption) (*BackupRestoreServiceRestoreOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewBackupRestoreServiceRestoreParams() - } - op := &runtime.ClientOperation{ - ID: "BackupRestoreService_Restore", - Method: "POST", - PathPattern: "/v1beta1/clusters:restore", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &BackupRestoreServiceRestoreReader{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.(*BackupRestoreServiceRestoreOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*BackupRestoreServiceRestoreDefault) - 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/serverless_br/client/backup_restore_service/backup_restore_service_delete_backup_parameters.go b/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_delete_backup_parameters.go deleted file mode 100644 index 9ff1011f..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_delete_backup_parameters.go +++ /dev/null @@ -1,151 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package backup_restore_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" -) - -// NewBackupRestoreServiceDeleteBackupParams creates a new BackupRestoreServiceDeleteBackupParams 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 NewBackupRestoreServiceDeleteBackupParams() *BackupRestoreServiceDeleteBackupParams { - return &BackupRestoreServiceDeleteBackupParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewBackupRestoreServiceDeleteBackupParamsWithTimeout creates a new BackupRestoreServiceDeleteBackupParams object -// with the ability to set a timeout on a request. -func NewBackupRestoreServiceDeleteBackupParamsWithTimeout(timeout time.Duration) *BackupRestoreServiceDeleteBackupParams { - return &BackupRestoreServiceDeleteBackupParams{ - timeout: timeout, - } -} - -// NewBackupRestoreServiceDeleteBackupParamsWithContext creates a new BackupRestoreServiceDeleteBackupParams object -// with the ability to set a context for a request. -func NewBackupRestoreServiceDeleteBackupParamsWithContext(ctx context.Context) *BackupRestoreServiceDeleteBackupParams { - return &BackupRestoreServiceDeleteBackupParams{ - Context: ctx, - } -} - -// NewBackupRestoreServiceDeleteBackupParamsWithHTTPClient creates a new BackupRestoreServiceDeleteBackupParams object -// with the ability to set a custom HTTPClient for a request. -func NewBackupRestoreServiceDeleteBackupParamsWithHTTPClient(client *http.Client) *BackupRestoreServiceDeleteBackupParams { - return &BackupRestoreServiceDeleteBackupParams{ - HTTPClient: client, - } -} - -/* -BackupRestoreServiceDeleteBackupParams contains all the parameters to send to the API endpoint - - for the backup restore service delete backup operation. - - Typically these are written to a http.Request. -*/ -type BackupRestoreServiceDeleteBackupParams struct { - - /* BackupID. - - Required. The ID of the backup to be retrieved. - */ - BackupID string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the backup restore service delete backup params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *BackupRestoreServiceDeleteBackupParams) WithDefaults() *BackupRestoreServiceDeleteBackupParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the backup restore service delete backup params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *BackupRestoreServiceDeleteBackupParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the backup restore service delete backup params -func (o *BackupRestoreServiceDeleteBackupParams) WithTimeout(timeout time.Duration) *BackupRestoreServiceDeleteBackupParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the backup restore service delete backup params -func (o *BackupRestoreServiceDeleteBackupParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the backup restore service delete backup params -func (o *BackupRestoreServiceDeleteBackupParams) WithContext(ctx context.Context) *BackupRestoreServiceDeleteBackupParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the backup restore service delete backup params -func (o *BackupRestoreServiceDeleteBackupParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the backup restore service delete backup params -func (o *BackupRestoreServiceDeleteBackupParams) WithHTTPClient(client *http.Client) *BackupRestoreServiceDeleteBackupParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the backup restore service delete backup params -func (o *BackupRestoreServiceDeleteBackupParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithBackupID adds the backupID to the backup restore service delete backup params -func (o *BackupRestoreServiceDeleteBackupParams) WithBackupID(backupID string) *BackupRestoreServiceDeleteBackupParams { - o.SetBackupID(backupID) - return o -} - -// SetBackupID adds the backupId to the backup restore service delete backup params -func (o *BackupRestoreServiceDeleteBackupParams) SetBackupID(backupID string) { - o.BackupID = backupID -} - -// WriteToRequest writes these params to a swagger request -func (o *BackupRestoreServiceDeleteBackupParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - // path param backupId - if err := r.SetPathParam("backupId", o.BackupID); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_delete_backup_responses.go b/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_delete_backup_responses.go deleted file mode 100644 index f128b578..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_delete_backup_responses.go +++ /dev/null @@ -1,187 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package backup_restore_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/serverless_br/models" -) - -// BackupRestoreServiceDeleteBackupReader is a Reader for the BackupRestoreServiceDeleteBackup structure. -type BackupRestoreServiceDeleteBackupReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *BackupRestoreServiceDeleteBackupReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewBackupRestoreServiceDeleteBackupOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - default: - result := NewBackupRestoreServiceDeleteBackupDefault(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 - } -} - -// NewBackupRestoreServiceDeleteBackupOK creates a BackupRestoreServiceDeleteBackupOK with default headers values -func NewBackupRestoreServiceDeleteBackupOK() *BackupRestoreServiceDeleteBackupOK { - return &BackupRestoreServiceDeleteBackupOK{} -} - -/* -BackupRestoreServiceDeleteBackupOK describes a response with status code 200, with default header values. - -A successful response. -*/ -type BackupRestoreServiceDeleteBackupOK struct { - Payload *models.V1beta1Backup -} - -// IsSuccess returns true when this backup restore service delete backup o k response has a 2xx status code -func (o *BackupRestoreServiceDeleteBackupOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this backup restore service delete backup o k response has a 3xx status code -func (o *BackupRestoreServiceDeleteBackupOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this backup restore service delete backup o k response has a 4xx status code -func (o *BackupRestoreServiceDeleteBackupOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this backup restore service delete backup o k response has a 5xx status code -func (o *BackupRestoreServiceDeleteBackupOK) IsServerError() bool { - return false -} - -// IsCode returns true when this backup restore service delete backup o k response a status code equal to that given -func (o *BackupRestoreServiceDeleteBackupOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the backup restore service delete backup o k response -func (o *BackupRestoreServiceDeleteBackupOK) Code() int { - return 200 -} - -func (o *BackupRestoreServiceDeleteBackupOK) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[DELETE /v1beta1/backups/{backupId}][%d] backupRestoreServiceDeleteBackupOK %s", 200, payload) -} - -func (o *BackupRestoreServiceDeleteBackupOK) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[DELETE /v1beta1/backups/{backupId}][%d] backupRestoreServiceDeleteBackupOK %s", 200, payload) -} - -func (o *BackupRestoreServiceDeleteBackupOK) GetPayload() *models.V1beta1Backup { - return o.Payload -} - -func (o *BackupRestoreServiceDeleteBackupOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.V1beta1Backup) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewBackupRestoreServiceDeleteBackupDefault creates a BackupRestoreServiceDeleteBackupDefault with default headers values -func NewBackupRestoreServiceDeleteBackupDefault(code int) *BackupRestoreServiceDeleteBackupDefault { - return &BackupRestoreServiceDeleteBackupDefault{ - _statusCode: code, - } -} - -/* -BackupRestoreServiceDeleteBackupDefault describes a response with status code -1, with default header values. - -An unexpected error response. -*/ -type BackupRestoreServiceDeleteBackupDefault struct { - _statusCode int - - Payload *models.RPCStatus -} - -// IsSuccess returns true when this backup restore service delete backup default response has a 2xx status code -func (o *BackupRestoreServiceDeleteBackupDefault) IsSuccess() bool { - return o._statusCode/100 == 2 -} - -// IsRedirect returns true when this backup restore service delete backup default response has a 3xx status code -func (o *BackupRestoreServiceDeleteBackupDefault) IsRedirect() bool { - return o._statusCode/100 == 3 -} - -// IsClientError returns true when this backup restore service delete backup default response has a 4xx status code -func (o *BackupRestoreServiceDeleteBackupDefault) IsClientError() bool { - return o._statusCode/100 == 4 -} - -// IsServerError returns true when this backup restore service delete backup default response has a 5xx status code -func (o *BackupRestoreServiceDeleteBackupDefault) IsServerError() bool { - return o._statusCode/100 == 5 -} - -// IsCode returns true when this backup restore service delete backup default response a status code equal to that given -func (o *BackupRestoreServiceDeleteBackupDefault) IsCode(code int) bool { - return o._statusCode == code -} - -// Code gets the status code for the backup restore service delete backup default response -func (o *BackupRestoreServiceDeleteBackupDefault) Code() int { - return o._statusCode -} - -func (o *BackupRestoreServiceDeleteBackupDefault) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[DELETE /v1beta1/backups/{backupId}][%d] BackupRestoreService_DeleteBackup default %s", o._statusCode, payload) -} - -func (o *BackupRestoreServiceDeleteBackupDefault) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[DELETE /v1beta1/backups/{backupId}][%d] BackupRestoreService_DeleteBackup default %s", o._statusCode, payload) -} - -func (o *BackupRestoreServiceDeleteBackupDefault) GetPayload() *models.RPCStatus { - return o.Payload -} - -func (o *BackupRestoreServiceDeleteBackupDefault) 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/serverless_br/client/backup_restore_service/backup_restore_service_get_backup_parameters.go b/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_get_backup_parameters.go deleted file mode 100644 index 7e4d55f4..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_get_backup_parameters.go +++ /dev/null @@ -1,151 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package backup_restore_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" -) - -// NewBackupRestoreServiceGetBackupParams creates a new BackupRestoreServiceGetBackupParams 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 NewBackupRestoreServiceGetBackupParams() *BackupRestoreServiceGetBackupParams { - return &BackupRestoreServiceGetBackupParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewBackupRestoreServiceGetBackupParamsWithTimeout creates a new BackupRestoreServiceGetBackupParams object -// with the ability to set a timeout on a request. -func NewBackupRestoreServiceGetBackupParamsWithTimeout(timeout time.Duration) *BackupRestoreServiceGetBackupParams { - return &BackupRestoreServiceGetBackupParams{ - timeout: timeout, - } -} - -// NewBackupRestoreServiceGetBackupParamsWithContext creates a new BackupRestoreServiceGetBackupParams object -// with the ability to set a context for a request. -func NewBackupRestoreServiceGetBackupParamsWithContext(ctx context.Context) *BackupRestoreServiceGetBackupParams { - return &BackupRestoreServiceGetBackupParams{ - Context: ctx, - } -} - -// NewBackupRestoreServiceGetBackupParamsWithHTTPClient creates a new BackupRestoreServiceGetBackupParams object -// with the ability to set a custom HTTPClient for a request. -func NewBackupRestoreServiceGetBackupParamsWithHTTPClient(client *http.Client) *BackupRestoreServiceGetBackupParams { - return &BackupRestoreServiceGetBackupParams{ - HTTPClient: client, - } -} - -/* -BackupRestoreServiceGetBackupParams contains all the parameters to send to the API endpoint - - for the backup restore service get backup operation. - - Typically these are written to a http.Request. -*/ -type BackupRestoreServiceGetBackupParams struct { - - /* BackupID. - - Required. The ID of the backup to be retrieved. - */ - BackupID string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the backup restore service get backup params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *BackupRestoreServiceGetBackupParams) WithDefaults() *BackupRestoreServiceGetBackupParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the backup restore service get backup params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *BackupRestoreServiceGetBackupParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the backup restore service get backup params -func (o *BackupRestoreServiceGetBackupParams) WithTimeout(timeout time.Duration) *BackupRestoreServiceGetBackupParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the backup restore service get backup params -func (o *BackupRestoreServiceGetBackupParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the backup restore service get backup params -func (o *BackupRestoreServiceGetBackupParams) WithContext(ctx context.Context) *BackupRestoreServiceGetBackupParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the backup restore service get backup params -func (o *BackupRestoreServiceGetBackupParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the backup restore service get backup params -func (o *BackupRestoreServiceGetBackupParams) WithHTTPClient(client *http.Client) *BackupRestoreServiceGetBackupParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the backup restore service get backup params -func (o *BackupRestoreServiceGetBackupParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithBackupID adds the backupID to the backup restore service get backup params -func (o *BackupRestoreServiceGetBackupParams) WithBackupID(backupID string) *BackupRestoreServiceGetBackupParams { - o.SetBackupID(backupID) - return o -} - -// SetBackupID adds the backupId to the backup restore service get backup params -func (o *BackupRestoreServiceGetBackupParams) SetBackupID(backupID string) { - o.BackupID = backupID -} - -// WriteToRequest writes these params to a swagger request -func (o *BackupRestoreServiceGetBackupParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - // path param backupId - if err := r.SetPathParam("backupId", o.BackupID); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_get_backup_responses.go b/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_get_backup_responses.go deleted file mode 100644 index f2f8a1a7..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_get_backup_responses.go +++ /dev/null @@ -1,187 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package backup_restore_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/serverless_br/models" -) - -// BackupRestoreServiceGetBackupReader is a Reader for the BackupRestoreServiceGetBackup structure. -type BackupRestoreServiceGetBackupReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *BackupRestoreServiceGetBackupReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewBackupRestoreServiceGetBackupOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - default: - result := NewBackupRestoreServiceGetBackupDefault(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 - } -} - -// NewBackupRestoreServiceGetBackupOK creates a BackupRestoreServiceGetBackupOK with default headers values -func NewBackupRestoreServiceGetBackupOK() *BackupRestoreServiceGetBackupOK { - return &BackupRestoreServiceGetBackupOK{} -} - -/* -BackupRestoreServiceGetBackupOK describes a response with status code 200, with default header values. - -A successful response. -*/ -type BackupRestoreServiceGetBackupOK struct { - Payload *models.V1beta1Backup -} - -// IsSuccess returns true when this backup restore service get backup o k response has a 2xx status code -func (o *BackupRestoreServiceGetBackupOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this backup restore service get backup o k response has a 3xx status code -func (o *BackupRestoreServiceGetBackupOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this backup restore service get backup o k response has a 4xx status code -func (o *BackupRestoreServiceGetBackupOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this backup restore service get backup o k response has a 5xx status code -func (o *BackupRestoreServiceGetBackupOK) IsServerError() bool { - return false -} - -// IsCode returns true when this backup restore service get backup o k response a status code equal to that given -func (o *BackupRestoreServiceGetBackupOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the backup restore service get backup o k response -func (o *BackupRestoreServiceGetBackupOK) Code() int { - return 200 -} - -func (o *BackupRestoreServiceGetBackupOK) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /v1beta1/backups/{backupId}][%d] backupRestoreServiceGetBackupOK %s", 200, payload) -} - -func (o *BackupRestoreServiceGetBackupOK) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /v1beta1/backups/{backupId}][%d] backupRestoreServiceGetBackupOK %s", 200, payload) -} - -func (o *BackupRestoreServiceGetBackupOK) GetPayload() *models.V1beta1Backup { - return o.Payload -} - -func (o *BackupRestoreServiceGetBackupOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.V1beta1Backup) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewBackupRestoreServiceGetBackupDefault creates a BackupRestoreServiceGetBackupDefault with default headers values -func NewBackupRestoreServiceGetBackupDefault(code int) *BackupRestoreServiceGetBackupDefault { - return &BackupRestoreServiceGetBackupDefault{ - _statusCode: code, - } -} - -/* -BackupRestoreServiceGetBackupDefault describes a response with status code -1, with default header values. - -An unexpected error response. -*/ -type BackupRestoreServiceGetBackupDefault struct { - _statusCode int - - Payload *models.RPCStatus -} - -// IsSuccess returns true when this backup restore service get backup default response has a 2xx status code -func (o *BackupRestoreServiceGetBackupDefault) IsSuccess() bool { - return o._statusCode/100 == 2 -} - -// IsRedirect returns true when this backup restore service get backup default response has a 3xx status code -func (o *BackupRestoreServiceGetBackupDefault) IsRedirect() bool { - return o._statusCode/100 == 3 -} - -// IsClientError returns true when this backup restore service get backup default response has a 4xx status code -func (o *BackupRestoreServiceGetBackupDefault) IsClientError() bool { - return o._statusCode/100 == 4 -} - -// IsServerError returns true when this backup restore service get backup default response has a 5xx status code -func (o *BackupRestoreServiceGetBackupDefault) IsServerError() bool { - return o._statusCode/100 == 5 -} - -// IsCode returns true when this backup restore service get backup default response a status code equal to that given -func (o *BackupRestoreServiceGetBackupDefault) IsCode(code int) bool { - return o._statusCode == code -} - -// Code gets the status code for the backup restore service get backup default response -func (o *BackupRestoreServiceGetBackupDefault) Code() int { - return o._statusCode -} - -func (o *BackupRestoreServiceGetBackupDefault) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /v1beta1/backups/{backupId}][%d] BackupRestoreService_GetBackup default %s", o._statusCode, payload) -} - -func (o *BackupRestoreServiceGetBackupDefault) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /v1beta1/backups/{backupId}][%d] BackupRestoreService_GetBackup default %s", o._statusCode, payload) -} - -func (o *BackupRestoreServiceGetBackupDefault) GetPayload() *models.RPCStatus { - return o.Payload -} - -func (o *BackupRestoreServiceGetBackupDefault) 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/serverless_br/client/backup_restore_service/backup_restore_service_list_backups_parameters.go b/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_list_backups_parameters.go deleted file mode 100644 index 5f2211f9..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_list_backups_parameters.go +++ /dev/null @@ -1,227 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package backup_restore_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" -) - -// NewBackupRestoreServiceListBackupsParams creates a new BackupRestoreServiceListBackupsParams 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 NewBackupRestoreServiceListBackupsParams() *BackupRestoreServiceListBackupsParams { - return &BackupRestoreServiceListBackupsParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewBackupRestoreServiceListBackupsParamsWithTimeout creates a new BackupRestoreServiceListBackupsParams object -// with the ability to set a timeout on a request. -func NewBackupRestoreServiceListBackupsParamsWithTimeout(timeout time.Duration) *BackupRestoreServiceListBackupsParams { - return &BackupRestoreServiceListBackupsParams{ - timeout: timeout, - } -} - -// NewBackupRestoreServiceListBackupsParamsWithContext creates a new BackupRestoreServiceListBackupsParams object -// with the ability to set a context for a request. -func NewBackupRestoreServiceListBackupsParamsWithContext(ctx context.Context) *BackupRestoreServiceListBackupsParams { - return &BackupRestoreServiceListBackupsParams{ - Context: ctx, - } -} - -// NewBackupRestoreServiceListBackupsParamsWithHTTPClient creates a new BackupRestoreServiceListBackupsParams object -// with the ability to set a custom HTTPClient for a request. -func NewBackupRestoreServiceListBackupsParamsWithHTTPClient(client *http.Client) *BackupRestoreServiceListBackupsParams { - return &BackupRestoreServiceListBackupsParams{ - HTTPClient: client, - } -} - -/* -BackupRestoreServiceListBackupsParams contains all the parameters to send to the API endpoint - - for the backup restore service list backups operation. - - Typically these are written to a http.Request. -*/ -type BackupRestoreServiceListBackupsParams struct { - - /* ClusterID. - - Required. The cluster ID to list backups for. - */ - ClusterID string - - /* PageSize. - - Optional. The maximum number of clusters to return. - - Format: int32 - */ - PageSize *int32 - - /* PageToken. - - Optional. The page token from the previous response for pagination. - */ - PageToken *string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the backup restore service list backups params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *BackupRestoreServiceListBackupsParams) WithDefaults() *BackupRestoreServiceListBackupsParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the backup restore service list backups params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *BackupRestoreServiceListBackupsParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the backup restore service list backups params -func (o *BackupRestoreServiceListBackupsParams) WithTimeout(timeout time.Duration) *BackupRestoreServiceListBackupsParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the backup restore service list backups params -func (o *BackupRestoreServiceListBackupsParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the backup restore service list backups params -func (o *BackupRestoreServiceListBackupsParams) WithContext(ctx context.Context) *BackupRestoreServiceListBackupsParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the backup restore service list backups params -func (o *BackupRestoreServiceListBackupsParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the backup restore service list backups params -func (o *BackupRestoreServiceListBackupsParams) WithHTTPClient(client *http.Client) *BackupRestoreServiceListBackupsParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the backup restore service list backups params -func (o *BackupRestoreServiceListBackupsParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithClusterID adds the clusterID to the backup restore service list backups params -func (o *BackupRestoreServiceListBackupsParams) WithClusterID(clusterID string) *BackupRestoreServiceListBackupsParams { - o.SetClusterID(clusterID) - return o -} - -// SetClusterID adds the clusterId to the backup restore service list backups params -func (o *BackupRestoreServiceListBackupsParams) SetClusterID(clusterID string) { - o.ClusterID = clusterID -} - -// WithPageSize adds the pageSize to the backup restore service list backups params -func (o *BackupRestoreServiceListBackupsParams) WithPageSize(pageSize *int32) *BackupRestoreServiceListBackupsParams { - o.SetPageSize(pageSize) - return o -} - -// SetPageSize adds the pageSize to the backup restore service list backups params -func (o *BackupRestoreServiceListBackupsParams) SetPageSize(pageSize *int32) { - o.PageSize = pageSize -} - -// WithPageToken adds the pageToken to the backup restore service list backups params -func (o *BackupRestoreServiceListBackupsParams) WithPageToken(pageToken *string) *BackupRestoreServiceListBackupsParams { - o.SetPageToken(pageToken) - return o -} - -// SetPageToken adds the pageToken to the backup restore service list backups params -func (o *BackupRestoreServiceListBackupsParams) SetPageToken(pageToken *string) { - o.PageToken = pageToken -} - -// WriteToRequest writes these params to a swagger request -func (o *BackupRestoreServiceListBackupsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - // query param clusterId - qrClusterID := o.ClusterID - qClusterID := qrClusterID - if qClusterID != "" { - - if err := r.SetQueryParam("clusterId", qClusterID); 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/serverless_br/client/backup_restore_service/backup_restore_service_list_backups_responses.go b/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_list_backups_responses.go deleted file mode 100644 index 4eb9d2fe..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_list_backups_responses.go +++ /dev/null @@ -1,187 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package backup_restore_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/serverless_br/models" -) - -// BackupRestoreServiceListBackupsReader is a Reader for the BackupRestoreServiceListBackups structure. -type BackupRestoreServiceListBackupsReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *BackupRestoreServiceListBackupsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewBackupRestoreServiceListBackupsOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - default: - result := NewBackupRestoreServiceListBackupsDefault(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 - } -} - -// NewBackupRestoreServiceListBackupsOK creates a BackupRestoreServiceListBackupsOK with default headers values -func NewBackupRestoreServiceListBackupsOK() *BackupRestoreServiceListBackupsOK { - return &BackupRestoreServiceListBackupsOK{} -} - -/* -BackupRestoreServiceListBackupsOK describes a response with status code 200, with default header values. - -A successful response. -*/ -type BackupRestoreServiceListBackupsOK struct { - Payload *models.V1beta1ListBackupsResponse -} - -// IsSuccess returns true when this backup restore service list backups o k response has a 2xx status code -func (o *BackupRestoreServiceListBackupsOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this backup restore service list backups o k response has a 3xx status code -func (o *BackupRestoreServiceListBackupsOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this backup restore service list backups o k response has a 4xx status code -func (o *BackupRestoreServiceListBackupsOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this backup restore service list backups o k response has a 5xx status code -func (o *BackupRestoreServiceListBackupsOK) IsServerError() bool { - return false -} - -// IsCode returns true when this backup restore service list backups o k response a status code equal to that given -func (o *BackupRestoreServiceListBackupsOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the backup restore service list backups o k response -func (o *BackupRestoreServiceListBackupsOK) Code() int { - return 200 -} - -func (o *BackupRestoreServiceListBackupsOK) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /v1beta1/backups][%d] backupRestoreServiceListBackupsOK %s", 200, payload) -} - -func (o *BackupRestoreServiceListBackupsOK) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /v1beta1/backups][%d] backupRestoreServiceListBackupsOK %s", 200, payload) -} - -func (o *BackupRestoreServiceListBackupsOK) GetPayload() *models.V1beta1ListBackupsResponse { - return o.Payload -} - -func (o *BackupRestoreServiceListBackupsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.V1beta1ListBackupsResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewBackupRestoreServiceListBackupsDefault creates a BackupRestoreServiceListBackupsDefault with default headers values -func NewBackupRestoreServiceListBackupsDefault(code int) *BackupRestoreServiceListBackupsDefault { - return &BackupRestoreServiceListBackupsDefault{ - _statusCode: code, - } -} - -/* -BackupRestoreServiceListBackupsDefault describes a response with status code -1, with default header values. - -An unexpected error response. -*/ -type BackupRestoreServiceListBackupsDefault struct { - _statusCode int - - Payload *models.RPCStatus -} - -// IsSuccess returns true when this backup restore service list backups default response has a 2xx status code -func (o *BackupRestoreServiceListBackupsDefault) IsSuccess() bool { - return o._statusCode/100 == 2 -} - -// IsRedirect returns true when this backup restore service list backups default response has a 3xx status code -func (o *BackupRestoreServiceListBackupsDefault) IsRedirect() bool { - return o._statusCode/100 == 3 -} - -// IsClientError returns true when this backup restore service list backups default response has a 4xx status code -func (o *BackupRestoreServiceListBackupsDefault) IsClientError() bool { - return o._statusCode/100 == 4 -} - -// IsServerError returns true when this backup restore service list backups default response has a 5xx status code -func (o *BackupRestoreServiceListBackupsDefault) IsServerError() bool { - return o._statusCode/100 == 5 -} - -// IsCode returns true when this backup restore service list backups default response a status code equal to that given -func (o *BackupRestoreServiceListBackupsDefault) IsCode(code int) bool { - return o._statusCode == code -} - -// Code gets the status code for the backup restore service list backups default response -func (o *BackupRestoreServiceListBackupsDefault) Code() int { - return o._statusCode -} - -func (o *BackupRestoreServiceListBackupsDefault) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /v1beta1/backups][%d] BackupRestoreService_ListBackups default %s", o._statusCode, payload) -} - -func (o *BackupRestoreServiceListBackupsDefault) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /v1beta1/backups][%d] BackupRestoreService_ListBackups default %s", o._statusCode, payload) -} - -func (o *BackupRestoreServiceListBackupsDefault) GetPayload() *models.RPCStatus { - return o.Payload -} - -func (o *BackupRestoreServiceListBackupsDefault) 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/serverless_br/client/backup_restore_service/backup_restore_service_restore_parameters.go b/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_restore_parameters.go deleted file mode 100644 index 0c797690..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_restore_parameters.go +++ /dev/null @@ -1,150 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package backup_restore_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/serverless_br/models" -) - -// NewBackupRestoreServiceRestoreParams creates a new BackupRestoreServiceRestoreParams 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 NewBackupRestoreServiceRestoreParams() *BackupRestoreServiceRestoreParams { - return &BackupRestoreServiceRestoreParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewBackupRestoreServiceRestoreParamsWithTimeout creates a new BackupRestoreServiceRestoreParams object -// with the ability to set a timeout on a request. -func NewBackupRestoreServiceRestoreParamsWithTimeout(timeout time.Duration) *BackupRestoreServiceRestoreParams { - return &BackupRestoreServiceRestoreParams{ - timeout: timeout, - } -} - -// NewBackupRestoreServiceRestoreParamsWithContext creates a new BackupRestoreServiceRestoreParams object -// with the ability to set a context for a request. -func NewBackupRestoreServiceRestoreParamsWithContext(ctx context.Context) *BackupRestoreServiceRestoreParams { - return &BackupRestoreServiceRestoreParams{ - Context: ctx, - } -} - -// NewBackupRestoreServiceRestoreParamsWithHTTPClient creates a new BackupRestoreServiceRestoreParams object -// with the ability to set a custom HTTPClient for a request. -func NewBackupRestoreServiceRestoreParamsWithHTTPClient(client *http.Client) *BackupRestoreServiceRestoreParams { - return &BackupRestoreServiceRestoreParams{ - HTTPClient: client, - } -} - -/* -BackupRestoreServiceRestoreParams contains all the parameters to send to the API endpoint - - for the backup restore service restore operation. - - Typically these are written to a http.Request. -*/ -type BackupRestoreServiceRestoreParams struct { - - // Body. - Body *models.V1beta1RestoreRequest - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the backup restore service restore params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *BackupRestoreServiceRestoreParams) WithDefaults() *BackupRestoreServiceRestoreParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the backup restore service restore params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *BackupRestoreServiceRestoreParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the backup restore service restore params -func (o *BackupRestoreServiceRestoreParams) WithTimeout(timeout time.Duration) *BackupRestoreServiceRestoreParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the backup restore service restore params -func (o *BackupRestoreServiceRestoreParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the backup restore service restore params -func (o *BackupRestoreServiceRestoreParams) WithContext(ctx context.Context) *BackupRestoreServiceRestoreParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the backup restore service restore params -func (o *BackupRestoreServiceRestoreParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the backup restore service restore params -func (o *BackupRestoreServiceRestoreParams) WithHTTPClient(client *http.Client) *BackupRestoreServiceRestoreParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the backup restore service restore params -func (o *BackupRestoreServiceRestoreParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithBody adds the body to the backup restore service restore params -func (o *BackupRestoreServiceRestoreParams) WithBody(body *models.V1beta1RestoreRequest) *BackupRestoreServiceRestoreParams { - o.SetBody(body) - return o -} - -// SetBody adds the body to the backup restore service restore params -func (o *BackupRestoreServiceRestoreParams) SetBody(body *models.V1beta1RestoreRequest) { - o.Body = body -} - -// WriteToRequest writes these params to a swagger request -func (o *BackupRestoreServiceRestoreParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - if o.Body != nil { - if err := r.SetBodyParam(o.Body); err != nil { - return err - } - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_restore_responses.go b/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_restore_responses.go deleted file mode 100644 index 0ebe07f5..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/client/backup_restore_service/backup_restore_service_restore_responses.go +++ /dev/null @@ -1,187 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package backup_restore_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/serverless_br/models" -) - -// BackupRestoreServiceRestoreReader is a Reader for the BackupRestoreServiceRestore structure. -type BackupRestoreServiceRestoreReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *BackupRestoreServiceRestoreReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewBackupRestoreServiceRestoreOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - default: - result := NewBackupRestoreServiceRestoreDefault(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 - } -} - -// NewBackupRestoreServiceRestoreOK creates a BackupRestoreServiceRestoreOK with default headers values -func NewBackupRestoreServiceRestoreOK() *BackupRestoreServiceRestoreOK { - return &BackupRestoreServiceRestoreOK{} -} - -/* -BackupRestoreServiceRestoreOK describes a response with status code 200, with default header values. - -A successful response. -*/ -type BackupRestoreServiceRestoreOK struct { - Payload *models.V1beta1RestoreResponse -} - -// IsSuccess returns true when this backup restore service restore o k response has a 2xx status code -func (o *BackupRestoreServiceRestoreOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this backup restore service restore o k response has a 3xx status code -func (o *BackupRestoreServiceRestoreOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this backup restore service restore o k response has a 4xx status code -func (o *BackupRestoreServiceRestoreOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this backup restore service restore o k response has a 5xx status code -func (o *BackupRestoreServiceRestoreOK) IsServerError() bool { - return false -} - -// IsCode returns true when this backup restore service restore o k response a status code equal to that given -func (o *BackupRestoreServiceRestoreOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the backup restore service restore o k response -func (o *BackupRestoreServiceRestoreOK) Code() int { - return 200 -} - -func (o *BackupRestoreServiceRestoreOK) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[POST /v1beta1/clusters:restore][%d] backupRestoreServiceRestoreOK %s", 200, payload) -} - -func (o *BackupRestoreServiceRestoreOK) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[POST /v1beta1/clusters:restore][%d] backupRestoreServiceRestoreOK %s", 200, payload) -} - -func (o *BackupRestoreServiceRestoreOK) GetPayload() *models.V1beta1RestoreResponse { - return o.Payload -} - -func (o *BackupRestoreServiceRestoreOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.V1beta1RestoreResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewBackupRestoreServiceRestoreDefault creates a BackupRestoreServiceRestoreDefault with default headers values -func NewBackupRestoreServiceRestoreDefault(code int) *BackupRestoreServiceRestoreDefault { - return &BackupRestoreServiceRestoreDefault{ - _statusCode: code, - } -} - -/* -BackupRestoreServiceRestoreDefault describes a response with status code -1, with default header values. - -An unexpected error response. -*/ -type BackupRestoreServiceRestoreDefault struct { - _statusCode int - - Payload *models.RPCStatus -} - -// IsSuccess returns true when this backup restore service restore default response has a 2xx status code -func (o *BackupRestoreServiceRestoreDefault) IsSuccess() bool { - return o._statusCode/100 == 2 -} - -// IsRedirect returns true when this backup restore service restore default response has a 3xx status code -func (o *BackupRestoreServiceRestoreDefault) IsRedirect() bool { - return o._statusCode/100 == 3 -} - -// IsClientError returns true when this backup restore service restore default response has a 4xx status code -func (o *BackupRestoreServiceRestoreDefault) IsClientError() bool { - return o._statusCode/100 == 4 -} - -// IsServerError returns true when this backup restore service restore default response has a 5xx status code -func (o *BackupRestoreServiceRestoreDefault) IsServerError() bool { - return o._statusCode/100 == 5 -} - -// IsCode returns true when this backup restore service restore default response a status code equal to that given -func (o *BackupRestoreServiceRestoreDefault) IsCode(code int) bool { - return o._statusCode == code -} - -// Code gets the status code for the backup restore service restore default response -func (o *BackupRestoreServiceRestoreDefault) Code() int { - return o._statusCode -} - -func (o *BackupRestoreServiceRestoreDefault) Error() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[POST /v1beta1/clusters:restore][%d] BackupRestoreService_Restore default %s", o._statusCode, payload) -} - -func (o *BackupRestoreServiceRestoreDefault) String() string { - payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[POST /v1beta1/clusters:restore][%d] BackupRestoreService_Restore default %s", o._statusCode, payload) -} - -func (o *BackupRestoreServiceRestoreDefault) GetPayload() *models.RPCStatus { - return o.Payload -} - -func (o *BackupRestoreServiceRestoreDefault) 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/serverless_br/client/import_service/import_service_abort_multipart_upload_parameters.go b/pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_abort_multipart_upload_parameters.go deleted file mode 100644 index ba2c5db9..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_abort_multipart_upload_parameters.go +++ /dev/null @@ -1,205 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package import_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" -) - -// NewImportServiceAbortMultipartUploadParams creates a new ImportServiceAbortMultipartUploadParams 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 NewImportServiceAbortMultipartUploadParams() *ImportServiceAbortMultipartUploadParams { - return &ImportServiceAbortMultipartUploadParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewImportServiceAbortMultipartUploadParamsWithTimeout creates a new ImportServiceAbortMultipartUploadParams object -// with the ability to set a timeout on a request. -func NewImportServiceAbortMultipartUploadParamsWithTimeout(timeout time.Duration) *ImportServiceAbortMultipartUploadParams { - return &ImportServiceAbortMultipartUploadParams{ - timeout: timeout, - } -} - -// NewImportServiceAbortMultipartUploadParamsWithContext creates a new ImportServiceAbortMultipartUploadParams object -// with the ability to set a context for a request. -func NewImportServiceAbortMultipartUploadParamsWithContext(ctx context.Context) *ImportServiceAbortMultipartUploadParams { - return &ImportServiceAbortMultipartUploadParams{ - Context: ctx, - } -} - -// NewImportServiceAbortMultipartUploadParamsWithHTTPClient creates a new ImportServiceAbortMultipartUploadParams object -// with the ability to set a custom HTTPClient for a request. -func NewImportServiceAbortMultipartUploadParamsWithHTTPClient(client *http.Client) *ImportServiceAbortMultipartUploadParams { - return &ImportServiceAbortMultipartUploadParams{ - HTTPClient: client, - } -} - -/* -ImportServiceAbortMultipartUploadParams contains all the parameters to send to the API endpoint - - for the import service abort multipart upload operation. - - Typically these are written to a http.Request. -*/ -type ImportServiceAbortMultipartUploadParams struct { - - /* ClusterID. - - The ID of the cluster to import into - */ - ClusterID string - - /* FileName. - - The name of the file to import - */ - FileName string - - /* UploadID. - - The ID of the upload - */ - UploadID string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the import service abort multipart upload params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ImportServiceAbortMultipartUploadParams) WithDefaults() *ImportServiceAbortMultipartUploadParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the import service abort multipart upload params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ImportServiceAbortMultipartUploadParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the import service abort multipart upload params -func (o *ImportServiceAbortMultipartUploadParams) WithTimeout(timeout time.Duration) *ImportServiceAbortMultipartUploadParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the import service abort multipart upload params -func (o *ImportServiceAbortMultipartUploadParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the import service abort multipart upload params -func (o *ImportServiceAbortMultipartUploadParams) WithContext(ctx context.Context) *ImportServiceAbortMultipartUploadParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the import service abort multipart upload params -func (o *ImportServiceAbortMultipartUploadParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the import service abort multipart upload params -func (o *ImportServiceAbortMultipartUploadParams) WithHTTPClient(client *http.Client) *ImportServiceAbortMultipartUploadParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the import service abort multipart upload params -func (o *ImportServiceAbortMultipartUploadParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithClusterID adds the clusterID to the import service abort multipart upload params -func (o *ImportServiceAbortMultipartUploadParams) WithClusterID(clusterID string) *ImportServiceAbortMultipartUploadParams { - o.SetClusterID(clusterID) - return o -} - -// SetClusterID adds the clusterId to the import service abort multipart upload params -func (o *ImportServiceAbortMultipartUploadParams) SetClusterID(clusterID string) { - o.ClusterID = clusterID -} - -// WithFileName adds the fileName to the import service abort multipart upload params -func (o *ImportServiceAbortMultipartUploadParams) WithFileName(fileName string) *ImportServiceAbortMultipartUploadParams { - o.SetFileName(fileName) - return o -} - -// SetFileName adds the fileName to the import service abort multipart upload params -func (o *ImportServiceAbortMultipartUploadParams) SetFileName(fileName string) { - o.FileName = fileName -} - -// WithUploadID adds the uploadID to the import service abort multipart upload params -func (o *ImportServiceAbortMultipartUploadParams) WithUploadID(uploadID string) *ImportServiceAbortMultipartUploadParams { - o.SetUploadID(uploadID) - return o -} - -// SetUploadID adds the uploadId to the import service abort multipart upload params -func (o *ImportServiceAbortMultipartUploadParams) SetUploadID(uploadID string) { - o.UploadID = uploadID -} - -// WriteToRequest writes these params to a swagger request -func (o *ImportServiceAbortMultipartUploadParams) 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 - } - - // query param fileName - qrFileName := o.FileName - qFileName := qrFileName - if qFileName != "" { - - if err := r.SetQueryParam("fileName", qFileName); err != nil { - return err - } - } - - // query param uploadId - qrUploadID := o.UploadID - qUploadID := qrUploadID - if qUploadID != "" { - - if err := r.SetQueryParam("uploadId", qUploadID); err != nil { - return err - } - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_abort_multipart_upload_responses.go b/pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_abort_multipart_upload_responses.go deleted file mode 100644 index 086af619..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_abort_multipart_upload_responses.go +++ /dev/null @@ -1,180 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package import_service - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/models" -) - -// ImportServiceAbortMultipartUploadReader is a Reader for the ImportServiceAbortMultipartUpload structure. -type ImportServiceAbortMultipartUploadReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *ImportServiceAbortMultipartUploadReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewImportServiceAbortMultipartUploadOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - default: - result := NewImportServiceAbortMultipartUploadDefault(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 - } -} - -// NewImportServiceAbortMultipartUploadOK creates a ImportServiceAbortMultipartUploadOK with default headers values -func NewImportServiceAbortMultipartUploadOK() *ImportServiceAbortMultipartUploadOK { - return &ImportServiceAbortMultipartUploadOK{} -} - -/* -ImportServiceAbortMultipartUploadOK describes a response with status code 200, with default header values. - -A successful response. -*/ -type ImportServiceAbortMultipartUploadOK struct { - Payload interface{} -} - -// IsSuccess returns true when this import service abort multipart upload o k response has a 2xx status code -func (o *ImportServiceAbortMultipartUploadOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this import service abort multipart upload o k response has a 3xx status code -func (o *ImportServiceAbortMultipartUploadOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this import service abort multipart upload o k response has a 4xx status code -func (o *ImportServiceAbortMultipartUploadOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this import service abort multipart upload o k response has a 5xx status code -func (o *ImportServiceAbortMultipartUploadOK) IsServerError() bool { - return false -} - -// IsCode returns true when this import service abort multipart upload o k response a status code equal to that given -func (o *ImportServiceAbortMultipartUploadOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the import service abort multipart upload o k response -func (o *ImportServiceAbortMultipartUploadOK) Code() int { - return 200 -} - -func (o *ImportServiceAbortMultipartUploadOK) Error() string { - return fmt.Sprintf("[POST /v1beta1/clusters/{clusterId}/upload_url/abort][%d] importServiceAbortMultipartUploadOK %+v", 200, o.Payload) -} - -func (o *ImportServiceAbortMultipartUploadOK) String() string { - return fmt.Sprintf("[POST /v1beta1/clusters/{clusterId}/upload_url/abort][%d] importServiceAbortMultipartUploadOK %+v", 200, o.Payload) -} - -func (o *ImportServiceAbortMultipartUploadOK) GetPayload() interface{} { - return o.Payload -} - -func (o *ImportServiceAbortMultipartUploadOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewImportServiceAbortMultipartUploadDefault creates a ImportServiceAbortMultipartUploadDefault with default headers values -func NewImportServiceAbortMultipartUploadDefault(code int) *ImportServiceAbortMultipartUploadDefault { - return &ImportServiceAbortMultipartUploadDefault{ - _statusCode: code, - } -} - -/* -ImportServiceAbortMultipartUploadDefault describes a response with status code -1, with default header values. - -An unexpected error response. -*/ -type ImportServiceAbortMultipartUploadDefault struct { - _statusCode int - - Payload *models.RPCStatus -} - -// IsSuccess returns true when this import service abort multipart upload default response has a 2xx status code -func (o *ImportServiceAbortMultipartUploadDefault) IsSuccess() bool { - return o._statusCode/100 == 2 -} - -// IsRedirect returns true when this import service abort multipart upload default response has a 3xx status code -func (o *ImportServiceAbortMultipartUploadDefault) IsRedirect() bool { - return o._statusCode/100 == 3 -} - -// IsClientError returns true when this import service abort multipart upload default response has a 4xx status code -func (o *ImportServiceAbortMultipartUploadDefault) IsClientError() bool { - return o._statusCode/100 == 4 -} - -// IsServerError returns true when this import service abort multipart upload default response has a 5xx status code -func (o *ImportServiceAbortMultipartUploadDefault) IsServerError() bool { - return o._statusCode/100 == 5 -} - -// IsCode returns true when this import service abort multipart upload default response a status code equal to that given -func (o *ImportServiceAbortMultipartUploadDefault) IsCode(code int) bool { - return o._statusCode == code -} - -// Code gets the status code for the import service abort multipart upload default response -func (o *ImportServiceAbortMultipartUploadDefault) Code() int { - return o._statusCode -} - -func (o *ImportServiceAbortMultipartUploadDefault) Error() string { - return fmt.Sprintf("[POST /v1beta1/clusters/{clusterId}/upload_url/abort][%d] ImportService_AbortMultipartUpload default %+v", o._statusCode, o.Payload) -} - -func (o *ImportServiceAbortMultipartUploadDefault) String() string { - return fmt.Sprintf("[POST /v1beta1/clusters/{clusterId}/upload_url/abort][%d] ImportService_AbortMultipartUpload default %+v", o._statusCode, o.Payload) -} - -func (o *ImportServiceAbortMultipartUploadDefault) GetPayload() *models.RPCStatus { - return o.Payload -} - -func (o *ImportServiceAbortMultipartUploadDefault) 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/serverless_br/client/import_service/import_service_client.go b/pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_client.go deleted file mode 100644 index 5aae2f43..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_client.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package import_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" - "github.com/go-openapi/strfmt" -) - -// New creates a new import service API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { - return &Client{transport: transport, formats: formats} -} - -/* -Client for import service API -*/ -type Client struct { - transport runtime.ClientTransport - formats strfmt.Registry -} - -// ClientOption is the option for Client methods -type ClientOption func(*runtime.ClientOperation) - -// ClientService is the interface for Client methods -type ClientService interface { - ImportServiceAbortMultipartUpload(params *ImportServiceAbortMultipartUploadParams, opts ...ClientOption) (*ImportServiceAbortMultipartUploadOK, error) - - ImportServiceCompleteMultipartUpload(params *ImportServiceCompleteMultipartUploadParams, opts ...ClientOption) (*ImportServiceCompleteMultipartUploadOK, error) - - ImportServiceGenerateUploadURL(params *ImportServiceGenerateUploadURLParams, opts ...ClientOption) (*ImportServiceGenerateUploadURLOK, error) - - SetTransport(transport runtime.ClientTransport) -} - -/* -ImportServiceAbortMultipartUpload import service abort multipart upload API -*/ -func (a *Client) ImportServiceAbortMultipartUpload(params *ImportServiceAbortMultipartUploadParams, opts ...ClientOption) (*ImportServiceAbortMultipartUploadOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewImportServiceAbortMultipartUploadParams() - } - op := &runtime.ClientOperation{ - ID: "ImportService_AbortMultipartUpload", - Method: "POST", - PathPattern: "/v1beta1/clusters/{clusterId}/upload_url/abort", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &ImportServiceAbortMultipartUploadReader{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.(*ImportServiceAbortMultipartUploadOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*ImportServiceAbortMultipartUploadDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) -} - -/* -ImportServiceCompleteMultipartUpload import service complete multipart upload API -*/ -func (a *Client) ImportServiceCompleteMultipartUpload(params *ImportServiceCompleteMultipartUploadParams, opts ...ClientOption) (*ImportServiceCompleteMultipartUploadOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewImportServiceCompleteMultipartUploadParams() - } - op := &runtime.ClientOperation{ - ID: "ImportService_CompleteMultipartUpload", - Method: "POST", - PathPattern: "/v1beta1/clusters/{clusterId}/upload_url/complete", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &ImportServiceCompleteMultipartUploadReader{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.(*ImportServiceCompleteMultipartUploadOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*ImportServiceCompleteMultipartUploadDefault) - return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) -} - -/* -ImportServiceGenerateUploadURL generates upload url for importing data -*/ -func (a *Client) ImportServiceGenerateUploadURL(params *ImportServiceGenerateUploadURLParams, opts ...ClientOption) (*ImportServiceGenerateUploadURLOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewImportServiceGenerateUploadURLParams() - } - op := &runtime.ClientOperation{ - ID: "ImportService_GenerateUploadUrl", - Method: "GET", - PathPattern: "/v1beta1/clusters/{clusterId}/upload_url", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &ImportServiceGenerateUploadURLReader{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.(*ImportServiceGenerateUploadURLOK) - if ok { - return success, nil - } - // unexpected success response - unexpectedSuccess := result.(*ImportServiceGenerateUploadURLDefault) - 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/serverless_br/client/import_service/import_service_complete_multipart_upload_parameters.go b/pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_complete_multipart_upload_parameters.go deleted file mode 100644 index 913fc5d8..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_complete_multipart_upload_parameters.go +++ /dev/null @@ -1,205 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package import_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" -) - -// NewImportServiceCompleteMultipartUploadParams creates a new ImportServiceCompleteMultipartUploadParams 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 NewImportServiceCompleteMultipartUploadParams() *ImportServiceCompleteMultipartUploadParams { - return &ImportServiceCompleteMultipartUploadParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewImportServiceCompleteMultipartUploadParamsWithTimeout creates a new ImportServiceCompleteMultipartUploadParams object -// with the ability to set a timeout on a request. -func NewImportServiceCompleteMultipartUploadParamsWithTimeout(timeout time.Duration) *ImportServiceCompleteMultipartUploadParams { - return &ImportServiceCompleteMultipartUploadParams{ - timeout: timeout, - } -} - -// NewImportServiceCompleteMultipartUploadParamsWithContext creates a new ImportServiceCompleteMultipartUploadParams object -// with the ability to set a context for a request. -func NewImportServiceCompleteMultipartUploadParamsWithContext(ctx context.Context) *ImportServiceCompleteMultipartUploadParams { - return &ImportServiceCompleteMultipartUploadParams{ - Context: ctx, - } -} - -// NewImportServiceCompleteMultipartUploadParamsWithHTTPClient creates a new ImportServiceCompleteMultipartUploadParams object -// with the ability to set a custom HTTPClient for a request. -func NewImportServiceCompleteMultipartUploadParamsWithHTTPClient(client *http.Client) *ImportServiceCompleteMultipartUploadParams { - return &ImportServiceCompleteMultipartUploadParams{ - HTTPClient: client, - } -} - -/* -ImportServiceCompleteMultipartUploadParams contains all the parameters to send to the API endpoint - - for the import service complete multipart upload operation. - - Typically these are written to a http.Request. -*/ -type ImportServiceCompleteMultipartUploadParams struct { - - /* ClusterID. - - The ID of the cluster to import into - */ - ClusterID string - - /* FileName. - - The name of the file to import - */ - FileName string - - /* UploadID. - - The ID of the upload - */ - UploadID string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the import service complete multipart upload params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ImportServiceCompleteMultipartUploadParams) WithDefaults() *ImportServiceCompleteMultipartUploadParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the import service complete multipart upload params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ImportServiceCompleteMultipartUploadParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the import service complete multipart upload params -func (o *ImportServiceCompleteMultipartUploadParams) WithTimeout(timeout time.Duration) *ImportServiceCompleteMultipartUploadParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the import service complete multipart upload params -func (o *ImportServiceCompleteMultipartUploadParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the import service complete multipart upload params -func (o *ImportServiceCompleteMultipartUploadParams) WithContext(ctx context.Context) *ImportServiceCompleteMultipartUploadParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the import service complete multipart upload params -func (o *ImportServiceCompleteMultipartUploadParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the import service complete multipart upload params -func (o *ImportServiceCompleteMultipartUploadParams) WithHTTPClient(client *http.Client) *ImportServiceCompleteMultipartUploadParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the import service complete multipart upload params -func (o *ImportServiceCompleteMultipartUploadParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithClusterID adds the clusterID to the import service complete multipart upload params -func (o *ImportServiceCompleteMultipartUploadParams) WithClusterID(clusterID string) *ImportServiceCompleteMultipartUploadParams { - o.SetClusterID(clusterID) - return o -} - -// SetClusterID adds the clusterId to the import service complete multipart upload params -func (o *ImportServiceCompleteMultipartUploadParams) SetClusterID(clusterID string) { - o.ClusterID = clusterID -} - -// WithFileName adds the fileName to the import service complete multipart upload params -func (o *ImportServiceCompleteMultipartUploadParams) WithFileName(fileName string) *ImportServiceCompleteMultipartUploadParams { - o.SetFileName(fileName) - return o -} - -// SetFileName adds the fileName to the import service complete multipart upload params -func (o *ImportServiceCompleteMultipartUploadParams) SetFileName(fileName string) { - o.FileName = fileName -} - -// WithUploadID adds the uploadID to the import service complete multipart upload params -func (o *ImportServiceCompleteMultipartUploadParams) WithUploadID(uploadID string) *ImportServiceCompleteMultipartUploadParams { - o.SetUploadID(uploadID) - return o -} - -// SetUploadID adds the uploadId to the import service complete multipart upload params -func (o *ImportServiceCompleteMultipartUploadParams) SetUploadID(uploadID string) { - o.UploadID = uploadID -} - -// WriteToRequest writes these params to a swagger request -func (o *ImportServiceCompleteMultipartUploadParams) 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 - } - - // query param fileName - qrFileName := o.FileName - qFileName := qrFileName - if qFileName != "" { - - if err := r.SetQueryParam("fileName", qFileName); err != nil { - return err - } - } - - // query param uploadId - qrUploadID := o.UploadID - qUploadID := qrUploadID - if qUploadID != "" { - - if err := r.SetQueryParam("uploadId", qUploadID); err != nil { - return err - } - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_complete_multipart_upload_responses.go b/pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_complete_multipart_upload_responses.go deleted file mode 100644 index 64445485..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_complete_multipart_upload_responses.go +++ /dev/null @@ -1,180 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package import_service - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/models" -) - -// ImportServiceCompleteMultipartUploadReader is a Reader for the ImportServiceCompleteMultipartUpload structure. -type ImportServiceCompleteMultipartUploadReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *ImportServiceCompleteMultipartUploadReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewImportServiceCompleteMultipartUploadOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - default: - result := NewImportServiceCompleteMultipartUploadDefault(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 - } -} - -// NewImportServiceCompleteMultipartUploadOK creates a ImportServiceCompleteMultipartUploadOK with default headers values -func NewImportServiceCompleteMultipartUploadOK() *ImportServiceCompleteMultipartUploadOK { - return &ImportServiceCompleteMultipartUploadOK{} -} - -/* -ImportServiceCompleteMultipartUploadOK describes a response with status code 200, with default header values. - -A successful response. -*/ -type ImportServiceCompleteMultipartUploadOK struct { - Payload interface{} -} - -// IsSuccess returns true when this import service complete multipart upload o k response has a 2xx status code -func (o *ImportServiceCompleteMultipartUploadOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this import service complete multipart upload o k response has a 3xx status code -func (o *ImportServiceCompleteMultipartUploadOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this import service complete multipart upload o k response has a 4xx status code -func (o *ImportServiceCompleteMultipartUploadOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this import service complete multipart upload o k response has a 5xx status code -func (o *ImportServiceCompleteMultipartUploadOK) IsServerError() bool { - return false -} - -// IsCode returns true when this import service complete multipart upload o k response a status code equal to that given -func (o *ImportServiceCompleteMultipartUploadOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the import service complete multipart upload o k response -func (o *ImportServiceCompleteMultipartUploadOK) Code() int { - return 200 -} - -func (o *ImportServiceCompleteMultipartUploadOK) Error() string { - return fmt.Sprintf("[POST /v1beta1/clusters/{clusterId}/upload_url/complete][%d] importServiceCompleteMultipartUploadOK %+v", 200, o.Payload) -} - -func (o *ImportServiceCompleteMultipartUploadOK) String() string { - return fmt.Sprintf("[POST /v1beta1/clusters/{clusterId}/upload_url/complete][%d] importServiceCompleteMultipartUploadOK %+v", 200, o.Payload) -} - -func (o *ImportServiceCompleteMultipartUploadOK) GetPayload() interface{} { - return o.Payload -} - -func (o *ImportServiceCompleteMultipartUploadOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewImportServiceCompleteMultipartUploadDefault creates a ImportServiceCompleteMultipartUploadDefault with default headers values -func NewImportServiceCompleteMultipartUploadDefault(code int) *ImportServiceCompleteMultipartUploadDefault { - return &ImportServiceCompleteMultipartUploadDefault{ - _statusCode: code, - } -} - -/* -ImportServiceCompleteMultipartUploadDefault describes a response with status code -1, with default header values. - -An unexpected error response. -*/ -type ImportServiceCompleteMultipartUploadDefault struct { - _statusCode int - - Payload *models.RPCStatus -} - -// IsSuccess returns true when this import service complete multipart upload default response has a 2xx status code -func (o *ImportServiceCompleteMultipartUploadDefault) IsSuccess() bool { - return o._statusCode/100 == 2 -} - -// IsRedirect returns true when this import service complete multipart upload default response has a 3xx status code -func (o *ImportServiceCompleteMultipartUploadDefault) IsRedirect() bool { - return o._statusCode/100 == 3 -} - -// IsClientError returns true when this import service complete multipart upload default response has a 4xx status code -func (o *ImportServiceCompleteMultipartUploadDefault) IsClientError() bool { - return o._statusCode/100 == 4 -} - -// IsServerError returns true when this import service complete multipart upload default response has a 5xx status code -func (o *ImportServiceCompleteMultipartUploadDefault) IsServerError() bool { - return o._statusCode/100 == 5 -} - -// IsCode returns true when this import service complete multipart upload default response a status code equal to that given -func (o *ImportServiceCompleteMultipartUploadDefault) IsCode(code int) bool { - return o._statusCode == code -} - -// Code gets the status code for the import service complete multipart upload default response -func (o *ImportServiceCompleteMultipartUploadDefault) Code() int { - return o._statusCode -} - -func (o *ImportServiceCompleteMultipartUploadDefault) Error() string { - return fmt.Sprintf("[POST /v1beta1/clusters/{clusterId}/upload_url/complete][%d] ImportService_CompleteMultipartUpload default %+v", o._statusCode, o.Payload) -} - -func (o *ImportServiceCompleteMultipartUploadDefault) String() string { - return fmt.Sprintf("[POST /v1beta1/clusters/{clusterId}/upload_url/complete][%d] ImportService_CompleteMultipartUpload default %+v", o._statusCode, o.Payload) -} - -func (o *ImportServiceCompleteMultipartUploadDefault) GetPayload() *models.RPCStatus { - return o.Payload -} - -func (o *ImportServiceCompleteMultipartUploadDefault) 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/serverless_br/client/import_service/import_service_generate_upload_url_parameters.go b/pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_generate_upload_url_parameters.go deleted file mode 100644 index 1e6d4172..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_generate_upload_url_parameters.go +++ /dev/null @@ -1,208 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package import_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" -) - -// NewImportServiceGenerateUploadURLParams creates a new ImportServiceGenerateUploadURLParams 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 NewImportServiceGenerateUploadURLParams() *ImportServiceGenerateUploadURLParams { - return &ImportServiceGenerateUploadURLParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewImportServiceGenerateUploadURLParamsWithTimeout creates a new ImportServiceGenerateUploadURLParams object -// with the ability to set a timeout on a request. -func NewImportServiceGenerateUploadURLParamsWithTimeout(timeout time.Duration) *ImportServiceGenerateUploadURLParams { - return &ImportServiceGenerateUploadURLParams{ - timeout: timeout, - } -} - -// NewImportServiceGenerateUploadURLParamsWithContext creates a new ImportServiceGenerateUploadURLParams object -// with the ability to set a context for a request. -func NewImportServiceGenerateUploadURLParamsWithContext(ctx context.Context) *ImportServiceGenerateUploadURLParams { - return &ImportServiceGenerateUploadURLParams{ - Context: ctx, - } -} - -// NewImportServiceGenerateUploadURLParamsWithHTTPClient creates a new ImportServiceGenerateUploadURLParams object -// with the ability to set a custom HTTPClient for a request. -func NewImportServiceGenerateUploadURLParamsWithHTTPClient(client *http.Client) *ImportServiceGenerateUploadURLParams { - return &ImportServiceGenerateUploadURLParams{ - HTTPClient: client, - } -} - -/* -ImportServiceGenerateUploadURLParams contains all the parameters to send to the API endpoint - - for the import service generate upload Url operation. - - Typically these are written to a http.Request. -*/ -type ImportServiceGenerateUploadURLParams struct { - - /* ClusterID. - - The ID of the cluster to import into - */ - ClusterID string - - /* FileName. - - The name of the file to import - */ - FileName string - - /* PartNumber. - - The number of parts to split the file into - - Format: int32 - */ - PartNumber int32 - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the import service generate upload Url params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ImportServiceGenerateUploadURLParams) WithDefaults() *ImportServiceGenerateUploadURLParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the import service generate upload Url params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ImportServiceGenerateUploadURLParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the import service generate upload Url params -func (o *ImportServiceGenerateUploadURLParams) WithTimeout(timeout time.Duration) *ImportServiceGenerateUploadURLParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the import service generate upload Url params -func (o *ImportServiceGenerateUploadURLParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the import service generate upload Url params -func (o *ImportServiceGenerateUploadURLParams) WithContext(ctx context.Context) *ImportServiceGenerateUploadURLParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the import service generate upload Url params -func (o *ImportServiceGenerateUploadURLParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the import service generate upload Url params -func (o *ImportServiceGenerateUploadURLParams) WithHTTPClient(client *http.Client) *ImportServiceGenerateUploadURLParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the import service generate upload Url params -func (o *ImportServiceGenerateUploadURLParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithClusterID adds the clusterID to the import service generate upload Url params -func (o *ImportServiceGenerateUploadURLParams) WithClusterID(clusterID string) *ImportServiceGenerateUploadURLParams { - o.SetClusterID(clusterID) - return o -} - -// SetClusterID adds the clusterId to the import service generate upload Url params -func (o *ImportServiceGenerateUploadURLParams) SetClusterID(clusterID string) { - o.ClusterID = clusterID -} - -// WithFileName adds the fileName to the import service generate upload Url params -func (o *ImportServiceGenerateUploadURLParams) WithFileName(fileName string) *ImportServiceGenerateUploadURLParams { - o.SetFileName(fileName) - return o -} - -// SetFileName adds the fileName to the import service generate upload Url params -func (o *ImportServiceGenerateUploadURLParams) SetFileName(fileName string) { - o.FileName = fileName -} - -// WithPartNumber adds the partNumber to the import service generate upload Url params -func (o *ImportServiceGenerateUploadURLParams) WithPartNumber(partNumber int32) *ImportServiceGenerateUploadURLParams { - o.SetPartNumber(partNumber) - return o -} - -// SetPartNumber adds the partNumber to the import service generate upload Url params -func (o *ImportServiceGenerateUploadURLParams) SetPartNumber(partNumber int32) { - o.PartNumber = partNumber -} - -// WriteToRequest writes these params to a swagger request -func (o *ImportServiceGenerateUploadURLParams) 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 - } - - // query param fileName - qrFileName := o.FileName - qFileName := qrFileName - if qFileName != "" { - - if err := r.SetQueryParam("fileName", qFileName); err != nil { - return err - } - } - - // query param partNumber - qrPartNumber := o.PartNumber - qPartNumber := swag.FormatInt32(qrPartNumber) - if qPartNumber != "" { - - if err := r.SetQueryParam("partNumber", qPartNumber); err != nil { - return err - } - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_generate_upload_url_responses.go b/pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_generate_upload_url_responses.go deleted file mode 100644 index 732795ff..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/client/import_service/import_service_generate_upload_url_responses.go +++ /dev/null @@ -1,182 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package import_service - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless_br/models" -) - -// ImportServiceGenerateUploadURLReader is a Reader for the ImportServiceGenerateUploadURL structure. -type ImportServiceGenerateUploadURLReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *ImportServiceGenerateUploadURLReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewImportServiceGenerateUploadURLOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - default: - result := NewImportServiceGenerateUploadURLDefault(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 - } -} - -// NewImportServiceGenerateUploadURLOK creates a ImportServiceGenerateUploadURLOK with default headers values -func NewImportServiceGenerateUploadURLOK() *ImportServiceGenerateUploadURLOK { - return &ImportServiceGenerateUploadURLOK{} -} - -/* -ImportServiceGenerateUploadURLOK describes a response with status code 200, with default header values. - -A successful response. -*/ -type ImportServiceGenerateUploadURLOK struct { - Payload *models.V1beta1GenerateUploadURLResponse -} - -// IsSuccess returns true when this import service generate upload Url o k response has a 2xx status code -func (o *ImportServiceGenerateUploadURLOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this import service generate upload Url o k response has a 3xx status code -func (o *ImportServiceGenerateUploadURLOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this import service generate upload Url o k response has a 4xx status code -func (o *ImportServiceGenerateUploadURLOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this import service generate upload Url o k response has a 5xx status code -func (o *ImportServiceGenerateUploadURLOK) IsServerError() bool { - return false -} - -// IsCode returns true when this import service generate upload Url o k response a status code equal to that given -func (o *ImportServiceGenerateUploadURLOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the import service generate upload Url o k response -func (o *ImportServiceGenerateUploadURLOK) Code() int { - return 200 -} - -func (o *ImportServiceGenerateUploadURLOK) Error() string { - return fmt.Sprintf("[GET /v1beta1/clusters/{clusterId}/upload_url][%d] importServiceGenerateUploadUrlOK %+v", 200, o.Payload) -} - -func (o *ImportServiceGenerateUploadURLOK) String() string { - return fmt.Sprintf("[GET /v1beta1/clusters/{clusterId}/upload_url][%d] importServiceGenerateUploadUrlOK %+v", 200, o.Payload) -} - -func (o *ImportServiceGenerateUploadURLOK) GetPayload() *models.V1beta1GenerateUploadURLResponse { - return o.Payload -} - -func (o *ImportServiceGenerateUploadURLOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.V1beta1GenerateUploadURLResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewImportServiceGenerateUploadURLDefault creates a ImportServiceGenerateUploadURLDefault with default headers values -func NewImportServiceGenerateUploadURLDefault(code int) *ImportServiceGenerateUploadURLDefault { - return &ImportServiceGenerateUploadURLDefault{ - _statusCode: code, - } -} - -/* -ImportServiceGenerateUploadURLDefault describes a response with status code -1, with default header values. - -An unexpected error response. -*/ -type ImportServiceGenerateUploadURLDefault struct { - _statusCode int - - Payload *models.RPCStatus -} - -// IsSuccess returns true when this import service generate upload Url default response has a 2xx status code -func (o *ImportServiceGenerateUploadURLDefault) IsSuccess() bool { - return o._statusCode/100 == 2 -} - -// IsRedirect returns true when this import service generate upload Url default response has a 3xx status code -func (o *ImportServiceGenerateUploadURLDefault) IsRedirect() bool { - return o._statusCode/100 == 3 -} - -// IsClientError returns true when this import service generate upload Url default response has a 4xx status code -func (o *ImportServiceGenerateUploadURLDefault) IsClientError() bool { - return o._statusCode/100 == 4 -} - -// IsServerError returns true when this import service generate upload Url default response has a 5xx status code -func (o *ImportServiceGenerateUploadURLDefault) IsServerError() bool { - return o._statusCode/100 == 5 -} - -// IsCode returns true when this import service generate upload Url default response a status code equal to that given -func (o *ImportServiceGenerateUploadURLDefault) IsCode(code int) bool { - return o._statusCode == code -} - -// Code gets the status code for the import service generate upload Url default response -func (o *ImportServiceGenerateUploadURLDefault) Code() int { - return o._statusCode -} - -func (o *ImportServiceGenerateUploadURLDefault) Error() string { - return fmt.Sprintf("[GET /v1beta1/clusters/{clusterId}/upload_url][%d] ImportService_GenerateUploadUrl default %+v", o._statusCode, o.Payload) -} - -func (o *ImportServiceGenerateUploadURLDefault) String() string { - return fmt.Sprintf("[GET /v1beta1/clusters/{clusterId}/upload_url][%d] ImportService_GenerateUploadUrl default %+v", o._statusCode, o.Payload) -} - -func (o *ImportServiceGenerateUploadURLDefault) GetPayload() *models.RPCStatus { - return o.Payload -} - -func (o *ImportServiceGenerateUploadURLDefault) 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/serverless_br/client/tidbcloud_serverless_client.go b/pkg/tidbcloud/v1beta1/serverless_br/client/tidbcloud_serverless_client.go deleted file mode 100644 index e57e0aa9..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/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/serverless_br/client/backup_restore_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.BackupRestoreService = backup_restore_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 { - BackupRestoreService backup_restore_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.BackupRestoreService.SetTransport(transport) -} diff --git a/pkg/tidbcloud/v1beta1/serverless_br/models/protobuf_any.go b/pkg/tidbcloud/v1beta1/serverless_br/models/protobuf_any.go deleted file mode 100644 index f25b51ed..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/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/serverless_br/models/restore_request_point_in_time.go b/pkg/tidbcloud/v1beta1/serverless_br/models/restore_request_point_in_time.go deleted file mode 100644 index b2b2ec55..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/models/restore_request_point_in_time.go +++ /dev/null @@ -1,77 +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" -) - -// RestoreRequestPointInTime restore request point in time -// -// swagger:model RestoreRequestPointInTime -type RestoreRequestPointInTime struct { - - // backup time - // Format: date-time - BackupTime strfmt.DateTime `json:"backupTime,omitempty"` - - // cluster Id - ClusterID string `json:"clusterId,omitempty"` -} - -// Validate validates this restore request point in time -func (m *RestoreRequestPointInTime) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateBackupTime(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *RestoreRequestPointInTime) validateBackupTime(formats strfmt.Registry) error { - if swag.IsZero(m.BackupTime) { // not required - return nil - } - - if err := validate.FormatOf("backupTime", "body", "date-time", m.BackupTime.String(), formats); err != nil { - return err - } - - return nil -} - -// ContextValidate validates this restore request point in time based on context it is used -func (m *RestoreRequestPointInTime) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *RestoreRequestPointInTime) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *RestoreRequestPointInTime) UnmarshalBinary(b []byte) error { - var res RestoreRequestPointInTime - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless_br/models/restore_request_snapshot.go b/pkg/tidbcloud/v1beta1/serverless_br/models/restore_request_snapshot.go deleted file mode 100644 index db4b1745..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/models/restore_request_snapshot.go +++ /dev/null @@ -1,50 +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/strfmt" - "github.com/go-openapi/swag" -) - -// RestoreRequestSnapshot restore request snapshot -// -// swagger:model RestoreRequestSnapshot -type RestoreRequestSnapshot struct { - - // backup Id - BackupID string `json:"backupId,omitempty"` -} - -// Validate validates this restore request snapshot -func (m *RestoreRequestSnapshot) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this restore request snapshot based on context it is used -func (m *RestoreRequestSnapshot) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *RestoreRequestSnapshot) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *RestoreRequestSnapshot) UnmarshalBinary(b []byte) error { - var res RestoreRequestSnapshot - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless_br/models/rpc_status.go b/pkg/tidbcloud/v1beta1/serverless_br/models/rpc_status.go deleted file mode 100644 index 922eaa86..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/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/serverless_br/models/v1beta1_backup.go b/pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_backup.go deleted file mode 100644 index f4ed53d4..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_backup.go +++ /dev/null @@ -1,144 +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" -) - -// V1beta1Backup Message for backup resource. -// -// swagger:model v1beta1Backup -type V1beta1Backup struct { - - // Output_only. The unique ID of the backup. - // Read Only: true - BackupID string `json:"backupId,omitempty"` - - // Required. The cluster ID that backup belong to. - // Required: true - ClusterID *string `json:"clusterId"` - - // Output_only. Timestamp when the backup was created. - // Read Only: true - // Format: date-time - CreateTime strfmt.DateTime `json:"createTime,omitempty"` - - // Output_only. The unique name of the backup. - // Read Only: true - Name string `json:"name,omitempty"` -} - -// Validate validates this v1beta1 backup -func (m *V1beta1Backup) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateClusterID(formats); err != nil { - res = append(res, err) - } - - if err := m.validateCreateTime(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *V1beta1Backup) validateClusterID(formats strfmt.Registry) error { - - if err := validate.Required("clusterId", "body", m.ClusterID); err != nil { - return err - } - - return nil -} - -func (m *V1beta1Backup) 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 -} - -// ContextValidate validate this v1beta1 backup based on the context it is used -func (m *V1beta1Backup) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateBackupID(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateCreateTime(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateName(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *V1beta1Backup) contextValidateBackupID(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "backupId", "body", string(m.BackupID)); err != nil { - return err - } - - return nil -} - -func (m *V1beta1Backup) 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 *V1beta1Backup) contextValidateName(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "name", "body", string(m.Name)); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *V1beta1Backup) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *V1beta1Backup) UnmarshalBinary(b []byte) error { - var res V1beta1Backup - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_generate_upload_url_response.go b/pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_generate_upload_url_response.go deleted file mode 100644 index b76462ce..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_generate_upload_url_response.go +++ /dev/null @@ -1,53 +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/strfmt" - "github.com/go-openapi/swag" -) - -// V1beta1GenerateUploadURLResponse v1beta1 generate upload Url response -// -// swagger:model v1beta1GenerateUploadUrlResponse -type V1beta1GenerateUploadURLResponse struct { - - // The ID of the upload - UploadID string `json:"uploadId,omitempty"` - - // The URL to upload the file to - UploadURL []string `json:"uploadUrl"` -} - -// Validate validates this v1beta1 generate upload Url response -func (m *V1beta1GenerateUploadURLResponse) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this v1beta1 generate upload Url response based on context it is used -func (m *V1beta1GenerateUploadURLResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *V1beta1GenerateUploadURLResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *V1beta1GenerateUploadURLResponse) UnmarshalBinary(b []byte) error { - var res V1beta1GenerateUploadURLResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_list_backups_response.go b/pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_list_backups_response.go deleted file mode 100644 index 354b5981..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_list_backups_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" -) - -// V1beta1ListBackupsResponse v1beta1 list backups response -// -// swagger:model v1beta1ListBackupsResponse -type V1beta1ListBackupsResponse struct { - - // A list of clusters. - Backups []*V1beta1Backup `json:"backups"` - - // Token provided to retrieve the next page of results. - NextPageToken string `json:"nextPageToken,omitempty"` - - // Total number of backups. - TotalSize int64 `json:"totalSize,omitempty"` -} - -// Validate validates this v1beta1 list backups response -func (m *V1beta1ListBackupsResponse) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateBackups(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *V1beta1ListBackupsResponse) validateBackups(formats strfmt.Registry) error { - if swag.IsZero(m.Backups) { // not required - return nil - } - - for i := 0; i < len(m.Backups); i++ { - if swag.IsZero(m.Backups[i]) { // not required - continue - } - - if m.Backups[i] != nil { - if err := m.Backups[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("backups" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("backups" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// ContextValidate validate this v1beta1 list backups response based on the context it is used -func (m *V1beta1ListBackupsResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateBackups(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *V1beta1ListBackupsResponse) contextValidateBackups(ctx context.Context, formats strfmt.Registry) error { - - for i := 0; i < len(m.Backups); i++ { - - if m.Backups[i] != nil { - - if swag.IsZero(m.Backups[i]) { // not required - return nil - } - - if err := m.Backups[i].ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("backups" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("backups" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// MarshalBinary interface implementation -func (m *V1beta1ListBackupsResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *V1beta1ListBackupsResponse) UnmarshalBinary(b []byte) error { - var res V1beta1ListBackupsResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_restore_request.go b/pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_restore_request.go deleted file mode 100644 index f2e8026a..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_restore_request.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" -) - -// V1beta1RestoreRequest v1beta1 restore request -// -// swagger:model v1beta1RestoreRequest -type V1beta1RestoreRequest struct { - - // point in time - PointInTime *RestoreRequestPointInTime `json:"pointInTime,omitempty"` - - // snapshot - Snapshot *RestoreRequestSnapshot `json:"snapshot,omitempty"` -} - -// Validate validates this v1beta1 restore request -func (m *V1beta1RestoreRequest) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validatePointInTime(formats); err != nil { - res = append(res, err) - } - - if err := m.validateSnapshot(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *V1beta1RestoreRequest) validatePointInTime(formats strfmt.Registry) error { - if swag.IsZero(m.PointInTime) { // not required - return nil - } - - if m.PointInTime != nil { - if err := m.PointInTime.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("pointInTime") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("pointInTime") - } - return err - } - } - - return nil -} - -func (m *V1beta1RestoreRequest) validateSnapshot(formats strfmt.Registry) error { - if swag.IsZero(m.Snapshot) { // not required - return nil - } - - if m.Snapshot != nil { - if err := m.Snapshot.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("snapshot") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("snapshot") - } - return err - } - } - - return nil -} - -// ContextValidate validate this v1beta1 restore request based on the context it is used -func (m *V1beta1RestoreRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidatePointInTime(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateSnapshot(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *V1beta1RestoreRequest) contextValidatePointInTime(ctx context.Context, formats strfmt.Registry) error { - - if m.PointInTime != nil { - - if swag.IsZero(m.PointInTime) { // not required - return nil - } - - if err := m.PointInTime.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("pointInTime") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("pointInTime") - } - return err - } - } - - return nil -} - -func (m *V1beta1RestoreRequest) contextValidateSnapshot(ctx context.Context, formats strfmt.Registry) error { - - if m.Snapshot != nil { - - if swag.IsZero(m.Snapshot) { // not required - return nil - } - - if err := m.Snapshot.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("snapshot") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("snapshot") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (m *V1beta1RestoreRequest) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *V1beta1RestoreRequest) UnmarshalBinary(b []byte) error { - var res V1beta1RestoreRequest - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_restore_response.go b/pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_restore_response.go deleted file mode 100644 index c2e63ff1..00000000 --- a/pkg/tidbcloud/v1beta1/serverless_br/models/v1beta1_restore_response.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" -) - -// V1beta1RestoreResponse v1beta1 restore response -// -// swagger:model v1beta1RestoreResponse -type V1beta1RestoreResponse struct { - - // cluster Id - // Required: true - ClusterID *string `json:"clusterId"` -} - -// Validate validates this v1beta1 restore response -func (m *V1beta1RestoreResponse) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateClusterID(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *V1beta1RestoreResponse) validateClusterID(formats strfmt.Registry) error { - - if err := validate.Required("clusterId", "body", m.ClusterID); err != nil { - return err - } - - return nil -} - -// ContextValidate validates this v1beta1 restore response based on context it is used -func (m *V1beta1RestoreResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *V1beta1RestoreResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *V1beta1RestoreResponse) UnmarshalBinary(b []byte) error { - var res V1beta1RestoreResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -}