Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TiDB Cloud CLI New #17056

Merged
merged 22 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TOC-tidb-cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@
- [list](/tidb-cloud/ticloud-cluster-list.md)
- [update](/tidb-cloud/ticloud-serverless-update.md)
- [spending-limit](/tidb-cloud/ticloud-serverless-spending-limit.md)
- [regions](/tidb-cloud/ticloud-serverless-regions.md)
- [region](/tidb-cloud/ticloud-serverless-region.md)
- [shell](/tidb-cloud/ticloud-serverless-shell.md)
- branch
- [create](/tidb-cloud/ticloud-branch-create.md)
Expand Down
41 changes: 25 additions & 16 deletions tidb-cloud/cli-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ title: TiDB Cloud CLI Reference
summary: Provides an overview of TiDB Cloud CLI.
---

# TiDB Cloud CLI Reference
# TiDB Cloud CLI Reference <span style="color: #fff; background-color: #00bfff; border-radius: 4px; font-size: 0.5em; vertical-align: middle; margin-left: 16px; padding: 0 2px;">Beta</span>

> **Note:**
>
> TiDB Cloud CLI is in beta.

TiDB Cloud CLI is a command line interface, which allows you to operate TiDB Cloud from your terminal with a few lines of commands. In the TiDB Cloud CLI, you can easily manage your TiDB Cloud clusters, import data to your clusters, and perform more operations.

Expand All @@ -17,19 +21,19 @@ The following table lists the commands available for the TiDB Cloud CLI.

To use the `ticloud` CLI in your terminal, run `ticloud [command] [subcommand]`. If you are using [TiUP](https://docs.pingcap.com/tidb/stable/tiup-overview), use `tiup cloud [command] [subcommand]` instead.

| Command | Subcommand | Description |
|--------------------|--------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|
| auth | login, logout | Login and logout |
| serverless | create, delete, describe, list, update, spending-limit, regions, shell | Manage TiDB Serverless clusters |
| serverless branch | create, delete, describe, list, shell | Manage TiDB Serverless branches |
| serverless import | cancel, describe, list, start | Manage TiDB Serverless [import](/tidb-cloud/tidb-cloud-migration-overview.md#import-data-from-files-to-tidb-cloud) tasks |
| serverless export | create, describe, list, cancel, download | Manage TiDB Serverless export tasks |
| ai | - | Chat with TiDB Bot |
| completion | bash, fish, powershell, zsh | Generate completion script for specified shell |
| config | create, delete, describe, edit, list, set, use | Configure user profiles |
| project | list | Manage projects |
| update | - | Update the CLI to the latest version |
| help | cluster, completion, config, help, import, project, update | View help for any command |
| Command | Subcommand | Description |
|-------------------|--------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|
| auth | login, logout | Login and logout |
| serverless (alias: s) | create, delete, describe, list, update, spending-limit, regions, shell | Manage TiDB Serverless clusters |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| serverless (alias: s) | create, delete, describe, list, update, spending-limit, regions, shell | Manage TiDB Serverless clusters |
| serverless (alias: s) | create, delete, describe, list, update, spending-limit, region, shell | Manage TiDB Serverless clusters |

qiancai marked this conversation as resolved.
Show resolved Hide resolved
| serverless branch | create, delete, describe, list, shell | Manage TiDB Serverless branches |
| serverless import | cancel, describe, list, start | Manage TiDB Serverless import tasks |
| serverless export | create, describe, list, cancel, download | Manage TiDB Serverless export tasks |
| ai | - | Chat with TiDB Bot |
| completion | bash, fish, powershell, zsh | Generate completion script for specified shell |
| config | create, delete, describe, edit, list, set, use | Configure user profiles |
| project | list | Manage projects |
| update | - | Update the CLI to the latest version |
| help | cluster, completion, config, help, import, project, update | View help for any command |

## Command modes

Expand All @@ -45,12 +49,16 @@ The TiDB Cloud CLI provides two modes for some commands for easy use:

## User profile

For the TiDB Cloud CLI, a user profile is a collection of properties associated with a user, including the profile name, public key, and private key. To use TiDB Cloud CLI, you must create a user profile first.
For the TiDB Cloud CLI, a user profile is a collection of properties associated with a user, including the profile name, public key, private key, and OAuth token. To use TiDB Cloud CLI, you must have a user profile.

### Create a user profile
### Create a user profile with TiDB Cloud API key

Use [`ticloud config create`](/tidb-cloud/ticloud-config-create.md) to create a user profile.

### Create a user profile with OAuth token

Use [`ticloud auth login`](/tidb-cloud/ticloud-auth-login.md) to assign OAuth token to the current profile. If no profiles exist, a profile named `default` will be created automatically.

### List all user profiles

Use [`ticloud config list`](/tidb-cloud/ticloud-config-list.md) to list all user profiles.
Expand Down Expand Up @@ -109,6 +117,7 @@ The following table lists the global flags for the TiDB Cloud CLI.
|----------------------|---------------------------------------------------------|----------|------------------------------------------------------------------------------------------------------------------|
| --no-color | Disables color in output. | No | Only works in non-interactive mode. In interactive mode, disabling color might not work with some UI components. |
shiyuhang0 marked this conversation as resolved.
Show resolved Hide resolved
| -P, --profile string | Specifies the active user profile used in this command. | No | Works in both non-interactive and interactive modes. |
| -D, --debug | Enable debug mode | No | Works in both non-interactive and interactive modes. |

## Feedback

Expand Down
77 changes: 42 additions & 35 deletions tidb-cloud/get-started-with-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ TiDB Cloud provides a command-line interface (CLI) [`ticloud`](https://github.co
- Import data to your clusters.
- Export data from your clusters.

> **Note:**
>
> TiDB Cloud CLI is in beta.

## Before you begin

- Have a TiDB Cloud account. If you do not have one, [sign up for a free trial](https://tidbcloud.com/free-trial).
- [Create a TiDB Cloud API Key](https://docs.pingcap.com/tidbcloud/api/v1beta#section/Authentication/API-Key-Management).

## Installation

Expand Down Expand Up @@ -82,6 +85,44 @@ Install the MySQL command-line client if you do not have it. You can refer to th
</div>
</SimpleTab>

## Quick start

[TiDB Serverless](/tidb-cloud/select-cluster-tier.md#tidb-serverless) is the best way to get started with TiDB Cloud. In this section, you will learn how to create a TiDB Serverless cluster with TiDB Cloud CLI.

### Create a user profile or log into TiDB Cloud

Before creating a cluster with TiDB Cloud CLI, you need to either create a user profile or log into TiDB Cloud.

- Create a user profile with your [TiDB Cloud API key](https://docs.pingcap.com/tidbcloud/api/v1beta#section/Authentication/API-Key-Management):

```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.

### Create a TiDB Serverless cluster

To create a TiDB Serverless cluster, enter the following command, and then follow the CLI prompts to provide the required information:

```shell
ticloud serverless create
```

## Use the TiDB Cloud CLI

View all commands available:
Expand Down Expand Up @@ -124,40 +165,6 @@ Update to the latest version by TiUP:
tiup update cloud
```

## Quick start

[TiDB Serverless](/tidb-cloud/select-cluster-tier.md#tidb-serverless) is the best way to get started with TiDB Cloud. In this section, you will learn how to create a TiDB Serverless cluster with TiDB Cloud CLI.

### Create a user profile or log into TiDB Cloud

Before creating a cluster, you need to create a user profile with your TiDB Cloud API Key:

```shell
ticloud config create
```

> **Warning:**
>
> The profile name **MUST NOT** contain `.`.

You can also log into TiDB Cloud directly. This will add OAuth token to the current profile, or to a new created profile called `default` if you do not have any profiles yet.

```
ticloud auth login
```

> **Note:**
>
> TiDB Cloud API Key has higher priority than oauth token. If you have both, the API Key will be used.

### Create a TiDB Serverless cluster

To create a TiDB Serverless cluster, enter the following command, and then follow the CLI prompts to provide the required information:

```shell
ticloud serverless create
```

## What's next

Check out [CLI reference](/tidb-cloud/cli-reference.md) to explore more features of TiDB Cloud CLI.
Expand Down
4 changes: 2 additions & 2 deletions tidb-cloud/release-notes-2023.md
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ This page lists the release notes of [TiDB Cloud](https://www.pingcap.com/tidb-c

**CLI changes**

- Add a new command [`ticloud cluster connect-info`](/tidb-cloud/ticloud-cluster-connect-info.md) for [TiDB Cloud CLI](/tidb-cloud/cli-reference.md).
- Add a new command `ticloud cluster connect-info` for [TiDB Cloud CLI](/tidb-cloud/cli-reference.md).

`ticloud cluster connect-info` is a command that allows you to get the connection string of a cluster. To use this command, [update `ticloud`](/tidb-cloud/ticloud-update.md) to v0.3.2 or a later version.

Expand Down Expand Up @@ -890,7 +890,7 @@ This page lists the release notes of [TiDB Cloud](https://www.pingcap.com/tidb-c

**CLI changes**

- Add a new command [`ticloud connect`](/tidb-cloud/ticloud-connect.md) for [TiDB Cloud CLI](/tidb-cloud/cli-reference.md).
- Add a new command [`ticloud connect`](/tidb-cloud/ticloud-serverless-shell.md) for [TiDB Cloud CLI](/tidb-cloud/cli-reference.md).

`ticloud connect` is a command that allows you to connect to your TiDB Cloud cluster from your local machine without installing any SQL clients. After connecting to your TiDB Cloud cluster, you can execute SQL statements in the TiDB Cloud CLI.

Expand Down
Loading
Loading