From d7181c9c3987d291c2beec3a600da6fce3882889 Mon Sep 17 00:00:00 2001 From: shiyuhang <1136742008@qq.com> Date: Wed, 4 Feb 2026 16:43:16 +0800 Subject: [PATCH 1/9] first version --- .../create-ticloud-cli-command/LICENSE.txt | 177 +++++++++++++++ .../create-ticloud-cli-command/SKILL.md | 127 +++++++++++ .../assets/command.md | 19 ++ .../assets/empty.go | 25 +++ .../assets/example/create.go | 162 ++++++++++++++ .../assets/example/create_test.go | 15 ++ .../assets/example/delete.go | 158 ++++++++++++++ .../assets/example/delete_test.go | 15 ++ .../assets/example/descibe_test.go | 15 ++ .../assets/example/describe.go | 139 ++++++++++++ .../assets/example/example.go | 37 ++++ .../assets/example/list.go | 153 +++++++++++++ .../assets/example/list_test.go | 15 ++ .../assets/example/ui.go | 131 +++++++++++ .../references/bubbletea.md | 205 ++++++++++++++++++ .../references/cobra.md | 66 ++++++ .../references/flag.md | 185 ++++++++++++++++ .../references/sdk.md | 18 ++ .../references/tidbcloud-cli.md | 63 ++++++ .../references/ui.md | 53 +++++ .../references/ut.md | 16 ++ .../update-ticloud-cli-command/LICENSE.txt | 177 +++++++++++++++ .../update-ticloud-cli-command/SKILL.md | 73 +++++++ .../references/bubbletea.md | 205 ++++++++++++++++++ .../references/cobra.md | 66 ++++++ .../references/flag.md | 185 ++++++++++++++++ .../references/sdk.md | 18 ++ .../references/tidbcloud-cli.md | 63 ++++++ .../references/ui.md | 53 +++++ .../references/ut.md | 16 ++ internal/flag/flag.go | 1 + internal/ui/text_one_input_model.go | 91 ++++++++ 32 files changed, 2742 insertions(+) create mode 100644 .cursor/skills/create-ticloud-cli-command/LICENSE.txt create mode 100644 .cursor/skills/create-ticloud-cli-command/SKILL.md create mode 100644 .cursor/skills/create-ticloud-cli-command/assets/command.md create mode 100644 .cursor/skills/create-ticloud-cli-command/assets/empty.go create mode 100644 .cursor/skills/create-ticloud-cli-command/assets/example/create.go create mode 100644 .cursor/skills/create-ticloud-cli-command/assets/example/create_test.go create mode 100644 .cursor/skills/create-ticloud-cli-command/assets/example/delete.go create mode 100644 .cursor/skills/create-ticloud-cli-command/assets/example/delete_test.go create mode 100644 .cursor/skills/create-ticloud-cli-command/assets/example/descibe_test.go create mode 100644 .cursor/skills/create-ticloud-cli-command/assets/example/describe.go create mode 100644 .cursor/skills/create-ticloud-cli-command/assets/example/example.go create mode 100644 .cursor/skills/create-ticloud-cli-command/assets/example/list.go create mode 100644 .cursor/skills/create-ticloud-cli-command/assets/example/list_test.go create mode 100644 .cursor/skills/create-ticloud-cli-command/assets/example/ui.go create mode 100644 .cursor/skills/create-ticloud-cli-command/references/bubbletea.md create mode 100644 .cursor/skills/create-ticloud-cli-command/references/cobra.md create mode 100644 .cursor/skills/create-ticloud-cli-command/references/flag.md create mode 100644 .cursor/skills/create-ticloud-cli-command/references/sdk.md create mode 100644 .cursor/skills/create-ticloud-cli-command/references/tidbcloud-cli.md create mode 100644 .cursor/skills/create-ticloud-cli-command/references/ui.md create mode 100644 .cursor/skills/create-ticloud-cli-command/references/ut.md create mode 100644 .cursor/skills/update-ticloud-cli-command/LICENSE.txt create mode 100644 .cursor/skills/update-ticloud-cli-command/SKILL.md create mode 100644 .cursor/skills/update-ticloud-cli-command/references/bubbletea.md create mode 100644 .cursor/skills/update-ticloud-cli-command/references/cobra.md create mode 100644 .cursor/skills/update-ticloud-cli-command/references/flag.md create mode 100644 .cursor/skills/update-ticloud-cli-command/references/sdk.md create mode 100644 .cursor/skills/update-ticloud-cli-command/references/tidbcloud-cli.md create mode 100644 .cursor/skills/update-ticloud-cli-command/references/ui.md create mode 100644 .cursor/skills/update-ticloud-cli-command/references/ut.md create mode 100644 internal/ui/text_one_input_model.go diff --git a/.cursor/skills/create-ticloud-cli-command/LICENSE.txt b/.cursor/skills/create-ticloud-cli-command/LICENSE.txt new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/LICENSE.txt @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/.cursor/skills/create-ticloud-cli-command/SKILL.md b/.cursor/skills/create-ticloud-cli-command/SKILL.md new file mode 100644 index 00000000..cd1b5309 --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/SKILL.md @@ -0,0 +1,127 @@ +--- +name: create-ticloud-cli-command +description: Builds TiDB Cloud CLI commands. Use when creating new commands. +license: Complete terms in LICENSE.txt +metadata: + author: shiyuhang0 +--- + +# Create TiCloud CLI Command + +This skill builds TiDB Cloud CLI commands, helping users create new commands with production-ready code. + +## When to use + +- The user asks to create new CLI commands or subcommands. +- Do not use when the agent does not support plan mode. + +## About TiDB Cloud CLI + +TiDB Cloud CLI (TiCloud CLI) is a command-line interface for interacting with TiDB Cloud, built on the Cobra library. + +Key design of TiDB Cloud CLI: +- Built on the Cobra library. +- Uses the TiDB Cloud Open API as the client and keeps the SDK inside the project. +- Every command supports both interactive and non-interactive modes. + +- More about TiDB Cloud CLI: `references/tidbcloud-cli.md`. +- More about Cobra: `references/cobra.md`. + +## Core Principles + +### Plan first + +The AI agent must switch to plan mode to collect information from the user and generate a plan first. + +Then use agent mode to generate the code. + +### Test first + +If the user requires testing, testing takes precedence over implementation. Write tests first, then implement, and finally validate against the tests. + +### Declarative + +The user must declare the command format; the implementation must comply with that declared format. + +## Workflow + +Must follow the workflow below: + +### Generate SDK phase + +Detect whether there are new or modified Swagger files under `/pkg/tidbcloud`. Skip this phase if none are found. + +If detection fails, prompt the user: "Do you need to update swagger and generate SDK?" Skip this phase if the user does not need it. + +Once in this phase, follow the guide in `references/sdk.md` to generate the SDK. + +### Plan phase + +The agent must switch to plan mode in this phase. + +The agent must ask the user for the following information during the plan phase: +1. **Command format**: If the user does not provide the command format, ask them to provide it first. See `assets/command.md` for the command format template. +2. **Tests**: Ask whether the user needs tests. Tests are recommended. +3. **Other necessary information** + +Generate the plan after the user confirms all the information. + +### Agent phase + +The agent must switch to agent mode in this phase. Follow the workflow below: + +1. **Write unit tests** +2. **Implement command** +3. **Run tests** + +#### Write unit tests + +Skip this step if the user does not need tests. + +Write unit tests following `references/ut.md`. If the tests need to invoke the command, create the empty command first. See `assets/empty.go`. + +#### Implement command + +Implement the command following the patterns in `assets/example`. + +The implementation must meet the following requirements: + +1. **Command definition**: Include name, aliases, example, and other necessary attributes. + +2. **Flags definition**: Include flag type, description, default value, etc. Infer flag information from the Swagger spec and SDK client parameters. See `references/flag.md` for more details. + +3. **Flags retrieval**: Implement retrieval logic for both interactive and non-interactive modes. For interactive mode, UI is required. The UI is based on the Bubbletea library. See `references/ui.md` for more details. + +4. **Dual mode support**: Support both interactive and non-interactive modes. Rules: + 1. **Detect mode** with `MarkInteractive`: + - Default to interactive. + - If any non-interactive flag is provided, switch to non-interactive and mark required flags. + 2. **Interactive constraints**: + - If `!h.IOStreams.CanPrompt`, return an error instructing the user to use non-interactive flags. + +5. **SDK calls**: Use the SDK client in `api_client.go` to call the corresponding method. Note that `assets/example` does not include this part (it is only a template); it must be included when implementing the actual command. + +#### Run the tests + +Skip this step if the user does not need tests. + +Run tests with: `go test -race -cover -count=1 path -v` + +For example, to run tests under `internal/cli/serverless/branch`: `go test -race -cover -count=1 ./internal/cli/serverless/branch -v` + +Ensure all tests pass. If they do not pass, fix the implementation or the tests. + +## Final Code Structure + +The final code structure must follow the structure in `assets/example`: + +- Command Go files. +- UI Go files. +- Test files if needed. + +Command output should follow the patterns in `assets/example`: + +- **Human output**: Print a concise, user-friendly message; use `color.GreenString` for success. Avoid raw JSON in human mode. +- **JSON output**: Use `output.PrintJson` with a stable, predictable payload (e.g. keys like `message`, resource IDs, `items`). +- **No TTY**: Default to JSON output for list/describe-style commands (see `assets/example/list.go`). +- **Examples**: Include `Example` blocks for both interactive and non-interactive usage (see `assets/example/create.go` and `assets/example/list.go`). \ No newline at end of file diff --git a/.cursor/skills/create-ticloud-cli-command/assets/command.md b/.cursor/skills/create-ticloud-cli-command/assets/command.md new file mode 100644 index 00000000..437b28ef --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/assets/command.md @@ -0,0 +1,19 @@ +# Command format + +This document describes the command format users need to provide. The following uses the example resource: + +``` +example create: ticloud serverless example create -c --displayname +example get: ticloud serverless example get -c --example-id +example list: ticloud serverless example list -c --output +example delete: ticloud serverless example delete -c --example-id --force +``` + +Flags can be omitted and inferred from the TiDB Cloud SDK. The following are also accepted: + +``` +ticloud serverless example create +ticloud serverless example get +ticloud serverless example list +ticloud serverless example delete +``` \ No newline at end of file diff --git a/.cursor/skills/create-ticloud-cli-command/assets/empty.go b/.cursor/skills/create-ticloud-cli-command/assets/empty.go new file mode 100644 index 00000000..b1ea855e --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/assets/empty.go @@ -0,0 +1,25 @@ +// Copyright 2026 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 example + +import ( + "github.com/spf13/cobra" + + "github.com/tidbcloud/tidbcloud-cli/internal" +) + +func CreateCmd(h *internal.Helper) *cobra.Command { + return nil +} diff --git a/.cursor/skills/create-ticloud-cli-command/assets/example/create.go b/.cursor/skills/create-ticloud-cli-command/assets/example/create.go new file mode 100644 index 00000000..6b482f51 --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/assets/example/create.go @@ -0,0 +1,162 @@ +// Copyright 2026 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 example + +import ( + "fmt" + + "github.com/fatih/color" + "github.com/juju/errors" + "github.com/spf13/cobra" + + "github.com/tidbcloud/tidbcloud-cli/internal" + "github.com/tidbcloud/tidbcloud-cli/internal/config" + "github.com/tidbcloud/tidbcloud-cli/internal/flag" + "github.com/tidbcloud/tidbcloud-cli/internal/service/cloud" +) + +type CreateOpts struct { + interactive bool +} + +func (o CreateOpts) NonInteractiveFlags() []string { + return []string{ + flag.ClusterID, + flag.DisplayName, + } +} + +func (o CreateOpts) RequiredFlags() []string { + return []string{ + flag.ClusterID, + flag.DisplayName, + } +} + +func (o *CreateOpts) MarkInteractive(cmd *cobra.Command) error { + o.interactive = true + for _, fn := range o.NonInteractiveFlags() { + if f := cmd.Flags().Lookup(fn); f != nil && f.Changed { + o.interactive = false + } + } + if !o.interactive { + for _, fn := range o.RequiredFlags() { + if err := cmd.MarkFlagRequired(fn); err != nil { + return err + } + } + } + return nil +} + +func CreateCmd(h *internal.Helper) *cobra.Command { + opts := &CreateOpts{interactive: true} + + cmd := &cobra.Command{ + Use: "create", + Short: "Create an example resource", + Args: cobra.NoArgs, + Example: fmt.Sprintf(` Create an example resource (interactive): + $ %[1]s serverless example create + + Create an example resource (non-interactive): + $ %[1]s serverless example create -c --display-name + + Create with multi-line input flags (non-interactive): + $ %[1]s serverless example create -c --display-name \ + --s3.uri \ + --s3.access-key-id \ + --s3.secret-access-key `, config.CliName), + PreRunE: func(cmd *cobra.Command, args []string) error { + return opts.MarkInteractive(cmd) + }, + RunE: func(cmd *cobra.Command, args []string) error { + ctx := cmd.Context() + d, err := h.Client() + if err != nil { + return err + } + var clusterID, displayName string + var s3URI, s3AccessKeyID, s3SecretAccessKey string + if opts.interactive { + if !h.IOStreams.CanPrompt { + return errors.New("The terminal doesn't support interactive mode, please use non-interactive mode") + } + project, err := cloud.GetSelectedProject(ctx, h.QueryPageSize, d) + if err != nil { + return err + } + cluster, err := cloud.GetSelectedCluster(ctx, project.ID, h.QueryPageSize, d) + if err != nil { + return err + } + clusterID = cluster.ID + + displayName, err = GetDisplayNameInput() + if err != nil { + return err + } + + s3URI, s3AccessKeyID, s3SecretAccessKey, err = GetS3Inputs() + if err != nil { + return err + } + } else { + var err error + clusterID, err = cmd.Flags().GetString(flag.ClusterID) + if err != nil { + return errors.Trace(err) + } + displayName, err = cmd.Flags().GetString(flag.DisplayName) + if err != nil { + return errors.Trace(err) + } + s3URI, err = cmd.Flags().GetString(flag.S3URI) + if err != nil { + return errors.Trace(err) + } + s3AccessKeyID, err = cmd.Flags().GetString(flag.S3AccessKeyID) + if err != nil { + return errors.Trace(err) + } + s3SecretAccessKey, err = cmd.Flags().GetString(flag.S3SecretAccessKey) + if err != nil { + return errors.Trace(err) + } + } + + if clusterID == "" { + return errors.New("cluster id is required") + } + if displayName == "" { + return errors.New("display name is required") + } + + // TODO implement the create logic + _, err = fmt.Fprintln(h.IOStreams.Out, color.GreenString("example %s created", "example-id")) + if err != nil { + return err + } + }, + } + + cmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The cluster ID.") + cmd.Flags().StringP(flag.DisplayName, flag.DisplayNameShort, "", "Display name for the example resource.") + cmd.Flags().String(flag.S3URI, "", "The S3 URI.") + cmd.Flags().String(flag.S3AccessKeyID, "", "The S3 access key ID.") + cmd.Flags().String(flag.S3SecretAccessKey, "", "The S3 secret access key.") + return cmd +} diff --git a/.cursor/skills/create-ticloud-cli-command/assets/example/create_test.go b/.cursor/skills/create-ticloud-cli-command/assets/example/create_test.go new file mode 100644 index 00000000..3bccf7ff --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/assets/example/create_test.go @@ -0,0 +1,15 @@ +// Copyright 2026 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 example diff --git a/.cursor/skills/create-ticloud-cli-command/assets/example/delete.go b/.cursor/skills/create-ticloud-cli-command/assets/example/delete.go new file mode 100644 index 00000000..4af3135b --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/assets/example/delete.go @@ -0,0 +1,158 @@ +// Copyright 2026 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 example + +import ( + "fmt" + + "github.com/AlecAivazis/survey/v2" + "github.com/fatih/color" + "github.com/juju/errors" + "github.com/spf13/cobra" + + "github.com/tidbcloud/tidbcloud-cli/internal" + "github.com/tidbcloud/tidbcloud-cli/internal/config" + "github.com/tidbcloud/tidbcloud-cli/internal/flag" + "github.com/tidbcloud/tidbcloud-cli/internal/service/cloud" +) + +type DeleteOpts struct { + interactive bool +} + +func (o DeleteOpts) NonInteractiveFlags() []string { + return []string{ + flag.ClusterID, + flag.ExampleID, + flag.Force, + } +} + +func (o DeleteOpts) RequiredFlags() []string { + return []string{ + flag.ClusterID, + flag.DisplayName, + } +} + +func (o *DeleteOpts) MarkInteractive(cmd *cobra.Command) error { + o.interactive = true + for _, fn := range o.NonInteractiveFlags() { + if f := cmd.Flags().Lookup(fn); f != nil && f.Changed { + o.interactive = false + } + } + if !o.interactive { + for _, fn := range o.RequiredFlags() { + if err := cmd.MarkFlagRequired(fn); err != nil { + return err + } + } + } + return nil +} + +func DeleteCmd(h *internal.Helper) *cobra.Command { + opts := &DeleteOpts{interactive: true} + var force bool + + cmd := &cobra.Command{ + Use: "delete", + Aliases: []string{"rm"}, + Short: "Delete an example resource", + Args: cobra.NoArgs, + Example: fmt.Sprintf(` Delete an example resource (interactive): + $ %[1]s serverless example delete + + Delete an example resource (non-interactive): + $ %[1]s serverless example delete -c --example-id `, config.CliName), + PreRunE: func(cmd *cobra.Command, args []string) error { + return opts.MarkInteractive(cmd) + }, + RunE: func(cmd *cobra.Command, args []string) error { + ctx := cmd.Context() + d, err := h.Client() + if err != nil { + return err + } + var clusterID, exampleID string + if opts.interactive { + if !h.IOStreams.CanPrompt { + return errors.New("The terminal doesn't support interactive mode, please use non-interactive mode") + } + project, err := cloud.GetSelectedProject(ctx, h.QueryPageSize, d) + if err != nil { + return err + } + cluster, err := cloud.GetSelectedCluster(ctx, project.ID, h.QueryPageSize, d) + if err != nil { + return err + } + clusterID = cluster.ID + + example, err := GetSelectedExample(ctx, clusterID, h.QueryPageSize, d) + if err != nil { + return err + } + exampleID = example.ID + } else { + var err error + clusterID, err = cmd.Flags().GetString(flag.ClusterID) + if err != nil { + return errors.Trace(err) + } + exampleID, err = cmd.Flags().GetString(flag.ExampleID) + if err != nil { + return errors.Trace(err) + } + force, err = cmd.Flags().GetBool(flag.Force) + if err != nil { + return errors.Trace(err) + } + } + + if clusterID == "" { + return errors.New("cluster id is required") + } + if exampleID == "" { + return errors.New("example id is required") + } + + if !force { + if !h.IOStreams.CanPrompt { + return errors.New("The terminal doesn't support prompt, run with --force to skip confirmation") + } + var confirm string + if err := survey.AskOne(&survey.Input{Message: DeleteConfirmPrompt}, &confirm); err != nil { + return err + } + if confirm != "yes" { + return errors.New("deletion cancelled") + } + } + + // TODO implement the create logic + _, err = fmt.Fprintln(h.IOStreams.Out, color.GreenString("example %s deleted", "example-id")) + if err != nil { + return err + } + }, + } + + cmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The cluster ID.") + cmd.Flags().String(flag.ExampleID, "", "The example ID.") + cmd.Flags().BoolVar(&force, flag.Force, false, "Delete without confirmation.") + return cmd +} diff --git a/.cursor/skills/create-ticloud-cli-command/assets/example/delete_test.go b/.cursor/skills/create-ticloud-cli-command/assets/example/delete_test.go new file mode 100644 index 00000000..3bccf7ff --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/assets/example/delete_test.go @@ -0,0 +1,15 @@ +// Copyright 2026 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 example diff --git a/.cursor/skills/create-ticloud-cli-command/assets/example/descibe_test.go b/.cursor/skills/create-ticloud-cli-command/assets/example/descibe_test.go new file mode 100644 index 00000000..3bccf7ff --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/assets/example/descibe_test.go @@ -0,0 +1,15 @@ +// Copyright 2026 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 example diff --git a/.cursor/skills/create-ticloud-cli-command/assets/example/describe.go b/.cursor/skills/create-ticloud-cli-command/assets/example/describe.go new file mode 100644 index 00000000..44815198 --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/assets/example/describe.go @@ -0,0 +1,139 @@ +// Copyright 2026 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 example + +import ( + "fmt" + + "github.com/juju/errors" + "github.com/spf13/cobra" + + "github.com/tidbcloud/tidbcloud-cli/internal" + "github.com/tidbcloud/tidbcloud-cli/internal/config" + "github.com/tidbcloud/tidbcloud-cli/internal/flag" + "github.com/tidbcloud/tidbcloud-cli/internal/output" + "github.com/tidbcloud/tidbcloud-cli/internal/service/cloud" +) + +type DescribeOpts struct { + interactive bool +} + +func (o DescribeOpts) NonInteractiveFlags() []string { + return []string{ + flag.ClusterID, + flag.ExampleID, + } +} + +func (o DescribeOpts) RequiredFlags() []string { + return []string{ + flag.ClusterID, + flag.ExampleID, + } +} + +func (o *DescribeOpts) MarkInteractive(cmd *cobra.Command) error { + o.interactive = true + for _, fn := range o.NonInteractiveFlags() { + if f := cmd.Flags().Lookup(fn); f != nil && f.Changed { + o.interactive = false + } + } + if !o.interactive { + for _, fn := range o.RequiredFlags() { + if err := cmd.MarkFlagRequired(fn); err != nil { + return err + } + } + } + return nil +} + +func DescribeCmd(h *internal.Helper) *cobra.Command { + opts := &DescribeOpts{interactive: true} + + cmd := &cobra.Command{ + Use: "describe", + Aliases: []string{"get"}, + Short: "Describe an example resource", + Args: cobra.NoArgs, + Example: fmt.Sprintf(` Describe an example resource (interactive): + $ %[1]s serverless example describe + + Describe an example resource (non-interactive): + $ %[1]s serverless example describe -c --example-id `, config.CliName), + PreRunE: func(cmd *cobra.Command, args []string) error { + return opts.MarkInteractive(cmd) + }, + RunE: func(cmd *cobra.Command, args []string) error { + ctx := cmd.Context() + d, err := h.Client() + if err != nil { + return err + } + var clusterID, exampleID string + if opts.interactive { + if !h.IOStreams.CanPrompt { + return errors.New("The terminal doesn't support interactive mode, please use non-interactive mode") + } + project, err := cloud.GetSelectedProject(ctx, h.QueryPageSize, d) + if err != nil { + return err + } + cluster, err := cloud.GetSelectedCluster(ctx, project.ID, h.QueryPageSize, d) + if err != nil { + return err + } + clusterID = cluster.ID + + example, err := GetSelectedExample(ctx, clusterID, h.QueryPageSize, d) + if err != nil { + return err + } + exampleID = example.ID + } else { + var err error + clusterID, err = cmd.Flags().GetString(flag.ClusterID) + if err != nil { + return errors.Trace(err) + } + exampleID, err = cmd.Flags().GetString(flag.ExampleID) + if err != nil { + return errors.Trace(err) + } + } + + if clusterID == "" { + return errors.New("cluster id is required") + } + if exampleID == "" { + return errors.New("example id is required") + } + + // TODO implement the get logic, now just mock the payload + payload := map[string]string{ + "message": UnwiredFeaturePrompt, + "cluster_id": clusterID, + "example_id": exampleID, + } + return output.PrintJson(h.IOStreams.Out, payload) + }, + } + + cmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The cluster ID.") + cmd.Flags().String(flag.ExampleID, "", "The example ID.") + return cmd +} diff --git a/.cursor/skills/create-ticloud-cli-command/assets/example/example.go b/.cursor/skills/create-ticloud-cli-command/assets/example/example.go new file mode 100644 index 00000000..b3b804cc --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/assets/example/example.go @@ -0,0 +1,37 @@ +// Copyright 2026 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 example + +import ( + "github.com/spf13/cobra" + + "github.com/tidbcloud/tidbcloud-cli/internal" +) + +func ExampleCmd(h *internal.Helper) *cobra.Command { + cmd := &cobra.Command{ + Use: "example", + Short: "Manage example resources", + } + + cmd.AddCommand( + CreateCmd(h), + DescribeCmd(h), + DeleteCmd(h), + ListCmd(h), + ) + + return cmd +} diff --git a/.cursor/skills/create-ticloud-cli-command/assets/example/list.go b/.cursor/skills/create-ticloud-cli-command/assets/example/list.go new file mode 100644 index 00000000..8f525711 --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/assets/example/list.go @@ -0,0 +1,153 @@ +// Copyright 2026 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 example + +import ( + "fmt" + + "github.com/fatih/color" + "github.com/juju/errors" + "github.com/spf13/cobra" + + "github.com/tidbcloud/tidbcloud-cli/internal" + "github.com/tidbcloud/tidbcloud-cli/internal/config" + "github.com/tidbcloud/tidbcloud-cli/internal/flag" + "github.com/tidbcloud/tidbcloud-cli/internal/output" + "github.com/tidbcloud/tidbcloud-cli/internal/service/cloud" +) + +type ListOpts struct { + interactive bool +} + +func (o ListOpts) NonInteractiveFlags() []string { + return []string{ + flag.ClusterID, + } +} + +func (o ListOpts) RequiredFlags() []string { + return []string{ + flag.ClusterID, + } +} + +func (o *ListOpts) MarkInteractive(cmd *cobra.Command) error { + o.interactive = true + for _, fn := range o.NonInteractiveFlags() { + if f := cmd.Flags().Lookup(fn); f != nil && f.Changed { + o.interactive = false + } + } + if !o.interactive { + for _, fn := range o.RequiredFlags() { + if err := cmd.MarkFlagRequired(fn); err != nil { + return err + } + } + } + return nil +} + +func ListCmd(h *internal.Helper) *cobra.Command { + opts := &ListOpts{interactive: true} + + cmd := &cobra.Command{ + Use: "list", + Aliases: []string{"ls"}, + Short: "List example resources", + Args: cobra.NoArgs, + Example: fmt.Sprintf(` List example resources (interactive): + $ %[1]s serverless example list + + List example resources (non-interactive): + $ %[1]s serverless example list -c + + List example resources with json format: + $ %[1]s serverless example list -o json`, config.CliName), + PreRunE: func(cmd *cobra.Command, args []string) error { + return opts.MarkInteractive(cmd) + }, + RunE: func(cmd *cobra.Command, args []string) error { + ctx := cmd.Context() + d, err := h.Client() + if err != nil { + return err + } + var clusterID string + if opts.interactive { + if !h.IOStreams.CanPrompt { + return errors.New("The terminal doesn't support interactive mode, please use non-interactive mode") + } + project, err := cloud.GetSelectedProject(ctx, h.QueryPageSize, d) + if err != nil { + return err + } + cluster, err := cloud.GetSelectedCluster(ctx, project.ID, h.QueryPageSize, d) + if err != nil { + return err + } + clusterID = cluster.ID + } else { + var err error + clusterID, err = cmd.Flags().GetString(flag.ClusterID) + if err != nil { + return errors.Trace(err) + } + } + + if clusterID == "" { + return errors.New("cluster id is required") + } + + // TODO implement the list logic, now just mock the payload + payload := map[string]interface{}{ + "message": UnwiredFeaturePrompt, + "cluster_id": clusterID, + "items": []interface{}{}, + } + + format, err := cmd.Flags().GetString(flag.Output) + if err != nil { + return errors.Trace(err) + } + + if format == output.JsonFormat || !h.IOStreams.CanPrompt { + err := output.PrintJson(h.IOStreams.Out, payload) + if err != nil { + return errors.Trace(err) + } + } else if format == output.HumanFormat { + columns := []output.Column{ + // Omit code to define columns + } + var rows []output.Row + // Omit code to generate rows + err := output.PrintHumanTable(h.IOStreams.Out, columns, rows) + if err != nil { + return errors.Trace(err) + } + return nil + } else { + return fmt.Errorf("unsupported output format: %s", format) + } + return nil + }, + } + + cmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The cluster ID.") + cmd.Flags().StringP(flag.Output, flag.OutputShort, output.HumanFormat, flag.OutputHelp) + return cmd +} diff --git a/.cursor/skills/create-ticloud-cli-command/assets/example/list_test.go b/.cursor/skills/create-ticloud-cli-command/assets/example/list_test.go new file mode 100644 index 00000000..3bccf7ff --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/assets/example/list_test.go @@ -0,0 +1,15 @@ +// Copyright 2026 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 example diff --git a/.cursor/skills/create-ticloud-cli-command/assets/example/ui.go b/.cursor/skills/create-ticloud-cli-command/assets/example/ui.go new file mode 100644 index 00000000..058ce70e --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/assets/example/ui.go @@ -0,0 +1,131 @@ +// Copyright 2026 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 example + +import ( + "context" + "fmt" + + "github.com/AlecAivazis/survey/v2" + tea "github.com/charmbracelet/bubbletea" + "github.com/juju/errors" + + "github.com/tidbcloud/tidbcloud-cli/internal/flag" + "github.com/tidbcloud/tidbcloud-cli/internal/service/cloud" + "github.com/tidbcloud/tidbcloud-cli/internal/ui" + "github.com/tidbcloud/tidbcloud-cli/internal/util" +) + +const ( + ExampleNamePrompt = "Input the example name:" + DeleteConfirmPrompt = "Type 'yes' to confirm deletion:" + UnwiredFeaturePrompt = "This command is not wired to an API yet." +) + +var s3InputDescriptions = map[string]string{ + flag.S3URI: "S3 URI (e.g., s3://bucket/path)", + flag.S3AccessKeyID: "S3 access key ID", + flag.S3SecretAccessKey: "S3 secret access key", +} + +type Example struct { + ID string + DisplayName string +} + +func (e Example) String() string { + return fmt.Sprintf("%s(%s)", e.DisplayName, e.ID) +} + +func GetSelectedExample(ctx context.Context, clusterID string, pageSize int64, client cloud.TiDBCloudClient) (*Example, error) { + // examples, err := client.ListExamples(ctx, clusterID, pageSize, nil) + // if err != nil { + // return nil, errors.Trace(err) + // } + + // var items = make([]interface{}, 0, len(examples)) + // for _, example := range examples { + // items = append(items, &Example{ID: *example.ExampleId, DisplayName: *example.DisplayName}) + // } + + items := []interface{}{ + &Example{ID: "example-1", DisplayName: "Example One"}, + &Example{ID: "example-2", DisplayName: "Example Two"}, + &Example{ID: "example-3", DisplayName: "Example Three"}, + } + + if len(items) == 0 { + return nil, fmt.Errorf("no available examples found") + } + + model, err := ui.InitialSelectModel(items, "Choose the example:") + if err != nil { + return nil, errors.Trace(err) + } + itemsPerPage := 6 + model.EnablePagination(itemsPerPage) + model.EnableFilter() + + p := tea.NewProgram(model) + exampleModel, err := p.Run() + if err != nil { + return nil, errors.Trace(err) + } + if m, _ := exampleModel.(ui.SelectModel); m.Interrupted { + return nil, util.InterruptError + } + selected := exampleModel.(ui.SelectModel).GetSelectedItem() + if selected == nil { + return nil, errors.New("no example selected") + } + return selected.(*Example), nil +} + +func GetDisplayNameInput() (string, error) { + model, err := ui.InitialOneInputModel(ExampleNamePrompt, "example-name") + if err != nil { + return "", errors.Trace(err) + } + if model.Interrupted { + return "", util.InterruptError + } + if model.Err != nil { + return "", model.Err + } + return model.Input.Value(), nil +} + +func GetS3Inputs() (string, string, string, error) { + fmt.Fprintln(h.IOStreams.Out, "Pl") + inputs := []string{flag.S3URI, flag.S3AccessKeyID, flag.S3SecretAccessKey} + textInput, err := ui.InitialInputModel(inputs, s3InputDescriptions) + if err != nil { + return "", "", "", err + } + + s3URI := textInput.Inputs[0].Value() + if s3URI == "" { + return "", "", "", errors.New("empty S3 URI") + } + s3AccessKeyID := textInput.Inputs[1].Value() + if s3AccessKeyID == "" { + return "", "", "", errors.New("empty S3 access key ID") + } + s3SecretAccessKey := textInput.Inputs[2].Value() + if s3SecretAccessKey == "" { + return "", "", "", errors.New("empty S3 secret access key") + } + return s3URI, s3AccessKeyID, s3SecretAccessKey, nil +} diff --git a/.cursor/skills/create-ticloud-cli-command/references/bubbletea.md b/.cursor/skills/create-ticloud-cli-command/references/bubbletea.md new file mode 100644 index 00000000..a617a895 --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/references/bubbletea.md @@ -0,0 +1,205 @@ +## Bubbletea Knowledge + +Bubble Tea is based on the functional design paradigms of The Elm +Architecture, which happens to work nicely with Go. It's a delightful way +to build applications. + +This tutorial assumes you have a working knowledge of Go. + +### Enough! Let's get to it. + +For this tutorial, we're making a shopping list. + +To start we'll define our package and import some libraries. Our only external +import will be the Bubble Tea library, which we'll call `tea` for short. + +```go +package main + +// These imports will be used later on the tutorial. If you save the file +// now, Go might complain they are unused, but that's fine. +// You may also need to run `go mod tidy` to download bubbletea and its +// dependencies. +import ( + "fmt" + "os" + + tea "github.com/charmbracelet/bubbletea" +) +``` + +Bubble Tea programs are comprised of a **model** that describes the application +state and three simple methods on that model: + +- **Init**, a function that returns an initial command for the application to run. +- **Update**, a function that handles incoming events and updates the model accordingly. +- **View**, a function that renders the UI based on the data in the model. + +### The Model + +So let's start by defining our model which will store our application's state. +It can be any type, but a `struct` usually makes the most sense. + +```go +type model struct { + choices []string // items on the to-do list + cursor int // which to-do list item our cursor is pointing at + selected map[int]struct{} // which to-do items are selected +} +``` + +### Initialization + +Next, we’ll define our application’s initial state. In this case, we’re defining +a function to return our initial model, however, we could just as easily define +the initial model as a variable elsewhere, too. + +```go +func initialModel() model { + return model{ + // Our to-do list is a grocery list + choices: []string{"Buy carrots", "Buy celery", "Buy kohlrabi"}, + + // A map which indicates which choices are selected. We're using + // the map like a mathematical set. The keys refer to the indexes + // of the `choices` slice, above. + selected: make(map[int]struct{}), + } +} +``` + +Next, we define the `Init` method. `Init` can return a `Cmd` that could perform +some initial I/O. For now, we don't need to do any I/O, so for the command, +we'll just return `nil`, which translates to "no command." + +```go +func (m model) Init() tea.Cmd { + // Just return `nil`, which means "no I/O right now, please." + return nil +} +``` + +### The Update Method + +Next up is the update method. The update function is called when ”things +happen.” Its job is to look at what has happened and return an updated model in +response. It can also return a `Cmd` to make more things happen, but for now +don't worry about that part. + +In our case, when a user presses the down arrow, `Update`’s job is to notice +that the down arrow was pressed and move the cursor accordingly (or not). + +The “something happened” comes in the form of a `Msg`, which can be any type. +Messages are the result of some I/O that took place, such as a keypress, timer +tick, or a response from a server. + +We usually figure out which type of `Msg` we received with a type switch, but +you could also use a type assertion. + +For now, we'll just deal with `tea.KeyMsg` messages, which are automatically +sent to the update function when keys are pressed. + +```go +func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + switch msg := msg.(type) { + + // Is it a key press? + case tea.KeyMsg: + + // Cool, what was the actual key pressed? + switch msg.String() { + + // These keys should exit the program. + case "ctrl+c", "q": + return m, tea.Quit + + // The "up" and "k" keys move the cursor up + case "up", "k": + if m.cursor > 0 { + m.cursor-- + } + + // The "down" and "j" keys move the cursor down + case "down", "j": + if m.cursor < len(m.choices)-1 { + m.cursor++ + } + + // The "enter" key and the spacebar (a literal space) toggle + // the selected state for the item that the cursor is pointing at. + case "enter", " ": + _, ok := m.selected[m.cursor] + if ok { + delete(m.selected, m.cursor) + } else { + m.selected[m.cursor] = struct{}{} + } + } + } + + // Return the updated model to the Bubble Tea runtime for processing. + // Note that we're not returning a command. + return m, nil +} +``` + +You may have noticed that ctrl+c and q above return +a `tea.Quit` command with the model. That’s a special command which instructs +the Bubble Tea runtime to quit, exiting the program. + +### The View Method + +At last, it’s time to render our UI. Of all the methods, the view is the +simplest. We look at the model in its current state and use it to return +a `string`. That string is our UI! + +Because the view describes the entire UI of your application, you don’t have to +worry about redrawing logic and stuff like that. Bubble Tea takes care of it +for you. + +```go +func (m model) View() string { + // The header + s := "What should we buy at the market?\n\n" + + // Iterate over our choices + for i, choice := range m.choices { + + // Is the cursor pointing at this choice? + cursor := " " // no cursor + if m.cursor == i { + cursor = ">" // cursor! + } + + // Is this choice selected? + checked := " " // not selected + if _, ok := m.selected[i]; ok { + checked = "x" // selected! + } + + // Render the row + s += fmt.Sprintf("%s [%s] %s\n", cursor, checked, choice) + } + + // The footer + s += "\nPress q to quit.\n" + + // Send the UI for rendering + return s +} +``` + +### All Together Now + +The last step is to simply run our program. We pass our initial model to +`tea.NewProgram` and let it rip: + +```go +func main() { + p := tea.NewProgram(initialModel()) + if _, err := p.Run(); err != nil { + fmt.Printf("Alas, there's been an error: %v", err) + os.Exit(1) + } +} +``` \ No newline at end of file diff --git a/.cursor/skills/create-ticloud-cli-command/references/cobra.md b/.cursor/skills/create-ticloud-cli-command/references/cobra.md new file mode 100644 index 00000000..f398c30a --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/references/cobra.md @@ -0,0 +1,66 @@ +# Cobra Knowledge + +# Overview + +Cobra is a library providing a simple interface to create powerful modern CLI +interfaces similar to git & go tools. + +Cobra provides: +* Easy subcommand-based CLIs: `app server`, `app fetch`, etc. +* Fully POSIX-compliant flags (including short & long versions) +* Nested subcommands +* Global, local and cascading flags +* Intelligent suggestions (`app srver`... did you mean `app server`?) +* Automatic help generation for commands and flags +* Grouping help for subcommands +* Automatic help flag recognition of `-h`, `--help`, etc. +* Automatically generated shell autocomplete for your application (bash, zsh, fish, powershell) +* Automatically generated man pages for your application +* Command aliases so you can change things without breaking them +* The flexibility to define your own help, usage, etc. +* Optional seamless integration with viper for 12-factor apps + +# Concepts + +Cobra is built on a structure of commands, arguments & flags. + +**Commands** represent actions, **Args** are things and **Flags** are modifiers for those actions. + +The best applications read like sentences when used, and as a result, users +intuitively know how to interact with them. + +The pattern to follow is +`APPNAME VERB NOUN --ADJECTIVE` + or +`APPNAME COMMAND ARG --FLAG`. + +A few good real world examples may better illustrate this point. + +In the following example, 'server' is a command, and 'port' is a flag: + + hugo server --port=1313 + +In this command we are telling Git to clone the url bare. + + git clone URL --bare + +## Commands + +Command is the central point of the application. Each interaction that +the application supports will be contained in a Command. A command can +have children commands and optionally run an action. + +In the example above, 'server' is the command. + +## Flags + +A flag is a way to modify the behavior of a command. Cobra supports +fully POSIX-compliant flags as well as the Go flag package. +A Cobra command can define flags that persist through to children commands +and flags that are only available to that command. + +In the example above, 'port' is the flag. + +Flag functionality is provided by the pflag +library, a fork of the flag standard library +which maintains the same interface while adding POSIX compliance. \ No newline at end of file diff --git a/.cursor/skills/create-ticloud-cli-command/references/flag.md b/.cursor/skills/create-ticloud-cli-command/references/flag.md new file mode 100644 index 00000000..736b847a --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/references/flag.md @@ -0,0 +1,185 @@ +# Flag inference + +1. Infer flags if the user does not provide the command with flags. + +Skip this if the user has already provided flags. + +Infer flags from the Swagger spec and SDK client parameters. For example, see the branch create command in `internal/cli/serverless/branch/create.go`. + +The SDK client parameter `Branch` is as follows: + +``` +type Branch struct { + // The unique identifier for the branch. + Name *string `json:"name,omitempty"` + // The system-generated ID of the branch. + BranchId *string `json:"branchId,omitempty"` + // The user-defined name of the branch. + DisplayName string `json:"displayName"` + // The ID of the cluster to which the branch belongs. + ClusterId *string `json:"clusterId,omitempty"` + // The ID of the branch parent. + ParentId *string `json:"parentId,omitempty"` + // The email address of the user who create the branch. + CreatedBy *string `json:"createdBy,omitempty"` + // The state of the branch. + State *BranchState `json:"state,omitempty"` + // The connection endpoints for accessing the branch. + Endpoints *BranchEndpoints `json:"endpoints,omitempty"` + // The unique prefix automatically generated for SQL usernames on this cluster. TiDB Cloud uses this prefix to distinguish between clusters. For more information, see [User name prefix](https://docs.pingcap.com/tidbcloud/select-cluster-tier/#user-name-prefix). + UserPrefix NullableString `json:"userPrefix,omitempty"` + // The timestamp when the branch was created, in the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + CreateTime *time.Time `json:"createTime,omitempty"` + // The timestamp when the branch was last updated, in the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + UpdateTime *time.Time `json:"updateTime,omitempty"` + // The annotations for the branch. + Annotations *map[string]string `json:"annotations,omitempty"` + // The display name of the parent branch from which the branch was created. + ParentDisplayName *string `json:"parentDisplayName,omitempty"` + // The point in time on the parent branch from which the branch is created. The timestamp is truncated to seconds without rounding. + ParentTimestamp NullableTime `json:"parentTimestamp,omitempty"` + // The root password of the branch. It must be between 8 and 64 characters long and can contain letters, numbers, and special characters. + RootPassword *string `json:"rootPassword,omitempty" validate:"regexp=^.{8,64}$"` + AdditionalProperties map[string]interface{} +} +``` + +The part of the swagger is as follows: + +``` + "parameters": [ + { + "name": "clusterId", + "description": "The ID of the cluster to which the branch belongs.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "branch", + "description": "The branch being created.", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Branch" + } + } + ], + +"Branch": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The unique identifier for the branch.", + "readOnly": true + }, + "branchId": { + "type": "string", + "description": "The system-generated ID of the branch.", + "readOnly": true + }, + "displayName": { + "type": "string", + "description": "The user-defined name of the branch." + }, + "clusterId": { + "type": "string", + "description": "The ID of the cluster to which the branch belongs.", + "readOnly": true + }, + "parentId": { + "type": "string", + "description": "The ID of the branch parent." + }, + "createdBy": { + "type": "string", + "description": "The email address of the user who create the branch.", + "readOnly": true + }, + "state": { + "description": "The state of the branch.", + "readOnly": true, + "allOf": [ + { + "$ref": "#/definitions/Branch.State" + } + ] + }, + "endpoints": { + "description": "The connection endpoints for accessing the branch.", + "readOnly": true, + "allOf": [ + { + "$ref": "#/definitions/Branch.Endpoints" + } + ] + }, + "userPrefix": { + "type": "string", + "x-nullable": true, + "description": "The unique prefix automatically generated for SQL usernames on this cluster. TiDB Cloud uses this prefix to distinguish between clusters. For more information, see [User name prefix](https://docs.pingcap.com/tidbcloud/select-cluster-tier/#user-name-prefix).", + "readOnly": true + }, + "createTime": { + "type": "string", + "format": "date-time", + "description": "The timestamp when the branch was created, in the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.", + "readOnly": true + }, + "updateTime": { + "type": "string", + "format": "date-time", + "description": "The timestamp when the branch was last updated, in the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.", + "readOnly": true + }, + "annotations": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "The annotations for the branch." + }, + "parentDisplayName": { + "type": "string", + "description": "The display name of the parent branch from which the branch was created.", + "readOnly": true + }, + "parentTimestamp": { + "type": "string", + "format": "date-time", + "x-nullable": true, + "description": "The point in time on the parent branch from which the branch is created. The timestamp is truncated to seconds without rounding." + }, + "rootPassword": { + "type": "string", + "example": "my-shining-password", + "description": "The root password of the branch. It must be between 8 and 64 characters long and can contain letters, numbers, and special characters.", + "maxLength": 64, + "minLength": 8, + "pattern": "^.{8,64}$" + } + }, + "description": "Message for branch.", + "required": [ + "displayName" + ] + } +``` + +Generally, flags should exclude readOnly fields in the Swagger spec and include other fields. Exceptions may occur, so this rule is not mandatory. + +``` + createCmd.Flags().StringP(flag.DisplayName, flag.DisplayNameShort, "", "The displayName of the branch to be created.") + createCmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The ID of the cluster, in which the branch will be created.") + createCmd.Flags().StringP(flag.ParentID, "", "", "The ID of the branch parent, default is cluster id.") + createCmd.Flags().StringP(flag.ParentTimestamp, "", "", "The timestamp of the parent branch, default is current time. (RFC3339 format, e.g., 2024-01-01T00:00:00Z)") +``` + +2. Infer flag types from the SDK client parameter types. + +For example: if the parameter is a string type, use `Flags().String`. + +Flag inference may be inaccurate, so: +- Always ask the user when unsure about flags or flag types. +- Always ask the user to confirm the final result. diff --git a/.cursor/skills/create-ticloud-cli-command/references/sdk.md b/.cursor/skills/create-ticloud-cli-command/references/sdk.md new file mode 100644 index 00000000..84ff36c1 --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/references/sdk.md @@ -0,0 +1,18 @@ +# TiDB Cloud SDK knowledge + +TiDB Cloud CLI keeps the TiDB Cloud Open API SDK inside the project. + +Key points about the SDK: + +1. Swagger files are the single source of truth for the SDK; they live under `/pkg/tidbcloud`. +2. The openapi-generator library generates the SDK from Swagger. You do not need to know openapi-generator in detail; use the commands in the `Makefile` to invoke it. +3. `internal/service/cloud/api_client.go` combines the generated SDKs into a single client. +4. Mocks for `api_client.go` must also be generated. + +It is the user's responsibility to add or change Swagger files under `pkg/tidbcloud/`. + +It is the AI agent's responsibility to generate the SDK. Follow the workflow below: + +1. Run the appropriate command based on where Swagger files were added or changed. For example, if `pkg/tidbcloud/v1beta1/serverless` changed, run `generate-v1beta1-serverless-client`. If you cannot determine which Swagger changed, run `make generate-v1beta1-client` to generate all. +2. Update `internal/service/cloud/api_client.go` according to the generated SDK. If new methods appear in the SDK, add new interface methods and implementations in `api_client.go` following the existing code style. If new API clients appear, wrap them in the `ClientDelegate` struct. +3. Run `make generate-mocks` to refresh mocks. Do not edit mock files by hand; they must be auto-generated by this command. \ No newline at end of file diff --git a/.cursor/skills/create-ticloud-cli-command/references/tidbcloud-cli.md b/.cursor/skills/create-ticloud-cli-command/references/tidbcloud-cli.md new file mode 100644 index 00000000..8142dff0 --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/references/tidbcloud-cli.md @@ -0,0 +1,63 @@ +# TiDB Cloud CLI Knowledge + +## TiDB Cloud + +TiDB Cloud is a fully-managed Database-as-a-Service (DBaaS) that brings TiDB, an open-source Hybrid Transactional and Analytical Processing (HTAP) database, to your cloud. TiDB Cloud offers an easy way to deploy and manage databases to let you focus on your applications, not the complexities of the databases. You can create TiDB Cloud clusters to quickly build mission-critical applications on Amazon Web Services (AWS), Google Cloud, Microsoft Azure, and Alibaba Cloud. + +## TiDB Cloud CLI + +TiDB Cloud provides a command-line interface (CLI) `ticloud` for you to interact with TiDB Cloud from your terminal with a few lines of commands. For example, you can easily perform the following operations using `ticloud`: + +- Create, delete, and list your clusters. +- Import data to your clusters. +- Export data from your clusters. + +### TiDB Cloud CLI Auth + +- Create a user profile with your TiDB Cloud API key + + ```shell + ticloud config create + ``` + + > **Warning:** + > + > The profile name **MUST NOT** contain `.`. + +- Log into TiDB Cloud with authentication: + + ```shell + ticloud auth login + ``` + + After successful login, an OAuth token will be assigned to the current profile. If no profiles exist, the token will be assigned to a profile named `default`. + +> **Note:** +> +> In the preceding two methods, the TiDB Cloud API key takes precedence over the OAuth token. If both are available, the API key will be used. + +### Use the TiDB Cloud CLI + +View all commands available: + +```shell +ticloud --help +``` + +Verify that you are using the latest version: + +```shell +ticloud version +``` + +If not, update to the latest version: + +```shell +ticloud update +``` + +Create a TiDB Cloud cluster: + +```shell +ticloud serverless create +``` \ No newline at end of file diff --git a/.cursor/skills/create-ticloud-cli-command/references/ui.md b/.cursor/skills/create-ticloud-cli-command/references/ui.md new file mode 100644 index 00000000..2c957b71 --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/references/ui.md @@ -0,0 +1,53 @@ +# TiDB Cloud UI + +## Overview + +The basic UI lives under `internal/ui`; command-specific UI is under each command package (e.g. `assets/example/ui.go`). + +Live example: `internal/cli/serverless/changefeed/ui.go` + +## Forbidden + +github.com/AlecAivazis/survey/v2 is no longer maintained. + +Use it only for deletion confirmation. Do not use it for any other case. + +Deletion confirmation example: +``` +if err := survey.AskOne(&survey.Input{Message: DeleteConfirmPrompt}, &confirm); err != nil { + return err + } +``` + +## Selection UI (IDs, enums, predefined options) + +Use selection UI for IDs, enum fields, and any fixed option set. + +- Use `ui.InitialSelectModel(items, prompt)` with `bubbletea`. +- Enable pagination and filter: + - `model.EnablePagination(6)` + - `model.EnableFilter()` +- Handle interrupt: + - If model reports `Interrupted`, return `util.InterruptError`. +- Example pattern: see `assets/example/ui.go` (`GetSelectedExample`). + +Live Example: see `internal/service/cloud/logic.go` (`GetSelectedChangefeed`,`GetSelectedCluster`) + +## Simple input UI (single field) + +Use `ui.InitialOneInputModel` for any single field. + +- Example: `GetDisplayNameInput` in `assets/example/ui.go`. + +## Complex composite input (multiple related fields) + +For grouped or multi-field inputs, use `ui.InitialInputModel`. + +- Provide a list of keys and a description map for each field. +- Read values from `textInput.Inputs[i].Value()`. +- Validate each required field and return explicit errors. +- Example pattern: `GetS3Inputs` in `assets/example/ui.go`. + +## Others + +More UI components are in `internal/ui`. If what you need is not there, create a basic UI under `internal/ui` based on Bubbletea. See `references/bubbletea.md` for more information. diff --git a/.cursor/skills/create-ticloud-cli-command/references/ut.md b/.cursor/skills/create-ticloud-cli-command/references/ut.md new file mode 100644 index 00000000..9c4dd622 --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/references/ut.md @@ -0,0 +1,16 @@ +# Unit tests + +This document describes how to write TiDB Cloud CLI unit tests. + +Follow the patterns under `internal/cli/serverless/branch`: + +- Use generated mocks for service calls. +- Use `suite.Suite` with `SetupTest` to set `NO_COLOR`, create `iostream.Test()`, and inject a mock client. +- Use table-driven tests for flag combinations and error cases. +- Validate both `stdout` and `stderr` contents exactly. +- Assert mock expectations only on success paths. +- Cover: + - Required flags errors. + - Shorthand flags (`-c`, `-b`, `-o`, etc.). + - Output formats (`json` vs human). + - Multi-page list behavior when applicable. \ No newline at end of file diff --git a/.cursor/skills/update-ticloud-cli-command/LICENSE.txt b/.cursor/skills/update-ticloud-cli-command/LICENSE.txt new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/.cursor/skills/update-ticloud-cli-command/LICENSE.txt @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/.cursor/skills/update-ticloud-cli-command/SKILL.md b/.cursor/skills/update-ticloud-cli-command/SKILL.md new file mode 100644 index 00000000..d4aee2df --- /dev/null +++ b/.cursor/skills/update-ticloud-cli-command/SKILL.md @@ -0,0 +1,73 @@ +--- +name: update-ticloud-cli-command +description: Update TiDB Cloud CLI commands. Use when adding new flags or updating existing commands. +license: Complete terms in LICENSE.txt +metadata: + author: shiyuhang0 +--- + +# Update TiCloud CLI Command + +This skill updates TiDB Cloud CLI existing commands, helping users update existing commands with production-ready code. + +## When to use + +- The user asks to add flags to existing commands. +- The user asks to update logic of existing commands. + +## About TiDB Cloud CLI + +TiDB Cloud CLI (TiCloud CLI) is a command-line interface for interacting with TiDB Cloud, built on the Cobra library. + +Key design of TiDB Cloud CLI: +- Built on the Cobra library. +- Uses the TiDB Cloud Open API as the client and keeps the SDK inside the project. +- Every command supports both interactive and non-interactive modes. + +- More about TiDB Cloud CLI: `references/tidbcloud-cli.md`. +- More about Cobra: `references/cobra.md`. + +## Workflow + +Must follow the workflow below: + +### Generate SDK phase + +Detect whether there are new or modified Swagger files under `/pkg/tidbcloud`. Skip this phase if none are found. + +If detection fails, prompt the user: "Do you need to update swagger and generate SDK?" Skip this phase if the user does not need it. + +Once in this phase, follow the guide in `references/sdk.md` to generate the SDK. + +### Plan phase + +The agent needs to switch to plan mode if supported. This phase can be skipped if user already provide enough informations. + +The agent must ask the user for the following information during the plan phase: +1. **Updating Information**: Ask the user for details of the update, including whether new flags need to be added (if yes, request the user to provide them), and whether existing logic needs to be modified (if yes, ask the user to provide a specific description of the logic). +2. **Other necessary information** + +Generate the plan after the user confirms all the information. + +### Agent phase + +The agent must switch to agent mode in this phase. Follow the workflow below: + +1. **Update command** +2. **Write and run tests** + +#### Update command + +Update the command according to user-provided information and current command code style. + +If new flags are added: +- Refer to `references/flag.md` for the flag definition. +- Refer to `references/ui.md` for the UI design. + +#### Write and run the tests + +Skip this step if the test file does not exist. Otherwise, write unit tests following `references/ut.md`. Then run tests with: `go test -race -cover -count=1 path -v` + +For example, to run tests under `internal/cli/serverless/branch`: `go test -race -cover -count=1 ./internal/cli/serverless/branch -v` + +Ensure all tests pass. If they do not pass, fix the implementation or the tests. \ No newline at end of file diff --git a/.cursor/skills/update-ticloud-cli-command/references/bubbletea.md b/.cursor/skills/update-ticloud-cli-command/references/bubbletea.md new file mode 100644 index 00000000..a617a895 --- /dev/null +++ b/.cursor/skills/update-ticloud-cli-command/references/bubbletea.md @@ -0,0 +1,205 @@ +## Bubbletea Knowledge + +Bubble Tea is based on the functional design paradigms of The Elm +Architecture, which happens to work nicely with Go. It's a delightful way +to build applications. + +This tutorial assumes you have a working knowledge of Go. + +### Enough! Let's get to it. + +For this tutorial, we're making a shopping list. + +To start we'll define our package and import some libraries. Our only external +import will be the Bubble Tea library, which we'll call `tea` for short. + +```go +package main + +// These imports will be used later on the tutorial. If you save the file +// now, Go might complain they are unused, but that's fine. +// You may also need to run `go mod tidy` to download bubbletea and its +// dependencies. +import ( + "fmt" + "os" + + tea "github.com/charmbracelet/bubbletea" +) +``` + +Bubble Tea programs are comprised of a **model** that describes the application +state and three simple methods on that model: + +- **Init**, a function that returns an initial command for the application to run. +- **Update**, a function that handles incoming events and updates the model accordingly. +- **View**, a function that renders the UI based on the data in the model. + +### The Model + +So let's start by defining our model which will store our application's state. +It can be any type, but a `struct` usually makes the most sense. + +```go +type model struct { + choices []string // items on the to-do list + cursor int // which to-do list item our cursor is pointing at + selected map[int]struct{} // which to-do items are selected +} +``` + +### Initialization + +Next, we’ll define our application’s initial state. In this case, we’re defining +a function to return our initial model, however, we could just as easily define +the initial model as a variable elsewhere, too. + +```go +func initialModel() model { + return model{ + // Our to-do list is a grocery list + choices: []string{"Buy carrots", "Buy celery", "Buy kohlrabi"}, + + // A map which indicates which choices are selected. We're using + // the map like a mathematical set. The keys refer to the indexes + // of the `choices` slice, above. + selected: make(map[int]struct{}), + } +} +``` + +Next, we define the `Init` method. `Init` can return a `Cmd` that could perform +some initial I/O. For now, we don't need to do any I/O, so for the command, +we'll just return `nil`, which translates to "no command." + +```go +func (m model) Init() tea.Cmd { + // Just return `nil`, which means "no I/O right now, please." + return nil +} +``` + +### The Update Method + +Next up is the update method. The update function is called when ”things +happen.” Its job is to look at what has happened and return an updated model in +response. It can also return a `Cmd` to make more things happen, but for now +don't worry about that part. + +In our case, when a user presses the down arrow, `Update`’s job is to notice +that the down arrow was pressed and move the cursor accordingly (or not). + +The “something happened” comes in the form of a `Msg`, which can be any type. +Messages are the result of some I/O that took place, such as a keypress, timer +tick, or a response from a server. + +We usually figure out which type of `Msg` we received with a type switch, but +you could also use a type assertion. + +For now, we'll just deal with `tea.KeyMsg` messages, which are automatically +sent to the update function when keys are pressed. + +```go +func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + switch msg := msg.(type) { + + // Is it a key press? + case tea.KeyMsg: + + // Cool, what was the actual key pressed? + switch msg.String() { + + // These keys should exit the program. + case "ctrl+c", "q": + return m, tea.Quit + + // The "up" and "k" keys move the cursor up + case "up", "k": + if m.cursor > 0 { + m.cursor-- + } + + // The "down" and "j" keys move the cursor down + case "down", "j": + if m.cursor < len(m.choices)-1 { + m.cursor++ + } + + // The "enter" key and the spacebar (a literal space) toggle + // the selected state for the item that the cursor is pointing at. + case "enter", " ": + _, ok := m.selected[m.cursor] + if ok { + delete(m.selected, m.cursor) + } else { + m.selected[m.cursor] = struct{}{} + } + } + } + + // Return the updated model to the Bubble Tea runtime for processing. + // Note that we're not returning a command. + return m, nil +} +``` + +You may have noticed that ctrl+c and q above return +a `tea.Quit` command with the model. That’s a special command which instructs +the Bubble Tea runtime to quit, exiting the program. + +### The View Method + +At last, it’s time to render our UI. Of all the methods, the view is the +simplest. We look at the model in its current state and use it to return +a `string`. That string is our UI! + +Because the view describes the entire UI of your application, you don’t have to +worry about redrawing logic and stuff like that. Bubble Tea takes care of it +for you. + +```go +func (m model) View() string { + // The header + s := "What should we buy at the market?\n\n" + + // Iterate over our choices + for i, choice := range m.choices { + + // Is the cursor pointing at this choice? + cursor := " " // no cursor + if m.cursor == i { + cursor = ">" // cursor! + } + + // Is this choice selected? + checked := " " // not selected + if _, ok := m.selected[i]; ok { + checked = "x" // selected! + } + + // Render the row + s += fmt.Sprintf("%s [%s] %s\n", cursor, checked, choice) + } + + // The footer + s += "\nPress q to quit.\n" + + // Send the UI for rendering + return s +} +``` + +### All Together Now + +The last step is to simply run our program. We pass our initial model to +`tea.NewProgram` and let it rip: + +```go +func main() { + p := tea.NewProgram(initialModel()) + if _, err := p.Run(); err != nil { + fmt.Printf("Alas, there's been an error: %v", err) + os.Exit(1) + } +} +``` \ No newline at end of file diff --git a/.cursor/skills/update-ticloud-cli-command/references/cobra.md b/.cursor/skills/update-ticloud-cli-command/references/cobra.md new file mode 100644 index 00000000..f398c30a --- /dev/null +++ b/.cursor/skills/update-ticloud-cli-command/references/cobra.md @@ -0,0 +1,66 @@ +# Cobra Knowledge + +# Overview + +Cobra is a library providing a simple interface to create powerful modern CLI +interfaces similar to git & go tools. + +Cobra provides: +* Easy subcommand-based CLIs: `app server`, `app fetch`, etc. +* Fully POSIX-compliant flags (including short & long versions) +* Nested subcommands +* Global, local and cascading flags +* Intelligent suggestions (`app srver`... did you mean `app server`?) +* Automatic help generation for commands and flags +* Grouping help for subcommands +* Automatic help flag recognition of `-h`, `--help`, etc. +* Automatically generated shell autocomplete for your application (bash, zsh, fish, powershell) +* Automatically generated man pages for your application +* Command aliases so you can change things without breaking them +* The flexibility to define your own help, usage, etc. +* Optional seamless integration with viper for 12-factor apps + +# Concepts + +Cobra is built on a structure of commands, arguments & flags. + +**Commands** represent actions, **Args** are things and **Flags** are modifiers for those actions. + +The best applications read like sentences when used, and as a result, users +intuitively know how to interact with them. + +The pattern to follow is +`APPNAME VERB NOUN --ADJECTIVE` + or +`APPNAME COMMAND ARG --FLAG`. + +A few good real world examples may better illustrate this point. + +In the following example, 'server' is a command, and 'port' is a flag: + + hugo server --port=1313 + +In this command we are telling Git to clone the url bare. + + git clone URL --bare + +## Commands + +Command is the central point of the application. Each interaction that +the application supports will be contained in a Command. A command can +have children commands and optionally run an action. + +In the example above, 'server' is the command. + +## Flags + +A flag is a way to modify the behavior of a command. Cobra supports +fully POSIX-compliant flags as well as the Go flag package. +A Cobra command can define flags that persist through to children commands +and flags that are only available to that command. + +In the example above, 'port' is the flag. + +Flag functionality is provided by the pflag +library, a fork of the flag standard library +which maintains the same interface while adding POSIX compliance. \ No newline at end of file diff --git a/.cursor/skills/update-ticloud-cli-command/references/flag.md b/.cursor/skills/update-ticloud-cli-command/references/flag.md new file mode 100644 index 00000000..736b847a --- /dev/null +++ b/.cursor/skills/update-ticloud-cli-command/references/flag.md @@ -0,0 +1,185 @@ +# Flag inference + +1. Infer flags if the user does not provide the command with flags. + +Skip this if the user has already provided flags. + +Infer flags from the Swagger spec and SDK client parameters. For example, see the branch create command in `internal/cli/serverless/branch/create.go`. + +The SDK client parameter `Branch` is as follows: + +``` +type Branch struct { + // The unique identifier for the branch. + Name *string `json:"name,omitempty"` + // The system-generated ID of the branch. + BranchId *string `json:"branchId,omitempty"` + // The user-defined name of the branch. + DisplayName string `json:"displayName"` + // The ID of the cluster to which the branch belongs. + ClusterId *string `json:"clusterId,omitempty"` + // The ID of the branch parent. + ParentId *string `json:"parentId,omitempty"` + // The email address of the user who create the branch. + CreatedBy *string `json:"createdBy,omitempty"` + // The state of the branch. + State *BranchState `json:"state,omitempty"` + // The connection endpoints for accessing the branch. + Endpoints *BranchEndpoints `json:"endpoints,omitempty"` + // The unique prefix automatically generated for SQL usernames on this cluster. TiDB Cloud uses this prefix to distinguish between clusters. For more information, see [User name prefix](https://docs.pingcap.com/tidbcloud/select-cluster-tier/#user-name-prefix). + UserPrefix NullableString `json:"userPrefix,omitempty"` + // The timestamp when the branch was created, in the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + CreateTime *time.Time `json:"createTime,omitempty"` + // The timestamp when the branch was last updated, in the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + UpdateTime *time.Time `json:"updateTime,omitempty"` + // The annotations for the branch. + Annotations *map[string]string `json:"annotations,omitempty"` + // The display name of the parent branch from which the branch was created. + ParentDisplayName *string `json:"parentDisplayName,omitempty"` + // The point in time on the parent branch from which the branch is created. The timestamp is truncated to seconds without rounding. + ParentTimestamp NullableTime `json:"parentTimestamp,omitempty"` + // The root password of the branch. It must be between 8 and 64 characters long and can contain letters, numbers, and special characters. + RootPassword *string `json:"rootPassword,omitempty" validate:"regexp=^.{8,64}$"` + AdditionalProperties map[string]interface{} +} +``` + +The part of the swagger is as follows: + +``` + "parameters": [ + { + "name": "clusterId", + "description": "The ID of the cluster to which the branch belongs.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "branch", + "description": "The branch being created.", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Branch" + } + } + ], + +"Branch": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The unique identifier for the branch.", + "readOnly": true + }, + "branchId": { + "type": "string", + "description": "The system-generated ID of the branch.", + "readOnly": true + }, + "displayName": { + "type": "string", + "description": "The user-defined name of the branch." + }, + "clusterId": { + "type": "string", + "description": "The ID of the cluster to which the branch belongs.", + "readOnly": true + }, + "parentId": { + "type": "string", + "description": "The ID of the branch parent." + }, + "createdBy": { + "type": "string", + "description": "The email address of the user who create the branch.", + "readOnly": true + }, + "state": { + "description": "The state of the branch.", + "readOnly": true, + "allOf": [ + { + "$ref": "#/definitions/Branch.State" + } + ] + }, + "endpoints": { + "description": "The connection endpoints for accessing the branch.", + "readOnly": true, + "allOf": [ + { + "$ref": "#/definitions/Branch.Endpoints" + } + ] + }, + "userPrefix": { + "type": "string", + "x-nullable": true, + "description": "The unique prefix automatically generated for SQL usernames on this cluster. TiDB Cloud uses this prefix to distinguish between clusters. For more information, see [User name prefix](https://docs.pingcap.com/tidbcloud/select-cluster-tier/#user-name-prefix).", + "readOnly": true + }, + "createTime": { + "type": "string", + "format": "date-time", + "description": "The timestamp when the branch was created, in the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.", + "readOnly": true + }, + "updateTime": { + "type": "string", + "format": "date-time", + "description": "The timestamp when the branch was last updated, in the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.", + "readOnly": true + }, + "annotations": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "The annotations for the branch." + }, + "parentDisplayName": { + "type": "string", + "description": "The display name of the parent branch from which the branch was created.", + "readOnly": true + }, + "parentTimestamp": { + "type": "string", + "format": "date-time", + "x-nullable": true, + "description": "The point in time on the parent branch from which the branch is created. The timestamp is truncated to seconds without rounding." + }, + "rootPassword": { + "type": "string", + "example": "my-shining-password", + "description": "The root password of the branch. It must be between 8 and 64 characters long and can contain letters, numbers, and special characters.", + "maxLength": 64, + "minLength": 8, + "pattern": "^.{8,64}$" + } + }, + "description": "Message for branch.", + "required": [ + "displayName" + ] + } +``` + +Generally, flags should exclude readOnly fields in the Swagger spec and include other fields. Exceptions may occur, so this rule is not mandatory. + +``` + createCmd.Flags().StringP(flag.DisplayName, flag.DisplayNameShort, "", "The displayName of the branch to be created.") + createCmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The ID of the cluster, in which the branch will be created.") + createCmd.Flags().StringP(flag.ParentID, "", "", "The ID of the branch parent, default is cluster id.") + createCmd.Flags().StringP(flag.ParentTimestamp, "", "", "The timestamp of the parent branch, default is current time. (RFC3339 format, e.g., 2024-01-01T00:00:00Z)") +``` + +2. Infer flag types from the SDK client parameter types. + +For example: if the parameter is a string type, use `Flags().String`. + +Flag inference may be inaccurate, so: +- Always ask the user when unsure about flags or flag types. +- Always ask the user to confirm the final result. diff --git a/.cursor/skills/update-ticloud-cli-command/references/sdk.md b/.cursor/skills/update-ticloud-cli-command/references/sdk.md new file mode 100644 index 00000000..b0090a0c --- /dev/null +++ b/.cursor/skills/update-ticloud-cli-command/references/sdk.md @@ -0,0 +1,18 @@ +# TiDB Cloud SDK knowledge + +TiDB Cloud CLI keeps the TiDB Cloud Open API SDK inside the project. + +Key points about the SDK: + +1. Swagger files are the single source of truth for the SDK; they live under `/pkg/tidbcloud/v1beta1`. +2. The openapi-generator library generates the SDK from Swagger. You do not need to know openapi-generator in detail; use the commands in the `Makefile` to invoke it. +3. `internal/service/cloud/api_client.go` combines the generated SDKs into a single client. +4. Mocks for `api_client.go` must also be generated. + +It is the user's responsibility to add or change Swagger files under `pkg/tidbcloud/`. + +It is the AI agent's responsibility to generate the SDK. Follow the workflow below: + +1. Run the appropriate command based on where Swagger files were added or changed. For example, if `pkg/tidbcloud/serverless` changed, run `generate-v1beta1-serverless-client`. If you cannot determine which Swagger changed, run `make generate-v1beta1-client` to generate all. +2. Update `internal/service/cloud/api_client.go` according to the generated SDK. If new methods appear in the SDK, add new interface methods and implementations in `api_client.go` following the existing code style. If new API clients appear, wrap them in the `ClientDelegate` struct. +3. Run `make generate-mocks` to refresh mocks. Do not edit mock files by hand; they must be auto-generated by this command. \ No newline at end of file diff --git a/.cursor/skills/update-ticloud-cli-command/references/tidbcloud-cli.md b/.cursor/skills/update-ticloud-cli-command/references/tidbcloud-cli.md new file mode 100644 index 00000000..8142dff0 --- /dev/null +++ b/.cursor/skills/update-ticloud-cli-command/references/tidbcloud-cli.md @@ -0,0 +1,63 @@ +# TiDB Cloud CLI Knowledge + +## TiDB Cloud + +TiDB Cloud is a fully-managed Database-as-a-Service (DBaaS) that brings TiDB, an open-source Hybrid Transactional and Analytical Processing (HTAP) database, to your cloud. TiDB Cloud offers an easy way to deploy and manage databases to let you focus on your applications, not the complexities of the databases. You can create TiDB Cloud clusters to quickly build mission-critical applications on Amazon Web Services (AWS), Google Cloud, Microsoft Azure, and Alibaba Cloud. + +## TiDB Cloud CLI + +TiDB Cloud provides a command-line interface (CLI) `ticloud` for you to interact with TiDB Cloud from your terminal with a few lines of commands. For example, you can easily perform the following operations using `ticloud`: + +- Create, delete, and list your clusters. +- Import data to your clusters. +- Export data from your clusters. + +### TiDB Cloud CLI Auth + +- Create a user profile with your TiDB Cloud API key + + ```shell + ticloud config create + ``` + + > **Warning:** + > + > The profile name **MUST NOT** contain `.`. + +- Log into TiDB Cloud with authentication: + + ```shell + ticloud auth login + ``` + + After successful login, an OAuth token will be assigned to the current profile. If no profiles exist, the token will be assigned to a profile named `default`. + +> **Note:** +> +> In the preceding two methods, the TiDB Cloud API key takes precedence over the OAuth token. If both are available, the API key will be used. + +### Use the TiDB Cloud CLI + +View all commands available: + +```shell +ticloud --help +``` + +Verify that you are using the latest version: + +```shell +ticloud version +``` + +If not, update to the latest version: + +```shell +ticloud update +``` + +Create a TiDB Cloud cluster: + +```shell +ticloud serverless create +``` \ No newline at end of file diff --git a/.cursor/skills/update-ticloud-cli-command/references/ui.md b/.cursor/skills/update-ticloud-cli-command/references/ui.md new file mode 100644 index 00000000..2c957b71 --- /dev/null +++ b/.cursor/skills/update-ticloud-cli-command/references/ui.md @@ -0,0 +1,53 @@ +# TiDB Cloud UI + +## Overview + +The basic UI lives under `internal/ui`; command-specific UI is under each command package (e.g. `assets/example/ui.go`). + +Live example: `internal/cli/serverless/changefeed/ui.go` + +## Forbidden + +github.com/AlecAivazis/survey/v2 is no longer maintained. + +Use it only for deletion confirmation. Do not use it for any other case. + +Deletion confirmation example: +``` +if err := survey.AskOne(&survey.Input{Message: DeleteConfirmPrompt}, &confirm); err != nil { + return err + } +``` + +## Selection UI (IDs, enums, predefined options) + +Use selection UI for IDs, enum fields, and any fixed option set. + +- Use `ui.InitialSelectModel(items, prompt)` with `bubbletea`. +- Enable pagination and filter: + - `model.EnablePagination(6)` + - `model.EnableFilter()` +- Handle interrupt: + - If model reports `Interrupted`, return `util.InterruptError`. +- Example pattern: see `assets/example/ui.go` (`GetSelectedExample`). + +Live Example: see `internal/service/cloud/logic.go` (`GetSelectedChangefeed`,`GetSelectedCluster`) + +## Simple input UI (single field) + +Use `ui.InitialOneInputModel` for any single field. + +- Example: `GetDisplayNameInput` in `assets/example/ui.go`. + +## Complex composite input (multiple related fields) + +For grouped or multi-field inputs, use `ui.InitialInputModel`. + +- Provide a list of keys and a description map for each field. +- Read values from `textInput.Inputs[i].Value()`. +- Validate each required field and return explicit errors. +- Example pattern: `GetS3Inputs` in `assets/example/ui.go`. + +## Others + +More UI components are in `internal/ui`. If what you need is not there, create a basic UI under `internal/ui` based on Bubbletea. See `references/bubbletea.md` for more information. diff --git a/.cursor/skills/update-ticloud-cli-command/references/ut.md b/.cursor/skills/update-ticloud-cli-command/references/ut.md new file mode 100644 index 00000000..9c4dd622 --- /dev/null +++ b/.cursor/skills/update-ticloud-cli-command/references/ut.md @@ -0,0 +1,16 @@ +# Unit tests + +This document describes how to write TiDB Cloud CLI unit tests. + +Follow the patterns under `internal/cli/serverless/branch`: + +- Use generated mocks for service calls. +- Use `suite.Suite` with `SetupTest` to set `NO_COLOR`, create `iostream.Test()`, and inject a mock client. +- Use table-driven tests for flag combinations and error cases. +- Validate both `stdout` and `stderr` contents exactly. +- Assert mock expectations only on success paths. +- Cover: + - Required flags errors. + - Shorthand flags (`-c`, `-b`, `-o`, etc.). + - Output formats (`json` vs human). + - Multi-page list behavior when applicable. \ No newline at end of file diff --git a/internal/flag/flag.go b/internal/flag/flag.go index 315d91b4..e81a11df 100644 --- a/internal/flag/flag.go +++ b/internal/flag/flag.go @@ -15,6 +15,7 @@ package flag const ( + ExampleID string = "example-id" ClusterID string = "cluster-id" ClusterIDShort string = "c" LocalConcurrency string = "local.concurrency" diff --git a/internal/ui/text_one_input_model.go b/internal/ui/text_one_input_model.go new file mode 100644 index 00000000..395a0ac8 --- /dev/null +++ b/internal/ui/text_one_input_model.go @@ -0,0 +1,91 @@ +// Copyright 2026 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 ui + +import ( + "fmt" + + "github.com/charmbracelet/bubbles/textinput" + tea "github.com/charmbracelet/bubbletea" + "github.com/juju/errors" + "github.com/tidbcloud/tidbcloud-cli/internal/config" + "github.com/tidbcloud/tidbcloud-cli/internal/util" +) + +type TextOneInputModel struct { + Prompt string + Input textinput.Model + Err error + Interrupted bool +} + +func (m TextOneInputModel) Init() tea.Cmd { + return textinput.Blink +} + +func (m TextOneInputModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + var cmd tea.Cmd + + switch msg := msg.(type) { + case tea.KeyMsg: + switch msg.Type { + case tea.KeyEnter: + return m, tea.Quit + case tea.KeyCtrlC, tea.KeyEsc: + m.Interrupted = true + return m, tea.Quit + } + + case errMsg: + m.Err = msg + return m, nil + } + + m.Input, cmd = m.Input.Update(msg) + return m, cmd +} + +func (m TextOneInputModel) View() string { + return fmt.Sprintf( + "%s\n\n%s\n\n%s\n\n", + m.Prompt, + m.Input.View(), + helpMessageStyle("Press Enter to submit (esc to quit)"), + ) +} + +// InitialOneInputModel runs an interactive single-line input and returns the model and any error. +// view is the prompt line shown above the input. placeholder is used as the input placeholder text. +func InitialOneInputModel(prompt, placeholder string) (TextOneInputModel, error) { + ti := textinput.New() + ti.Placeholder = placeholder + ti.Focus() + ti.PromptStyle = config.FocusedStyle + ti.TextStyle = config.FocusedStyle + + p := tea.NewProgram(TextOneInputModel{Prompt: prompt, Input: ti}) + model, err := p.Run() + finalModel := model.(TextOneInputModel) + if err != nil { + return finalModel, errors.Trace(err) + } + if finalModel.Interrupted { + return finalModel, util.InterruptError + } + if finalModel.Err != nil { + return finalModel, finalModel.Err + } + return finalModel, nil +} From fb94c995c50e69d92ad032d5e563fa56ec6b2c83 Mon Sep 17 00:00:00 2001 From: shiyuhang <1136742008@qq.com> Date: Thu, 5 Feb 2026 16:56:00 +0800 Subject: [PATCH 2/9] remove private link connection --- Makefile | 6 +- internal/cli/serverless/cluster.go | 2 - internal/cli/serverless/privatelink/attach.go | 199 ---- internal/cli/serverless/privatelink/create.go | 229 ----- internal/cli/serverless/privatelink/delete.go | 150 --- .../cli/serverless/privatelink/describe.go | 127 --- internal/cli/serverless/privatelink/detach.go | 143 --- internal/cli/serverless/privatelink/list.go | 153 --- .../cli/serverless/privatelink/privatelink.go | 41 - internal/cli/serverless/privatelink/ui.go | 81 -- internal/cli/serverless/privatelink/zone.go | 108 --- internal/mock/api_client.go | 212 ----- internal/service/cloud/api_client.go | 87 +- internal/service/cloud/logic.go | 107 --- .../serverless/privatelink.swagger.json | 673 -------------- .../v1beta1/serverless/privatelink/.gitignore | 24 - .../privatelink/.openapi-generator-ignore | 23 - .../privatelink/.openapi-generator/FILES | 27 - .../privatelink/.openapi-generator/VERSION | 1 - .../serverless/privatelink/.travis.yml | 8 - .../v1beta1/serverless/privatelink/README.md | 134 --- .../serverless/privatelink/api/openapi.yaml | 726 --------------- .../api_private_link_connection_service.go | 872 ------------------ .../v1beta1/serverless/privatelink/client.go | 655 ------------- .../serverless/privatelink/configuration.go | 214 ----- .../serverless/privatelink/git_push.sh | 57 -- .../model_alicloud_endpoint_service.go | 243 ----- .../serverless/privatelink/model_any.go | 153 --- .../privatelink/model_attach_domain.go | 433 --------- .../privatelink/model_aws_endpoint_service.go | 280 ------ .../serverless/privatelink/model_domain.go | 229 ----- .../model_get_availability_zones_response.go | 192 ---- ..._list_private_link_connections_response.go | 227 ----- .../model_private_link_connection.go | 576 ------------ ...rivate_link_connection_domain_type_enum.go | 105 --- ..._connection_service_attach_domains_body.go | 205 ---- ...ice_create_private_link_connection_body.go | 167 ---- ..._connection_service_detach_domains_body.go | 167 ---- ...rivate_link_connections_state_parameter.go | 111 --- ...odel_private_link_connection_state_enum.go | 111 --- ...model_private_link_connection_type_enum.go | 105 --- .../serverless/privatelink/model_status.go | 227 ----- .../serverless/privatelink/response.go | 47 - .../v1beta1/serverless/privatelink/utils.go | 361 -------- 44 files changed, 9 insertions(+), 8989 deletions(-) delete mode 100644 internal/cli/serverless/privatelink/attach.go delete mode 100644 internal/cli/serverless/privatelink/create.go delete mode 100644 internal/cli/serverless/privatelink/delete.go delete mode 100644 internal/cli/serverless/privatelink/describe.go delete mode 100644 internal/cli/serverless/privatelink/detach.go delete mode 100644 internal/cli/serverless/privatelink/list.go delete mode 100644 internal/cli/serverless/privatelink/privatelink.go delete mode 100644 internal/cli/serverless/privatelink/ui.go delete mode 100644 internal/cli/serverless/privatelink/zone.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink.swagger.json delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/.gitignore delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/.openapi-generator-ignore delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/.openapi-generator/FILES delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/.openapi-generator/VERSION delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/.travis.yml delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/README.md delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/api/openapi.yaml delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/api_private_link_connection_service.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/client.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/configuration.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/git_push.sh delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/model_alicloud_endpoint_service.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/model_any.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/model_attach_domain.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/model_aws_endpoint_service.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/model_domain.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/model_get_availability_zones_response.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/model_list_private_link_connections_response.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_domain_type_enum.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_attach_domains_body.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_create_private_link_connection_body.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_detach_domains_body.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_list_private_link_connections_state_parameter.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_state_enum.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_type_enum.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/model_status.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/response.go delete mode 100644 pkg/tidbcloud/v1beta1/serverless/privatelink/utils.go diff --git a/Makefile b/Makefile index 051a8013..cd6ae38a 100644 --- a/Makefile +++ b/Makefile @@ -22,9 +22,9 @@ setup: deps devtools ## Set up dev env generate-mocks: ## Generate mock objects @echo "==> Generating mock objects" go install github.com/vektra/mockery/v2@v2.53.5 - mockery --name TiDBCloudClient --recursive --output=internal/mock --outpkg mock --filename api_client.go - mockery --name EventsSender --recursive --output=internal/mock --outpkg mock --filename sender.go - mockery --name Uploader --recursive --output=internal/mock --outpkg mock --filename uploader.go + mockery --name TiDBCloudClient --recursive --dir=internal/service/cloud --output=internal/mock --outpkg mock --filename api_client.go + mockery --name EventsSender --recursive --dir=internal/telemetry --output=internal/mock --outpkg mock --filename sender.go + mockery --name Uploader --recursive --dir=internal/service/aws/s3 --output=internal/mock --outpkg mock --filename uploader.go .PHONY: addcopy addcopy: ## Add copyright to all files diff --git a/internal/cli/serverless/cluster.go b/internal/cli/serverless/cluster.go index 5f3b8574..25b74c74 100644 --- a/internal/cli/serverless/cluster.go +++ b/internal/cli/serverless/cluster.go @@ -23,7 +23,6 @@ import ( "github.com/tidbcloud/tidbcloud-cli/internal/cli/serverless/dataimport" "github.com/tidbcloud/tidbcloud-cli/internal/cli/serverless/export" "github.com/tidbcloud/tidbcloud-cli/internal/cli/serverless/migration" - "github.com/tidbcloud/tidbcloud-cli/internal/cli/serverless/privatelink" "github.com/tidbcloud/tidbcloud-cli/internal/cli/serverless/sqluser" "github.com/spf13/cobra" @@ -54,7 +53,6 @@ func Cmd(h *internal.Helper) *cobra.Command { serverlessCmd.AddCommand(CapacityCmd(h)) serverlessCmd.AddCommand(authorizednetwork.AuthorizedNetworkCmd(h)) serverlessCmd.AddCommand(changefeed.ChangefeedCmd(h)) - serverlessCmd.AddCommand(privatelink.PrivateLinkConnectionCmd(h)) serverlessCmd.AddCommand(migration.MigrationCmd(h)) return serverlessCmd diff --git a/internal/cli/serverless/privatelink/attach.go b/internal/cli/serverless/privatelink/attach.go deleted file mode 100644 index 65df8377..00000000 --- a/internal/cli/serverless/privatelink/attach.go +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright 2026 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 privatelink - -import ( - "fmt" - "strings" - - "github.com/AlecAivazis/survey/v2" - "github.com/fatih/color" - "github.com/juju/errors" - "github.com/spf13/cobra" - - "github.com/tidbcloud/tidbcloud-cli/internal" - "github.com/tidbcloud/tidbcloud-cli/internal/config" - "github.com/tidbcloud/tidbcloud-cli/internal/flag" - "github.com/tidbcloud/tidbcloud-cli/internal/output" - "github.com/tidbcloud/tidbcloud-cli/internal/service/cloud" - plapi "github.com/tidbcloud/tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/privatelink" -) - -type AttachDomainOpts struct { - interactive bool -} - -func (o AttachDomainOpts) NonInteractiveFlags() []string { - return []string{ - flag.ClusterID, - flag.PrivateLinkConnectionID, - flag.PLCAttachDomainType, - flag.PLCAttachDomainUniqueName, - } -} - -func (o AttachDomainOpts) RequiredFlags() []string { - return []string{ - flag.ClusterID, - flag.PrivateLinkConnectionID, - flag.PLCAttachDomainType, - } -} - -func (o *AttachDomainOpts) MarkInteractive(cmd *cobra.Command) error { - o.interactive = true - for _, fn := range o.NonInteractiveFlags() { - if f := cmd.Flags().Lookup(fn); f != nil && f.Changed { - o.interactive = false - } - } - if !o.interactive { - for _, fn := range o.RequiredFlags() { - if err := cmd.MarkFlagRequired(fn); err != nil { - return err - } - } - } - return nil -} - -func AttachDomainCmd(h *internal.Helper) *cobra.Command { - opts := &AttachDomainOpts{interactive: true} - cmd := &cobra.Command{ - Use: "attach-domains", - Short: "Attach domains to a private link connection", - Args: cobra.NoArgs, - Example: fmt.Sprintf(` Attach domain (interactive): - $ %[1]s serverless private-link-connection attach-domains - - Attach domain (non-interactive): - $ %[1]s serverless private-link-connection attach-domains -c --private-link-connection-id --type --unique-name `, config.CliName), - PreRunE: func(cmd *cobra.Command, args []string) error { - return opts.MarkInteractive(cmd) - }, - RunE: func(cmd *cobra.Command, args []string) error { - d, err := h.Client() - if err != nil { - return err - } - ctx := cmd.Context() - - var clusterID, plcID string - var domainType plapi.PrivateLinkConnectionDomainTypeEnum - var uniqueName string - var dryRun bool - dryRun, err = cmd.Flags().GetBool(flag.DryRun) - if err != nil { - return errors.Trace(err) - } - if opts.interactive { - if !h.IOStreams.CanPrompt { - return errors.New("The terminal doesn't support interactive mode, please use non-interactive mode") - } - - project, err := cloud.GetSelectedProject(ctx, h.QueryPageSize, d) - if err != nil { - return err - } - cluster, err := cloud.GetSelectedCluster(ctx, project.ID, h.QueryPageSize, d) - if err != nil { - return err - } - clusterID = cluster.ID - - privatelink, err := cloud.GetSelectedPrivateLinkConnection(ctx, cluster.ID, int32(h.QueryPageSize), d) - if err != nil { - return err - } - plcID = privatelink.ID - - domainType, err = GetSelectedPLCAttachDomainType() - if err != nil { - return err - } - - switch domainType { - case plapi.PRIVATELINKCONNECTIONDOMAINTYPEENUM_CONFLUENT: - if err := survey.AskOne(&survey.Input{Message: "Domain unique name:"}, &uniqueName); err != nil { - return err - } - case plapi.PRIVATELINKCONNECTIONDOMAINTYPEENUM_TIDBCLOUD_MANAGED: - if !dryRun { - if err := survey.AskOne(&survey.Input{Message: "Domain unique name:"}, &uniqueName); err != nil { - return err - } - } - default: - return errors.New("invalid domain type") - } - } else { - var err error - clusterID, err = cmd.Flags().GetString(flag.ClusterID) - if err != nil { - return errors.Trace(err) - } - plcID, err = cmd.Flags().GetString(flag.PrivateLinkConnectionID) - if err != nil { - return errors.Trace(err) - } - domainTypeStr, err := cmd.Flags().GetString(flag.PLCAttachDomainType) - if err != nil { - return errors.Trace(err) - } - domainType = plapi.PrivateLinkConnectionDomainTypeEnum(domainTypeStr) - uniqueName, err = cmd.Flags().GetString(flag.PLCAttachDomainUniqueName) - if err != nil { - return errors.Trace(err) - } - - if domainType == "" { - return errors.New("domain type is required") - } - } - - body := &plapi.PrivateLinkConnectionServiceAttachDomainsBody{ - AttachDomain: plapi.AttachDomain{ - Type: domainType, - UniqueName: &uniqueName, - }, - ValidateOnly: &dryRun, - } - - resp, err := d.AttachPrivateLinkDomains(ctx, clusterID, plcID, body) - if err != nil { - return errors.Trace(err) - } - if !dryRun { - return output.PrintJson(h.IOStreams.Out, resp) - } - domains := make([]string, 0, len(resp.Domains)) - for _, domain := range resp.Domains { - domains = append(domains, *domain.Name) - } - fmt.Fprintf(h.IOStreams.Out, "unique name %s:\n%s\n", - color.BlueString("%v", *resp.UniqueName), - color.GreenString("%v", strings.Join(domains, "\n"))) - return nil - }, - } - - cmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The cluster ID.") - cmd.Flags().String(flag.PrivateLinkConnectionID, "", "The private link connection ID.") - cmd.Flags().String(flag.PLCAttachDomainType, "", fmt.Sprintf("The type of domain to attach, one of: %v", plapi.AllowedPrivateLinkConnectionDomainTypeEnumEnumValues)) - cmd.Flags().String(flag.PLCAttachDomainUniqueName, "", "The unique name of the domain to attach, you can use --dry-run to generate the unique name when attaching a TiDB Cloud managed domain.") - cmd.Flags().Bool(flag.DryRun, false, "Set dry run mode to only show generated domains without attaching them.") - - return cmd -} diff --git a/internal/cli/serverless/privatelink/create.go b/internal/cli/serverless/privatelink/create.go deleted file mode 100644 index 6d0ac0e7..00000000 --- a/internal/cli/serverless/privatelink/create.go +++ /dev/null @@ -1,229 +0,0 @@ -// Copyright 2026 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 privatelink - -import ( - "fmt" - - "github.com/AlecAivazis/survey/v2" - "github.com/fatih/color" - "github.com/juju/errors" - "github.com/spf13/cobra" - - "github.com/tidbcloud/tidbcloud-cli/internal" - "github.com/tidbcloud/tidbcloud-cli/internal/config" - "github.com/tidbcloud/tidbcloud-cli/internal/flag" - "github.com/tidbcloud/tidbcloud-cli/internal/service/cloud" - "github.com/tidbcloud/tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/privatelink" -) - -type CreateOpts struct { - interactive bool -} - -func (o CreateOpts) NonInteractiveFlags() []string { - return []string{ - flag.ClusterID, - flag.DisplayName, - flag.PrivateLinkConnectionType, - } -} - -func (o *CreateOpts) MarkInteractive(cmd *cobra.Command) error { - o.interactive = true - for _, fn := range o.NonInteractiveFlags() { - f := cmd.Flags().Lookup(fn) - if f != nil && f.Changed { - o.interactive = false - } - } - if !o.interactive { - for _, fn := range o.NonInteractiveFlags() { - if err := cmd.MarkFlagRequired(fn); err != nil { - return err - } - } - } - return nil -} - -func CreateCmd(h *internal.Helper) *cobra.Command { - opts := &CreateOpts{interactive: true} - - cmd := &cobra.Command{ - Use: "create", - Short: "Create a private link connection for dataflow", - Args: cobra.NoArgs, - Example: fmt.Sprintf(` Create a private link connection (interactive): - $ %[1]s serverless private-link-connection create - - Create a private link connection which connect to alicloud endpoint service (non-interactive): - $ %[1]s serverless private-link-connection create -c --display-name --type ALICLOUD_ENDPOINT_SERVICE --alicloud.endpoint-service-name - - Create a private link connection which connect to aws endpoint service (non-interactive): - $ %[1]s serverless private-link-connection create -c --display-name --type AWS_ENDPOINT_SERVICE --aws.endpoint-service-name `, config.CliName), - PreRunE: func(cmd *cobra.Command, args []string) error { - return opts.MarkInteractive(cmd) - }, - RunE: func(cmd *cobra.Command, args []string) error { - d, err := h.Client() - if err != nil { - return err - } - ctx := cmd.Context() - - var clusterID, displayName string - var connectionType privatelink.PrivateLinkConnectionTypeEnum - var awsEndpointServiceName, AWSEndpointServiceRegion string - var alicloudEndpointServiceName string - if opts.interactive { - if !h.IOStreams.CanPrompt { - return errors.New("The terminal doesn't support interactive mode, please use non-interactive mode") - } - project, err := cloud.GetSelectedProject(ctx, h.QueryPageSize, d) - if err != nil { - return err - } - cluster, err := cloud.GetSelectedCluster(ctx, project.ID, h.QueryPageSize, d) - if err != nil { - return err - } - clusterID = cluster.ID - - if err := survey.AskOne( - &survey.Input{Message: DisplayNamePrompt}, - &displayName, - survey.WithValidator(survey.Required), - ); err != nil { - return err - } - if displayName == "" { - return errors.New("display name is required") - } - - connectionType, err = GetSelectedPrivateLinkConnectionType() - if err != nil { - return err - } - switch connectionType { - case privatelink.PRIVATELINKCONNECTIONTYPEENUM_AWS_ENDPOINT_SERVICE: - if err = survey.AskOne(&survey.Input{Message: AWSEndpointServiceNamePrompt}, &awsEndpointServiceName, survey.WithValidator(survey.Required)); err != nil { - return err - } - crossRegion := false - if err = survey.AskOne(&survey.Confirm{Message: AWSEndpointServiceRegionConfirmPrompt, Default: false}, &crossRegion); err != nil { - return err - } - if crossRegion { - if err := survey.AskOne(&survey.Input{Message: AWSEndpointServiceRegionPrompt}, &AWSEndpointServiceRegion, survey.WithValidator(survey.Required)); err != nil { - return err - } - } - case privatelink.PRIVATELINKCONNECTIONTYPEENUM_ALICLOUD_ENDPOINT_SERVICE: - if err := survey.AskOne(&survey.Input{Message: AlicloudEndpointServiceNamePrompt}, &alicloudEndpointServiceName, survey.WithValidator(survey.Required)); err != nil { - return err - } - } - } else { - var err error - clusterID, err = cmd.Flags().GetString(flag.ClusterID) - if err != nil { - return errors.Trace(err) - } - displayName, err = cmd.Flags().GetString(flag.DisplayName) - if err != nil { - return errors.Trace(err) - } - connectionTypeStr, err := cmd.Flags().GetString(flag.PrivateLinkConnectionType) - if err != nil { - return errors.Trace(err) - } - connectionType = privatelink.PrivateLinkConnectionTypeEnum(connectionTypeStr) - - awsEndpointServiceName, err = cmd.Flags().GetString(flag.AWSEndpointServiceName) - if err != nil { - return errors.Trace(err) - } - alicloudEndpointServiceName, err = cmd.Flags().GetString(flag.AlicloudEndpointServiceName) - if err != nil { - return errors.Trace(err) - } - AWSEndpointServiceRegion, err = cmd.Flags().GetString(flag.AWSEndpointServiceRegion) - if err != nil { - return errors.Trace(err) - } - } - - // build request body - body := privatelink.PrivateLinkConnection{ - ClusterId: clusterID, - } - - if displayName == "" { - return errors.New("display name is required") - } - body.DisplayName = displayName - - switch connectionType { - case privatelink.PRIVATELINKCONNECTIONTYPEENUM_AWS_ENDPOINT_SERVICE: - if awsEndpointServiceName == "" { - return errors.New("aws endpoint service name is required for aws endpoint service type") - } - body.Type = privatelink.PRIVATELINKCONNECTIONTYPEENUM_AWS_ENDPOINT_SERVICE - var region *string - if AWSEndpointServiceRegion != "" { - region = &AWSEndpointServiceRegion - } - body.AwsEndpointService = &privatelink.AwsEndpointService{ - Name: awsEndpointServiceName, - Region: region, - } - case privatelink.PRIVATELINKCONNECTIONTYPEENUM_ALICLOUD_ENDPOINT_SERVICE: - if alicloudEndpointServiceName == "" { - return errors.New("alicloud endpoint service name is required for alicloud endpoint service type") - } - body.Type = privatelink.PRIVATELINKCONNECTIONTYPEENUM_ALICLOUD_ENDPOINT_SERVICE - body.AlicloudEndpointService = &privatelink.AlicloudEndpointService{ - Name: alicloudEndpointServiceName, - } - default: - return errors.Errorf("unsupported private link connection type: %s", connectionType) - } - - res, err := d.CreatePrivateLinkConnection(ctx, - clusterID, - &privatelink.PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody{ - PrivateLinkConnection: body, - }, - ) - if err != nil { - return errors.Trace(err) - } - _, err = fmt.Fprintln(h.IOStreams.Out, color.GreenString("Private link connection %s created", *res.PrivateLinkConnectionId)) - if err != nil { - return err - } - return nil - }, - } - - cmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The cluster ID.") - cmd.Flags().String(flag.DisplayName, "", "Display name for the private link connection.") - cmd.Flags().String(flag.PrivateLinkConnectionType, "", fmt.Sprintf("Type of the private link connection, one of %q", privatelink.AllowedPrivateLinkConnectionTypeEnumEnumValues)) - cmd.Flags().String(flag.AWSEndpointServiceName, "", "AWS endpoint service name.") - cmd.Flags().String(flag.AlicloudEndpointServiceName, "", "Alicloud endpoint service name.") - cmd.Flags().String(flag.AWSEndpointServiceRegion, "", "AWS endpoint service region.") - return cmd -} diff --git a/internal/cli/serverless/privatelink/delete.go b/internal/cli/serverless/privatelink/delete.go deleted file mode 100644 index 230e2e74..00000000 --- a/internal/cli/serverless/privatelink/delete.go +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2026 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 privatelink - -import ( - "fmt" - - "github.com/AlecAivazis/survey/v2" - "github.com/fatih/color" - "github.com/juju/errors" - "github.com/spf13/cobra" - - "github.com/tidbcloud/tidbcloud-cli/internal" - "github.com/tidbcloud/tidbcloud-cli/internal/config" - "github.com/tidbcloud/tidbcloud-cli/internal/flag" - "github.com/tidbcloud/tidbcloud-cli/internal/service/cloud" -) - -type DeleteOpts struct { - interactive bool -} - -func (o DeleteOpts) NonInteractiveFlags() []string { - return []string{ - flag.ClusterID, - flag.PrivateLinkConnectionID, - flag.Force, - } -} - -func (o *DeleteOpts) MarkInteractive(cmd *cobra.Command) error { - o.interactive = true - for _, fn := range o.NonInteractiveFlags() { - if f := cmd.Flags().Lookup(fn); f != nil && f.Changed { - o.interactive = false - } - } - if !o.interactive { - // require cluster-id and plc-id in non-interactive mode - for _, fn := range []string{flag.ClusterID, flag.PrivateLinkConnectionID} { - if err := cmd.MarkFlagRequired(fn); err != nil { - return err - } - } - } - return nil -} - -func DeleteCmd(h *internal.Helper) *cobra.Command { - opts := &DeleteOpts{interactive: true} - var force bool - - cmd := &cobra.Command{ - Use: "delete", - Aliases: []string{"rm"}, - Short: "Delete a private link connection for dataflow", - Args: cobra.NoArgs, - Example: fmt.Sprintf(` Delete a private link connection (interactive): - $ %[1]s serverless private-link-connection delete - - Delete a private link connection (non-interactive): - $ %[1]s serverless private-link-connection delete -c --private-link-connection-id `, config.CliName), - PreRunE: func(cmd *cobra.Command, args []string) error { - return opts.MarkInteractive(cmd) - }, - RunE: func(cmd *cobra.Command, args []string) error { - d, err := h.Client() - if err != nil { - return err - } - ctx := cmd.Context() - - var clusterID, plcID string - if opts.interactive { - if !h.IOStreams.CanPrompt { - return errors.New("The terminal doesn't support interactive mode, please use non-interactive mode") - } - project, err := cloud.GetSelectedProject(ctx, h.QueryPageSize, d) - if err != nil { - return err - } - cluster, err := cloud.GetSelectedCluster(ctx, project.ID, h.QueryPageSize, d) - if err != nil { - return err - } - clusterID = cluster.ID - privatelink, err := cloud.GetSelectedPrivateLinkConnection(ctx, cluster.ID, int32(h.QueryPageSize), d) - if err != nil { - return err - } - plcID = privatelink.ID - } else { - var err error - clusterID, err = cmd.Flags().GetString(flag.ClusterID) - if err != nil { - return errors.Trace(err) - } - plcID, err = cmd.Flags().GetString(flag.PrivateLinkConnectionID) - if err != nil { - return errors.Trace(err) - } - force, err = cmd.Flags().GetBool(flag.Force) - if err != nil { - return errors.Trace(err) - } - } - - if plcID == "" { - return errors.New("private link connection id is required") - } - - if !force { - if !h.IOStreams.CanPrompt { - return errors.New("The terminal doesn't support prompt, run with --force to skip confirmation") - } - var confirm string - if err := survey.AskOne(&survey.Input{Message: "Type 'yes' to confirm deletion:"}, &confirm); err != nil { - return err - } - if confirm != "yes" { - return errors.New("deletion cancelled") - } - } - - _, err = d.DeletePrivateLinkConnection(ctx, clusterID, plcID) - if err != nil { - return errors.Trace(err) - } - fmt.Fprintln(h.IOStreams.Out, color.GreenString("Private link connection deleted")) - return nil - }, - } - - cmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The cluster ID.") - cmd.Flags().String(flag.PrivateLinkConnectionID, "", "The private link connection ID.") - cmd.Flags().BoolVar(&force, flag.Force, false, "Delete without confirmation.") - return cmd -} diff --git a/internal/cli/serverless/privatelink/describe.go b/internal/cli/serverless/privatelink/describe.go deleted file mode 100644 index f44e7c0f..00000000 --- a/internal/cli/serverless/privatelink/describe.go +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2026 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 privatelink - -import ( - "fmt" - - "github.com/juju/errors" - "github.com/spf13/cobra" - - "github.com/tidbcloud/tidbcloud-cli/internal" - "github.com/tidbcloud/tidbcloud-cli/internal/config" - "github.com/tidbcloud/tidbcloud-cli/internal/flag" - "github.com/tidbcloud/tidbcloud-cli/internal/output" - "github.com/tidbcloud/tidbcloud-cli/internal/service/cloud" -) - -type DescribeOpts struct { - interactive bool -} - -func (o DescribeOpts) NonInteractiveFlags() []string { - return []string{ - flag.ClusterID, - flag.PrivateLinkConnectionID, - } -} - -func (o *DescribeOpts) MarkInteractive(cmd *cobra.Command) error { - o.interactive = true - for _, fn := range o.NonInteractiveFlags() { - if f := cmd.Flags().Lookup(fn); f != nil && f.Changed { - o.interactive = false - } - } - if !o.interactive { - for _, fn := range o.NonInteractiveFlags() { - if err := cmd.MarkFlagRequired(fn); err != nil { - return err - } - } - } - return nil -} - -func DescribeCmd(h *internal.Helper) *cobra.Command { - opts := &DescribeOpts{interactive: true} - - cmd := &cobra.Command{ - Use: "describe", - Aliases: []string{"get"}, - Short: "Describe a private link connection for dataflow", - Args: cobra.NoArgs, - Example: fmt.Sprintf(` Describe a private link connection (interactive): - $ %[1]s serverless private-link-connection describe - - Describe a private link connection (non-interactive): - $ %[1]s serverless private-link-connection describe -c --private-link-connection-id `, config.CliName), - PreRunE: func(cmd *cobra.Command, args []string) error { - return opts.MarkInteractive(cmd) - }, - RunE: func(cmd *cobra.Command, args []string) error { - d, err := h.Client() - if err != nil { - return err - } - ctx := cmd.Context() - - var clusterID, plcID string - if opts.interactive { - if !h.IOStreams.CanPrompt { - return errors.New("The terminal doesn't support interactive mode, please use non-interactive mode") - } - project, err := cloud.GetSelectedProject(ctx, h.QueryPageSize, d) - if err != nil { - return err - } - cluster, err := cloud.GetSelectedCluster(ctx, project.ID, h.QueryPageSize, d) - if err != nil { - return err - } - clusterID = cluster.ID - privatelink, err := cloud.GetSelectedPrivateLinkConnection(ctx, cluster.ID, int32(h.QueryPageSize), d) - if err != nil { - return err - } - plcID = privatelink.ID - } else { - var err error - clusterID, err = cmd.Flags().GetString(flag.ClusterID) - if err != nil { - return errors.Trace(err) - } - plcID, err = cmd.Flags().GetString(flag.PrivateLinkConnectionID) - if err != nil { - return errors.Trace(err) - } - } - - if plcID == "" { - return errors.New("private link connection id is required") - } - - res, err := d.GetPrivateLinkConnection(ctx, clusterID, plcID) - if err != nil { - return errors.Trace(err) - } - return output.PrintJson(h.IOStreams.Out, res) - }, - } - - cmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The cluster ID.") - cmd.Flags().String(flag.PrivateLinkConnectionID, "", "The private link connection ID.") - return cmd -} diff --git a/internal/cli/serverless/privatelink/detach.go b/internal/cli/serverless/privatelink/detach.go deleted file mode 100644 index 5570ed34..00000000 --- a/internal/cli/serverless/privatelink/detach.go +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright 2026 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 privatelink - -import ( - "fmt" - "strings" - - "github.com/fatih/color" - "github.com/juju/errors" - "github.com/spf13/cobra" - - "github.com/tidbcloud/tidbcloud-cli/internal" - "github.com/tidbcloud/tidbcloud-cli/internal/config" - "github.com/tidbcloud/tidbcloud-cli/internal/flag" - "github.com/tidbcloud/tidbcloud-cli/internal/service/cloud" - plapi "github.com/tidbcloud/tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/privatelink" -) - -type DetachDomainOpts struct { - interactive bool -} - -func (o DetachDomainOpts) NonInteractiveFlags() []string { - return []string{ - flag.ClusterID, - flag.PrivateLinkConnectionID, - flag.PLCAttachDomainID, - } -} - -func (o *DetachDomainOpts) MarkInteractive(cmd *cobra.Command) error { - o.interactive = true - for _, fn := range o.NonInteractiveFlags() { - if f := cmd.Flags().Lookup(fn); f != nil && f.Changed { - o.interactive = false - } - } - if !o.interactive { - for _, fn := range o.NonInteractiveFlags() { - if err := cmd.MarkFlagRequired(fn); err != nil { - return err - } - } - } - return nil -} - -func DetachDomainCmd(h *internal.Helper) *cobra.Command { - opts := &DetachDomainOpts{interactive: true} - - cmd := &cobra.Command{ - Use: "detach-domains", - Short: "Detach domains from a private link connection", - Args: cobra.NoArgs, - Example: fmt.Sprintf(` Detach domains (interactive): - $ %[1]s serverless private-link-connection detach - - Detach domains (non-interactive): - $ %[1]s serverless private-link-connection detach-domains -c --private-link-connection-id --attach-domain-id `, config.CliName), - PreRunE: func(cmd *cobra.Command, args []string) error { - return opts.MarkInteractive(cmd) - }, - RunE: func(cmd *cobra.Command, args []string) error { - d, err := h.Client() - if err != nil { - return err - } - ctx := cmd.Context() - - var clusterID, plcID, attachID string - if opts.interactive { - if !h.IOStreams.CanPrompt { - return errors.New("The terminal doesn't support interactive mode, please use non-interactive mode") - } - project, err := cloud.GetSelectedProject(ctx, h.QueryPageSize, d) - if err != nil { - return err - } - cluster, err := cloud.GetSelectedCluster(ctx, project.ID, h.QueryPageSize, d) - if err != nil { - return err - } - clusterID = cluster.ID - privatelink, err := cloud.GetSelectedPrivateLinkConnection(ctx, cluster.ID, int32(h.QueryPageSize), d) - if err != nil { - return err - } - plcID = privatelink.ID - attach, err := cloud.GetSelectedAttachDomain(ctx, cluster.ID, privatelink.ID, d) - if err != nil { - return err - } - attachID = attach.ID - } else { - var err error - clusterID, err = cmd.Flags().GetString(flag.ClusterID) - if err != nil { - return errors.Trace(err) - } - plcID, err = cmd.Flags().GetString(flag.PrivateLinkConnectionID) - if err != nil { - return errors.Trace(err) - } - attachID, err = cmd.Flags().GetString(flag.PLCAttachDomainID) - if err != nil { - return errors.Trace(err) - } - } - - body := &plapi.PrivateLinkConnectionServiceDetachDomainsBody{ - AttachDomainId: attachID, - } - resp, err := d.DetachPrivateLinkDomains(ctx, clusterID, plcID, body) - if err != nil { - return errors.Trace(err) - } - domains := make([]string, 0, len(resp.Domains)) - for _, domain := range resp.Domains { - domains = append(domains, *domain.Name) - } - fmt.Fprintf(h.IOStreams.Out, "Successfully detached domains:\n%s\n", color.GreenString("%v", strings.Join(domains, "\n"))) - return nil - }, - } - - cmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The cluster ID.") - cmd.Flags().String(flag.PrivateLinkConnectionID, "", "The private link connection ID.") - cmd.Flags().String(flag.PLCAttachDomainID, "", "The private link connection attach domain ID.") - return cmd -} diff --git a/internal/cli/serverless/privatelink/list.go b/internal/cli/serverless/privatelink/list.go deleted file mode 100644 index 2388fee3..00000000 --- a/internal/cli/serverless/privatelink/list.go +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright 2026 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 privatelink - -import ( - "fmt" - "time" - - "github.com/juju/errors" - "github.com/spf13/cobra" - - "github.com/tidbcloud/tidbcloud-cli/internal" - "github.com/tidbcloud/tidbcloud-cli/internal/config" - "github.com/tidbcloud/tidbcloud-cli/internal/flag" - "github.com/tidbcloud/tidbcloud-cli/internal/output" - "github.com/tidbcloud/tidbcloud-cli/internal/service/cloud" -) - -type ListOpts struct { - interactive bool -} - -func (o ListOpts) NonInteractiveFlags() []string { - return []string{ - flag.ClusterID, - } -} - -func (o *ListOpts) MarkInteractive(cmd *cobra.Command) error { - o.interactive = true - for _, fn := range o.NonInteractiveFlags() { - if f := cmd.Flags().Lookup(fn); f != nil && f.Changed { - o.interactive = false - } - } - if !o.interactive { - for _, fn := range o.NonInteractiveFlags() { - if err := cmd.MarkFlagRequired(fn); err != nil { - return err - } - } - } - return nil -} - -func ListCmd(h *internal.Helper) *cobra.Command { - opts := &ListOpts{interactive: true} - - cmd := &cobra.Command{ - Use: "list", - Aliases: []string{"list"}, - Short: "List private link connections for dataflow", - Args: cobra.NoArgs, - Example: fmt.Sprintf(` List private link connections (interactive): - $ %[1]s serverless private-link-connection list - - Describe a private link connection (non-interactive): - $ %[1]s serverless private-link-connection list -c `, config.CliName), - PreRunE: func(cmd *cobra.Command, args []string) error { - return opts.MarkInteractive(cmd) - }, - RunE: func(cmd *cobra.Command, args []string) error { - d, err := h.Client() - if err != nil { - return err - } - ctx := cmd.Context() - - var clusterID string - if opts.interactive { - if !h.IOStreams.CanPrompt { - return errors.New("The terminal doesn't support interactive mode, please use non-interactive mode") - } - project, err := cloud.GetSelectedProject(ctx, h.QueryPageSize, d) - if err != nil { - return err - } - cluster, err := cloud.GetSelectedCluster(ctx, project.ID, h.QueryPageSize, d) - if err != nil { - return err - } - clusterID = cluster.ID - } else { - var err error - clusterID, err = cmd.Flags().GetString(flag.ClusterID) - if err != nil { - return errors.Trace(err) - } - } - - format, err := cmd.Flags().GetString(flag.Output) - if err != nil { - return errors.Trace(err) - } - - pageSize := int32(h.QueryPageSize) - resp, err := d.ListPrivateLinkConnections(ctx, clusterID, &pageSize, nil) - if err != nil { - return errors.Trace(err) - } - - if format == output.JsonFormat || !h.IOStreams.CanPrompt { - err := output.PrintJson(h.IOStreams.Out, resp) - if err != nil { - return errors.Trace(err) - } - } else if format == output.HumanFormat { - columns := []output.Column{ - "ID", - "Name", - "Type", - "State", - "CreateTime", - } - var rows []output.Row - for _, item := range resp.PrivateLinkConnections { - rows = append(rows, output.Row{ - *item.PrivateLinkConnectionId, - item.DisplayName, - string(item.Type), - string(*item.State), - item.CreateTime.Format(time.RFC3339), - }) - } - err := output.PrintHumanTable(h.IOStreams.Out, columns, rows) - if err != nil { - return errors.Trace(err) - } - return nil - } else { - return fmt.Errorf("unsupported output format: %s", format) - } - return nil - }, - } - - cmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The cluster ID.") - cmd.Flags().StringP(flag.Output, flag.OutputShort, output.HumanFormat, flag.OutputHelp) - - return cmd -} diff --git a/internal/cli/serverless/privatelink/privatelink.go b/internal/cli/serverless/privatelink/privatelink.go deleted file mode 100644 index 47584b89..00000000 --- a/internal/cli/serverless/privatelink/privatelink.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2026 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 privatelink - -import ( - "github.com/spf13/cobra" - - "github.com/tidbcloud/tidbcloud-cli/internal" -) - -func PrivateLinkConnectionCmd(h *internal.Helper) *cobra.Command { - cmd := &cobra.Command{ - Use: "private-link-connection", - Aliases: []string{"plc", "private-link"}, - Short: "Manage private link connections for dataflow", - } - - cmd.AddCommand( - CreateCmd(h), - DescribeCmd(h), - DeleteCmd(h), - ListCmd(h), - GetZonesCmd(h), - AttachDomainCmd(h), - DetachDomainCmd(h), - ) - - return cmd -} diff --git a/internal/cli/serverless/privatelink/ui.go b/internal/cli/serverless/privatelink/ui.go deleted file mode 100644 index 02ff833f..00000000 --- a/internal/cli/serverless/privatelink/ui.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2026 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 privatelink - -import ( - tea "github.com/charmbracelet/bubbletea" - "github.com/juju/errors" - "github.com/tidbcloud/tidbcloud-cli/internal/ui" - "github.com/tidbcloud/tidbcloud-cli/internal/util" - "github.com/tidbcloud/tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/privatelink" -) - -const ( - DisplayNamePrompt = "Input the display name:" - AWSEndpointServiceNamePrompt = "Input the AWS endpoint service name:" - AlicloudEndpointServiceNamePrompt = "Input the Alicloud endpoint service name:" - AWSEndpointServiceRegionPrompt = "Input the AWS endpoint service region:" - AWSEndpointServiceRegionConfirmPrompt = "Is the endpoint service cross region?" -) - -func GetSelectedPrivateLinkConnectionType() (privatelink.PrivateLinkConnectionTypeEnum, error) { - types := make([]interface{}, 0, len(privatelink.AllowedPrivateLinkConnectionTypeEnumEnumValues)) - for _, v := range privatelink.AllowedPrivateLinkConnectionTypeEnumEnumValues { - types = append(types, v) - } - selectModel, err := ui.InitialSelectModel(types, "Choose the private link connection type:") - if err != nil { - return "", errors.Trace(err) - } - p := tea.NewProgram(selectModel) - model, err := p.Run() - if err != nil { - return "", errors.Trace(err) - } - if m, _ := model.(ui.SelectModel); m.Interrupted { - return "", util.InterruptError - } - - resp := model.(ui.SelectModel).GetSelectedItem() - if resp == nil { - return "", errors.New("no private link connection type selected") - } - return resp.(privatelink.PrivateLinkConnectionTypeEnum), nil -} - -func GetSelectedPLCAttachDomainType() (privatelink.PrivateLinkConnectionDomainTypeEnum, error) { - types := make([]interface{}, 0, len(privatelink.AllowedPrivateLinkConnectionDomainTypeEnumEnumValues)) - for _, v := range privatelink.AllowedPrivateLinkConnectionDomainTypeEnumEnumValues { - types = append(types, v) - } - selectModel, err := ui.InitialSelectModel(types, "Choose the private link connection domain type:") - if err != nil { - return "", errors.Trace(err) - } - p := tea.NewProgram(selectModel) - model, err := p.Run() - if err != nil { - return "", errors.Trace(err) - } - if m, _ := model.(ui.SelectModel); m.Interrupted { - return "", util.InterruptError - } - - resp := model.(ui.SelectModel).GetSelectedItem() - if resp == nil { - return "", errors.New("no private link connection domain type selected") - } - return resp.(privatelink.PrivateLinkConnectionDomainTypeEnum), nil -} diff --git a/internal/cli/serverless/privatelink/zone.go b/internal/cli/serverless/privatelink/zone.go deleted file mode 100644 index 5af72223..00000000 --- a/internal/cli/serverless/privatelink/zone.go +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2026 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 privatelink - -import ( - "fmt" - - "github.com/juju/errors" - "github.com/spf13/cobra" - - "github.com/tidbcloud/tidbcloud-cli/internal" - "github.com/tidbcloud/tidbcloud-cli/internal/config" - "github.com/tidbcloud/tidbcloud-cli/internal/flag" - "github.com/tidbcloud/tidbcloud-cli/internal/output" - "github.com/tidbcloud/tidbcloud-cli/internal/service/cloud" -) - -type GetZonesOpts struct { - interactive bool -} - -func (o GetZonesOpts) NonInteractiveFlags() []string { - return []string{ - flag.ClusterID, - } -} - -func (o *GetZonesOpts) MarkInteractive(cmd *cobra.Command) error { - o.interactive = true - for _, fn := range o.NonInteractiveFlags() { - if f := cmd.Flags().Lookup(fn); f != nil && f.Changed { - o.interactive = false - } - } - if !o.interactive { - for _, fn := range o.NonInteractiveFlags() { - if err := cmd.MarkFlagRequired(fn); err != nil { - return err - } - } - } - return nil -} - -func GetZonesCmd(h *internal.Helper) *cobra.Command { - opts := &GetZonesOpts{interactive: true} - - cmd := &cobra.Command{ - Use: "zones", - Short: "Get account and availability zones", - Args: cobra.NoArgs, - Example: fmt.Sprintf(` Get availability zones (interactive): - $ %[1]s serverless private-link-connection get-zones - - Get availability zones (non-interactive): - $ %[1]s serverless private-link-connection zones -c `, config.CliName), - PreRunE: func(cmd *cobra.Command, args []string) error { - return opts.MarkInteractive(cmd) - }, - RunE: func(cmd *cobra.Command, args []string) error { - d, err := h.Client() - if err != nil { - return err - } - ctx := cmd.Context() - - var clusterID string - if opts.interactive { - project, err := cloud.GetSelectedProject(ctx, h.QueryPageSize, d) - if err != nil { - return err - } - cluster, err := cloud.GetSelectedCluster(ctx, project.ID, h.QueryPageSize, d) - if err != nil { - return err - } - clusterID = cluster.ID - } else { - var err error - clusterID, err = cmd.Flags().GetString(flag.ClusterID) - if err != nil { - return errors.Trace(err) - } - } - - resp, err := d.GetPrivateLinkAvailabilityZones(ctx, clusterID) - if err != nil { - return errors.Trace(err) - } - return output.PrintJson(h.IOStreams.Out, resp) - }, - } - - cmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The cluster ID.") - return cmd -} diff --git a/internal/mock/api_client.go b/internal/mock/api_client.go index c90d0790..61fcb2c0 100644 --- a/internal/mock/api_client.go +++ b/internal/mock/api_client.go @@ -23,8 +23,6 @@ import ( migration "github.com/tidbcloud/tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/migration" mock "github.com/stretchr/testify/mock" - - privatelink "github.com/tidbcloud/tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/privatelink" ) // TiDBCloudClient is an autogenerated mock type for the TiDBCloudClient type @@ -32,36 +30,6 @@ type TiDBCloudClient struct { mock.Mock } -// AttachPrivateLinkDomains provides a mock function with given fields: ctx, clusterId, privateLinkConnectionId, body -func (_m *TiDBCloudClient) AttachPrivateLinkDomains(ctx context.Context, clusterId string, privateLinkConnectionId string, body *privatelink.PrivateLinkConnectionServiceAttachDomainsBody) (*privatelink.AttachDomain, error) { - ret := _m.Called(ctx, clusterId, privateLinkConnectionId, body) - - if len(ret) == 0 { - panic("no return value specified for AttachPrivateLinkDomains") - } - - var r0 *privatelink.AttachDomain - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, *privatelink.PrivateLinkConnectionServiceAttachDomainsBody) (*privatelink.AttachDomain, error)); ok { - return rf(ctx, clusterId, privateLinkConnectionId, body) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, *privatelink.PrivateLinkConnectionServiceAttachDomainsBody) *privatelink.AttachDomain); ok { - r0 = rf(ctx, clusterId, privateLinkConnectionId, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*privatelink.AttachDomain) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, *privatelink.PrivateLinkConnectionServiceAttachDomainsBody) error); ok { - r1 = rf(ctx, clusterId, privateLinkConnectionId, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // CancelExport provides a mock function with given fields: ctx, clusterId, exportId func (_m *TiDBCloudClient) CancelExport(ctx context.Context, clusterId string, exportId string) (*export.Export, error) { ret := _m.Called(ctx, clusterId, exportId) @@ -404,36 +372,6 @@ func (_m *TiDBCloudClient) CreateMigrationPrecheck(ctx context.Context, clusterI return r0, r1 } -// CreatePrivateLinkConnection provides a mock function with given fields: ctx, clusterId, body -func (_m *TiDBCloudClient) CreatePrivateLinkConnection(ctx context.Context, clusterId string, body *privatelink.PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) (*privatelink.PrivateLinkConnection, error) { - ret := _m.Called(ctx, clusterId, body) - - if len(ret) == 0 { - panic("no return value specified for CreatePrivateLinkConnection") - } - - var r0 *privatelink.PrivateLinkConnection - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, *privatelink.PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) (*privatelink.PrivateLinkConnection, error)); ok { - return rf(ctx, clusterId, body) - } - if rf, ok := ret.Get(0).(func(context.Context, string, *privatelink.PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) *privatelink.PrivateLinkConnection); ok { - r0 = rf(ctx, clusterId, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*privatelink.PrivateLinkConnection) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, *privatelink.PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) error); ok { - r1 = rf(ctx, clusterId, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // CreateSQLUser provides a mock function with given fields: ctx, clusterID, body func (_m *TiDBCloudClient) CreateSQLUser(ctx context.Context, clusterID string, body *iam.ApiCreateSqlUserReq) (*iam.ApiSqlUser, error) { ret := _m.Called(ctx, clusterID, body) @@ -674,36 +612,6 @@ func (_m *TiDBCloudClient) DeleteMigration(ctx context.Context, clusterId string return r0, r1 } -// DeletePrivateLinkConnection provides a mock function with given fields: ctx, clusterId, privateLinkConnectionId -func (_m *TiDBCloudClient) DeletePrivateLinkConnection(ctx context.Context, clusterId string, privateLinkConnectionId string) (*privatelink.PrivateLinkConnection, error) { - ret := _m.Called(ctx, clusterId, privateLinkConnectionId) - - if len(ret) == 0 { - panic("no return value specified for DeletePrivateLinkConnection") - } - - var r0 *privatelink.PrivateLinkConnection - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (*privatelink.PrivateLinkConnection, error)); ok { - return rf(ctx, clusterId, privateLinkConnectionId) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string) *privatelink.PrivateLinkConnection); ok { - r0 = rf(ctx, clusterId, privateLinkConnectionId) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*privatelink.PrivateLinkConnection) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { - r1 = rf(ctx, clusterId, privateLinkConnectionId) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // DeleteSQLUser provides a mock function with given fields: ctx, clusterID, userName func (_m *TiDBCloudClient) DeleteSQLUser(ctx context.Context, clusterID string, userName string) (*iam.ApiBasicResp, error) { ret := _m.Called(ctx, clusterID, userName) @@ -764,36 +672,6 @@ func (_m *TiDBCloudClient) DescribeSchemaTable(ctx context.Context, clusterId st return r0, r1 } -// DetachPrivateLinkDomains provides a mock function with given fields: ctx, clusterId, privateLinkConnectionId, body -func (_m *TiDBCloudClient) DetachPrivateLinkDomains(ctx context.Context, clusterId string, privateLinkConnectionId string, body *privatelink.PrivateLinkConnectionServiceDetachDomainsBody) (*privatelink.AttachDomain, error) { - ret := _m.Called(ctx, clusterId, privateLinkConnectionId, body) - - if len(ret) == 0 { - panic("no return value specified for DetachPrivateLinkDomains") - } - - var r0 *privatelink.AttachDomain - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, *privatelink.PrivateLinkConnectionServiceDetachDomainsBody) (*privatelink.AttachDomain, error)); ok { - return rf(ctx, clusterId, privateLinkConnectionId, body) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, *privatelink.PrivateLinkConnectionServiceDetachDomainsBody) *privatelink.AttachDomain); ok { - r0 = rf(ctx, clusterId, privateLinkConnectionId, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*privatelink.AttachDomain) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, *privatelink.PrivateLinkConnectionServiceDetachDomainsBody) error); ok { - r1 = rf(ctx, clusterId, privateLinkConnectionId, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // DownloadAuditLogs provides a mock function with given fields: ctx, clusterID, body func (_m *TiDBCloudClient) DownloadAuditLogs(ctx context.Context, clusterID string, body *auditlog.DatabaseAuditLogServiceDownloadAuditLogFilesBody) (*auditlog.DownloadAuditLogFilesResponse, error) { ret := _m.Called(ctx, clusterID, body) @@ -1184,66 +1062,6 @@ func (_m *TiDBCloudClient) GetMigrationPrecheck(ctx context.Context, clusterId s return r0, r1 } -// GetPrivateLinkAvailabilityZones provides a mock function with given fields: ctx, clusterId -func (_m *TiDBCloudClient) GetPrivateLinkAvailabilityZones(ctx context.Context, clusterId string) (*privatelink.GetAvailabilityZonesResponse, error) { - ret := _m.Called(ctx, clusterId) - - if len(ret) == 0 { - panic("no return value specified for GetPrivateLinkAvailabilityZones") - } - - var r0 *privatelink.GetAvailabilityZonesResponse - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (*privatelink.GetAvailabilityZonesResponse, error)); ok { - return rf(ctx, clusterId) - } - if rf, ok := ret.Get(0).(func(context.Context, string) *privatelink.GetAvailabilityZonesResponse); ok { - r0 = rf(ctx, clusterId) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*privatelink.GetAvailabilityZonesResponse) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, clusterId) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetPrivateLinkConnection provides a mock function with given fields: ctx, clusterId, privateLinkConnectionId -func (_m *TiDBCloudClient) GetPrivateLinkConnection(ctx context.Context, clusterId string, privateLinkConnectionId string) (*privatelink.PrivateLinkConnection, error) { - ret := _m.Called(ctx, clusterId, privateLinkConnectionId) - - if len(ret) == 0 { - panic("no return value specified for GetPrivateLinkConnection") - } - - var r0 *privatelink.PrivateLinkConnection - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (*privatelink.PrivateLinkConnection, error)); ok { - return rf(ctx, clusterId, privateLinkConnectionId) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string) *privatelink.PrivateLinkConnection); ok { - r0 = rf(ctx, clusterId, privateLinkConnectionId) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*privatelink.PrivateLinkConnection) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { - r1 = rf(ctx, clusterId, privateLinkConnectionId) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // GetSQLUser provides a mock function with given fields: ctx, clusterID, userName func (_m *TiDBCloudClient) GetSQLUser(ctx context.Context, clusterID string, userName string) (*iam.ApiSqlUser, error) { ret := _m.Called(ctx, clusterID, userName) @@ -1574,36 +1392,6 @@ func (_m *TiDBCloudClient) ListMigrations(ctx context.Context, clusterId string, return r0, r1 } -// ListPrivateLinkConnections provides a mock function with given fields: ctx, clusterId, pageSize, pageToken -func (_m *TiDBCloudClient) ListPrivateLinkConnections(ctx context.Context, clusterId string, pageSize *int32, pageToken *string) (*privatelink.ListPrivateLinkConnectionsResponse, error) { - ret := _m.Called(ctx, clusterId, pageSize, pageToken) - - if len(ret) == 0 { - panic("no return value specified for ListPrivateLinkConnections") - } - - var r0 *privatelink.ListPrivateLinkConnectionsResponse - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, *int32, *string) (*privatelink.ListPrivateLinkConnectionsResponse, error)); ok { - return rf(ctx, clusterId, pageSize, pageToken) - } - if rf, ok := ret.Get(0).(func(context.Context, string, *int32, *string) *privatelink.ListPrivateLinkConnectionsResponse); ok { - r0 = rf(ctx, clusterId, pageSize, pageToken) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*privatelink.ListPrivateLinkConnectionsResponse) - } - } - - 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) - } - - return r0, r1 -} - // ListProjects provides a mock function with given fields: ctx, pageSize, pageToken func (_m *TiDBCloudClient) ListProjects(ctx context.Context, pageSize *int32, pageToken *string) (*iam.ApiListProjectsRsp, error) { ret := _m.Called(ctx, pageSize, pageToken) diff --git a/internal/service/cloud/api_client.go b/internal/service/cloud/api_client.go index 760aba20..a09b7206 100644 --- a/internal/service/cloud/api_client.go +++ b/internal/service/cloud/api_client.go @@ -35,7 +35,6 @@ import ( "github.com/tidbcloud/tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/export" "github.com/tidbcloud/tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/imp" "github.com/tidbcloud/tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/migration" - "github.com/tidbcloud/tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/privatelink" "github.com/icholy/digest" ) @@ -162,15 +161,6 @@ type TiDBCloudClient interface { UpdateAuditLogConfig(ctx context.Context, clusterID string, body *auditlog.DatabaseAuditLogServiceUpdateAuditLogConfigBody) (*auditlog.AuditLogConfig, error) GetAuditLogConfig(ctx context.Context, clusterID string) (*auditlog.AuditLogConfig, error) - // ===== Private Link Connection ===== - CreatePrivateLinkConnection(ctx context.Context, clusterId string, body *privatelink.PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) (*privatelink.PrivateLinkConnection, error) - DeletePrivateLinkConnection(ctx context.Context, clusterId string, privateLinkConnectionId string) (*privatelink.PrivateLinkConnection, error) - GetPrivateLinkConnection(ctx context.Context, clusterId string, privateLinkConnectionId string) (*privatelink.PrivateLinkConnection, error) - ListPrivateLinkConnections(ctx context.Context, clusterId string, pageSize *int32, pageToken *string) (*privatelink.ListPrivateLinkConnectionsResponse, error) - GetPrivateLinkAvailabilityZones(ctx context.Context, clusterId string) (*privatelink.GetAvailabilityZonesResponse, error) - AttachPrivateLinkDomains(ctx context.Context, clusterId string, privateLinkConnectionId string, body *privatelink.PrivateLinkConnectionServiceAttachDomainsBody) (*privatelink.AttachDomain, error) - DetachPrivateLinkDomains(ctx context.Context, clusterId string, privateLinkConnectionId string, body *privatelink.PrivateLinkConnectionServiceDetachDomainsBody) (*privatelink.AttachDomain, error) - // ===== Private Link Connection ===== } type ClientDelegate struct { @@ -182,13 +172,12 @@ type ClientDelegate struct { ec *export.APIClient alc *auditlog.APIClient cdc *cdc.APIClient - plc *privatelink.APIClient mc *migration.APIClient } func NewClientDelegateWithToken(token string, serverlessEndpoint string, iamEndpoint string) (*ClientDelegate, error) { transport := NewBearTokenTransport(token) - bc, sc, brc, sic, ec, ic, alc, cdc, plc, mc, err := NewApiClient(transport, serverlessEndpoint, iamEndpoint) + bc, sc, brc, sic, ec, ic, alc, cdc, mc, err := NewApiClient(transport, serverlessEndpoint, iamEndpoint) if err != nil { return nil, err } @@ -201,14 +190,13 @@ func NewClientDelegateWithToken(token string, serverlessEndpoint string, iamEndp sic: sic, alc: alc, cdc: cdc, - plc: plc, mc: mc, }, nil } func NewClientDelegateWithApiKey(publicKey string, privateKey string, serverlessEndpoint string, iamEndpoint string) (*ClientDelegate, error) { transport := NewDigestTransport(publicKey, privateKey) - bc, sc, brc, sic, ec, ic, alc, cdc, plc, mc, err := NewApiClient(transport, serverlessEndpoint, iamEndpoint) + bc, sc, brc, sic, ec, ic, alc, cdc, mc, err := NewApiClient(transport, serverlessEndpoint, iamEndpoint) if err != nil { return nil, err } @@ -221,7 +209,6 @@ func NewClientDelegateWithApiKey(publicKey string, privateKey string, serverless sic: sic, alc: alc, cdc: cdc, - plc: plc, mc: mc, }, nil } @@ -681,64 +668,7 @@ func (d *ClientDelegate) GetAuditLogConfig(ctx context.Context, clusterID string return res, parseError(err, h) } -// ===== Private Link Connection ===== -func (d *ClientDelegate) CreatePrivateLinkConnection(ctx context.Context, clusterId string, body *privatelink.PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) (*privatelink.PrivateLinkConnection, error) { - r := d.plc.PrivateLinkConnectionServiceAPI.PrivateLinkConnectionServiceCreatePrivateLinkConnection(ctx, clusterId) - if body != nil { - r = r.Body(*body) - } - res, h, err := r.Execute() - return res, parseError(err, h) -} - -func (d *ClientDelegate) DeletePrivateLinkConnection(ctx context.Context, clusterId string, privateLinkConnectionId string) (*privatelink.PrivateLinkConnection, error) { - res, h, err := d.plc.PrivateLinkConnectionServiceAPI.PrivateLinkConnectionServiceDeletePrivateLinkConnection(ctx, clusterId, privateLinkConnectionId).Execute() - return res, parseError(err, h) -} - -func (d *ClientDelegate) GetPrivateLinkConnection(ctx context.Context, clusterId string, privateLinkConnectionId string) (*privatelink.PrivateLinkConnection, error) { - res, h, err := d.plc.PrivateLinkConnectionServiceAPI.PrivateLinkConnectionServiceGetPrivateLinkConnection(ctx, clusterId, privateLinkConnectionId).Execute() - return res, parseError(err, h) -} - -func (d *ClientDelegate) ListPrivateLinkConnections(ctx context.Context, clusterId string, pageSize *int32, pageToken *string) (*privatelink.ListPrivateLinkConnectionsResponse, error) { - r := d.plc.PrivateLinkConnectionServiceAPI.PrivateLinkConnectionServiceListPrivateLinkConnections(ctx, clusterId) - if pageSize != nil { - r = r.PageSize(*pageSize) - } - if pageToken != nil { - r = r.PageToken(*pageToken) - } - res, h, err := r.Execute() - return res, parseError(err, h) -} - -func (d *ClientDelegate) GetPrivateLinkAvailabilityZones(ctx context.Context, clusterId string) (*privatelink.GetAvailabilityZonesResponse, error) { - res, h, err := d.plc.PrivateLinkConnectionServiceAPI.PrivateLinkConnectionServiceGetAvailabilityZones(ctx, clusterId).Execute() - return res, parseError(err, h) -} - -func (d *ClientDelegate) AttachPrivateLinkDomains(ctx context.Context, clusterId string, privateLinkConnectionId string, body *privatelink.PrivateLinkConnectionServiceAttachDomainsBody) (*privatelink.AttachDomain, error) { - r := d.plc.PrivateLinkConnectionServiceAPI.PrivateLinkConnectionServiceAttachDomains(ctx, clusterId, privateLinkConnectionId) - if body != nil { - r = r.Body(*body) - } - res, h, err := r.Execute() - return res, parseError(err, h) -} - -func (d *ClientDelegate) DetachPrivateLinkDomains(ctx context.Context, clusterId string, privateLinkConnectionId string, body *privatelink.PrivateLinkConnectionServiceDetachDomainsBody) (*privatelink.AttachDomain, error) { - r := d.plc.PrivateLinkConnectionServiceAPI.PrivateLinkConnectionServiceDetachDomains(ctx, clusterId, privateLinkConnectionId) - if body != nil { - r = r.Body(*body) - } - res, h, err := r.Execute() - return res, parseError(err, h) -} - -// ===== Private Link Connection ===== - -func NewApiClient(rt http.RoundTripper, serverlessEndpoint string, iamEndpoint string) (*branch.APIClient, *cluster.APIClient, *br.APIClient, *imp.APIClient, *export.APIClient, *iam.APIClient, *auditlog.APIClient, *cdc.APIClient, *privatelink.APIClient, *migration.APIClient, error) { +func NewApiClient(rt http.RoundTripper, serverlessEndpoint string, iamEndpoint string) (*branch.APIClient, *cluster.APIClient, *br.APIClient, *imp.APIClient, *export.APIClient, *iam.APIClient, *auditlog.APIClient, *cdc.APIClient, *migration.APIClient, error) { httpclient := &http.Client{ Transport: rt, } @@ -746,12 +676,12 @@ func NewApiClient(rt http.RoundTripper, serverlessEndpoint string, iamEndpoint s // v1beta1 api (serverless) serverlessURL, err := prop.ValidateApiUrl(serverlessEndpoint) if err != nil { - return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err + return nil, nil, nil, nil, nil, nil, nil, nil, nil, err } iamURL, err := prop.ValidateApiUrl(iamEndpoint) if err != nil { - return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err + return nil, nil, nil, nil, nil, nil, nil, nil, nil, err } userAgent := fmt.Sprintf("%s/%s", config.CliName, version.Version) @@ -796,11 +726,6 @@ func NewApiClient(rt http.RoundTripper, serverlessEndpoint string, iamEndpoint s cdcCfg.Host = serverlessURL.Host cdcCfg.UserAgent = userAgent - privateLinkCfg := privatelink.NewConfiguration() - privateLinkCfg.HTTPClient = httpclient - privateLinkCfg.Host = serverlessURL.Host - privateLinkCfg.UserAgent = userAgent - migrationCfg := migration.NewConfiguration() migrationCfg.HTTPClient = httpclient migrationCfg.Host = serverlessURL.Host @@ -810,7 +735,7 @@ func NewApiClient(rt http.RoundTripper, serverlessEndpoint string, iamEndpoint s br.NewAPIClient(backupRestoreCfg), imp.NewAPIClient(importCfg), export.NewAPIClient(exportCfg), iam.NewAPIClient(iamCfg), auditlog.NewAPIClient(auditLogCfg), cdc.NewAPIClient(cdcCfg), - privatelink.NewAPIClient(privateLinkCfg), migration.NewAPIClient(migrationCfg), nil + migration.NewAPIClient(migrationCfg), nil } func NewDigestTransport(publicKey, privateKey string) http.RoundTripper { diff --git a/internal/service/cloud/logic.go b/internal/service/cloud/logic.go index 673a745e..b04c3d8a 100644 --- a/internal/service/cloud/logic.go +++ b/internal/service/cloud/logic.go @@ -22,7 +22,6 @@ import ( "github.com/tidbcloud/tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/auditlog" "github.com/tidbcloud/tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/br" - "github.com/tidbcloud/tidbcloud-cli/pkg/tidbcloud/v1beta1/serverless/privatelink" "github.com/tidbcloud/tidbcloud-cli/internal/ui" "github.com/tidbcloud/tidbcloud-cli/internal/util" @@ -1167,109 +1166,3 @@ func GetSelectedFilterRule(ctx context.Context, clusterID string, client TiDBClo } return selected.(*AuditLogFilterRule), nil } - -func GetSelectedPrivateLinkConnection(ctx context.Context, clusterID string, pageSize int32, client TiDBCloudClient) (*PrivateLinkConnection, error) { - privateLinkConnections, err := RetrievePrivateLinkConnections(ctx, clusterID, pageSize, client) - if err != nil { - return nil, err - } - - var items = make([]interface{}, 0) - for _, item := range privateLinkConnections { - items = append(items, &PrivateLinkConnection{ - ID: *item.PrivateLinkConnectionId, - DisplayName: item.DisplayName, - }) - } - - if len(items) == 0 { - return nil, fmt.Errorf("no available private link connection found") - } - - selectModel, err := ui.InitialSelectModel(items, "Choose the private link connection:") - if err != nil { - return nil, errors.Trace(err) - } - itemsPerPage := 6 - selectModel.EnablePagination(itemsPerPage) - selectModel.EnableFilter() - - p := tea.NewProgram(selectModel) - model, err := p.Run() - if err != nil { - return nil, errors.Trace(err) - } - if m, _ := model.(ui.SelectModel); m.Interrupted { - return nil, util.InterruptError - } - resp := model.(ui.SelectModel).GetSelectedItem() - if resp == nil { - return nil, errors.New("no private link connection") - } - return resp.(*PrivateLinkConnection), nil -} - -func GetSelectedAttachDomain(ctx context.Context, clusterID, plcId string, client TiDBCloudClient) (*AttachDomain, error) { - plc, err := client.GetPrivateLinkConnection(ctx, clusterID, plcId) - if err != nil { - return nil, err - } - - var items = make([]interface{}, 0) - for _, item := range plc.AttachedDomains { - items = append(items, &AttachDomain{ - ID: *item.AttachDomainId, - UniqueName: *item.UniqueName, - Type: string(item.Type), - }) - } - - if len(items) == 0 { - return nil, fmt.Errorf("no available private link connection attach domain found") - } - - selectModel, err := ui.InitialSelectModel(items, "Choose the attached domain:") - if err != nil { - return nil, errors.Trace(err) - } - itemsPerPage := 6 - selectModel.EnablePagination(itemsPerPage) - selectModel.EnableFilter() - - p := tea.NewProgram(selectModel) - model, err := p.Run() - if err != nil { - return nil, errors.Trace(err) - } - if m, _ := model.(ui.SelectModel); m.Interrupted { - return nil, util.InterruptError - } - resp := model.(ui.SelectModel).GetSelectedItem() - if resp == nil { - return nil, errors.New("no attach domain") - } - return resp.(*AttachDomain), nil -} - -func RetrievePrivateLinkConnections(ctx context.Context, clusterID string, pageSize int32, d TiDBCloudClient) ([]privatelink.PrivateLinkConnection, error) { - var pageToken *string - resp, err := d.ListPrivateLinkConnections(ctx, clusterID, &pageSize, nil) - if err != nil { - return nil, errors.Trace(err) - } - - items := make([]privatelink.PrivateLinkConnection, 0) - items = append(items, resp.PrivateLinkConnections...) - for { - pageToken = resp.NextPageToken - if pageToken == nil || *pageToken == "" { - break - } - resp, err := d.ListPrivateLinkConnections(ctx, clusterID, &pageSize, pageToken) - if err != nil { - return nil, errors.Trace(err) - } - items = append(items, resp.PrivateLinkConnections...) - } - return items, nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink.swagger.json b/pkg/tidbcloud/v1beta1/serverless/privatelink.swagger.json deleted file mode 100644 index 4c3d0473..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink.swagger.json +++ /dev/null @@ -1,673 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "TiDB Cloud Serverless Private Link Connection Open API", - "description": "TiDB Cloud Serverless Private Link Connection Open API", - "version": "v1beta1" - }, - "tags": [ - { - "name": "PrivateLinkConnectionService" - } - ], - "host": "serverless.tidbapi.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "paths": { - "/v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}": { - "get": { - "summary": "Get a private link connection.", - "operationId": "PrivateLinkConnectionService_GetPrivateLinkConnection", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/PrivateLinkConnection" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/Status" - } - } - }, - "parameters": [ - { - "name": "clusterId", - "description": "The cluster ID.", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "privateLinkConnectionId", - "description": "The private link connection ID.", - "in": "path", - "required": true, - "type": "string" - } - ], - "tags": [ - "PrivateLinkConnectionService" - ] - }, - "delete": { - "summary": "Delete a private link connection.", - "operationId": "PrivateLinkConnectionService_DeletePrivateLinkConnection", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/PrivateLinkConnection" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/Status" - } - } - }, - "parameters": [ - { - "name": "clusterId", - "description": "The cluster ID.", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "privateLinkConnectionId", - "description": "The private link connection ID.", - "in": "path", - "required": true, - "type": "string" - } - ], - "tags": [ - "PrivateLinkConnectionService" - ] - } - }, - "/v1beta1/clusters/{clusterId}/privateLinkConnections": { - "get": { - "summary": "List private link connections.", - "operationId": "PrivateLinkConnectionService_ListPrivateLinkConnections", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/ListPrivateLinkConnectionsResponse" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/Status" - } - } - }, - "parameters": [ - { - "name": "clusterId", - "description": "The cluster ID.", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "pageSize", - "description": "The maximum number to return.", - "in": "query", - "required": false, - "type": "integer", - "format": "int32" - }, - { - "name": "pageToken", - "description": "The page token for pagination.", - "in": "query", - "required": false, - "type": "string" - }, - { - "name": "state", - "description": " - CREATING: The private link connection is being created.\n - ACTIVE: The private link connection is active.\n - FAILED: The private link connection is in failed state.\n - PENDING_ACCEPTANCE: The private link connection is pending acceptance. only for AWS endpoint service and Alicloud endpoint service.\n - DELETING: The private link connection is being deleted.", - "in": "query", - "required": false, - "type": "string", - "enum": [ - "CREATING", - "ACTIVE", - "FAILED", - "PENDING_ACCEPTANCE", - "DELETING" - ] - } - ], - "tags": [ - "PrivateLinkConnectionService" - ] - }, - "post": { - "summary": "Create a private link connection.", - "operationId": "PrivateLinkConnectionService_CreatePrivateLinkConnection", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/PrivateLinkConnection" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/Status" - } - } - }, - "parameters": [ - { - "name": "clusterId", - "description": "The cluster ID.", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/PrivateLinkConnectionService.CreatePrivateLinkConnectionBody" - } - } - ], - "tags": [ - "PrivateLinkConnectionService" - ] - } - }, - "/v1beta1/clusters/{clusterId}/privateLinkConnections:getAvailabilityZones": { - "get": { - "summary": "Get account and availability zones information for private link connection.", - "operationId": "PrivateLinkConnectionService_GetAvailabilityZones", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/GetAvailabilityZonesResponse" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/Status" - } - } - }, - "parameters": [ - { - "name": "clusterId", - "description": "The cluster ID.", - "in": "path", - "required": true, - "type": "string" - } - ], - "tags": [ - "PrivateLinkConnectionService" - ] - } - }, - "/v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}:attachDomains": { - "post": { - "summary": "Attach domains for private link connection.", - "operationId": "PrivateLinkConnectionService_AttachDomains", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/AttachDomain" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/Status" - } - } - }, - "parameters": [ - { - "name": "clusterId", - "description": "The cluster ID.", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "privateLinkConnectionId", - "description": "The private link connection ID.", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/PrivateLinkConnectionService.AttachDomainsBody" - } - } - ], - "tags": [ - "PrivateLinkConnectionService" - ] - } - }, - "/v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}:detachDomains": { - "post": { - "summary": "Detach domains for private link connection.", - "operationId": "PrivateLinkConnectionService_DetachDomains", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/AttachDomain" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/Status" - } - } - }, - "parameters": [ - { - "name": "clusterId", - "description": "The cluster ID.", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "privateLinkConnectionId", - "description": "The private link connection ID.", - "in": "path", - "required": true, - "type": "string" - }, - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/PrivateLinkConnectionService.DetachDomainsBody" - } - } - ], - "tags": [ - "PrivateLinkConnectionService" - ] - } - } - }, - "definitions": { - "AlicloudEndpointService": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "The endpoint service name." - }, - "endpointId": { - "type": "string", - "description": "The endpoint ID.", - "readOnly": true - }, - "availabilityZoneIds": { - "type": "array", - "items": { - "type": "string" - }, - "description": "The availability zones of the endpoint.", - "readOnly": true - } - }, - "required": [ - "name" - ] - }, - "Any": { - "type": "object", - "properties": { - "@type": { - "type": "string" - } - }, - "additionalProperties": {} - }, - "AttachDomain": { - "type": "object", - "properties": { - "attachDomainId": { - "type": "string", - "description": "The attach domain ID.", - "readOnly": true - }, - "clusterId": { - "type": "string", - "description": "The cluster ID.", - "readOnly": true - }, - "privateLinkConnectionId": { - "type": "string", - "description": "The private link connection ID.", - "readOnly": true - }, - "type": { - "description": "The domain type to attach.", - "allOf": [ - { - "$ref": "#/definitions/PrivateLinkConnectionDomainType.Enum" - } - ] - }, - "uniqueName": { - "type": "string", - "description": "The unique name of the domain to attach, it can be empty only when type is TIDBCLOUD_MANAGED and validate_only is true." - }, - "domains": { - "type": "array", - "items": { - "type": "object", - "$ref": "#/definitions/Domain" - }, - "description": "The domains attached.", - "readOnly": true - }, - "createdBy": { - "type": "string", - "description": "The user who attach the domain.", - "readOnly": true - }, - "createTime": { - "type": "string", - "format": "date-time", - "title": "create time", - "readOnly": true - } - }, - "required": [ - "type" - ] - }, - "AwsEndpointService": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "The endpoint service name." - }, - "region": { - "type": "string", - "title": "The region of endpoint service name, default to cluster's region" - }, - "endpointId": { - "type": "string", - "description": "The endpoint ID.", - "readOnly": true - }, - "availabilityZoneIds": { - "type": "array", - "items": { - "type": "string" - }, - "description": "The availability zones of the endpoint.", - "readOnly": true - } - }, - "required": [ - "name" - ] - }, - "Domain": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "The domain name.", - "readOnly": true - }, - "state": { - "type": "string", - "title": "The domain state", - "readOnly": true - }, - "message": { - "type": "string", - "description": "Fail message if the domain is in failed state.", - "readOnly": true - } - } - }, - "GetAvailabilityZonesResponse": { - "type": "object", - "properties": { - "accountId": { - "type": "string", - "description": "The account ID." - }, - "azIds": { - "type": "array", - "items": { - "type": "string" - }, - "description": "Availability zone ids." - } - } - }, - "ListPrivateLinkConnectionsResponse": { - "type": "object", - "properties": { - "privateLinkConnections": { - "type": "array", - "items": { - "type": "object", - "$ref": "#/definitions/PrivateLinkConnection" - } - }, - "nextPageToken": { - "type": "string" - }, - "totalSize": { - "type": "integer", - "format": "int64" - } - } - }, - "PrivateLinkConnection": { - "type": "object", - "properties": { - "privateLinkConnectionId": { - "type": "string", - "title": "The private link connection ID, format: plc-xxx", - "readOnly": true - }, - "clusterId": { - "type": "string", - "description": "The ID of the cluster." - }, - "displayName": { - "type": "string", - "description": "Display name for the private link connection." - }, - "state": { - "description": "The state of the private link connection.", - "readOnly": true, - "allOf": [ - { - "$ref": "#/definitions/PrivateLinkConnectionState.Enum" - } - ] - }, - "message": { - "type": "string", - "description": "The message describing fail reason.", - "readOnly": true - }, - "createdBy": { - "type": "string", - "description": "The user who created the private link connection.", - "readOnly": true - }, - "createTime": { - "type": "string", - "format": "date-time", - "description": "Timestamp when the private link connection was created.", - "readOnly": true - }, - "updateTime": { - "type": "string", - "format": "date-time", - "x-nullable": true, - "description": "Timestamp when the private link connection was updated.", - "readOnly": true - }, - "type": { - "title": "The type of the private link connection", - "allOf": [ - { - "$ref": "#/definitions/PrivateLinkConnectionType.Enum" - } - ] - }, - "attachedDomains": { - "type": "array", - "items": { - "type": "object", - "$ref": "#/definitions/AttachDomain" - }, - "title": "The attached domains for the private link connection, only display in Get API", - "readOnly": true - }, - "awsEndpointService": { - "$ref": "#/definitions/AwsEndpointService" - }, - "alicloudEndpointService": { - "$ref": "#/definitions/AlicloudEndpointService" - } - }, - "required": [ - "clusterId", - "displayName", - "type" - ] - }, - "PrivateLinkConnectionDomainType.Enum": { - "type": "string", - "enum": [ - "TIDBCLOUD_MANAGED", - "CONFLUENT" - ], - "description": " - TIDBCLOUD_MANAGED: The domain pattern is .plc.tidbcloud.com.\n - CONFLUENT: The domain pattern is .confluent.cloud." - }, - "PrivateLinkConnectionService.AttachDomainsBody": { - "type": "object", - "properties": { - "attachDomain": { - "description": "The domain to attach.", - "allOf": [ - { - "$ref": "#/definitions/AttachDomain" - } - ] - }, - "validateOnly": { - "type": "boolean", - "description": "Only validate the request and return the domains without attaching them." - } - }, - "required": [ - "attachDomain" - ] - }, - "PrivateLinkConnectionService.CreatePrivateLinkConnectionBody": { - "type": "object", - "properties": { - "privateLinkConnection": { - "description": "The private link connection to create.", - "allOf": [ - { - "$ref": "#/definitions/PrivateLinkConnection" - } - ] - } - }, - "required": [ - "privateLinkConnection" - ] - }, - "PrivateLinkConnectionService.DetachDomainsBody": { - "type": "object", - "properties": { - "attachDomainId": { - "type": "string", - "description": "The attached domain ID to detach." - } - }, - "required": [ - "attachDomainId" - ] - }, - "PrivateLinkConnectionState.Enum": { - "type": "string", - "enum": [ - "CREATING", - "ACTIVE", - "FAILED", - "PENDING_ACCEPTANCE", - "DELETING" - ], - "description": " - CREATING: The private link connection is being created.\n - ACTIVE: The private link connection is active.\n - FAILED: The private link connection is in failed state.\n - PENDING_ACCEPTANCE: The private link connection is pending acceptance. only for AWS endpoint service and Alicloud endpoint service.\n - DELETING: The private link connection is being deleted." - }, - "PrivateLinkConnectionType.Enum": { - "type": "string", - "enum": [ - "AWS_ENDPOINT_SERVICE", - "ALICLOUD_ENDPOINT_SERVICE" - ], - "description": " - AWS_ENDPOINT_SERVICE: AWS endpoint service type.\n - ALICLOUD_ENDPOINT_SERVICE: Alicloud endpoint service type." - }, - "Status": { - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - }, - "details": { - "type": "array", - "items": { - "type": "object", - "$ref": "#/definitions/Any" - } - } - } - } - } -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/.gitignore b/pkg/tidbcloud/v1beta1/serverless/privatelink/.gitignore deleted file mode 100644 index daf913b1..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# 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/privatelink/.openapi-generator-ignore b/pkg/tidbcloud/v1beta1/serverless/privatelink/.openapi-generator-ignore deleted file mode 100644 index 7484ee59..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/.openapi-generator-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# 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/privatelink/.openapi-generator/FILES b/pkg/tidbcloud/v1beta1/serverless/privatelink/.openapi-generator/FILES deleted file mode 100644 index 3e00c6b7..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/.openapi-generator/FILES +++ /dev/null @@ -1,27 +0,0 @@ -.gitignore -.openapi-generator-ignore -.travis.yml -README.md -api/openapi.yaml -api_private_link_connection_service.go -client.go -configuration.go -git_push.sh -model_alicloud_endpoint_service.go -model_any.go -model_attach_domain.go -model_aws_endpoint_service.go -model_domain.go -model_get_availability_zones_response.go -model_list_private_link_connections_response.go -model_private_link_connection.go -model_private_link_connection_domain_type_enum.go -model_private_link_connection_service_attach_domains_body.go -model_private_link_connection_service_create_private_link_connection_body.go -model_private_link_connection_service_detach_domains_body.go -model_private_link_connection_service_list_private_link_connections_state_parameter.go -model_private_link_connection_state_enum.go -model_private_link_connection_type_enum.go -model_status.go -response.go -utils.go diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/.openapi-generator/VERSION b/pkg/tidbcloud/v1beta1/serverless/privatelink/.openapi-generator/VERSION deleted file mode 100644 index 5f84a81d..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -7.12.0 diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/.travis.yml b/pkg/tidbcloud/v1beta1/serverless/privatelink/.travis.yml deleted file mode 100644 index f5cb2ce9..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: go - -install: - - go get -d -v . - -script: - - go build -v ./ - diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/README.md b/pkg/tidbcloud/v1beta1/serverless/privatelink/README.md deleted file mode 100644 index b43215ae..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/README.md +++ /dev/null @@ -1,134 +0,0 @@ -# Go API client for privatelink - -TiDB Cloud Serverless Private Link Connection 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.12.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 privatelink "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 `privatelink.ContextServerIndex` of type `int`. - -```go -ctx := context.WithValue(context.Background(), privatelink.ContextServerIndex, 1) -``` - -### Templated Server URL - -Templated server URL is formatted using default variables from configuration or from context value `privatelink.ContextServerVariables` of type `map[string]string`. - -```go -ctx := context.WithValue(context.Background(), privatelink.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 `privatelink.ContextOperationServerIndices` and `privatelink.ContextOperationServerVariables` context maps. - -```go -ctx := context.WithValue(context.Background(), privatelink.ContextOperationServerIndices, map[string]int{ - "{classname}Service.{nickname}": 2, -}) -ctx = context.WithValue(context.Background(), privatelink.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 ------------- | ------------- | ------------- | ------------- -*PrivateLinkConnectionServiceAPI* | [**PrivateLinkConnectionServiceAttachDomains**](docs/PrivateLinkConnectionServiceAPI.md#privatelinkconnectionserviceattachdomains) | **Post** /v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}:attachDomains | Attach domains for private link connection. -*PrivateLinkConnectionServiceAPI* | [**PrivateLinkConnectionServiceCreatePrivateLinkConnection**](docs/PrivateLinkConnectionServiceAPI.md#privatelinkconnectionservicecreateprivatelinkconnection) | **Post** /v1beta1/clusters/{clusterId}/privateLinkConnections | Create a private link connection. -*PrivateLinkConnectionServiceAPI* | [**PrivateLinkConnectionServiceDeletePrivateLinkConnection**](docs/PrivateLinkConnectionServiceAPI.md#privatelinkconnectionservicedeleteprivatelinkconnection) | **Delete** /v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId} | Delete a private link connection. -*PrivateLinkConnectionServiceAPI* | [**PrivateLinkConnectionServiceDetachDomains**](docs/PrivateLinkConnectionServiceAPI.md#privatelinkconnectionservicedetachdomains) | **Post** /v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}:detachDomains | Detach domains for private link connection. -*PrivateLinkConnectionServiceAPI* | [**PrivateLinkConnectionServiceGetAvailabilityZones**](docs/PrivateLinkConnectionServiceAPI.md#privatelinkconnectionservicegetavailabilityzones) | **Get** /v1beta1/clusters/{clusterId}/privateLinkConnections:getAvailabilityZones | Get account and availability zones information for private link connection. -*PrivateLinkConnectionServiceAPI* | [**PrivateLinkConnectionServiceGetPrivateLinkConnection**](docs/PrivateLinkConnectionServiceAPI.md#privatelinkconnectionservicegetprivatelinkconnection) | **Get** /v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId} | Get a private link connection. -*PrivateLinkConnectionServiceAPI* | [**PrivateLinkConnectionServiceListPrivateLinkConnections**](docs/PrivateLinkConnectionServiceAPI.md#privatelinkconnectionservicelistprivatelinkconnections) | **Get** /v1beta1/clusters/{clusterId}/privateLinkConnections | List private link connections. - - -## Documentation For Models - - - [AlicloudEndpointService](docs/AlicloudEndpointService.md) - - [Any](docs/Any.md) - - [AttachDomain](docs/AttachDomain.md) - - [AwsEndpointService](docs/AwsEndpointService.md) - - [Domain](docs/Domain.md) - - [GetAvailabilityZonesResponse](docs/GetAvailabilityZonesResponse.md) - - [ListPrivateLinkConnectionsResponse](docs/ListPrivateLinkConnectionsResponse.md) - - [PrivateLinkConnection](docs/PrivateLinkConnection.md) - - [PrivateLinkConnectionDomainTypeEnum](docs/PrivateLinkConnectionDomainTypeEnum.md) - - [PrivateLinkConnectionServiceAttachDomainsBody](docs/PrivateLinkConnectionServiceAttachDomainsBody.md) - - [PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody](docs/PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody.md) - - [PrivateLinkConnectionServiceDetachDomainsBody](docs/PrivateLinkConnectionServiceDetachDomainsBody.md) - - [PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter](docs/PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter.md) - - [PrivateLinkConnectionStateEnum](docs/PrivateLinkConnectionStateEnum.md) - - [PrivateLinkConnectionTypeEnum](docs/PrivateLinkConnectionTypeEnum.md) - - [Status](docs/Status.md) - - -## Documentation For Authorization - -Endpoints do not require authorization. - - -## Documentation for Utility Methods - -Due to the fact that model structure members are all pointers, this package contains -a number of utility functions to easily obtain pointers to values of basic types. -Each of these functions takes a value of the given basic type and returns a pointer to it: - -* `PtrBool` -* `PtrInt` -* `PtrInt32` -* `PtrInt64` -* `PtrFloat` -* `PtrFloat32` -* `PtrFloat64` -* `PtrString` -* `PtrTime` - -## Author - - - diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/api/openapi.yaml b/pkg/tidbcloud/v1beta1/serverless/privatelink/api/openapi.yaml deleted file mode 100644 index d1b57164..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/api/openapi.yaml +++ /dev/null @@ -1,726 +0,0 @@ -openapi: 3.0.1 -info: - description: TiDB Cloud Serverless Private Link Connection Open API - title: TiDB Cloud Serverless Private Link Connection Open API - version: v1beta1 -servers: -- url: https://serverless.tidbapi.com/ -tags: -- name: PrivateLinkConnectionService -paths: - /v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}: - delete: - operationId: PrivateLinkConnectionService_DeletePrivateLinkConnection - parameters: - - description: The cluster ID. - in: path - name: clusterId - required: true - schema: - type: string - - description: The private link connection ID. - in: path - name: privateLinkConnectionId - required: true - schema: - type: string - responses: - "200": - content: - application/json: - schema: - $ref: '#/components/schemas/PrivateLinkConnection' - description: A successful response. - default: - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - description: An unexpected error response. - summary: Delete a private link connection. - tags: - - PrivateLinkConnectionService - get: - operationId: PrivateLinkConnectionService_GetPrivateLinkConnection - parameters: - - description: The cluster ID. - in: path - name: clusterId - required: true - schema: - type: string - - description: The private link connection ID. - in: path - name: privateLinkConnectionId - required: true - schema: - type: string - responses: - "200": - content: - application/json: - schema: - $ref: '#/components/schemas/PrivateLinkConnection' - description: A successful response. - default: - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - description: An unexpected error response. - summary: Get a private link connection. - tags: - - PrivateLinkConnectionService - /v1beta1/clusters/{clusterId}/privateLinkConnections: - get: - operationId: PrivateLinkConnectionService_ListPrivateLinkConnections - parameters: - - description: The cluster ID. - in: path - name: clusterId - required: true - schema: - type: string - - description: The maximum number to return. - in: query - name: pageSize - schema: - format: int32 - type: integer - - description: The page token for pagination. - in: query - name: pageToken - schema: - type: string - - description: |2- - - CREATING: The private link connection is being created. - - ACTIVE: The private link connection is active. - - FAILED: The private link connection is in failed state. - - PENDING_ACCEPTANCE: The private link connection is pending acceptance. only for AWS endpoint service and Alicloud endpoint service. - - DELETING: The private link connection is being deleted. - in: query - name: state - schema: - $ref: '#/components/schemas/PrivateLinkConnectionService_ListPrivateLinkConnections_state_parameter' - responses: - "200": - content: - application/json: - schema: - $ref: '#/components/schemas/ListPrivateLinkConnectionsResponse' - description: A successful response. - default: - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - description: An unexpected error response. - summary: List private link connections. - tags: - - PrivateLinkConnectionService - post: - operationId: PrivateLinkConnectionService_CreatePrivateLinkConnection - parameters: - - description: The cluster ID. - in: path - name: clusterId - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/PrivateLinkConnectionService.CreatePrivateLinkConnectionBody' - required: true - responses: - "200": - content: - application/json: - schema: - $ref: '#/components/schemas/PrivateLinkConnection' - description: A successful response. - default: - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - description: An unexpected error response. - summary: Create a private link connection. - tags: - - PrivateLinkConnectionService - x-codegen-request-body-name: body - /v1beta1/clusters/{clusterId}/privateLinkConnections:getAvailabilityZones: - get: - operationId: PrivateLinkConnectionService_GetAvailabilityZones - parameters: - - description: The cluster ID. - in: path - name: clusterId - required: true - schema: - type: string - responses: - "200": - content: - application/json: - schema: - $ref: '#/components/schemas/GetAvailabilityZonesResponse' - description: A successful response. - default: - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - description: An unexpected error response. - summary: Get account and availability zones information for private link connection. - tags: - - PrivateLinkConnectionService - /v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}:attachDomains: - post: - operationId: PrivateLinkConnectionService_AttachDomains - parameters: - - description: The cluster ID. - in: path - name: clusterId - required: true - schema: - type: string - - description: The private link connection ID. - in: path - name: privateLinkConnectionId - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/PrivateLinkConnectionService.AttachDomainsBody' - required: true - responses: - "200": - content: - application/json: - schema: - $ref: '#/components/schemas/AttachDomain' - description: A successful response. - default: - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - description: An unexpected error response. - summary: Attach domains for private link connection. - tags: - - PrivateLinkConnectionService - x-codegen-request-body-name: body - /v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}:detachDomains: - post: - operationId: PrivateLinkConnectionService_DetachDomains - parameters: - - description: The cluster ID. - in: path - name: clusterId - required: true - schema: - type: string - - description: The private link connection ID. - in: path - name: privateLinkConnectionId - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/PrivateLinkConnectionService.DetachDomainsBody' - required: true - responses: - "200": - content: - application/json: - schema: - $ref: '#/components/schemas/AttachDomain' - description: A successful response. - default: - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - description: An unexpected error response. - summary: Detach domains for private link connection. - tags: - - PrivateLinkConnectionService - x-codegen-request-body-name: body -components: - schemas: - AlicloudEndpointService: - example: - availabilityZoneIds: - - availabilityZoneIds - - availabilityZoneIds - endpointId: endpointId - name: name - properties: - name: - description: The endpoint service name. - type: string - endpointId: - description: The endpoint ID. - readOnly: true - type: string - availabilityZoneIds: - description: The availability zones of the endpoint. - items: - type: string - readOnly: true - type: array - required: - - name - type: object - Any: - additionalProperties: - type: object - example: - '@type': '@type' - properties: - '@type': - type: string - type: object - AttachDomain: - example: - uniqueName: uniqueName - createdBy: createdBy - createTime: 2000-01-23T04:56:07.000+00:00 - domains: - - name: name - state: state - message: message - - name: name - state: state - message: message - attachDomainId: attachDomainId - privateLinkConnectionId: privateLinkConnectionId - clusterId: clusterId - type: "{}" - properties: - attachDomainId: - description: The attach domain ID. - readOnly: true - type: string - clusterId: - description: The cluster ID. - readOnly: true - type: string - privateLinkConnectionId: - description: The private link connection ID. - readOnly: true - type: string - type: - allOf: - - $ref: '#/components/schemas/PrivateLinkConnectionDomainType.Enum' - description: The domain type to attach. - type: object - uniqueName: - description: "The unique name of the domain to attach, it can be empty only\ - \ when type is TIDBCLOUD_MANAGED and validate_only is true." - type: string - domains: - description: The domains attached. - items: - $ref: '#/components/schemas/Domain' - readOnly: true - type: array - createdBy: - description: The user who attach the domain. - readOnly: true - type: string - createTime: - format: date-time - readOnly: true - title: create time - type: string - required: - - type - type: object - AwsEndpointService: - example: - availabilityZoneIds: - - availabilityZoneIds - - availabilityZoneIds - endpointId: endpointId - name: name - region: region - properties: - name: - description: The endpoint service name. - type: string - region: - title: "The region of endpoint service name, default to cluster's region" - type: string - endpointId: - description: The endpoint ID. - readOnly: true - type: string - availabilityZoneIds: - description: The availability zones of the endpoint. - items: - type: string - readOnly: true - type: array - required: - - name - type: object - Domain: - example: - name: name - state: state - message: message - properties: - name: - description: The domain name. - readOnly: true - type: string - state: - readOnly: true - title: The domain state - type: string - message: - description: Fail message if the domain is in failed state. - readOnly: true - type: string - type: object - GetAvailabilityZonesResponse: - example: - azIds: - - azIds - - azIds - accountId: accountId - properties: - accountId: - description: The account ID. - type: string - azIds: - description: Availability zone ids. - items: - type: string - type: array - type: object - ListPrivateLinkConnectionsResponse: - example: - totalSize: 0 - nextPageToken: nextPageToken - privateLinkConnections: - - awsEndpointService: - availabilityZoneIds: - - availabilityZoneIds - - availabilityZoneIds - endpointId: endpointId - name: name - region: region - createdBy: createdBy - createTime: 2000-01-23T04:56:07.000+00:00 - displayName: displayName - attachedDomains: - - uniqueName: uniqueName - createdBy: createdBy - createTime: 2000-01-23T04:56:07.000+00:00 - domains: - - name: name - state: state - message: message - - name: name - state: state - message: message - attachDomainId: attachDomainId - privateLinkConnectionId: privateLinkConnectionId - clusterId: clusterId - type: "{}" - - uniqueName: uniqueName - createdBy: createdBy - createTime: 2000-01-23T04:56:07.000+00:00 - domains: - - name: name - state: state - message: message - - name: name - state: state - message: message - attachDomainId: attachDomainId - privateLinkConnectionId: privateLinkConnectionId - clusterId: clusterId - type: "{}" - privateLinkConnectionId: privateLinkConnectionId - updateTime: 2000-01-23T04:56:07.000+00:00 - clusterId: clusterId - state: "{}" - message: message - type: "{}" - alicloudEndpointService: - availabilityZoneIds: - - availabilityZoneIds - - availabilityZoneIds - endpointId: endpointId - name: name - - awsEndpointService: - availabilityZoneIds: - - availabilityZoneIds - - availabilityZoneIds - endpointId: endpointId - name: name - region: region - createdBy: createdBy - createTime: 2000-01-23T04:56:07.000+00:00 - displayName: displayName - attachedDomains: - - uniqueName: uniqueName - createdBy: createdBy - createTime: 2000-01-23T04:56:07.000+00:00 - domains: - - name: name - state: state - message: message - - name: name - state: state - message: message - attachDomainId: attachDomainId - privateLinkConnectionId: privateLinkConnectionId - clusterId: clusterId - type: "{}" - - uniqueName: uniqueName - createdBy: createdBy - createTime: 2000-01-23T04:56:07.000+00:00 - domains: - - name: name - state: state - message: message - - name: name - state: state - message: message - attachDomainId: attachDomainId - privateLinkConnectionId: privateLinkConnectionId - clusterId: clusterId - type: "{}" - privateLinkConnectionId: privateLinkConnectionId - updateTime: 2000-01-23T04:56:07.000+00:00 - clusterId: clusterId - state: "{}" - message: message - type: "{}" - alicloudEndpointService: - availabilityZoneIds: - - availabilityZoneIds - - availabilityZoneIds - endpointId: endpointId - name: name - properties: - privateLinkConnections: - items: - $ref: '#/components/schemas/PrivateLinkConnection' - type: array - nextPageToken: - type: string - totalSize: - format: int64 - type: integer - type: object - PrivateLinkConnection: - example: - awsEndpointService: - availabilityZoneIds: - - availabilityZoneIds - - availabilityZoneIds - endpointId: endpointId - name: name - region: region - createdBy: createdBy - createTime: 2000-01-23T04:56:07.000+00:00 - displayName: displayName - attachedDomains: - - uniqueName: uniqueName - createdBy: createdBy - createTime: 2000-01-23T04:56:07.000+00:00 - domains: - - name: name - state: state - message: message - - name: name - state: state - message: message - attachDomainId: attachDomainId - privateLinkConnectionId: privateLinkConnectionId - clusterId: clusterId - type: "{}" - - uniqueName: uniqueName - createdBy: createdBy - createTime: 2000-01-23T04:56:07.000+00:00 - domains: - - name: name - state: state - message: message - - name: name - state: state - message: message - attachDomainId: attachDomainId - privateLinkConnectionId: privateLinkConnectionId - clusterId: clusterId - type: "{}" - privateLinkConnectionId: privateLinkConnectionId - updateTime: 2000-01-23T04:56:07.000+00:00 - clusterId: clusterId - state: "{}" - message: message - type: "{}" - alicloudEndpointService: - availabilityZoneIds: - - availabilityZoneIds - - availabilityZoneIds - endpointId: endpointId - name: name - properties: - privateLinkConnectionId: - readOnly: true - title: "The private link connection ID, format: plc-xxx" - type: string - clusterId: - description: The ID of the cluster. - type: string - displayName: - description: Display name for the private link connection. - type: string - state: - allOf: - - $ref: '#/components/schemas/PrivateLinkConnectionState.Enum' - description: The state of the private link connection. - type: object - message: - description: The message describing fail reason. - readOnly: true - type: string - createdBy: - description: The user who created the private link connection. - readOnly: true - type: string - createTime: - description: Timestamp when the private link connection was created. - format: date-time - readOnly: true - type: string - updateTime: - description: Timestamp when the private link connection was updated. - format: date-time - nullable: true - readOnly: true - type: string - type: - allOf: - - $ref: '#/components/schemas/PrivateLinkConnectionType.Enum' - title: The type of the private link connection - type: object - attachedDomains: - items: - $ref: '#/components/schemas/AttachDomain' - readOnly: true - title: "The attached domains for the private link connection, only display\ - \ in Get API" - type: array - awsEndpointService: - $ref: '#/components/schemas/AwsEndpointService' - alicloudEndpointService: - $ref: '#/components/schemas/AlicloudEndpointService' - required: - - clusterId - - displayName - - type - type: object - PrivateLinkConnectionDomainType.Enum: - description: |2- - - TIDBCLOUD_MANAGED: The domain pattern is .plc.tidbcloud.com. - - CONFLUENT: The domain pattern is .confluent.cloud. - enum: - - TIDBCLOUD_MANAGED - - CONFLUENT - type: string - PrivateLinkConnectionService.AttachDomainsBody: - properties: - attachDomain: - allOf: - - $ref: '#/components/schemas/AttachDomain' - description: The domain to attach. - type: object - validateOnly: - description: Only validate the request and return the domains without attaching - them. - type: boolean - required: - - attachDomain - type: object - PrivateLinkConnectionService.CreatePrivateLinkConnectionBody: - properties: - privateLinkConnection: - allOf: - - $ref: '#/components/schemas/PrivateLinkConnection' - description: The private link connection to create. - type: object - required: - - privateLinkConnection - type: object - PrivateLinkConnectionService.DetachDomainsBody: - properties: - attachDomainId: - description: The attached domain ID to detach. - type: string - required: - - attachDomainId - type: object - PrivateLinkConnectionState.Enum: - description: |2- - - CREATING: The private link connection is being created. - - ACTIVE: The private link connection is active. - - FAILED: The private link connection is in failed state. - - PENDING_ACCEPTANCE: The private link connection is pending acceptance. only for AWS endpoint service and Alicloud endpoint service. - - DELETING: The private link connection is being deleted. - enum: - - CREATING - - ACTIVE - - FAILED - - PENDING_ACCEPTANCE - - DELETING - type: string - PrivateLinkConnectionType.Enum: - description: |2- - - AWS_ENDPOINT_SERVICE: AWS endpoint service type. - - ALICLOUD_ENDPOINT_SERVICE: Alicloud endpoint service type. - enum: - - AWS_ENDPOINT_SERVICE - - ALICLOUD_ENDPOINT_SERVICE - type: string - Status: - example: - code: 0 - details: - - '@type': '@type' - - '@type': '@type' - message: message - properties: - code: - format: int32 - type: integer - message: - type: string - details: - items: - $ref: '#/components/schemas/Any' - type: array - type: object - PrivateLinkConnectionService_ListPrivateLinkConnections_state_parameter: - enum: - - CREATING - - ACTIVE - - FAILED - - PENDING_ACCEPTANCE - - DELETING - type: string -x-original-swagger-version: "2.0" diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/api_private_link_connection_service.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/api_private_link_connection_service.go deleted file mode 100644 index 3669446c..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/api_private_link_connection_service.go +++ /dev/null @@ -1,872 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -import ( - "bytes" - "context" - "io" - "net/http" - "net/url" - "strings" -) - -// PrivateLinkConnectionServiceAPIService PrivateLinkConnectionServiceAPI service -type PrivateLinkConnectionServiceAPIService service - -type ApiPrivateLinkConnectionServiceAttachDomainsRequest struct { - ctx context.Context - ApiService *PrivateLinkConnectionServiceAPIService - clusterId string - privateLinkConnectionId string - body *PrivateLinkConnectionServiceAttachDomainsBody -} - -func (r ApiPrivateLinkConnectionServiceAttachDomainsRequest) Body(body PrivateLinkConnectionServiceAttachDomainsBody) ApiPrivateLinkConnectionServiceAttachDomainsRequest { - r.body = &body - return r -} - -func (r ApiPrivateLinkConnectionServiceAttachDomainsRequest) Execute() (*AttachDomain, *http.Response, error) { - return r.ApiService.PrivateLinkConnectionServiceAttachDomainsExecute(r) -} - -/* -PrivateLinkConnectionServiceAttachDomains Attach domains for private link connection. - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param clusterId The cluster ID. - @param privateLinkConnectionId The private link connection ID. - @return ApiPrivateLinkConnectionServiceAttachDomainsRequest -*/ -func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceAttachDomains(ctx context.Context, clusterId string, privateLinkConnectionId string) ApiPrivateLinkConnectionServiceAttachDomainsRequest { - return ApiPrivateLinkConnectionServiceAttachDomainsRequest{ - ApiService: a, - ctx: ctx, - clusterId: clusterId, - privateLinkConnectionId: privateLinkConnectionId, - } -} - -// Execute executes the request -// -// @return AttachDomain -func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceAttachDomainsExecute(r ApiPrivateLinkConnectionServiceAttachDomainsRequest) (*AttachDomain, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *AttachDomain - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PrivateLinkConnectionServiceAPIService.PrivateLinkConnectionServiceAttachDomains") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}:attachDomains" - localVarPath = strings.Replace(localVarPath, "{"+"clusterId"+"}", url.PathEscape(parameterValueToString(r.clusterId, "clusterId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"privateLinkConnectionId"+"}", url.PathEscape(parameterValueToString(r.privateLinkConnectionId, "privateLinkConnectionId")), -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 Status - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiPrivateLinkConnectionServiceCreatePrivateLinkConnectionRequest struct { - ctx context.Context - ApiService *PrivateLinkConnectionServiceAPIService - clusterId string - body *PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody -} - -func (r ApiPrivateLinkConnectionServiceCreatePrivateLinkConnectionRequest) Body(body PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) ApiPrivateLinkConnectionServiceCreatePrivateLinkConnectionRequest { - r.body = &body - return r -} - -func (r ApiPrivateLinkConnectionServiceCreatePrivateLinkConnectionRequest) Execute() (*PrivateLinkConnection, *http.Response, error) { - return r.ApiService.PrivateLinkConnectionServiceCreatePrivateLinkConnectionExecute(r) -} - -/* -PrivateLinkConnectionServiceCreatePrivateLinkConnection Create a private link connection. - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param clusterId The cluster ID. - @return ApiPrivateLinkConnectionServiceCreatePrivateLinkConnectionRequest -*/ -func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceCreatePrivateLinkConnection(ctx context.Context, clusterId string) ApiPrivateLinkConnectionServiceCreatePrivateLinkConnectionRequest { - return ApiPrivateLinkConnectionServiceCreatePrivateLinkConnectionRequest{ - ApiService: a, - ctx: ctx, - clusterId: clusterId, - } -} - -// Execute executes the request -// -// @return PrivateLinkConnection -func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceCreatePrivateLinkConnectionExecute(r ApiPrivateLinkConnectionServiceCreatePrivateLinkConnectionRequest) (*PrivateLinkConnection, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *PrivateLinkConnection - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PrivateLinkConnectionServiceAPIService.PrivateLinkConnectionServiceCreatePrivateLinkConnection") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/v1beta1/clusters/{clusterId}/privateLinkConnections" - 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 Status - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiPrivateLinkConnectionServiceDeletePrivateLinkConnectionRequest struct { - ctx context.Context - ApiService *PrivateLinkConnectionServiceAPIService - clusterId string - privateLinkConnectionId string -} - -func (r ApiPrivateLinkConnectionServiceDeletePrivateLinkConnectionRequest) Execute() (*PrivateLinkConnection, *http.Response, error) { - return r.ApiService.PrivateLinkConnectionServiceDeletePrivateLinkConnectionExecute(r) -} - -/* -PrivateLinkConnectionServiceDeletePrivateLinkConnection Delete a private link connection. - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param clusterId The cluster ID. - @param privateLinkConnectionId The private link connection ID. - @return ApiPrivateLinkConnectionServiceDeletePrivateLinkConnectionRequest -*/ -func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceDeletePrivateLinkConnection(ctx context.Context, clusterId string, privateLinkConnectionId string) ApiPrivateLinkConnectionServiceDeletePrivateLinkConnectionRequest { - return ApiPrivateLinkConnectionServiceDeletePrivateLinkConnectionRequest{ - ApiService: a, - ctx: ctx, - clusterId: clusterId, - privateLinkConnectionId: privateLinkConnectionId, - } -} - -// Execute executes the request -// -// @return PrivateLinkConnection -func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceDeletePrivateLinkConnectionExecute(r ApiPrivateLinkConnectionServiceDeletePrivateLinkConnectionRequest) (*PrivateLinkConnection, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodDelete - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *PrivateLinkConnection - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PrivateLinkConnectionServiceAPIService.PrivateLinkConnectionServiceDeletePrivateLinkConnection") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}" - localVarPath = strings.Replace(localVarPath, "{"+"clusterId"+"}", url.PathEscape(parameterValueToString(r.clusterId, "clusterId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"privateLinkConnectionId"+"}", url.PathEscape(parameterValueToString(r.privateLinkConnectionId, "privateLinkConnectionId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Status - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiPrivateLinkConnectionServiceDetachDomainsRequest struct { - ctx context.Context - ApiService *PrivateLinkConnectionServiceAPIService - clusterId string - privateLinkConnectionId string - body *PrivateLinkConnectionServiceDetachDomainsBody -} - -func (r ApiPrivateLinkConnectionServiceDetachDomainsRequest) Body(body PrivateLinkConnectionServiceDetachDomainsBody) ApiPrivateLinkConnectionServiceDetachDomainsRequest { - r.body = &body - return r -} - -func (r ApiPrivateLinkConnectionServiceDetachDomainsRequest) Execute() (*AttachDomain, *http.Response, error) { - return r.ApiService.PrivateLinkConnectionServiceDetachDomainsExecute(r) -} - -/* -PrivateLinkConnectionServiceDetachDomains Detach domains for private link connection. - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param clusterId The cluster ID. - @param privateLinkConnectionId The private link connection ID. - @return ApiPrivateLinkConnectionServiceDetachDomainsRequest -*/ -func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceDetachDomains(ctx context.Context, clusterId string, privateLinkConnectionId string) ApiPrivateLinkConnectionServiceDetachDomainsRequest { - return ApiPrivateLinkConnectionServiceDetachDomainsRequest{ - ApiService: a, - ctx: ctx, - clusterId: clusterId, - privateLinkConnectionId: privateLinkConnectionId, - } -} - -// Execute executes the request -// -// @return AttachDomain -func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceDetachDomainsExecute(r ApiPrivateLinkConnectionServiceDetachDomainsRequest) (*AttachDomain, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *AttachDomain - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PrivateLinkConnectionServiceAPIService.PrivateLinkConnectionServiceDetachDomains") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}:detachDomains" - localVarPath = strings.Replace(localVarPath, "{"+"clusterId"+"}", url.PathEscape(parameterValueToString(r.clusterId, "clusterId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"privateLinkConnectionId"+"}", url.PathEscape(parameterValueToString(r.privateLinkConnectionId, "privateLinkConnectionId")), -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 Status - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiPrivateLinkConnectionServiceGetAvailabilityZonesRequest struct { - ctx context.Context - ApiService *PrivateLinkConnectionServiceAPIService - clusterId string -} - -func (r ApiPrivateLinkConnectionServiceGetAvailabilityZonesRequest) Execute() (*GetAvailabilityZonesResponse, *http.Response, error) { - return r.ApiService.PrivateLinkConnectionServiceGetAvailabilityZonesExecute(r) -} - -/* -PrivateLinkConnectionServiceGetAvailabilityZones Get account and availability zones information for private link connection. - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param clusterId The cluster ID. - @return ApiPrivateLinkConnectionServiceGetAvailabilityZonesRequest -*/ -func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceGetAvailabilityZones(ctx context.Context, clusterId string) ApiPrivateLinkConnectionServiceGetAvailabilityZonesRequest { - return ApiPrivateLinkConnectionServiceGetAvailabilityZonesRequest{ - ApiService: a, - ctx: ctx, - clusterId: clusterId, - } -} - -// Execute executes the request -// -// @return GetAvailabilityZonesResponse -func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceGetAvailabilityZonesExecute(r ApiPrivateLinkConnectionServiceGetAvailabilityZonesRequest) (*GetAvailabilityZonesResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *GetAvailabilityZonesResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PrivateLinkConnectionServiceAPIService.PrivateLinkConnectionServiceGetAvailabilityZones") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/v1beta1/clusters/{clusterId}/privateLinkConnections:getAvailabilityZones" - 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 Status - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiPrivateLinkConnectionServiceGetPrivateLinkConnectionRequest struct { - ctx context.Context - ApiService *PrivateLinkConnectionServiceAPIService - clusterId string - privateLinkConnectionId string -} - -func (r ApiPrivateLinkConnectionServiceGetPrivateLinkConnectionRequest) Execute() (*PrivateLinkConnection, *http.Response, error) { - return r.ApiService.PrivateLinkConnectionServiceGetPrivateLinkConnectionExecute(r) -} - -/* -PrivateLinkConnectionServiceGetPrivateLinkConnection Get a private link connection. - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param clusterId The cluster ID. - @param privateLinkConnectionId The private link connection ID. - @return ApiPrivateLinkConnectionServiceGetPrivateLinkConnectionRequest -*/ -func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceGetPrivateLinkConnection(ctx context.Context, clusterId string, privateLinkConnectionId string) ApiPrivateLinkConnectionServiceGetPrivateLinkConnectionRequest { - return ApiPrivateLinkConnectionServiceGetPrivateLinkConnectionRequest{ - ApiService: a, - ctx: ctx, - clusterId: clusterId, - privateLinkConnectionId: privateLinkConnectionId, - } -} - -// Execute executes the request -// -// @return PrivateLinkConnection -func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceGetPrivateLinkConnectionExecute(r ApiPrivateLinkConnectionServiceGetPrivateLinkConnectionRequest) (*PrivateLinkConnection, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *PrivateLinkConnection - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PrivateLinkConnectionServiceAPIService.PrivateLinkConnectionServiceGetPrivateLinkConnection") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/v1beta1/clusters/{clusterId}/privateLinkConnections/{privateLinkConnectionId}" - localVarPath = strings.Replace(localVarPath, "{"+"clusterId"+"}", url.PathEscape(parameterValueToString(r.clusterId, "clusterId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"privateLinkConnectionId"+"}", url.PathEscape(parameterValueToString(r.privateLinkConnectionId, "privateLinkConnectionId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Status - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiPrivateLinkConnectionServiceListPrivateLinkConnectionsRequest struct { - ctx context.Context - ApiService *PrivateLinkConnectionServiceAPIService - clusterId string - pageSize *int32 - pageToken *string - state *PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter -} - -// The maximum number to return. -func (r ApiPrivateLinkConnectionServiceListPrivateLinkConnectionsRequest) PageSize(pageSize int32) ApiPrivateLinkConnectionServiceListPrivateLinkConnectionsRequest { - r.pageSize = &pageSize - return r -} - -// The page token for pagination. -func (r ApiPrivateLinkConnectionServiceListPrivateLinkConnectionsRequest) PageToken(pageToken string) ApiPrivateLinkConnectionServiceListPrivateLinkConnectionsRequest { - r.pageToken = &pageToken - return r -} - -// - CREATING: The private link connection is being created. - ACTIVE: The private link connection is active. - FAILED: The private link connection is in failed state. - PENDING_ACCEPTANCE: The private link connection is pending acceptance. only for AWS endpoint service and Alicloud endpoint service. - DELETING: The private link connection is being deleted. -func (r ApiPrivateLinkConnectionServiceListPrivateLinkConnectionsRequest) State(state PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) ApiPrivateLinkConnectionServiceListPrivateLinkConnectionsRequest { - r.state = &state - return r -} - -func (r ApiPrivateLinkConnectionServiceListPrivateLinkConnectionsRequest) Execute() (*ListPrivateLinkConnectionsResponse, *http.Response, error) { - return r.ApiService.PrivateLinkConnectionServiceListPrivateLinkConnectionsExecute(r) -} - -/* -PrivateLinkConnectionServiceListPrivateLinkConnections List private link connections. - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param clusterId The cluster ID. - @return ApiPrivateLinkConnectionServiceListPrivateLinkConnectionsRequest -*/ -func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceListPrivateLinkConnections(ctx context.Context, clusterId string) ApiPrivateLinkConnectionServiceListPrivateLinkConnectionsRequest { - return ApiPrivateLinkConnectionServiceListPrivateLinkConnectionsRequest{ - ApiService: a, - ctx: ctx, - clusterId: clusterId, - } -} - -// Execute executes the request -// -// @return ListPrivateLinkConnectionsResponse -func (a *PrivateLinkConnectionServiceAPIService) PrivateLinkConnectionServiceListPrivateLinkConnectionsExecute(r ApiPrivateLinkConnectionServiceListPrivateLinkConnectionsRequest) (*ListPrivateLinkConnectionsResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ListPrivateLinkConnectionsResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PrivateLinkConnectionServiceAPIService.PrivateLinkConnectionServiceListPrivateLinkConnections") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/v1beta1/clusters/{clusterId}/privateLinkConnections" - localVarPath = strings.Replace(localVarPath, "{"+"clusterId"+"}", url.PathEscape(parameterValueToString(r.clusterId, "clusterId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - if r.pageSize != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "pageSize", r.pageSize, "", "") - } - if r.pageToken != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "pageToken", r.pageToken, "", "") - } - if r.state != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "state", r.state, "", "") - } - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Status - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/client.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/client.go deleted file mode 100644 index b8eefe99..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/client.go +++ /dev/null @@ -1,655 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -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 Private Link Connection 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 - - PrivateLinkConnectionServiceAPI *PrivateLinkConnectionServiceAPIService -} - -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.PrivateLinkConnectionServiceAPI = (*PrivateLinkConnectionServiceAPIService)(&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 { - if actualObj, ok := obj.(interface{ GetActualInstanceValue() interface{} }); ok { - return fmt.Sprintf("%v", actualObj.GetActualInstanceValue()) - } - - 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/privatelink/configuration.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/configuration.go deleted file mode 100644 index 7b172bb9..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/configuration.go +++ /dev/null @@ -1,214 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -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/privatelink/git_push.sh b/pkg/tidbcloud/v1beta1/serverless/privatelink/git_push.sh deleted file mode 100644 index f53a75d4..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/git_push.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/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/privatelink/model_alicloud_endpoint_service.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_alicloud_endpoint_service.go deleted file mode 100644 index 2ecb9a49..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_alicloud_endpoint_service.go +++ /dev/null @@ -1,243 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -import ( - "encoding/json" - "fmt" -) - -// checks if the AlicloudEndpointService type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &AlicloudEndpointService{} - -// AlicloudEndpointService struct for AlicloudEndpointService -type AlicloudEndpointService struct { - // The endpoint service name. - Name string `json:"name"` - // The endpoint ID. - EndpointId *string `json:"endpointId,omitempty"` - // The availability zones of the endpoint. - AvailabilityZoneIds []string `json:"availabilityZoneIds,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _AlicloudEndpointService AlicloudEndpointService - -// NewAlicloudEndpointService instantiates a new AlicloudEndpointService 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 NewAlicloudEndpointService(name string) *AlicloudEndpointService { - this := AlicloudEndpointService{} - this.Name = name - return &this -} - -// NewAlicloudEndpointServiceWithDefaults instantiates a new AlicloudEndpointService 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 NewAlicloudEndpointServiceWithDefaults() *AlicloudEndpointService { - this := AlicloudEndpointService{} - return &this -} - -// GetName returns the Name field value -func (o *AlicloudEndpointService) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *AlicloudEndpointService) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *AlicloudEndpointService) SetName(v string) { - o.Name = v -} - -// GetEndpointId returns the EndpointId field value if set, zero value otherwise. -func (o *AlicloudEndpointService) GetEndpointId() string { - if o == nil || IsNil(o.EndpointId) { - var ret string - return ret - } - return *o.EndpointId -} - -// GetEndpointIdOk returns a tuple with the EndpointId field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *AlicloudEndpointService) GetEndpointIdOk() (*string, bool) { - if o == nil || IsNil(o.EndpointId) { - return nil, false - } - return o.EndpointId, true -} - -// HasEndpointId returns a boolean if a field has been set. -func (o *AlicloudEndpointService) HasEndpointId() bool { - if o != nil && !IsNil(o.EndpointId) { - return true - } - - return false -} - -// SetEndpointId gets a reference to the given string and assigns it to the EndpointId field. -func (o *AlicloudEndpointService) SetEndpointId(v string) { - o.EndpointId = &v -} - -// GetAvailabilityZoneIds returns the AvailabilityZoneIds field value if set, zero value otherwise. -func (o *AlicloudEndpointService) GetAvailabilityZoneIds() []string { - if o == nil || IsNil(o.AvailabilityZoneIds) { - var ret []string - return ret - } - return o.AvailabilityZoneIds -} - -// GetAvailabilityZoneIdsOk returns a tuple with the AvailabilityZoneIds field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *AlicloudEndpointService) GetAvailabilityZoneIdsOk() ([]string, bool) { - if o == nil || IsNil(o.AvailabilityZoneIds) { - return nil, false - } - return o.AvailabilityZoneIds, true -} - -// HasAvailabilityZoneIds returns a boolean if a field has been set. -func (o *AlicloudEndpointService) HasAvailabilityZoneIds() bool { - if o != nil && !IsNil(o.AvailabilityZoneIds) { - return true - } - - return false -} - -// SetAvailabilityZoneIds gets a reference to the given []string and assigns it to the AvailabilityZoneIds field. -func (o *AlicloudEndpointService) SetAvailabilityZoneIds(v []string) { - o.AvailabilityZoneIds = v -} - -func (o AlicloudEndpointService) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o AlicloudEndpointService) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["name"] = o.Name - if !IsNil(o.EndpointId) { - toSerialize["endpointId"] = o.EndpointId - } - if !IsNil(o.AvailabilityZoneIds) { - toSerialize["availabilityZoneIds"] = o.AvailabilityZoneIds - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *AlicloudEndpointService) 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{ - "name", - } - - 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) - } - } - - varAlicloudEndpointService := _AlicloudEndpointService{} - - err = json.Unmarshal(data, &varAlicloudEndpointService) - - if err != nil { - return err - } - - *o = AlicloudEndpointService(varAlicloudEndpointService) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "name") - delete(additionalProperties, "endpointId") - delete(additionalProperties, "availabilityZoneIds") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableAlicloudEndpointService struct { - value *AlicloudEndpointService - isSet bool -} - -func (v NullableAlicloudEndpointService) Get() *AlicloudEndpointService { - return v.value -} - -func (v *NullableAlicloudEndpointService) Set(val *AlicloudEndpointService) { - v.value = val - v.isSet = true -} - -func (v NullableAlicloudEndpointService) IsSet() bool { - return v.isSet -} - -func (v *NullableAlicloudEndpointService) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableAlicloudEndpointService(val *AlicloudEndpointService) *NullableAlicloudEndpointService { - return &NullableAlicloudEndpointService{value: val, isSet: true} -} - -func (v NullableAlicloudEndpointService) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableAlicloudEndpointService) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_any.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_any.go deleted file mode 100644 index ea7f1cfe..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_any.go +++ /dev/null @@ -1,153 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -import ( - "encoding/json" -) - -// checks if the Any type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &Any{} - -// Any struct for Any -type Any struct { - Type *string `json:"@type,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _Any Any - -// NewAny instantiates a new Any object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewAny() *Any { - this := Any{} - return &this -} - -// NewAnyWithDefaults instantiates a new Any object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewAnyWithDefaults() *Any { - this := Any{} - return &this -} - -// GetType returns the Type field value if set, zero value otherwise. -func (o *Any) GetType() string { - if o == nil || IsNil(o.Type) { - var ret string - return ret - } - return *o.Type -} - -// GetTypeOk returns a tuple with the Type field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Any) GetTypeOk() (*string, bool) { - if o == nil || IsNil(o.Type) { - return nil, false - } - return o.Type, true -} - -// HasType returns a boolean if a field has been set. -func (o *Any) HasType() bool { - if o != nil && !IsNil(o.Type) { - return true - } - - return false -} - -// SetType gets a reference to the given string and assigns it to the Type field. -func (o *Any) SetType(v string) { - o.Type = &v -} - -func (o Any) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o Any) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Type) { - toSerialize["@type"] = o.Type - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *Any) UnmarshalJSON(data []byte) (err error) { - varAny := _Any{} - - err = json.Unmarshal(data, &varAny) - - if err != nil { - return err - } - - *o = Any(varAny) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "@type") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableAny struct { - value *Any - isSet bool -} - -func (v NullableAny) Get() *Any { - return v.value -} - -func (v *NullableAny) Set(val *Any) { - v.value = val - v.isSet = true -} - -func (v NullableAny) IsSet() bool { - return v.isSet -} - -func (v *NullableAny) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableAny(val *Any) *NullableAny { - return &NullableAny{value: val, isSet: true} -} - -func (v NullableAny) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableAny) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_attach_domain.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_attach_domain.go deleted file mode 100644 index 71abf186..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_attach_domain.go +++ /dev/null @@ -1,433 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -import ( - "encoding/json" - "fmt" - "time" -) - -// checks if the AttachDomain type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &AttachDomain{} - -// AttachDomain struct for AttachDomain -type AttachDomain struct { - // The attach domain ID. - AttachDomainId *string `json:"attachDomainId,omitempty"` - // The cluster ID. - ClusterId *string `json:"clusterId,omitempty"` - // The private link connection ID. - PrivateLinkConnectionId *string `json:"privateLinkConnectionId,omitempty"` - // The domain type to attach. - Type PrivateLinkConnectionDomainTypeEnum `json:"type"` - // The unique name of the domain to attach, it can be empty only when type is TIDBCLOUD_MANAGED and validate_only is true. - UniqueName *string `json:"uniqueName,omitempty"` - // The domains attached. - Domains []Domain `json:"domains,omitempty"` - // The user who attach the domain. - CreatedBy *string `json:"createdBy,omitempty"` - CreateTime *time.Time `json:"createTime,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _AttachDomain AttachDomain - -// NewAttachDomain instantiates a new AttachDomain 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 NewAttachDomain(type_ PrivateLinkConnectionDomainTypeEnum) *AttachDomain { - this := AttachDomain{} - this.Type = type_ - return &this -} - -// NewAttachDomainWithDefaults instantiates a new AttachDomain 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 NewAttachDomainWithDefaults() *AttachDomain { - this := AttachDomain{} - return &this -} - -// GetAttachDomainId returns the AttachDomainId field value if set, zero value otherwise. -func (o *AttachDomain) GetAttachDomainId() string { - if o == nil || IsNil(o.AttachDomainId) { - var ret string - return ret - } - return *o.AttachDomainId -} - -// GetAttachDomainIdOk returns a tuple with the AttachDomainId field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *AttachDomain) GetAttachDomainIdOk() (*string, bool) { - if o == nil || IsNil(o.AttachDomainId) { - return nil, false - } - return o.AttachDomainId, true -} - -// HasAttachDomainId returns a boolean if a field has been set. -func (o *AttachDomain) HasAttachDomainId() bool { - if o != nil && !IsNil(o.AttachDomainId) { - return true - } - - return false -} - -// SetAttachDomainId gets a reference to the given string and assigns it to the AttachDomainId field. -func (o *AttachDomain) SetAttachDomainId(v string) { - o.AttachDomainId = &v -} - -// GetClusterId returns the ClusterId field value if set, zero value otherwise. -func (o *AttachDomain) 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 *AttachDomain) 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 *AttachDomain) 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 *AttachDomain) SetClusterId(v string) { - o.ClusterId = &v -} - -// GetPrivateLinkConnectionId returns the PrivateLinkConnectionId field value if set, zero value otherwise. -func (o *AttachDomain) GetPrivateLinkConnectionId() string { - if o == nil || IsNil(o.PrivateLinkConnectionId) { - var ret string - return ret - } - return *o.PrivateLinkConnectionId -} - -// GetPrivateLinkConnectionIdOk returns a tuple with the PrivateLinkConnectionId field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *AttachDomain) GetPrivateLinkConnectionIdOk() (*string, bool) { - if o == nil || IsNil(o.PrivateLinkConnectionId) { - return nil, false - } - return o.PrivateLinkConnectionId, true -} - -// HasPrivateLinkConnectionId returns a boolean if a field has been set. -func (o *AttachDomain) HasPrivateLinkConnectionId() bool { - if o != nil && !IsNil(o.PrivateLinkConnectionId) { - return true - } - - return false -} - -// SetPrivateLinkConnectionId gets a reference to the given string and assigns it to the PrivateLinkConnectionId field. -func (o *AttachDomain) SetPrivateLinkConnectionId(v string) { - o.PrivateLinkConnectionId = &v -} - -// GetType returns the Type field value -func (o *AttachDomain) GetType() PrivateLinkConnectionDomainTypeEnum { - if o == nil { - var ret PrivateLinkConnectionDomainTypeEnum - return ret - } - - return o.Type -} - -// GetTypeOk returns a tuple with the Type field value -// and a boolean to check if the value has been set. -func (o *AttachDomain) GetTypeOk() (*PrivateLinkConnectionDomainTypeEnum, bool) { - if o == nil { - return nil, false - } - return &o.Type, true -} - -// SetType sets field value -func (o *AttachDomain) SetType(v PrivateLinkConnectionDomainTypeEnum) { - o.Type = v -} - -// GetUniqueName returns the UniqueName field value if set, zero value otherwise. -func (o *AttachDomain) GetUniqueName() string { - if o == nil || IsNil(o.UniqueName) { - var ret string - return ret - } - return *o.UniqueName -} - -// GetUniqueNameOk returns a tuple with the UniqueName field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *AttachDomain) GetUniqueNameOk() (*string, bool) { - if o == nil || IsNil(o.UniqueName) { - return nil, false - } - return o.UniqueName, true -} - -// HasUniqueName returns a boolean if a field has been set. -func (o *AttachDomain) HasUniqueName() bool { - if o != nil && !IsNil(o.UniqueName) { - return true - } - - return false -} - -// SetUniqueName gets a reference to the given string and assigns it to the UniqueName field. -func (o *AttachDomain) SetUniqueName(v string) { - o.UniqueName = &v -} - -// GetDomains returns the Domains field value if set, zero value otherwise. -func (o *AttachDomain) GetDomains() []Domain { - if o == nil || IsNil(o.Domains) { - var ret []Domain - return ret - } - return o.Domains -} - -// GetDomainsOk returns a tuple with the Domains field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *AttachDomain) GetDomainsOk() ([]Domain, bool) { - if o == nil || IsNil(o.Domains) { - return nil, false - } - return o.Domains, true -} - -// HasDomains returns a boolean if a field has been set. -func (o *AttachDomain) HasDomains() bool { - if o != nil && !IsNil(o.Domains) { - return true - } - - return false -} - -// SetDomains gets a reference to the given []Domain and assigns it to the Domains field. -func (o *AttachDomain) SetDomains(v []Domain) { - o.Domains = v -} - -// GetCreatedBy returns the CreatedBy field value if set, zero value otherwise. -func (o *AttachDomain) 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 *AttachDomain) 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 *AttachDomain) 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 *AttachDomain) SetCreatedBy(v string) { - o.CreatedBy = &v -} - -// GetCreateTime returns the CreateTime field value if set, zero value otherwise. -func (o *AttachDomain) 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 *AttachDomain) 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 *AttachDomain) 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 *AttachDomain) SetCreateTime(v time.Time) { - o.CreateTime = &v -} - -func (o AttachDomain) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o AttachDomain) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.AttachDomainId) { - toSerialize["attachDomainId"] = o.AttachDomainId - } - if !IsNil(o.ClusterId) { - toSerialize["clusterId"] = o.ClusterId - } - if !IsNil(o.PrivateLinkConnectionId) { - toSerialize["privateLinkConnectionId"] = o.PrivateLinkConnectionId - } - toSerialize["type"] = o.Type - if !IsNil(o.UniqueName) { - toSerialize["uniqueName"] = o.UniqueName - } - if !IsNil(o.Domains) { - toSerialize["domains"] = o.Domains - } - if !IsNil(o.CreatedBy) { - toSerialize["createdBy"] = o.CreatedBy - } - if !IsNil(o.CreateTime) { - toSerialize["createTime"] = o.CreateTime - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *AttachDomain) 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{ - "type", - } - - 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) - } - } - - varAttachDomain := _AttachDomain{} - - err = json.Unmarshal(data, &varAttachDomain) - - if err != nil { - return err - } - - *o = AttachDomain(varAttachDomain) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "attachDomainId") - delete(additionalProperties, "clusterId") - delete(additionalProperties, "privateLinkConnectionId") - delete(additionalProperties, "type") - delete(additionalProperties, "uniqueName") - delete(additionalProperties, "domains") - delete(additionalProperties, "createdBy") - delete(additionalProperties, "createTime") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableAttachDomain struct { - value *AttachDomain - isSet bool -} - -func (v NullableAttachDomain) Get() *AttachDomain { - return v.value -} - -func (v *NullableAttachDomain) Set(val *AttachDomain) { - v.value = val - v.isSet = true -} - -func (v NullableAttachDomain) IsSet() bool { - return v.isSet -} - -func (v *NullableAttachDomain) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableAttachDomain(val *AttachDomain) *NullableAttachDomain { - return &NullableAttachDomain{value: val, isSet: true} -} - -func (v NullableAttachDomain) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableAttachDomain) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_aws_endpoint_service.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_aws_endpoint_service.go deleted file mode 100644 index 7a084b58..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_aws_endpoint_service.go +++ /dev/null @@ -1,280 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -import ( - "encoding/json" - "fmt" -) - -// checks if the AwsEndpointService type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &AwsEndpointService{} - -// AwsEndpointService struct for AwsEndpointService -type AwsEndpointService struct { - // The endpoint service name. - Name string `json:"name"` - Region *string `json:"region,omitempty"` - // The endpoint ID. - EndpointId *string `json:"endpointId,omitempty"` - // The availability zones of the endpoint. - AvailabilityZoneIds []string `json:"availabilityZoneIds,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _AwsEndpointService AwsEndpointService - -// NewAwsEndpointService instantiates a new AwsEndpointService 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 NewAwsEndpointService(name string) *AwsEndpointService { - this := AwsEndpointService{} - this.Name = name - return &this -} - -// NewAwsEndpointServiceWithDefaults instantiates a new AwsEndpointService 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 NewAwsEndpointServiceWithDefaults() *AwsEndpointService { - this := AwsEndpointService{} - return &this -} - -// GetName returns the Name field value -func (o *AwsEndpointService) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *AwsEndpointService) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *AwsEndpointService) SetName(v string) { - o.Name = v -} - -// GetRegion returns the Region field value if set, zero value otherwise. -func (o *AwsEndpointService) GetRegion() string { - if o == nil || IsNil(o.Region) { - var ret string - return ret - } - return *o.Region -} - -// GetRegionOk returns a tuple with the Region field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *AwsEndpointService) GetRegionOk() (*string, bool) { - if o == nil || IsNil(o.Region) { - return nil, false - } - return o.Region, true -} - -// HasRegion returns a boolean if a field has been set. -func (o *AwsEndpointService) HasRegion() bool { - if o != nil && !IsNil(o.Region) { - return true - } - - return false -} - -// SetRegion gets a reference to the given string and assigns it to the Region field. -func (o *AwsEndpointService) SetRegion(v string) { - o.Region = &v -} - -// GetEndpointId returns the EndpointId field value if set, zero value otherwise. -func (o *AwsEndpointService) GetEndpointId() string { - if o == nil || IsNil(o.EndpointId) { - var ret string - return ret - } - return *o.EndpointId -} - -// GetEndpointIdOk returns a tuple with the EndpointId field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *AwsEndpointService) GetEndpointIdOk() (*string, bool) { - if o == nil || IsNil(o.EndpointId) { - return nil, false - } - return o.EndpointId, true -} - -// HasEndpointId returns a boolean if a field has been set. -func (o *AwsEndpointService) HasEndpointId() bool { - if o != nil && !IsNil(o.EndpointId) { - return true - } - - return false -} - -// SetEndpointId gets a reference to the given string and assigns it to the EndpointId field. -func (o *AwsEndpointService) SetEndpointId(v string) { - o.EndpointId = &v -} - -// GetAvailabilityZoneIds returns the AvailabilityZoneIds field value if set, zero value otherwise. -func (o *AwsEndpointService) GetAvailabilityZoneIds() []string { - if o == nil || IsNil(o.AvailabilityZoneIds) { - var ret []string - return ret - } - return o.AvailabilityZoneIds -} - -// GetAvailabilityZoneIdsOk returns a tuple with the AvailabilityZoneIds field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *AwsEndpointService) GetAvailabilityZoneIdsOk() ([]string, bool) { - if o == nil || IsNil(o.AvailabilityZoneIds) { - return nil, false - } - return o.AvailabilityZoneIds, true -} - -// HasAvailabilityZoneIds returns a boolean if a field has been set. -func (o *AwsEndpointService) HasAvailabilityZoneIds() bool { - if o != nil && !IsNil(o.AvailabilityZoneIds) { - return true - } - - return false -} - -// SetAvailabilityZoneIds gets a reference to the given []string and assigns it to the AvailabilityZoneIds field. -func (o *AwsEndpointService) SetAvailabilityZoneIds(v []string) { - o.AvailabilityZoneIds = v -} - -func (o AwsEndpointService) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o AwsEndpointService) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["name"] = o.Name - if !IsNil(o.Region) { - toSerialize["region"] = o.Region - } - if !IsNil(o.EndpointId) { - toSerialize["endpointId"] = o.EndpointId - } - if !IsNil(o.AvailabilityZoneIds) { - toSerialize["availabilityZoneIds"] = o.AvailabilityZoneIds - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *AwsEndpointService) 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{ - "name", - } - - 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) - } - } - - varAwsEndpointService := _AwsEndpointService{} - - err = json.Unmarshal(data, &varAwsEndpointService) - - if err != nil { - return err - } - - *o = AwsEndpointService(varAwsEndpointService) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "name") - delete(additionalProperties, "region") - delete(additionalProperties, "endpointId") - delete(additionalProperties, "availabilityZoneIds") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableAwsEndpointService struct { - value *AwsEndpointService - isSet bool -} - -func (v NullableAwsEndpointService) Get() *AwsEndpointService { - return v.value -} - -func (v *NullableAwsEndpointService) Set(val *AwsEndpointService) { - v.value = val - v.isSet = true -} - -func (v NullableAwsEndpointService) IsSet() bool { - return v.isSet -} - -func (v *NullableAwsEndpointService) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableAwsEndpointService(val *AwsEndpointService) *NullableAwsEndpointService { - return &NullableAwsEndpointService{value: val, isSet: true} -} - -func (v NullableAwsEndpointService) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableAwsEndpointService) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_domain.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_domain.go deleted file mode 100644 index 26eae09c..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_domain.go +++ /dev/null @@ -1,229 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -import ( - "encoding/json" -) - -// checks if the Domain type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &Domain{} - -// Domain struct for Domain -type Domain struct { - // The domain name. - Name *string `json:"name,omitempty"` - State *string `json:"state,omitempty"` - // Fail message if the domain is in failed state. - Message *string `json:"message,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _Domain Domain - -// NewDomain instantiates a new Domain 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 NewDomain() *Domain { - this := Domain{} - return &this -} - -// NewDomainWithDefaults instantiates a new Domain 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 NewDomainWithDefaults() *Domain { - this := Domain{} - return &this -} - -// GetName returns the Name field value if set, zero value otherwise. -func (o *Domain) 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 *Domain) 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 *Domain) 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 *Domain) SetName(v string) { - o.Name = &v -} - -// GetState returns the State field value if set, zero value otherwise. -func (o *Domain) GetState() string { - if o == nil || IsNil(o.State) { - var ret string - 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 *Domain) GetStateOk() (*string, 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 *Domain) HasState() bool { - if o != nil && !IsNil(o.State) { - return true - } - - return false -} - -// SetState gets a reference to the given string and assigns it to the State field. -func (o *Domain) SetState(v string) { - o.State = &v -} - -// GetMessage returns the Message field value if set, zero value otherwise. -func (o *Domain) 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 *Domain) 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 *Domain) 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 *Domain) SetMessage(v string) { - o.Message = &v -} - -func (o Domain) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o Domain) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Name) { - toSerialize["name"] = o.Name - } - if !IsNil(o.State) { - toSerialize["state"] = o.State - } - if !IsNil(o.Message) { - toSerialize["message"] = o.Message - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *Domain) UnmarshalJSON(data []byte) (err error) { - varDomain := _Domain{} - - err = json.Unmarshal(data, &varDomain) - - if err != nil { - return err - } - - *o = Domain(varDomain) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "name") - delete(additionalProperties, "state") - delete(additionalProperties, "message") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableDomain struct { - value *Domain - isSet bool -} - -func (v NullableDomain) Get() *Domain { - return v.value -} - -func (v *NullableDomain) Set(val *Domain) { - v.value = val - v.isSet = true -} - -func (v NullableDomain) IsSet() bool { - return v.isSet -} - -func (v *NullableDomain) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableDomain(val *Domain) *NullableDomain { - return &NullableDomain{value: val, isSet: true} -} - -func (v NullableDomain) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableDomain) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_get_availability_zones_response.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_get_availability_zones_response.go deleted file mode 100644 index 92026134..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_get_availability_zones_response.go +++ /dev/null @@ -1,192 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -import ( - "encoding/json" -) - -// checks if the GetAvailabilityZonesResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &GetAvailabilityZonesResponse{} - -// GetAvailabilityZonesResponse struct for GetAvailabilityZonesResponse -type GetAvailabilityZonesResponse struct { - // The account ID. - AccountId *string `json:"accountId,omitempty"` - // Availability zone ids. - AzIds []string `json:"azIds,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _GetAvailabilityZonesResponse GetAvailabilityZonesResponse - -// NewGetAvailabilityZonesResponse instantiates a new GetAvailabilityZonesResponse 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 NewGetAvailabilityZonesResponse() *GetAvailabilityZonesResponse { - this := GetAvailabilityZonesResponse{} - return &this -} - -// NewGetAvailabilityZonesResponseWithDefaults instantiates a new GetAvailabilityZonesResponse 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 NewGetAvailabilityZonesResponseWithDefaults() *GetAvailabilityZonesResponse { - this := GetAvailabilityZonesResponse{} - return &this -} - -// GetAccountId returns the AccountId field value if set, zero value otherwise. -func (o *GetAvailabilityZonesResponse) GetAccountId() string { - if o == nil || IsNil(o.AccountId) { - var ret string - return ret - } - return *o.AccountId -} - -// GetAccountIdOk returns a tuple with the AccountId field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *GetAvailabilityZonesResponse) GetAccountIdOk() (*string, bool) { - if o == nil || IsNil(o.AccountId) { - return nil, false - } - return o.AccountId, true -} - -// HasAccountId returns a boolean if a field has been set. -func (o *GetAvailabilityZonesResponse) HasAccountId() bool { - if o != nil && !IsNil(o.AccountId) { - return true - } - - return false -} - -// SetAccountId gets a reference to the given string and assigns it to the AccountId field. -func (o *GetAvailabilityZonesResponse) SetAccountId(v string) { - o.AccountId = &v -} - -// GetAzIds returns the AzIds field value if set, zero value otherwise. -func (o *GetAvailabilityZonesResponse) GetAzIds() []string { - if o == nil || IsNil(o.AzIds) { - var ret []string - return ret - } - return o.AzIds -} - -// GetAzIdsOk returns a tuple with the AzIds field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *GetAvailabilityZonesResponse) GetAzIdsOk() ([]string, bool) { - if o == nil || IsNil(o.AzIds) { - return nil, false - } - return o.AzIds, true -} - -// HasAzIds returns a boolean if a field has been set. -func (o *GetAvailabilityZonesResponse) HasAzIds() bool { - if o != nil && !IsNil(o.AzIds) { - return true - } - - return false -} - -// SetAzIds gets a reference to the given []string and assigns it to the AzIds field. -func (o *GetAvailabilityZonesResponse) SetAzIds(v []string) { - o.AzIds = v -} - -func (o GetAvailabilityZonesResponse) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o GetAvailabilityZonesResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.AccountId) { - toSerialize["accountId"] = o.AccountId - } - if !IsNil(o.AzIds) { - toSerialize["azIds"] = o.AzIds - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *GetAvailabilityZonesResponse) UnmarshalJSON(data []byte) (err error) { - varGetAvailabilityZonesResponse := _GetAvailabilityZonesResponse{} - - err = json.Unmarshal(data, &varGetAvailabilityZonesResponse) - - if err != nil { - return err - } - - *o = GetAvailabilityZonesResponse(varGetAvailabilityZonesResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "accountId") - delete(additionalProperties, "azIds") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableGetAvailabilityZonesResponse struct { - value *GetAvailabilityZonesResponse - isSet bool -} - -func (v NullableGetAvailabilityZonesResponse) Get() *GetAvailabilityZonesResponse { - return v.value -} - -func (v *NullableGetAvailabilityZonesResponse) Set(val *GetAvailabilityZonesResponse) { - v.value = val - v.isSet = true -} - -func (v NullableGetAvailabilityZonesResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableGetAvailabilityZonesResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableGetAvailabilityZonesResponse(val *GetAvailabilityZonesResponse) *NullableGetAvailabilityZonesResponse { - return &NullableGetAvailabilityZonesResponse{value: val, isSet: true} -} - -func (v NullableGetAvailabilityZonesResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableGetAvailabilityZonesResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_list_private_link_connections_response.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_list_private_link_connections_response.go deleted file mode 100644 index 7aa35c19..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_list_private_link_connections_response.go +++ /dev/null @@ -1,227 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -import ( - "encoding/json" -) - -// checks if the ListPrivateLinkConnectionsResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ListPrivateLinkConnectionsResponse{} - -// ListPrivateLinkConnectionsResponse struct for ListPrivateLinkConnectionsResponse -type ListPrivateLinkConnectionsResponse struct { - PrivateLinkConnections []PrivateLinkConnection `json:"privateLinkConnections,omitempty"` - NextPageToken *string `json:"nextPageToken,omitempty"` - TotalSize *int64 `json:"totalSize,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _ListPrivateLinkConnectionsResponse ListPrivateLinkConnectionsResponse - -// NewListPrivateLinkConnectionsResponse instantiates a new ListPrivateLinkConnectionsResponse 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 NewListPrivateLinkConnectionsResponse() *ListPrivateLinkConnectionsResponse { - this := ListPrivateLinkConnectionsResponse{} - return &this -} - -// NewListPrivateLinkConnectionsResponseWithDefaults instantiates a new ListPrivateLinkConnectionsResponse 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 NewListPrivateLinkConnectionsResponseWithDefaults() *ListPrivateLinkConnectionsResponse { - this := ListPrivateLinkConnectionsResponse{} - return &this -} - -// GetPrivateLinkConnections returns the PrivateLinkConnections field value if set, zero value otherwise. -func (o *ListPrivateLinkConnectionsResponse) GetPrivateLinkConnections() []PrivateLinkConnection { - if o == nil || IsNil(o.PrivateLinkConnections) { - var ret []PrivateLinkConnection - return ret - } - return o.PrivateLinkConnections -} - -// GetPrivateLinkConnectionsOk returns a tuple with the PrivateLinkConnections field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *ListPrivateLinkConnectionsResponse) GetPrivateLinkConnectionsOk() ([]PrivateLinkConnection, bool) { - if o == nil || IsNil(o.PrivateLinkConnections) { - return nil, false - } - return o.PrivateLinkConnections, true -} - -// HasPrivateLinkConnections returns a boolean if a field has been set. -func (o *ListPrivateLinkConnectionsResponse) HasPrivateLinkConnections() bool { - if o != nil && !IsNil(o.PrivateLinkConnections) { - return true - } - - return false -} - -// SetPrivateLinkConnections gets a reference to the given []PrivateLinkConnection and assigns it to the PrivateLinkConnections field. -func (o *ListPrivateLinkConnectionsResponse) SetPrivateLinkConnections(v []PrivateLinkConnection) { - o.PrivateLinkConnections = v -} - -// GetNextPageToken returns the NextPageToken field value if set, zero value otherwise. -func (o *ListPrivateLinkConnectionsResponse) 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 *ListPrivateLinkConnectionsResponse) 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 *ListPrivateLinkConnectionsResponse) 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 *ListPrivateLinkConnectionsResponse) SetNextPageToken(v string) { - o.NextPageToken = &v -} - -// GetTotalSize returns the TotalSize field value if set, zero value otherwise. -func (o *ListPrivateLinkConnectionsResponse) 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 *ListPrivateLinkConnectionsResponse) 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 *ListPrivateLinkConnectionsResponse) 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 *ListPrivateLinkConnectionsResponse) SetTotalSize(v int64) { - o.TotalSize = &v -} - -func (o ListPrivateLinkConnectionsResponse) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ListPrivateLinkConnectionsResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.PrivateLinkConnections) { - toSerialize["privateLinkConnections"] = o.PrivateLinkConnections - } - if !IsNil(o.NextPageToken) { - toSerialize["nextPageToken"] = o.NextPageToken - } - if !IsNil(o.TotalSize) { - toSerialize["totalSize"] = o.TotalSize - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *ListPrivateLinkConnectionsResponse) UnmarshalJSON(data []byte) (err error) { - varListPrivateLinkConnectionsResponse := _ListPrivateLinkConnectionsResponse{} - - err = json.Unmarshal(data, &varListPrivateLinkConnectionsResponse) - - if err != nil { - return err - } - - *o = ListPrivateLinkConnectionsResponse(varListPrivateLinkConnectionsResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "privateLinkConnections") - delete(additionalProperties, "nextPageToken") - delete(additionalProperties, "totalSize") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableListPrivateLinkConnectionsResponse struct { - value *ListPrivateLinkConnectionsResponse - isSet bool -} - -func (v NullableListPrivateLinkConnectionsResponse) Get() *ListPrivateLinkConnectionsResponse { - return v.value -} - -func (v *NullableListPrivateLinkConnectionsResponse) Set(val *ListPrivateLinkConnectionsResponse) { - v.value = val - v.isSet = true -} - -func (v NullableListPrivateLinkConnectionsResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableListPrivateLinkConnectionsResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableListPrivateLinkConnectionsResponse(val *ListPrivateLinkConnectionsResponse) *NullableListPrivateLinkConnectionsResponse { - return &NullableListPrivateLinkConnectionsResponse{value: val, isSet: true} -} - -func (v NullableListPrivateLinkConnectionsResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableListPrivateLinkConnectionsResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection.go deleted file mode 100644 index 870d7460..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection.go +++ /dev/null @@ -1,576 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -import ( - "encoding/json" - "fmt" - "time" -) - -// checks if the PrivateLinkConnection type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &PrivateLinkConnection{} - -// PrivateLinkConnection struct for PrivateLinkConnection -type PrivateLinkConnection struct { - PrivateLinkConnectionId *string `json:"privateLinkConnectionId,omitempty"` - // The ID of the cluster. - ClusterId string `json:"clusterId"` - // Display name for the private link connection. - DisplayName string `json:"displayName"` - // The state of the private link connection. - State *PrivateLinkConnectionStateEnum `json:"state,omitempty"` - // The message describing fail reason. - Message *string `json:"message,omitempty"` - // The user who created the private link connection. - CreatedBy *string `json:"createdBy,omitempty"` - // Timestamp when the private link connection was created. - CreateTime *time.Time `json:"createTime,omitempty"` - // Timestamp when the private link connection was updated. - UpdateTime NullableTime `json:"updateTime,omitempty"` - Type PrivateLinkConnectionTypeEnum `json:"type"` - AttachedDomains []AttachDomain `json:"attachedDomains,omitempty"` - AwsEndpointService *AwsEndpointService `json:"awsEndpointService,omitempty"` - AlicloudEndpointService *AlicloudEndpointService `json:"alicloudEndpointService,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _PrivateLinkConnection PrivateLinkConnection - -// NewPrivateLinkConnection instantiates a new PrivateLinkConnection 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 NewPrivateLinkConnection(clusterId string, displayName string, type_ PrivateLinkConnectionTypeEnum) *PrivateLinkConnection { - this := PrivateLinkConnection{} - this.ClusterId = clusterId - this.DisplayName = displayName - this.Type = type_ - return &this -} - -// NewPrivateLinkConnectionWithDefaults instantiates a new PrivateLinkConnection 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 NewPrivateLinkConnectionWithDefaults() *PrivateLinkConnection { - this := PrivateLinkConnection{} - return &this -} - -// GetPrivateLinkConnectionId returns the PrivateLinkConnectionId field value if set, zero value otherwise. -func (o *PrivateLinkConnection) GetPrivateLinkConnectionId() string { - if o == nil || IsNil(o.PrivateLinkConnectionId) { - var ret string - return ret - } - return *o.PrivateLinkConnectionId -} - -// GetPrivateLinkConnectionIdOk returns a tuple with the PrivateLinkConnectionId field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *PrivateLinkConnection) GetPrivateLinkConnectionIdOk() (*string, bool) { - if o == nil || IsNil(o.PrivateLinkConnectionId) { - return nil, false - } - return o.PrivateLinkConnectionId, true -} - -// HasPrivateLinkConnectionId returns a boolean if a field has been set. -func (o *PrivateLinkConnection) HasPrivateLinkConnectionId() bool { - if o != nil && !IsNil(o.PrivateLinkConnectionId) { - return true - } - - return false -} - -// SetPrivateLinkConnectionId gets a reference to the given string and assigns it to the PrivateLinkConnectionId field. -func (o *PrivateLinkConnection) SetPrivateLinkConnectionId(v string) { - o.PrivateLinkConnectionId = &v -} - -// GetClusterId returns the ClusterId field value -func (o *PrivateLinkConnection) 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 *PrivateLinkConnection) GetClusterIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ClusterId, true -} - -// SetClusterId sets field value -func (o *PrivateLinkConnection) SetClusterId(v string) { - o.ClusterId = v -} - -// GetDisplayName returns the DisplayName field value -func (o *PrivateLinkConnection) 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 *PrivateLinkConnection) GetDisplayNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.DisplayName, true -} - -// SetDisplayName sets field value -func (o *PrivateLinkConnection) SetDisplayName(v string) { - o.DisplayName = v -} - -// GetState returns the State field value if set, zero value otherwise. -func (o *PrivateLinkConnection) GetState() PrivateLinkConnectionStateEnum { - if o == nil || IsNil(o.State) { - var ret PrivateLinkConnectionStateEnum - 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 *PrivateLinkConnection) GetStateOk() (*PrivateLinkConnectionStateEnum, 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 *PrivateLinkConnection) HasState() bool { - if o != nil && !IsNil(o.State) { - return true - } - - return false -} - -// SetState gets a reference to the given PrivateLinkConnectionStateEnum and assigns it to the State field. -func (o *PrivateLinkConnection) SetState(v PrivateLinkConnectionStateEnum) { - o.State = &v -} - -// GetMessage returns the Message field value if set, zero value otherwise. -func (o *PrivateLinkConnection) 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 *PrivateLinkConnection) 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 *PrivateLinkConnection) 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 *PrivateLinkConnection) SetMessage(v string) { - o.Message = &v -} - -// GetCreatedBy returns the CreatedBy field value if set, zero value otherwise. -func (o *PrivateLinkConnection) 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 *PrivateLinkConnection) 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 *PrivateLinkConnection) 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 *PrivateLinkConnection) SetCreatedBy(v string) { - o.CreatedBy = &v -} - -// GetCreateTime returns the CreateTime field value if set, zero value otherwise. -func (o *PrivateLinkConnection) 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 *PrivateLinkConnection) 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 *PrivateLinkConnection) 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 *PrivateLinkConnection) SetCreateTime(v time.Time) { - o.CreateTime = &v -} - -// GetUpdateTime returns the UpdateTime field value if set, zero value otherwise (both if not set or set to explicit null). -func (o *PrivateLinkConnection) GetUpdateTime() time.Time { - if o == nil || IsNil(o.UpdateTime.Get()) { - var ret time.Time - return ret - } - return *o.UpdateTime.Get() -} - -// GetUpdateTimeOk returns a tuple with the UpdateTime 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 *PrivateLinkConnection) GetUpdateTimeOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return o.UpdateTime.Get(), o.UpdateTime.IsSet() -} - -// HasUpdateTime returns a boolean if a field has been set. -func (o *PrivateLinkConnection) HasUpdateTime() bool { - if o != nil && o.UpdateTime.IsSet() { - return true - } - - return false -} - -// SetUpdateTime gets a reference to the given NullableTime and assigns it to the UpdateTime field. -func (o *PrivateLinkConnection) SetUpdateTime(v time.Time) { - o.UpdateTime.Set(&v) -} - -// SetUpdateTimeNil sets the value for UpdateTime to be an explicit nil -func (o *PrivateLinkConnection) SetUpdateTimeNil() { - o.UpdateTime.Set(nil) -} - -// UnsetUpdateTime ensures that no value is present for UpdateTime, not even an explicit nil -func (o *PrivateLinkConnection) UnsetUpdateTime() { - o.UpdateTime.Unset() -} - -// GetType returns the Type field value -func (o *PrivateLinkConnection) GetType() PrivateLinkConnectionTypeEnum { - if o == nil { - var ret PrivateLinkConnectionTypeEnum - return ret - } - - return o.Type -} - -// GetTypeOk returns a tuple with the Type field value -// and a boolean to check if the value has been set. -func (o *PrivateLinkConnection) GetTypeOk() (*PrivateLinkConnectionTypeEnum, bool) { - if o == nil { - return nil, false - } - return &o.Type, true -} - -// SetType sets field value -func (o *PrivateLinkConnection) SetType(v PrivateLinkConnectionTypeEnum) { - o.Type = v -} - -// GetAttachedDomains returns the AttachedDomains field value if set, zero value otherwise. -func (o *PrivateLinkConnection) GetAttachedDomains() []AttachDomain { - if o == nil || IsNil(o.AttachedDomains) { - var ret []AttachDomain - return ret - } - return o.AttachedDomains -} - -// GetAttachedDomainsOk returns a tuple with the AttachedDomains field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *PrivateLinkConnection) GetAttachedDomainsOk() ([]AttachDomain, bool) { - if o == nil || IsNil(o.AttachedDomains) { - return nil, false - } - return o.AttachedDomains, true -} - -// HasAttachedDomains returns a boolean if a field has been set. -func (o *PrivateLinkConnection) HasAttachedDomains() bool { - if o != nil && !IsNil(o.AttachedDomains) { - return true - } - - return false -} - -// SetAttachedDomains gets a reference to the given []AttachDomain and assigns it to the AttachedDomains field. -func (o *PrivateLinkConnection) SetAttachedDomains(v []AttachDomain) { - o.AttachedDomains = v -} - -// GetAwsEndpointService returns the AwsEndpointService field value if set, zero value otherwise. -func (o *PrivateLinkConnection) GetAwsEndpointService() AwsEndpointService { - if o == nil || IsNil(o.AwsEndpointService) { - var ret AwsEndpointService - return ret - } - return *o.AwsEndpointService -} - -// GetAwsEndpointServiceOk returns a tuple with the AwsEndpointService field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *PrivateLinkConnection) GetAwsEndpointServiceOk() (*AwsEndpointService, bool) { - if o == nil || IsNil(o.AwsEndpointService) { - return nil, false - } - return o.AwsEndpointService, true -} - -// HasAwsEndpointService returns a boolean if a field has been set. -func (o *PrivateLinkConnection) HasAwsEndpointService() bool { - if o != nil && !IsNil(o.AwsEndpointService) { - return true - } - - return false -} - -// SetAwsEndpointService gets a reference to the given AwsEndpointService and assigns it to the AwsEndpointService field. -func (o *PrivateLinkConnection) SetAwsEndpointService(v AwsEndpointService) { - o.AwsEndpointService = &v -} - -// GetAlicloudEndpointService returns the AlicloudEndpointService field value if set, zero value otherwise. -func (o *PrivateLinkConnection) GetAlicloudEndpointService() AlicloudEndpointService { - if o == nil || IsNil(o.AlicloudEndpointService) { - var ret AlicloudEndpointService - return ret - } - return *o.AlicloudEndpointService -} - -// GetAlicloudEndpointServiceOk returns a tuple with the AlicloudEndpointService field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *PrivateLinkConnection) GetAlicloudEndpointServiceOk() (*AlicloudEndpointService, bool) { - if o == nil || IsNil(o.AlicloudEndpointService) { - return nil, false - } - return o.AlicloudEndpointService, true -} - -// HasAlicloudEndpointService returns a boolean if a field has been set. -func (o *PrivateLinkConnection) HasAlicloudEndpointService() bool { - if o != nil && !IsNil(o.AlicloudEndpointService) { - return true - } - - return false -} - -// SetAlicloudEndpointService gets a reference to the given AlicloudEndpointService and assigns it to the AlicloudEndpointService field. -func (o *PrivateLinkConnection) SetAlicloudEndpointService(v AlicloudEndpointService) { - o.AlicloudEndpointService = &v -} - -func (o PrivateLinkConnection) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o PrivateLinkConnection) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.PrivateLinkConnectionId) { - toSerialize["privateLinkConnectionId"] = o.PrivateLinkConnectionId - } - toSerialize["clusterId"] = o.ClusterId - toSerialize["displayName"] = o.DisplayName - if !IsNil(o.State) { - toSerialize["state"] = o.State - } - if !IsNil(o.Message) { - toSerialize["message"] = o.Message - } - if !IsNil(o.CreatedBy) { - toSerialize["createdBy"] = o.CreatedBy - } - if !IsNil(o.CreateTime) { - toSerialize["createTime"] = o.CreateTime - } - if o.UpdateTime.IsSet() { - toSerialize["updateTime"] = o.UpdateTime.Get() - } - toSerialize["type"] = o.Type - if !IsNil(o.AttachedDomains) { - toSerialize["attachedDomains"] = o.AttachedDomains - } - if !IsNil(o.AwsEndpointService) { - toSerialize["awsEndpointService"] = o.AwsEndpointService - } - if !IsNil(o.AlicloudEndpointService) { - toSerialize["alicloudEndpointService"] = o.AlicloudEndpointService - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *PrivateLinkConnection) 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", - "displayName", - "type", - } - - 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) - } - } - - varPrivateLinkConnection := _PrivateLinkConnection{} - - err = json.Unmarshal(data, &varPrivateLinkConnection) - - if err != nil { - return err - } - - *o = PrivateLinkConnection(varPrivateLinkConnection) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "privateLinkConnectionId") - delete(additionalProperties, "clusterId") - delete(additionalProperties, "displayName") - delete(additionalProperties, "state") - delete(additionalProperties, "message") - delete(additionalProperties, "createdBy") - delete(additionalProperties, "createTime") - delete(additionalProperties, "updateTime") - delete(additionalProperties, "type") - delete(additionalProperties, "attachedDomains") - delete(additionalProperties, "awsEndpointService") - delete(additionalProperties, "alicloudEndpointService") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullablePrivateLinkConnection struct { - value *PrivateLinkConnection - isSet bool -} - -func (v NullablePrivateLinkConnection) Get() *PrivateLinkConnection { - return v.value -} - -func (v *NullablePrivateLinkConnection) Set(val *PrivateLinkConnection) { - v.value = val - v.isSet = true -} - -func (v NullablePrivateLinkConnection) IsSet() bool { - return v.isSet -} - -func (v *NullablePrivateLinkConnection) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullablePrivateLinkConnection(val *PrivateLinkConnection) *NullablePrivateLinkConnection { - return &NullablePrivateLinkConnection{value: val, isSet: true} -} - -func (v NullablePrivateLinkConnection) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullablePrivateLinkConnection) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_domain_type_enum.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_domain_type_enum.go deleted file mode 100644 index 7ef09a90..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_domain_type_enum.go +++ /dev/null @@ -1,105 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -import ( - "encoding/json" -) - -// PrivateLinkConnectionDomainTypeEnum - TIDBCLOUD_MANAGED: The domain pattern is .plc.tidbcloud.com. - CONFLUENT: The domain pattern is .confluent.cloud. -type PrivateLinkConnectionDomainTypeEnum string - -// List of PrivateLinkConnectionDomainType.Enum -const ( - PRIVATELINKCONNECTIONDOMAINTYPEENUM_TIDBCLOUD_MANAGED PrivateLinkConnectionDomainTypeEnum = "TIDBCLOUD_MANAGED" - PRIVATELINKCONNECTIONDOMAINTYPEENUM_CONFLUENT PrivateLinkConnectionDomainTypeEnum = "CONFLUENT" -) - -// All allowed values of PrivateLinkConnectionDomainTypeEnum enum -var AllowedPrivateLinkConnectionDomainTypeEnumEnumValues = []PrivateLinkConnectionDomainTypeEnum{ - "TIDBCLOUD_MANAGED", - "CONFLUENT", -} - -func (v *PrivateLinkConnectionDomainTypeEnum) UnmarshalJSON(src []byte) error { - var value string - err := json.Unmarshal(src, &value) - if err != nil { - return err - } - enumTypeValue := PrivateLinkConnectionDomainTypeEnum(value) - for _, existing := range AllowedPrivateLinkConnectionDomainTypeEnumEnumValues { - if existing == enumTypeValue { - *v = enumTypeValue - return nil - } - } - - *v = PrivateLinkConnectionDomainTypeEnum(value) - return nil -} - -// NewPrivateLinkConnectionDomainTypeEnumFromValue returns a pointer to a valid PrivateLinkConnectionDomainTypeEnum for the value passed as argument -func NewPrivateLinkConnectionDomainTypeEnumFromValue(v string) *PrivateLinkConnectionDomainTypeEnum { - ev := PrivateLinkConnectionDomainTypeEnum(v) - return &ev -} - -// IsValid return true if the value is valid for the enum, false otherwise -func (v PrivateLinkConnectionDomainTypeEnum) IsValid() bool { - for _, existing := range AllowedPrivateLinkConnectionDomainTypeEnumEnumValues { - if existing == v { - return true - } - } - return false -} - -// Ptr returns reference to PrivateLinkConnectionDomainType.Enum value -func (v PrivateLinkConnectionDomainTypeEnum) Ptr() *PrivateLinkConnectionDomainTypeEnum { - return &v -} - -type NullablePrivateLinkConnectionDomainTypeEnum struct { - value *PrivateLinkConnectionDomainTypeEnum - isSet bool -} - -func (v NullablePrivateLinkConnectionDomainTypeEnum) Get() *PrivateLinkConnectionDomainTypeEnum { - return v.value -} - -func (v *NullablePrivateLinkConnectionDomainTypeEnum) Set(val *PrivateLinkConnectionDomainTypeEnum) { - v.value = val - v.isSet = true -} - -func (v NullablePrivateLinkConnectionDomainTypeEnum) IsSet() bool { - return v.isSet -} - -func (v *NullablePrivateLinkConnectionDomainTypeEnum) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullablePrivateLinkConnectionDomainTypeEnum(val *PrivateLinkConnectionDomainTypeEnum) *NullablePrivateLinkConnectionDomainTypeEnum { - return &NullablePrivateLinkConnectionDomainTypeEnum{value: val, isSet: true} -} - -func (v NullablePrivateLinkConnectionDomainTypeEnum) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullablePrivateLinkConnectionDomainTypeEnum) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_attach_domains_body.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_attach_domains_body.go deleted file mode 100644 index 7aa462a2..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_attach_domains_body.go +++ /dev/null @@ -1,205 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -import ( - "encoding/json" - "fmt" -) - -// checks if the PrivateLinkConnectionServiceAttachDomainsBody type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &PrivateLinkConnectionServiceAttachDomainsBody{} - -// PrivateLinkConnectionServiceAttachDomainsBody struct for PrivateLinkConnectionServiceAttachDomainsBody -type PrivateLinkConnectionServiceAttachDomainsBody struct { - // The domain to attach. - AttachDomain AttachDomain `json:"attachDomain"` - // Only validate the request and return the domains without attaching them. - ValidateOnly *bool `json:"validateOnly,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _PrivateLinkConnectionServiceAttachDomainsBody PrivateLinkConnectionServiceAttachDomainsBody - -// NewPrivateLinkConnectionServiceAttachDomainsBody instantiates a new PrivateLinkConnectionServiceAttachDomainsBody 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 NewPrivateLinkConnectionServiceAttachDomainsBody(attachDomain AttachDomain) *PrivateLinkConnectionServiceAttachDomainsBody { - this := PrivateLinkConnectionServiceAttachDomainsBody{} - this.AttachDomain = attachDomain - return &this -} - -// NewPrivateLinkConnectionServiceAttachDomainsBodyWithDefaults instantiates a new PrivateLinkConnectionServiceAttachDomainsBody 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 NewPrivateLinkConnectionServiceAttachDomainsBodyWithDefaults() *PrivateLinkConnectionServiceAttachDomainsBody { - this := PrivateLinkConnectionServiceAttachDomainsBody{} - return &this -} - -// GetAttachDomain returns the AttachDomain field value -func (o *PrivateLinkConnectionServiceAttachDomainsBody) GetAttachDomain() AttachDomain { - if o == nil { - var ret AttachDomain - return ret - } - - return o.AttachDomain -} - -// GetAttachDomainOk returns a tuple with the AttachDomain field value -// and a boolean to check if the value has been set. -func (o *PrivateLinkConnectionServiceAttachDomainsBody) GetAttachDomainOk() (*AttachDomain, bool) { - if o == nil { - return nil, false - } - return &o.AttachDomain, true -} - -// SetAttachDomain sets field value -func (o *PrivateLinkConnectionServiceAttachDomainsBody) SetAttachDomain(v AttachDomain) { - o.AttachDomain = v -} - -// GetValidateOnly returns the ValidateOnly field value if set, zero value otherwise. -func (o *PrivateLinkConnectionServiceAttachDomainsBody) GetValidateOnly() bool { - if o == nil || IsNil(o.ValidateOnly) { - var ret bool - return ret - } - return *o.ValidateOnly -} - -// GetValidateOnlyOk returns a tuple with the ValidateOnly field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *PrivateLinkConnectionServiceAttachDomainsBody) GetValidateOnlyOk() (*bool, bool) { - if o == nil || IsNil(o.ValidateOnly) { - return nil, false - } - return o.ValidateOnly, true -} - -// HasValidateOnly returns a boolean if a field has been set. -func (o *PrivateLinkConnectionServiceAttachDomainsBody) HasValidateOnly() bool { - if o != nil && !IsNil(o.ValidateOnly) { - return true - } - - return false -} - -// SetValidateOnly gets a reference to the given bool and assigns it to the ValidateOnly field. -func (o *PrivateLinkConnectionServiceAttachDomainsBody) SetValidateOnly(v bool) { - o.ValidateOnly = &v -} - -func (o PrivateLinkConnectionServiceAttachDomainsBody) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o PrivateLinkConnectionServiceAttachDomainsBody) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["attachDomain"] = o.AttachDomain - if !IsNil(o.ValidateOnly) { - toSerialize["validateOnly"] = o.ValidateOnly - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *PrivateLinkConnectionServiceAttachDomainsBody) 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{ - "attachDomain", - } - - 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) - } - } - - varPrivateLinkConnectionServiceAttachDomainsBody := _PrivateLinkConnectionServiceAttachDomainsBody{} - - err = json.Unmarshal(data, &varPrivateLinkConnectionServiceAttachDomainsBody) - - if err != nil { - return err - } - - *o = PrivateLinkConnectionServiceAttachDomainsBody(varPrivateLinkConnectionServiceAttachDomainsBody) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "attachDomain") - delete(additionalProperties, "validateOnly") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullablePrivateLinkConnectionServiceAttachDomainsBody struct { - value *PrivateLinkConnectionServiceAttachDomainsBody - isSet bool -} - -func (v NullablePrivateLinkConnectionServiceAttachDomainsBody) Get() *PrivateLinkConnectionServiceAttachDomainsBody { - return v.value -} - -func (v *NullablePrivateLinkConnectionServiceAttachDomainsBody) Set(val *PrivateLinkConnectionServiceAttachDomainsBody) { - v.value = val - v.isSet = true -} - -func (v NullablePrivateLinkConnectionServiceAttachDomainsBody) IsSet() bool { - return v.isSet -} - -func (v *NullablePrivateLinkConnectionServiceAttachDomainsBody) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullablePrivateLinkConnectionServiceAttachDomainsBody(val *PrivateLinkConnectionServiceAttachDomainsBody) *NullablePrivateLinkConnectionServiceAttachDomainsBody { - return &NullablePrivateLinkConnectionServiceAttachDomainsBody{value: val, isSet: true} -} - -func (v NullablePrivateLinkConnectionServiceAttachDomainsBody) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullablePrivateLinkConnectionServiceAttachDomainsBody) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_create_private_link_connection_body.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_create_private_link_connection_body.go deleted file mode 100644 index ea47d8ff..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_create_private_link_connection_body.go +++ /dev/null @@ -1,167 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -import ( - "encoding/json" - "fmt" -) - -// checks if the PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody{} - -// PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody struct for PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody -type PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody struct { - // The private link connection to create. - PrivateLinkConnection PrivateLinkConnection `json:"privateLinkConnection"` - AdditionalProperties map[string]interface{} -} - -type _PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody - -// NewPrivateLinkConnectionServiceCreatePrivateLinkConnectionBody instantiates a new PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody 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 NewPrivateLinkConnectionServiceCreatePrivateLinkConnectionBody(privateLinkConnection PrivateLinkConnection) *PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody { - this := PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody{} - this.PrivateLinkConnection = privateLinkConnection - return &this -} - -// NewPrivateLinkConnectionServiceCreatePrivateLinkConnectionBodyWithDefaults instantiates a new PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody 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 NewPrivateLinkConnectionServiceCreatePrivateLinkConnectionBodyWithDefaults() *PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody { - this := PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody{} - return &this -} - -// GetPrivateLinkConnection returns the PrivateLinkConnection field value -func (o *PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) GetPrivateLinkConnection() PrivateLinkConnection { - if o == nil { - var ret PrivateLinkConnection - return ret - } - - return o.PrivateLinkConnection -} - -// GetPrivateLinkConnectionOk returns a tuple with the PrivateLinkConnection field value -// and a boolean to check if the value has been set. -func (o *PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) GetPrivateLinkConnectionOk() (*PrivateLinkConnection, bool) { - if o == nil { - return nil, false - } - return &o.PrivateLinkConnection, true -} - -// SetPrivateLinkConnection sets field value -func (o *PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) SetPrivateLinkConnection(v PrivateLinkConnection) { - o.PrivateLinkConnection = v -} - -func (o PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["privateLinkConnection"] = o.PrivateLinkConnection - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) 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{ - "privateLinkConnection", - } - - 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) - } - } - - varPrivateLinkConnectionServiceCreatePrivateLinkConnectionBody := _PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody{} - - err = json.Unmarshal(data, &varPrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) - - if err != nil { - return err - } - - *o = PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody(varPrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "privateLinkConnection") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullablePrivateLinkConnectionServiceCreatePrivateLinkConnectionBody struct { - value *PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody - isSet bool -} - -func (v NullablePrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) Get() *PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody { - return v.value -} - -func (v *NullablePrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) Set(val *PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) { - v.value = val - v.isSet = true -} - -func (v NullablePrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) IsSet() bool { - return v.isSet -} - -func (v *NullablePrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullablePrivateLinkConnectionServiceCreatePrivateLinkConnectionBody(val *PrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) *NullablePrivateLinkConnectionServiceCreatePrivateLinkConnectionBody { - return &NullablePrivateLinkConnectionServiceCreatePrivateLinkConnectionBody{value: val, isSet: true} -} - -func (v NullablePrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullablePrivateLinkConnectionServiceCreatePrivateLinkConnectionBody) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_detach_domains_body.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_detach_domains_body.go deleted file mode 100644 index fe3a28fc..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_detach_domains_body.go +++ /dev/null @@ -1,167 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -import ( - "encoding/json" - "fmt" -) - -// checks if the PrivateLinkConnectionServiceDetachDomainsBody type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &PrivateLinkConnectionServiceDetachDomainsBody{} - -// PrivateLinkConnectionServiceDetachDomainsBody struct for PrivateLinkConnectionServiceDetachDomainsBody -type PrivateLinkConnectionServiceDetachDomainsBody struct { - // The attached domain ID to detach. - AttachDomainId string `json:"attachDomainId"` - AdditionalProperties map[string]interface{} -} - -type _PrivateLinkConnectionServiceDetachDomainsBody PrivateLinkConnectionServiceDetachDomainsBody - -// NewPrivateLinkConnectionServiceDetachDomainsBody instantiates a new PrivateLinkConnectionServiceDetachDomainsBody 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 NewPrivateLinkConnectionServiceDetachDomainsBody(attachDomainId string) *PrivateLinkConnectionServiceDetachDomainsBody { - this := PrivateLinkConnectionServiceDetachDomainsBody{} - this.AttachDomainId = attachDomainId - return &this -} - -// NewPrivateLinkConnectionServiceDetachDomainsBodyWithDefaults instantiates a new PrivateLinkConnectionServiceDetachDomainsBody 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 NewPrivateLinkConnectionServiceDetachDomainsBodyWithDefaults() *PrivateLinkConnectionServiceDetachDomainsBody { - this := PrivateLinkConnectionServiceDetachDomainsBody{} - return &this -} - -// GetAttachDomainId returns the AttachDomainId field value -func (o *PrivateLinkConnectionServiceDetachDomainsBody) GetAttachDomainId() string { - if o == nil { - var ret string - return ret - } - - return o.AttachDomainId -} - -// GetAttachDomainIdOk returns a tuple with the AttachDomainId field value -// and a boolean to check if the value has been set. -func (o *PrivateLinkConnectionServiceDetachDomainsBody) GetAttachDomainIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.AttachDomainId, true -} - -// SetAttachDomainId sets field value -func (o *PrivateLinkConnectionServiceDetachDomainsBody) SetAttachDomainId(v string) { - o.AttachDomainId = v -} - -func (o PrivateLinkConnectionServiceDetachDomainsBody) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o PrivateLinkConnectionServiceDetachDomainsBody) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["attachDomainId"] = o.AttachDomainId - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *PrivateLinkConnectionServiceDetachDomainsBody) 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{ - "attachDomainId", - } - - 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) - } - } - - varPrivateLinkConnectionServiceDetachDomainsBody := _PrivateLinkConnectionServiceDetachDomainsBody{} - - err = json.Unmarshal(data, &varPrivateLinkConnectionServiceDetachDomainsBody) - - if err != nil { - return err - } - - *o = PrivateLinkConnectionServiceDetachDomainsBody(varPrivateLinkConnectionServiceDetachDomainsBody) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "attachDomainId") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullablePrivateLinkConnectionServiceDetachDomainsBody struct { - value *PrivateLinkConnectionServiceDetachDomainsBody - isSet bool -} - -func (v NullablePrivateLinkConnectionServiceDetachDomainsBody) Get() *PrivateLinkConnectionServiceDetachDomainsBody { - return v.value -} - -func (v *NullablePrivateLinkConnectionServiceDetachDomainsBody) Set(val *PrivateLinkConnectionServiceDetachDomainsBody) { - v.value = val - v.isSet = true -} - -func (v NullablePrivateLinkConnectionServiceDetachDomainsBody) IsSet() bool { - return v.isSet -} - -func (v *NullablePrivateLinkConnectionServiceDetachDomainsBody) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullablePrivateLinkConnectionServiceDetachDomainsBody(val *PrivateLinkConnectionServiceDetachDomainsBody) *NullablePrivateLinkConnectionServiceDetachDomainsBody { - return &NullablePrivateLinkConnectionServiceDetachDomainsBody{value: val, isSet: true} -} - -func (v NullablePrivateLinkConnectionServiceDetachDomainsBody) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullablePrivateLinkConnectionServiceDetachDomainsBody) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_list_private_link_connections_state_parameter.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_list_private_link_connections_state_parameter.go deleted file mode 100644 index a1c3b138..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_service_list_private_link_connections_state_parameter.go +++ /dev/null @@ -1,111 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -import ( - "encoding/json" -) - -// PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter the model 'PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter' -type PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter string - -// List of PrivateLinkConnectionService_ListPrivateLinkConnections_state_parameter -const ( - PRIVATELINKCONNECTIONSERVICELISTPRIVATELINKCONNECTIONSSTATEPARAMETER_CREATING PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter = "CREATING" - PRIVATELINKCONNECTIONSERVICELISTPRIVATELINKCONNECTIONSSTATEPARAMETER_ACTIVE PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter = "ACTIVE" - PRIVATELINKCONNECTIONSERVICELISTPRIVATELINKCONNECTIONSSTATEPARAMETER_FAILED PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter = "FAILED" - PRIVATELINKCONNECTIONSERVICELISTPRIVATELINKCONNECTIONSSTATEPARAMETER_PENDING_ACCEPTANCE PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter = "PENDING_ACCEPTANCE" - PRIVATELINKCONNECTIONSERVICELISTPRIVATELINKCONNECTIONSSTATEPARAMETER_DELETING PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter = "DELETING" -) - -// All allowed values of PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter enum -var AllowedPrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameterEnumValues = []PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter{ - "CREATING", - "ACTIVE", - "FAILED", - "PENDING_ACCEPTANCE", - "DELETING", -} - -func (v *PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) UnmarshalJSON(src []byte) error { - var value string - err := json.Unmarshal(src, &value) - if err != nil { - return err - } - enumTypeValue := PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter(value) - for _, existing := range AllowedPrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameterEnumValues { - if existing == enumTypeValue { - *v = enumTypeValue - return nil - } - } - - *v = PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter(value) - return nil -} - -// NewPrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameterFromValue returns a pointer to a valid PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter for the value passed as argument -func NewPrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameterFromValue(v string) *PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter { - ev := PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter(v) - return &ev -} - -// IsValid return true if the value is valid for the enum, false otherwise -func (v PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) IsValid() bool { - for _, existing := range AllowedPrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameterEnumValues { - if existing == v { - return true - } - } - return false -} - -// Ptr returns reference to PrivateLinkConnectionService_ListPrivateLinkConnections_state_parameter value -func (v PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) Ptr() *PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter { - return &v -} - -type NullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter struct { - value *PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter - isSet bool -} - -func (v NullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) Get() *PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter { - return v.value -} - -func (v *NullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) Set(val *PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) { - v.value = val - v.isSet = true -} - -func (v NullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) IsSet() bool { - return v.isSet -} - -func (v *NullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter(val *PrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) *NullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter { - return &NullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter{value: val, isSet: true} -} - -func (v NullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullablePrivateLinkConnectionServiceListPrivateLinkConnectionsStateParameter) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_state_enum.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_state_enum.go deleted file mode 100644 index d07e374e..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_state_enum.go +++ /dev/null @@ -1,111 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -import ( - "encoding/json" -) - -// PrivateLinkConnectionStateEnum - CREATING: The private link connection is being created. - ACTIVE: The private link connection is active. - FAILED: The private link connection is in failed state. - PENDING_ACCEPTANCE: The private link connection is pending acceptance. only for AWS endpoint service and Alicloud endpoint service. - DELETING: The private link connection is being deleted. -type PrivateLinkConnectionStateEnum string - -// List of PrivateLinkConnectionState.Enum -const ( - PRIVATELINKCONNECTIONSTATEENUM_CREATING PrivateLinkConnectionStateEnum = "CREATING" - PRIVATELINKCONNECTIONSTATEENUM_ACTIVE PrivateLinkConnectionStateEnum = "ACTIVE" - PRIVATELINKCONNECTIONSTATEENUM_FAILED PrivateLinkConnectionStateEnum = "FAILED" - PRIVATELINKCONNECTIONSTATEENUM_PENDING_ACCEPTANCE PrivateLinkConnectionStateEnum = "PENDING_ACCEPTANCE" - PRIVATELINKCONNECTIONSTATEENUM_DELETING PrivateLinkConnectionStateEnum = "DELETING" -) - -// All allowed values of PrivateLinkConnectionStateEnum enum -var AllowedPrivateLinkConnectionStateEnumEnumValues = []PrivateLinkConnectionStateEnum{ - "CREATING", - "ACTIVE", - "FAILED", - "PENDING_ACCEPTANCE", - "DELETING", -} - -func (v *PrivateLinkConnectionStateEnum) UnmarshalJSON(src []byte) error { - var value string - err := json.Unmarshal(src, &value) - if err != nil { - return err - } - enumTypeValue := PrivateLinkConnectionStateEnum(value) - for _, existing := range AllowedPrivateLinkConnectionStateEnumEnumValues { - if existing == enumTypeValue { - *v = enumTypeValue - return nil - } - } - - *v = PrivateLinkConnectionStateEnum(value) - return nil -} - -// NewPrivateLinkConnectionStateEnumFromValue returns a pointer to a valid PrivateLinkConnectionStateEnum for the value passed as argument -func NewPrivateLinkConnectionStateEnumFromValue(v string) *PrivateLinkConnectionStateEnum { - ev := PrivateLinkConnectionStateEnum(v) - return &ev -} - -// IsValid return true if the value is valid for the enum, false otherwise -func (v PrivateLinkConnectionStateEnum) IsValid() bool { - for _, existing := range AllowedPrivateLinkConnectionStateEnumEnumValues { - if existing == v { - return true - } - } - return false -} - -// Ptr returns reference to PrivateLinkConnectionState.Enum value -func (v PrivateLinkConnectionStateEnum) Ptr() *PrivateLinkConnectionStateEnum { - return &v -} - -type NullablePrivateLinkConnectionStateEnum struct { - value *PrivateLinkConnectionStateEnum - isSet bool -} - -func (v NullablePrivateLinkConnectionStateEnum) Get() *PrivateLinkConnectionStateEnum { - return v.value -} - -func (v *NullablePrivateLinkConnectionStateEnum) Set(val *PrivateLinkConnectionStateEnum) { - v.value = val - v.isSet = true -} - -func (v NullablePrivateLinkConnectionStateEnum) IsSet() bool { - return v.isSet -} - -func (v *NullablePrivateLinkConnectionStateEnum) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullablePrivateLinkConnectionStateEnum(val *PrivateLinkConnectionStateEnum) *NullablePrivateLinkConnectionStateEnum { - return &NullablePrivateLinkConnectionStateEnum{value: val, isSet: true} -} - -func (v NullablePrivateLinkConnectionStateEnum) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullablePrivateLinkConnectionStateEnum) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_type_enum.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_type_enum.go deleted file mode 100644 index 9faaef09..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_private_link_connection_type_enum.go +++ /dev/null @@ -1,105 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -import ( - "encoding/json" -) - -// PrivateLinkConnectionTypeEnum - AWS_ENDPOINT_SERVICE: AWS endpoint service type. - ALICLOUD_ENDPOINT_SERVICE: Alicloud endpoint service type. -type PrivateLinkConnectionTypeEnum string - -// List of PrivateLinkConnectionType.Enum -const ( - PRIVATELINKCONNECTIONTYPEENUM_AWS_ENDPOINT_SERVICE PrivateLinkConnectionTypeEnum = "AWS_ENDPOINT_SERVICE" - PRIVATELINKCONNECTIONTYPEENUM_ALICLOUD_ENDPOINT_SERVICE PrivateLinkConnectionTypeEnum = "ALICLOUD_ENDPOINT_SERVICE" -) - -// All allowed values of PrivateLinkConnectionTypeEnum enum -var AllowedPrivateLinkConnectionTypeEnumEnumValues = []PrivateLinkConnectionTypeEnum{ - "AWS_ENDPOINT_SERVICE", - "ALICLOUD_ENDPOINT_SERVICE", -} - -func (v *PrivateLinkConnectionTypeEnum) UnmarshalJSON(src []byte) error { - var value string - err := json.Unmarshal(src, &value) - if err != nil { - return err - } - enumTypeValue := PrivateLinkConnectionTypeEnum(value) - for _, existing := range AllowedPrivateLinkConnectionTypeEnumEnumValues { - if existing == enumTypeValue { - *v = enumTypeValue - return nil - } - } - - *v = PrivateLinkConnectionTypeEnum(value) - return nil -} - -// NewPrivateLinkConnectionTypeEnumFromValue returns a pointer to a valid PrivateLinkConnectionTypeEnum for the value passed as argument -func NewPrivateLinkConnectionTypeEnumFromValue(v string) *PrivateLinkConnectionTypeEnum { - ev := PrivateLinkConnectionTypeEnum(v) - return &ev -} - -// IsValid return true if the value is valid for the enum, false otherwise -func (v PrivateLinkConnectionTypeEnum) IsValid() bool { - for _, existing := range AllowedPrivateLinkConnectionTypeEnumEnumValues { - if existing == v { - return true - } - } - return false -} - -// Ptr returns reference to PrivateLinkConnectionType.Enum value -func (v PrivateLinkConnectionTypeEnum) Ptr() *PrivateLinkConnectionTypeEnum { - return &v -} - -type NullablePrivateLinkConnectionTypeEnum struct { - value *PrivateLinkConnectionTypeEnum - isSet bool -} - -func (v NullablePrivateLinkConnectionTypeEnum) Get() *PrivateLinkConnectionTypeEnum { - return v.value -} - -func (v *NullablePrivateLinkConnectionTypeEnum) Set(val *PrivateLinkConnectionTypeEnum) { - v.value = val - v.isSet = true -} - -func (v NullablePrivateLinkConnectionTypeEnum) IsSet() bool { - return v.isSet -} - -func (v *NullablePrivateLinkConnectionTypeEnum) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullablePrivateLinkConnectionTypeEnum(val *PrivateLinkConnectionTypeEnum) *NullablePrivateLinkConnectionTypeEnum { - return &NullablePrivateLinkConnectionTypeEnum{value: val, isSet: true} -} - -func (v NullablePrivateLinkConnectionTypeEnum) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullablePrivateLinkConnectionTypeEnum) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_status.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/model_status.go deleted file mode 100644 index 444f53ac..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/model_status.go +++ /dev/null @@ -1,227 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -import ( - "encoding/json" -) - -// checks if the Status type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &Status{} - -// Status struct for Status -type Status struct { - Code *int32 `json:"code,omitempty"` - Message *string `json:"message,omitempty"` - Details []Any `json:"details,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _Status Status - -// NewStatus instantiates a new Status object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewStatus() *Status { - this := Status{} - return &this -} - -// NewStatusWithDefaults instantiates a new Status object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewStatusWithDefaults() *Status { - this := Status{} - return &this -} - -// GetCode returns the Code field value if set, zero value otherwise. -func (o *Status) GetCode() int32 { - if o == nil || IsNil(o.Code) { - var ret int32 - return ret - } - return *o.Code -} - -// GetCodeOk returns a tuple with the Code field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Status) GetCodeOk() (*int32, bool) { - if o == nil || IsNil(o.Code) { - return nil, false - } - return o.Code, true -} - -// HasCode returns a boolean if a field has been set. -func (o *Status) HasCode() bool { - if o != nil && !IsNil(o.Code) { - return true - } - - return false -} - -// SetCode gets a reference to the given int32 and assigns it to the Code field. -func (o *Status) SetCode(v int32) { - o.Code = &v -} - -// GetMessage returns the Message field value if set, zero value otherwise. -func (o *Status) GetMessage() string { - if o == nil || IsNil(o.Message) { - var ret string - return ret - } - return *o.Message -} - -// GetMessageOk returns a tuple with the Message field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Status) GetMessageOk() (*string, bool) { - if o == nil || IsNil(o.Message) { - return nil, false - } - return o.Message, true -} - -// HasMessage returns a boolean if a field has been set. -func (o *Status) HasMessage() bool { - if o != nil && !IsNil(o.Message) { - return true - } - - return false -} - -// SetMessage gets a reference to the given string and assigns it to the Message field. -func (o *Status) SetMessage(v string) { - o.Message = &v -} - -// GetDetails returns the Details field value if set, zero value otherwise. -func (o *Status) GetDetails() []Any { - if o == nil || IsNil(o.Details) { - var ret []Any - return ret - } - return o.Details -} - -// GetDetailsOk returns a tuple with the Details field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Status) GetDetailsOk() ([]Any, bool) { - if o == nil || IsNil(o.Details) { - return nil, false - } - return o.Details, true -} - -// HasDetails returns a boolean if a field has been set. -func (o *Status) HasDetails() bool { - if o != nil && !IsNil(o.Details) { - return true - } - - return false -} - -// SetDetails gets a reference to the given []Any and assigns it to the Details field. -func (o *Status) SetDetails(v []Any) { - o.Details = v -} - -func (o Status) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o Status) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Code) { - toSerialize["code"] = o.Code - } - if !IsNil(o.Message) { - toSerialize["message"] = o.Message - } - if !IsNil(o.Details) { - toSerialize["details"] = o.Details - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *Status) UnmarshalJSON(data []byte) (err error) { - varStatus := _Status{} - - err = json.Unmarshal(data, &varStatus) - - if err != nil { - return err - } - - *o = Status(varStatus) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "code") - delete(additionalProperties, "message") - delete(additionalProperties, "details") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableStatus struct { - value *Status - isSet bool -} - -func (v NullableStatus) Get() *Status { - return v.value -} - -func (v *NullableStatus) Set(val *Status) { - v.value = val - v.isSet = true -} - -func (v NullableStatus) IsSet() bool { - return v.isSet -} - -func (v *NullableStatus) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableStatus(val *Status) *NullableStatus { - return &NullableStatus{value: val, isSet: true} -} - -func (v NullableStatus) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableStatus) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/pkg/tidbcloud/v1beta1/serverless/privatelink/response.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/response.go deleted file mode 100644 index 412bedb2..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/response.go +++ /dev/null @@ -1,47 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -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/privatelink/utils.go b/pkg/tidbcloud/v1beta1/serverless/privatelink/utils.go deleted file mode 100644 index c00cd816..00000000 --- a/pkg/tidbcloud/v1beta1/serverless/privatelink/utils.go +++ /dev/null @@ -1,361 +0,0 @@ -/* -TiDB Cloud Serverless Private Link Connection Open API - -TiDB Cloud Serverless Private Link Connection Open API - -API version: v1beta1 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package privatelink - -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...) -} From ec524f16e9f4f336a8e6d1ae65d18d229ce542e6 Mon Sep 17 00:00:00 2001 From: shiyuhang <1136742008@qq.com> Date: Thu, 5 Feb 2026 18:17:07 +0800 Subject: [PATCH 3/9] delete docs --- ...loud_serverless_private-link-connection.md | 29 ------------ ..._private-link-connection_attach-domains.md | 41 ----------------- ...rverless_private-link-connection_attach.md | 41 ----------------- ...rverless_private-link-connection_create.md | 45 ------------------- ...rverless_private-link-connection_delete.md | 39 ---------------- ...erless_private-link-connection_describe.md | 38 ---------------- ..._private-link-connection_detach-domains.md | 39 ---------------- ...rverless_private-link-connection_detach.md | 39 ---------------- ...serverless_private-link-connection_list.md | 38 ---------------- ...erverless_private-link-connection_zones.md | 37 --------------- 10 files changed, 386 deletions(-) delete mode 100644 docs/generate_doc/ticloud_serverless_private-link-connection.md delete mode 100644 docs/generate_doc/ticloud_serverless_private-link-connection_attach-domains.md delete mode 100644 docs/generate_doc/ticloud_serverless_private-link-connection_attach.md delete mode 100644 docs/generate_doc/ticloud_serverless_private-link-connection_create.md delete mode 100644 docs/generate_doc/ticloud_serverless_private-link-connection_delete.md delete mode 100644 docs/generate_doc/ticloud_serverless_private-link-connection_describe.md delete mode 100644 docs/generate_doc/ticloud_serverless_private-link-connection_detach-domains.md delete mode 100644 docs/generate_doc/ticloud_serverless_private-link-connection_detach.md delete mode 100644 docs/generate_doc/ticloud_serverless_private-link-connection_list.md delete mode 100644 docs/generate_doc/ticloud_serverless_private-link-connection_zones.md diff --git a/docs/generate_doc/ticloud_serverless_private-link-connection.md b/docs/generate_doc/ticloud_serverless_private-link-connection.md deleted file mode 100644 index 23d2f300..00000000 --- a/docs/generate_doc/ticloud_serverless_private-link-connection.md +++ /dev/null @@ -1,29 +0,0 @@ -## ticloud serverless private-link-connection - -Manage private link connections for dataflow - -### Options - -``` - -h, --help help for private-link-connection -``` - -### Options inherited from parent commands - -``` - -D, --debug Enable debug mode - --no-color Disable color output - -P, --profile string Profile to use from your configuration file -``` - -### SEE ALSO - -* [ticloud serverless](ticloud_serverless.md) - Manage TiDB Cloud Serverless clusters -* [ticloud serverless private-link-connection attach-domains](ticloud_serverless_private-link-connection_attach-domains.md) - Attach domains to a private link connection -* [ticloud serverless private-link-connection create](ticloud_serverless_private-link-connection_create.md) - Create a private link connection for dataflow -* [ticloud serverless private-link-connection delete](ticloud_serverless_private-link-connection_delete.md) - Delete a private link connection for dataflow -* [ticloud serverless private-link-connection describe](ticloud_serverless_private-link-connection_describe.md) - Describe a private link connection for dataflow -* [ticloud serverless private-link-connection detach-domains](ticloud_serverless_private-link-connection_detach-domains.md) - Detach domains from a private link connection -* [ticloud serverless private-link-connection list](ticloud_serverless_private-link-connection_list.md) - List private link connections for dataflow -* [ticloud serverless private-link-connection zones](ticloud_serverless_private-link-connection_zones.md) - Get account and availability zones - diff --git a/docs/generate_doc/ticloud_serverless_private-link-connection_attach-domains.md b/docs/generate_doc/ticloud_serverless_private-link-connection_attach-domains.md deleted file mode 100644 index 28f437ff..00000000 --- a/docs/generate_doc/ticloud_serverless_private-link-connection_attach-domains.md +++ /dev/null @@ -1,41 +0,0 @@ -## ticloud serverless private-link-connection attach-domains - -Attach domains to a private link connection - -``` -ticloud serverless private-link-connection attach-domains [flags] -``` - -### Examples - -``` - Attach domain (interactive): - $ ticloud serverless private-link-connection attach-domains - - Attach domain (non-interactive): - $ ticloud serverless private-link-connection attach-domains -c --private-link-connection-id --type --unique-name -``` - -### Options - -``` - -c, --cluster-id string The cluster ID. - --dry-run Set dry run mode to only show generated domains without attaching them. - -h, --help help for attach-domains - --private-link-connection-id string The private link connection ID. - --type string The type of domain to attach, one of: [TIDBCLOUD_MANAGED CONFLUENT] - --unique-name string The unique name of the domain to attach, you can use --dry-run to generate the unique name when attaching a TiDB Cloud managed domain. -``` - -### Options inherited from parent commands - -``` - -D, --debug Enable debug mode - --no-color Disable color output - -P, --profile string Profile to use from your configuration file -``` - -### SEE ALSO - -* [ticloud serverless private-link-connection](ticloud_serverless_private-link-connection.md) - Manage private link connections for dataflow - diff --git a/docs/generate_doc/ticloud_serverless_private-link-connection_attach.md b/docs/generate_doc/ticloud_serverless_private-link-connection_attach.md deleted file mode 100644 index fb0777f9..00000000 --- a/docs/generate_doc/ticloud_serverless_private-link-connection_attach.md +++ /dev/null @@ -1,41 +0,0 @@ -## ticloud serverless private-link-connection attach - -Attach domains to a private link connection - -``` -ticloud serverless private-link-connection attach [flags] -``` - -### Examples - -``` - Attach domain (interactive): - $ ticloud serverless private-link-connection attach - - Attach domain (non-interactive): - $ ticloud serverless private-link-connection attach -c --private-link-connection-id --type --unique-name -``` - -### Options - -``` - -c, --cluster-id string The cluster ID. - --dry-run set dry run mode to only show generated domains without attaching them. - -h, --help help for attach - --private-link-connection-id string The private link connection ID. - --type string The type of domain to attach, one of: [TIDBCLOUD_MANAGED CONFLUENT] - --unique-name string The unique name of the domain to attach, you can use --dry-run to generate the unique name when attaching a TiDB Cloud managed domain. -``` - -### Options inherited from parent commands - -``` - -D, --debug Enable debug mode - --no-color Disable color output - -P, --profile string Profile to use from your configuration file -``` - -### SEE ALSO - -* [ticloud serverless private-link-connection](ticloud_serverless_private-link-connection.md) - Manage private link connections for dataflow - diff --git a/docs/generate_doc/ticloud_serverless_private-link-connection_create.md b/docs/generate_doc/ticloud_serverless_private-link-connection_create.md deleted file mode 100644 index c0eab865..00000000 --- a/docs/generate_doc/ticloud_serverless_private-link-connection_create.md +++ /dev/null @@ -1,45 +0,0 @@ -## ticloud serverless private-link-connection create - -Create a private link connection for dataflow - -``` -ticloud serverless private-link-connection create [flags] -``` - -### Examples - -``` - Create a private link connection (interactive): - $ ticloud serverless private-link-connection create - - Create a private link connection which connect to alicloud endpoint service (non-interactive): - $ ticloud serverless private-link-connection create -c --display-name --type ALICLOUD_ENDPOINT_SERVICE --alicloud.endpoint-service-name - - Create a private link connection which connect to aws endpoint service (non-interactive): - $ ticloud serverless private-link-connection create -c --display-name --type AWS_ENDPOINT_SERVICE --aws.endpoint-service-name -``` - -### Options - -``` - --alicloud.endpoint-service-name string Alicloud endpoint service name. - --aws.endpoint-service-name string AWS endpoint service name. - --aws.endpoint-service-region string AWS endpoint service region. - -c, --cluster-id string The cluster ID. - --display-name string Display name for the private link connection. - -h, --help help for create - --type string Type of the private link connection, one of ["AWS_ENDPOINT_SERVICE" "ALICLOUD_ENDPOINT_SERVICE"] -``` - -### Options inherited from parent commands - -``` - -D, --debug Enable debug mode - --no-color Disable color output - -P, --profile string Profile to use from your configuration file -``` - -### SEE ALSO - -* [ticloud serverless private-link-connection](ticloud_serverless_private-link-connection.md) - Manage private link connections for dataflow - diff --git a/docs/generate_doc/ticloud_serverless_private-link-connection_delete.md b/docs/generate_doc/ticloud_serverless_private-link-connection_delete.md deleted file mode 100644 index 504b8ccc..00000000 --- a/docs/generate_doc/ticloud_serverless_private-link-connection_delete.md +++ /dev/null @@ -1,39 +0,0 @@ -## ticloud serverless private-link-connection delete - -Delete a private link connection for dataflow - -``` -ticloud serverless private-link-connection delete [flags] -``` - -### Examples - -``` - Delete a private link connection (interactive): - $ ticloud serverless private-link-connection delete - - Delete a private link connection (non-interactive): - $ ticloud serverless private-link-connection delete -c --private-link-connection-id -``` - -### Options - -``` - -c, --cluster-id string The cluster ID. - --force Delete without confirmation. - -h, --help help for delete - --private-link-connection-id string The private link connection ID. -``` - -### Options inherited from parent commands - -``` - -D, --debug Enable debug mode - --no-color Disable color output - -P, --profile string Profile to use from your configuration file -``` - -### SEE ALSO - -* [ticloud serverless private-link-connection](ticloud_serverless_private-link-connection.md) - Manage private link connections for dataflow - diff --git a/docs/generate_doc/ticloud_serverless_private-link-connection_describe.md b/docs/generate_doc/ticloud_serverless_private-link-connection_describe.md deleted file mode 100644 index b8b58327..00000000 --- a/docs/generate_doc/ticloud_serverless_private-link-connection_describe.md +++ /dev/null @@ -1,38 +0,0 @@ -## ticloud serverless private-link-connection describe - -Describe a private link connection for dataflow - -``` -ticloud serverless private-link-connection describe [flags] -``` - -### Examples - -``` - Describe a private link connection (interactive): - $ ticloud serverless private-link-connection describe - - Describe a private link connection (non-interactive): - $ ticloud serverless private-link-connection describe -c --private-link-connection-id -``` - -### Options - -``` - -c, --cluster-id string The cluster ID. - -h, --help help for describe - --private-link-connection-id string The private link connection ID. -``` - -### Options inherited from parent commands - -``` - -D, --debug Enable debug mode - --no-color Disable color output - -P, --profile string Profile to use from your configuration file -``` - -### SEE ALSO - -* [ticloud serverless private-link-connection](ticloud_serverless_private-link-connection.md) - Manage private link connections for dataflow - diff --git a/docs/generate_doc/ticloud_serverless_private-link-connection_detach-domains.md b/docs/generate_doc/ticloud_serverless_private-link-connection_detach-domains.md deleted file mode 100644 index 82015c70..00000000 --- a/docs/generate_doc/ticloud_serverless_private-link-connection_detach-domains.md +++ /dev/null @@ -1,39 +0,0 @@ -## ticloud serverless private-link-connection detach-domains - -Detach domains from a private link connection - -``` -ticloud serverless private-link-connection detach-domains [flags] -``` - -### Examples - -``` - Detach domains (interactive): - $ ticloud serverless private-link-connection detach - - Detach domains (non-interactive): - $ ticloud serverless private-link-connection detach-domains -c --private-link-connection-id --attach-domain-id -``` - -### Options - -``` - --attach-domain-id string The private link connection attach domain ID. - -c, --cluster-id string The cluster ID. - -h, --help help for detach-domains - --private-link-connection-id string The private link connection ID. -``` - -### Options inherited from parent commands - -``` - -D, --debug Enable debug mode - --no-color Disable color output - -P, --profile string Profile to use from your configuration file -``` - -### SEE ALSO - -* [ticloud serverless private-link-connection](ticloud_serverless_private-link-connection.md) - Manage private link connections for dataflow - diff --git a/docs/generate_doc/ticloud_serverless_private-link-connection_detach.md b/docs/generate_doc/ticloud_serverless_private-link-connection_detach.md deleted file mode 100644 index 6e6034d6..00000000 --- a/docs/generate_doc/ticloud_serverless_private-link-connection_detach.md +++ /dev/null @@ -1,39 +0,0 @@ -## ticloud serverless private-link-connection detach - -Detach domains from a private link connection - -``` -ticloud serverless private-link-connection detach [flags] -``` - -### Examples - -``` - Detach domains (interactive): - $ ticloud serverless private-link-connection detach - - Detach domains (non-interactive): - $ ticloud serverless private-link-connection detach -c --private-link-connection-id --plc-attach-domain-id -``` - -### Options - -``` - -c, --cluster-id string The cluster ID. - -h, --help help for detach - --plc-attach-domain-id string The private link connection attach domain ID. - --private-link-connection-id string The private link connection ID. -``` - -### Options inherited from parent commands - -``` - -D, --debug Enable debug mode - --no-color Disable color output - -P, --profile string Profile to use from your configuration file -``` - -### SEE ALSO - -* [ticloud serverless private-link-connection](ticloud_serverless_private-link-connection.md) - Manage private link connections for dataflow - diff --git a/docs/generate_doc/ticloud_serverless_private-link-connection_list.md b/docs/generate_doc/ticloud_serverless_private-link-connection_list.md deleted file mode 100644 index 63040c82..00000000 --- a/docs/generate_doc/ticloud_serverless_private-link-connection_list.md +++ /dev/null @@ -1,38 +0,0 @@ -## ticloud serverless private-link-connection list - -List private link connections for dataflow - -``` -ticloud serverless private-link-connection list [flags] -``` - -### Examples - -``` - List private link connections (interactive): - $ ticloud serverless private-link-connection list - - Describe a private link connection (non-interactive): - $ ticloud serverless private-link-connection list -c -``` - -### Options - -``` - -c, --cluster-id string The cluster ID. - -h, --help help for list - -o, --output string Output format, one of ["human" "json"]. For the complete result, please use json format. (default "human") -``` - -### Options inherited from parent commands - -``` - -D, --debug Enable debug mode - --no-color Disable color output - -P, --profile string Profile to use from your configuration file -``` - -### SEE ALSO - -* [ticloud serverless private-link-connection](ticloud_serverless_private-link-connection.md) - Manage private link connections for dataflow - diff --git a/docs/generate_doc/ticloud_serverless_private-link-connection_zones.md b/docs/generate_doc/ticloud_serverless_private-link-connection_zones.md deleted file mode 100644 index dfc5a2d6..00000000 --- a/docs/generate_doc/ticloud_serverless_private-link-connection_zones.md +++ /dev/null @@ -1,37 +0,0 @@ -## ticloud serverless private-link-connection zones - -Get account and availability zones - -``` -ticloud serverless private-link-connection zones [flags] -``` - -### Examples - -``` - Get availability zones (interactive): - $ ticloud serverless private-link-connection get-zones - - Get availability zones (non-interactive): - $ ticloud serverless private-link-connection zones -c -``` - -### Options - -``` - -c, --cluster-id string The cluster ID. - -h, --help help for zones -``` - -### Options inherited from parent commands - -``` - -D, --debug Enable debug mode - --no-color Disable color output - -P, --profile string Profile to use from your configuration file -``` - -### SEE ALSO - -* [ticloud serverless private-link-connection](ticloud_serverless_private-link-connection.md) - Manage private link connections for dataflow - From 6403cdacd44588d096103c2a6c4f32c4d2b32b93 Mon Sep 17 00:00:00 2001 From: shiyuhang <1136742008@qq.com> Date: Thu, 5 Feb 2026 18:17:56 +0800 Subject: [PATCH 4/9] delete docs --- docs/generate_doc/ticloud_serverless.md | 1 - internal/flag/flag.go | 9 --------- 2 files changed, 10 deletions(-) diff --git a/docs/generate_doc/ticloud_serverless.md b/docs/generate_doc/ticloud_serverless.md index d2c09ca0..6decb28b 100644 --- a/docs/generate_doc/ticloud_serverless.md +++ b/docs/generate_doc/ticloud_serverless.md @@ -31,7 +31,6 @@ Manage TiDB Cloud Serverless clusters * [ticloud serverless import](ticloud_serverless_import.md) - Manage TiDB Cloud Serverless data imports * [ticloud serverless list](ticloud_serverless_list.md) - List all TiDB Cloud Serverless clusters * [ticloud serverless migration](ticloud_serverless_migration.md) - Manage TiDB Cloud Serverless migrations -* [ticloud serverless private-link-connection](ticloud_serverless_private-link-connection.md) - Manage private link connections for dataflow * [ticloud serverless region](ticloud_serverless_region.md) - List all available regions for TiDB Cloud Serverless * [ticloud serverless shell](ticloud_serverless_shell.md) - Connect to a TiDB Cloud Serverless cluster * [ticloud serverless spending-limit](ticloud_serverless_spending-limit.md) - Set spending limit for a TiDB Cloud Serverless cluster diff --git a/internal/flag/flag.go b/internal/flag/flag.go index e81a11df..55397c9b 100644 --- a/internal/flag/flag.go +++ b/internal/flag/flag.go @@ -120,15 +120,6 @@ const ( Explain string = "explain" ChangefeedTemplateType string = "type" - PrivateLinkConnectionID string = "private-link-connection-id" - PrivateLinkConnectionType string = "type" - AWSEndpointServiceName string = "aws.endpoint-service-name" - AWSEndpointServiceRegion string = "aws.endpoint-service-region" - AlicloudEndpointServiceName string = "alicloud.endpoint-service-name" - PLCAttachDomainType string = "type" - PLCAttachDomainUniqueName string = "unique-name" - PLCAttachDomainID string = "attach-domain-id" - MigrationID string = "migration-id" MigrationIDShort string = "m" MigrationConfigFile string = "config-file" From ba91414b5f035973ee14c8d28df38415dba6893d Mon Sep 17 00:00:00 2001 From: shiyuhang <1136742008@qq.com> Date: Thu, 5 Feb 2026 18:23:12 +0800 Subject: [PATCH 5/9] opt and delete script --- .cursor/skills/create-ticloud-cli-command/SKILL.md | 2 +- .../skills/create-ticloud-cli-command/references/sdk.md | 9 ++++++--- Makefile | 4 ---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.cursor/skills/create-ticloud-cli-command/SKILL.md b/.cursor/skills/create-ticloud-cli-command/SKILL.md index cd1b5309..1f1657d5 100644 --- a/.cursor/skills/create-ticloud-cli-command/SKILL.md +++ b/.cursor/skills/create-ticloud-cli-command/SKILL.md @@ -107,7 +107,7 @@ Skip this step if the user does not need tests. Run tests with: `go test -race -cover -count=1 path -v` -For example, to run tests under `internal/cli/serverless/branch`: `go test -race -cover -count=1 ./internal/cli/serverless/branch -v` +For example, to run tests under `internal/cli/serverless/branch`: `go test -race -cover -count=1 ./internal/cli/serverless/branch -v`. Ensure all tests pass. If they do not pass, fix the implementation or the tests. diff --git a/.cursor/skills/create-ticloud-cli-command/references/sdk.md b/.cursor/skills/create-ticloud-cli-command/references/sdk.md index 84ff36c1..12426f2d 100644 --- a/.cursor/skills/create-ticloud-cli-command/references/sdk.md +++ b/.cursor/skills/create-ticloud-cli-command/references/sdk.md @@ -13,6 +13,9 @@ It is the user's responsibility to add or change Swagger files under `pkg/tidbcl It is the AI agent's responsibility to generate the SDK. Follow the workflow below: -1. Run the appropriate command based on where Swagger files were added or changed. For example, if `pkg/tidbcloud/v1beta1/serverless` changed, run `generate-v1beta1-serverless-client`. If you cannot determine which Swagger changed, run `make generate-v1beta1-client` to generate all. -2. Update `internal/service/cloud/api_client.go` according to the generated SDK. If new methods appear in the SDK, add new interface methods and implementations in `api_client.go` following the existing code style. If new API clients appear, wrap them in the `ClientDelegate` struct. -3. Run `make generate-mocks` to refresh mocks. Do not edit mock files by hand; they must be auto-generated by this command. \ No newline at end of file +1. Add +2. Run the appropriate command based on where Swagger files were added or changed. For example, if `pkg/tidbcloud/v1beta1/serverless` changed, run `generate-v1beta1-serverless-client`. If you cannot determine which Swagger changed, run `make generate-v1beta1-client` to generate all. +3. Update `internal/service/cloud/api_client.go` according to the generated SDK. If new methods appear in the SDK, add new interface methods and implementations in `api_client.go` following the existing code style. If new API clients appear, wrap them in the `ClientDelegate` struct. +4. Run `make generate-mocks` to refresh mocks. Do not edit mock files by hand; they must be auto-generated by this command. + +If any make command fails because of environment configuration, ask user to run the command instead. \ No newline at end of file diff --git a/Makefile b/Makefile index cd6ae38a..8a5f60c3 100644 --- a/Makefile +++ b/Makefile @@ -60,10 +60,6 @@ generate-v1beta1-serverless-client: install-openapi-generator ## Generate server rm -rf pkg/tidbcloud/v1beta1/serverless/migration cd tools/openapi-generator && npx openapi-generator-cli generate --inline-schema-options RESOLVE_INLINE_ENUMS=true --additional-properties=withGoMod=false,enumClassPrefix=true,disallowAdditionalPropertiesIfNotPresent=false --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/dm.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/migration --package-name migration -c go/config.yaml cd pkg && go fmt ./tidbcloud/v1beta1/serverless/... && goimports -w . - @echo "==> Generating serverless privatelink client" - rm -rf pkg/tidbcloud/v1beta1/serverless/privatelink - cd tools/openapi-generator && npx openapi-generator-cli generate --inline-schema-options RESOLVE_INLINE_ENUMS=true --additional-properties=withGoMod=false,enumClassPrefix=true,disallowAdditionalPropertiesIfNotPresent=false --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/privatelink.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/privatelink --package-name privatelink -c go/config.yaml - cd pkg && go fmt ./tidbcloud/v1beta1/serverless/... && goimports -w . .PHONY: generate-v1beta1-dedicated-client generate-v1beta1-dedicated-client: install-openapi-generator ## Generate dedicated client From 9a9a9f7895d512ea49a4aee32a7b7bec518e5e23 Mon Sep 17 00:00:00 2001 From: shiyuhang <1136742008@qq.com> Date: Thu, 5 Feb 2026 18:25:24 +0800 Subject: [PATCH 6/9] opt skill --- .cursor/skills/create-ticloud-cli-command/references/sdk.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cursor/skills/create-ticloud-cli-command/references/sdk.md b/.cursor/skills/create-ticloud-cli-command/references/sdk.md index 12426f2d..a5233bf7 100644 --- a/.cursor/skills/create-ticloud-cli-command/references/sdk.md +++ b/.cursor/skills/create-ticloud-cli-command/references/sdk.md @@ -13,7 +13,7 @@ It is the user's responsibility to add or change Swagger files under `pkg/tidbcl It is the AI agent's responsibility to generate the SDK. Follow the workflow below: -1. Add +1. If new swagger is added, add the generate client script in Makefile, refer the format under generate-v1beta1-serverless-client 2. Run the appropriate command based on where Swagger files were added or changed. For example, if `pkg/tidbcloud/v1beta1/serverless` changed, run `generate-v1beta1-serverless-client`. If you cannot determine which Swagger changed, run `make generate-v1beta1-client` to generate all. 3. Update `internal/service/cloud/api_client.go` according to the generated SDK. If new methods appear in the SDK, add new interface methods and implementations in `api_client.go` following the existing code style. If new API clients appear, wrap them in the `ClientDelegate` struct. 4. Run `make generate-mocks` to refresh mocks. Do not edit mock files by hand; they must be auto-generated by this command. From 7b88777342f4055847f1cea0b00237e62b88b9ce Mon Sep 17 00:00:00 2001 From: shiyuhang <1136742008@qq.com> Date: Thu, 5 Feb 2026 18:57:32 +0800 Subject: [PATCH 7/9] opt --- .cursor/skills/create-ticloud-cli-command/references/sdk.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.cursor/skills/create-ticloud-cli-command/references/sdk.md b/.cursor/skills/create-ticloud-cli-command/references/sdk.md index a5233bf7..db94bda7 100644 --- a/.cursor/skills/create-ticloud-cli-command/references/sdk.md +++ b/.cursor/skills/create-ticloud-cli-command/references/sdk.md @@ -16,6 +16,4 @@ It is the AI agent's responsibility to generate the SDK. Follow the workflow bel 1. If new swagger is added, add the generate client script in Makefile, refer the format under generate-v1beta1-serverless-client 2. Run the appropriate command based on where Swagger files were added or changed. For example, if `pkg/tidbcloud/v1beta1/serverless` changed, run `generate-v1beta1-serverless-client`. If you cannot determine which Swagger changed, run `make generate-v1beta1-client` to generate all. 3. Update `internal/service/cloud/api_client.go` according to the generated SDK. If new methods appear in the SDK, add new interface methods and implementations in `api_client.go` following the existing code style. If new API clients appear, wrap them in the `ClientDelegate` struct. -4. Run `make generate-mocks` to refresh mocks. Do not edit mock files by hand; they must be auto-generated by this command. - -If any make command fails because of environment configuration, ask user to run the command instead. \ No newline at end of file +4. Run `make generate-mocks` to refresh mocks. Do not edit mock files by hand; they must be auto-generated by this command. If `make generate-mocks` runs failed, ask user to run it. Do not continue before this command success unless user ask to skip! \ No newline at end of file From 516c31083d3a4187b11f03a79adf37b1841a1f91 Mon Sep 17 00:00:00 2001 From: shiyuhang <1136742008@qq.com> Date: Mon, 9 Feb 2026 11:56:47 +0800 Subject: [PATCH 8/9] opt --- .cursor/skills/create-ticloud-cli-command/README.md | 12 ++++++++++++ .cursor/skills/create-ticloud-cli-command/SKILL.md | 2 ++ .../create-ticloud-cli-command/assets/command.md | 9 +++++---- .../create-ticloud-cli-command/references/sdk.md | 3 +-- 4 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 .cursor/skills/create-ticloud-cli-command/README.md diff --git a/.cursor/skills/create-ticloud-cli-command/README.md b/.cursor/skills/create-ticloud-cli-command/README.md new file mode 100644 index 00000000..63eda5f1 --- /dev/null +++ b/.cursor/skills/create-ticloud-cli-command/README.md @@ -0,0 +1,12 @@ +# Guide for human + +It is the guide for human use. Do not read it as AI context. + +## How to use + +The create-ticloud-cli-command skill be triggered automatically whenever you want to create a new command. + +For example, you can trigger it by + +- 我希望创建一个 private link connection 相关的命令。 +- 我希望创建一个 private link connection 相关的命令,包含 ticloud serverless private-link-connection create, ticloud serverless private-link-connection,ticloud serverless private-link-connection list,ticloud serverless private-link-connection get,ticloud serverless private-link-connection delete 命令。 \ No newline at end of file diff --git a/.cursor/skills/create-ticloud-cli-command/SKILL.md b/.cursor/skills/create-ticloud-cli-command/SKILL.md index 1f1657d5..b351fc93 100644 --- a/.cursor/skills/create-ticloud-cli-command/SKILL.md +++ b/.cursor/skills/create-ticloud-cli-command/SKILL.md @@ -55,6 +55,8 @@ If detection fails, prompt the user: "Do you need to update swagger and generate Once in this phase, follow the guide in `references/sdk.md` to generate the SDK. +After SDK is generated, ask user to use go>=1.24 to run `make generate-mocks` manually! + ### Plan phase The agent must switch to plan mode in this phase. diff --git a/.cursor/skills/create-ticloud-cli-command/assets/command.md b/.cursor/skills/create-ticloud-cli-command/assets/command.md index 437b28ef..329a64bb 100644 --- a/.cursor/skills/create-ticloud-cli-command/assets/command.md +++ b/.cursor/skills/create-ticloud-cli-command/assets/command.md @@ -2,11 +2,12 @@ This document describes the command format users need to provide. The following uses the example resource: + ``` -example create: ticloud serverless example create -c --displayname -example get: ticloud serverless example get -c --example-id -example list: ticloud serverless example list -c --output -example delete: ticloud serverless example delete -c --example-id --force +ticloud serverless example create -c --displayname +ticloud serverless example get -c --example-id +ticloud serverless example list -c --output +ticloud serverless example delete -c --example-id --force ``` Flags can be omitted and inferred from the TiDB Cloud SDK. The following are also accepted: diff --git a/.cursor/skills/create-ticloud-cli-command/references/sdk.md b/.cursor/skills/create-ticloud-cli-command/references/sdk.md index db94bda7..b4641cb7 100644 --- a/.cursor/skills/create-ticloud-cli-command/references/sdk.md +++ b/.cursor/skills/create-ticloud-cli-command/references/sdk.md @@ -15,5 +15,4 @@ It is the AI agent's responsibility to generate the SDK. Follow the workflow bel 1. If new swagger is added, add the generate client script in Makefile, refer the format under generate-v1beta1-serverless-client 2. Run the appropriate command based on where Swagger files were added or changed. For example, if `pkg/tidbcloud/v1beta1/serverless` changed, run `generate-v1beta1-serverless-client`. If you cannot determine which Swagger changed, run `make generate-v1beta1-client` to generate all. -3. Update `internal/service/cloud/api_client.go` according to the generated SDK. If new methods appear in the SDK, add new interface methods and implementations in `api_client.go` following the existing code style. If new API clients appear, wrap them in the `ClientDelegate` struct. -4. Run `make generate-mocks` to refresh mocks. Do not edit mock files by hand; they must be auto-generated by this command. If `make generate-mocks` runs failed, ask user to run it. Do not continue before this command success unless user ask to skip! \ No newline at end of file +3. Update `internal/service/cloud/api_client.go` according to the generated SDK. If new methods appear in the SDK, add new interface methods and implementations in `api_client.go` following the existing code style. If new API clients appear, wrap them in the `ClientDelegate` struct. \ No newline at end of file From 42e7ee4e0dcef99f396e143b068d790cbc38fc86 Mon Sep 17 00:00:00 2001 From: shiyuhang <1136742008@qq.com> Date: Mon, 9 Feb 2026 13:04:52 +0800 Subject: [PATCH 9/9] opt --- .../create-ticloud-cli-command/SKILL.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.cursor/skills/create-ticloud-cli-command/SKILL.md b/.cursor/skills/create-ticloud-cli-command/SKILL.md index b351fc93..5d4e2fc2 100644 --- a/.cursor/skills/create-ticloud-cli-command/SKILL.md +++ b/.cursor/skills/create-ticloud-cli-command/SKILL.md @@ -49,9 +49,9 @@ Must follow the workflow below: ### Generate SDK phase -Detect whether there are new or modified Swagger files under `/pkg/tidbcloud`. Skip this phase if none are found. +Always prompt the user: "Do you need to add or update swagger? Please provide the swagger path if you need." -If detection fails, prompt the user: "Do you need to update swagger and generate SDK?" Skip this phase if the user does not need it. +Skip this phase if user does not need. Once in this phase, follow the guide in `references/sdk.md` to generate the SDK. @@ -62,7 +62,7 @@ After SDK is generated, ask user to use go>=1.24 to run `make generate-mocks` ma The agent must switch to plan mode in this phase. The agent must ask the user for the following information during the plan phase: -1. **Command format**: If the user does not provide the command format, ask them to provide it first. See `assets/command.md` for the command format template. +1. **Command format**: If the user does not provide the command format, ask them to provide it first. See `assets/command.md` for the command format template. The commnad flags can be omitted as it can be inferred from swagger. 2. **Tests**: Ask whether the user needs tests. Tests are recommended. 3. **Other necessary information** @@ -72,9 +72,14 @@ Generate the plan after the user confirms all the information. The agent must switch to agent mode in this phase. Follow the workflow below: -1. **Write unit tests** -2. **Implement command** -3. **Run tests** +1. **Ensure the generate SDK phase** +2. **Write unit tests** +3. **Implement command** +4. **Run tests** + +#### Ensure the sdk + +Ensure generate SDK phase has been done. #### Write unit tests @@ -90,7 +95,7 @@ The implementation must meet the following requirements: 1. **Command definition**: Include name, aliases, example, and other necessary attributes. -2. **Flags definition**: Include flag type, description, default value, etc. Infer flag information from the Swagger spec and SDK client parameters. See `references/flag.md` for more details. +2. **Flags definition**: Include flag type, description, default value, etc. Infer flag information from the Swagger spec and SDK client parameters. See `references/flag.md` for more details. Please get customer confirmation once the flags are set. 3. **Flags retrieval**: Implement retrieval logic for both interactive and non-interactive modes. For interactive mode, UI is required. The UI is based on the Bubbletea library. See `references/ui.md` for more details.