From 59420762f7859e8137ed0c91c23a7f4513f39fad Mon Sep 17 00:00:00 2001 From: shiyuhang <1136742008@qq.com> Date: Mon, 1 Sep 2025 10:38:48 +0800 Subject: [PATCH 1/3] add some explain --- internal/cli/serverless/sqluser/create.go | 10 ++++++++-- internal/cli/serverless/sqluser/update.go | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/cli/serverless/sqluser/create.go b/internal/cli/serverless/sqluser/create.go index 2ccbd17b..1a0d9591 100644 --- a/internal/cli/serverless/sqluser/create.go +++ b/internal/cli/serverless/sqluser/create.go @@ -54,6 +54,12 @@ var createSQLUserField = map[string]int{ flag.Password: 1, } +var supportedRoles = []string{ + util.ADMIN_ROLE, + util.READWRITE_ROLE, + util.READONLY_ROLE, +} + func (c CreateOpts) NonInteractiveFlags() []string { return []string{ flag.ClusterID, @@ -231,9 +237,9 @@ func CreateCmd(h *internal.Helper) *cobra.Command { } CreateCmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The ID of the cluster.") - CreateCmd.Flags().StringP(flag.User, flag.UserShort, "", "The name of the SQL user.") + CreateCmd.Flags().StringP(flag.User, flag.UserShort, "", "The name of the SQL user, user prefix will be added automatically.") CreateCmd.Flags().StringP(flag.Password, "", "", "The password of the SQL user.") - CreateCmd.Flags().StringSliceP(flag.UserRole, "", nil, "The role(s) of the SQL user.") + CreateCmd.Flags().StringSliceP(flag.UserRole, "", nil, fmt.Sprintf("The role(s) of the SQL user, supported roles %q", supportedRoles)) return CreateCmd } diff --git a/internal/cli/serverless/sqluser/update.go b/internal/cli/serverless/sqluser/update.go index c92bc768..a9ef4c91 100644 --- a/internal/cli/serverless/sqluser/update.go +++ b/internal/cli/serverless/sqluser/update.go @@ -287,7 +287,7 @@ func UpdateCmd(h *internal.Helper) *cobra.Command { updateCmd.Flags().StringP(flag.User, flag.UserShort, "", "The name of the SQL user to be updated.") updateCmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The cluster ID of the SQL user to be updated.") updateCmd.Flags().StringP(flag.Password, "", "", "The new password of the SQL user.") - updateCmd.Flags().StringSliceP(flag.UserRole, "", nil, "The new role(s) of the SQL user. Passing this flag replaces preexisting data.") + updateCmd.Flags().StringSliceP(flag.UserRole, "", nil, fmt.Sprintf("The new role(s) of the SQL user. Passing this flag replaces preexisting data, supported roles %q", supportedRoles)) updateCmd.Flags().StringSliceP(flag.AddRole, "", nil, "The role(s) to be added to the SQL user.") updateCmd.Flags().StringSliceP(flag.DeleteRole, "", nil, "The role(s) to be deleted from the SQL user.") From 0dff428649da180fb4ffb9811bfbc9d225d41a01 Mon Sep 17 00:00:00 2001 From: shiyuhang <1136742008@qq.com> Date: Mon, 1 Sep 2025 10:39:57 +0800 Subject: [PATCH 2/3] make generate doc --- docs/generate_doc/ticloud.md | 1 - docs/generate_doc/ticloud_config_set.md | 2 +- .../ticloud_serverless_audit-log.md | 5 +- .../ticloud_serverless_audit-log_config.md | 29 ++------- ...ud_serverless_audit-log_config_describe.md | 37 ++++++++++++ ...loud_serverless_audit-log_config_update.md | 59 +++++++++++++++++++ .../ticloud_serverless_audit-log_download.md | 2 +- ...serverless_audit-log_filter-rule_create.md | 12 ++-- ...serverless_audit-log_filter-rule_delete.md | 10 ++-- ...rverless_audit-log_filter-rule_describe.md | 8 +-- ...serverless_audit-log_filter-rule_update.md | 17 +++--- .../ticloud_serverless_sql-user_create.md | 4 +- .../ticloud_serverless_sql-user_update.md | 2 +- 13 files changed, 131 insertions(+), 57 deletions(-) create mode 100644 docs/generate_doc/ticloud_serverless_audit-log_config_describe.md create mode 100644 docs/generate_doc/ticloud_serverless_audit-log_config_update.md diff --git a/docs/generate_doc/ticloud.md b/docs/generate_doc/ticloud.md index 3fd1e523..c62d22ee 100644 --- a/docs/generate_doc/ticloud.md +++ b/docs/generate_doc/ticloud.md @@ -17,7 +17,6 @@ ticloud is a CLI library for communicating with TiDB Cloud's API. ### SEE ALSO -* [ticloud ai](ticloud_ai.md) - Chat with TiDB Bot * [ticloud auth](ticloud_auth.md) - Login and logout via TiDB Cloud API * [ticloud completion](ticloud_completion.md) - Generate the autocompletion script for the specified shell * [ticloud config](ticloud_config.md) - Configure and manage your user profiles diff --git a/docs/generate_doc/ticloud_config_set.md b/docs/generate_doc/ticloud_config_set.md index 60f6bd67..b531c4c6 100644 --- a/docs/generate_doc/ticloud_config_set.md +++ b/docs/generate_doc/ticloud_config_set.md @@ -5,7 +5,7 @@ Configure specific properties of the active profile ### Synopsis Configure specific properties of the active profile. -Available properties : [public-key private-key api-url serverless-endpoint iam-endpoint oauth-endpoint oauth-client-id oauth-client-secret telemetry-enabled]. +Available properties : [public-key private-key serverless-endpoint iam-endpoint oauth-endpoint oauth-client-id oauth-client-secret telemetry-enabled]. If using -P flag, the config in the specific profile will be set. If not, the config in the active profile will be set diff --git a/docs/generate_doc/ticloud_serverless_audit-log.md b/docs/generate_doc/ticloud_serverless_audit-log.md index 544414d4..1d865210 100644 --- a/docs/generate_doc/ticloud_serverless_audit-log.md +++ b/docs/generate_doc/ticloud_serverless_audit-log.md @@ -19,8 +19,7 @@ Manage TiDB Cloud Serverless database audit logging ### SEE ALSO * [ticloud serverless](ticloud_serverless.md) - Manage TiDB Cloud Serverless clusters -* [ticloud serverless audit-log config](ticloud_serverless_audit-log_config.md) - Configure the database audit logging -* [ticloud serverless audit-log describe](ticloud_serverless_audit-log_describe.md) - Describe the database audit logging configuration -* [ticloud serverless audit-log download](ticloud_serverless_audit-log_download.md) - Download the database audit logs +* [ticloud serverless audit-log config](ticloud_serverless_audit-log_config.md) - Manage TiDB Cloud Serverless database audit logging configuration +* [ticloud serverless audit-log download](ticloud_serverless_audit-log_download.md) - Download the database audit log files * [ticloud serverless audit-log filter-rule](ticloud_serverless_audit-log_filter-rule.md) - Manage TiDB Cloud Serverless database audit logging filter rules diff --git a/docs/generate_doc/ticloud_serverless_audit-log_config.md b/docs/generate_doc/ticloud_serverless_audit-log_config.md index 81a1a863..06ab8773 100644 --- a/docs/generate_doc/ticloud_serverless_audit-log_config.md +++ b/docs/generate_doc/ticloud_serverless_audit-log_config.md @@ -1,34 +1,11 @@ ## ticloud serverless audit-log config -Configure the database audit logging - -``` -ticloud serverless audit-log config [flags] -``` - -### Examples - -``` - Conigure the database audit logging in interactive mode: - $ ticloud serverless audit-log config - - Unredacted the database audit logging in non-interactive mode: - $ ticloud serverless audit-log config -c --unredacted - - Enable the database audit logging in non-interactive mode: - $ ticloud serverless audit-log config -c --enabled - - Disable the database audit logging in non-interactive mode: - $ ticloud serverless audit-log config -c --enabled=false -``` +Manage TiDB Cloud Serverless database audit logging configuration ### Options ``` - -c, --cluster-id string The ID of the cluster to be updated. - --enabled enable or disable the database audit logging. - -h, --help help for config - --unredacted unredacted or redacted the database audit logging. + -h, --help help for config ``` ### Options inherited from parent commands @@ -42,4 +19,6 @@ ticloud serverless audit-log config [flags] ### SEE ALSO * [ticloud serverless audit-log](ticloud_serverless_audit-log.md) - Manage TiDB Cloud Serverless database audit logging +* [ticloud serverless audit-log config describe](ticloud_serverless_audit-log_config_describe.md) - Describe the database audit logging configuration +* [ticloud serverless audit-log config update](ticloud_serverless_audit-log_config_update.md) - Update the database audit logging configuration diff --git a/docs/generate_doc/ticloud_serverless_audit-log_config_describe.md b/docs/generate_doc/ticloud_serverless_audit-log_config_describe.md new file mode 100644 index 00000000..6312ea27 --- /dev/null +++ b/docs/generate_doc/ticloud_serverless_audit-log_config_describe.md @@ -0,0 +1,37 @@ +## ticloud serverless audit-log config describe + +Describe the database audit logging configuration + +``` +ticloud serverless audit-log config describe [flags] +``` + +### Examples + +``` + Get the database audit logging configuration in interactive mode: + $ ticloud serverless audit-log config describe + + Get the database audit logging configuration in non-interactive mode: + $ ticloud serverless audit-log config describe -c +``` + +### Options + +``` + -c, --cluster-id string The cluster ID. + -h, --help help for describe +``` + +### 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 audit-log config](ticloud_serverless_audit-log_config.md) - Manage TiDB Cloud Serverless database audit logging configuration + diff --git a/docs/generate_doc/ticloud_serverless_audit-log_config_update.md b/docs/generate_doc/ticloud_serverless_audit-log_config_update.md new file mode 100644 index 00000000..a4f1cb27 --- /dev/null +++ b/docs/generate_doc/ticloud_serverless_audit-log_config_update.md @@ -0,0 +1,59 @@ +## ticloud serverless audit-log config update + +Update the database audit logging configuration + +``` +ticloud serverless audit-log config update [flags] +``` + +### Examples + +``` + Conigure database audit logging in interactive mode: + $ ticloud serverless audit-log config update + + Unredact the database audit log in non-interactive mode: + $ ticloud serverless audit-log config update -c --unredacted + + Enable database audit logging in non-interactive mode: + $ ticloud serverless audit-log config update -c --enabled + + Disable database audit logging in non-interactive mode: + $ ticloud serverless audit-log config update -c --enabled=false +``` + +### Options + +``` + --azblob.sas-token string The SAS token of Azure Blob. + --azblob.uri string The Azure Blob URI in azure://.blob.core.windows.net// format. Required when cloud storage is AZURE_BLOB. + --cloud-storage string The cloud storage. One of ["TIDB_CLOUD" "S3" "GCS" "AZURE_BLOB" "OSS"]. + -c, --cluster-id string The ID of the cluster to be updated. + --enabled enable or disable database audit logging. + --gcs.service-account-key string The base64 encoded service account key of GCS. + --gcs.uri string The GCS URI in gs:/// format. Required when cloud storage is GCS. + -h, --help help for update + --oss.access-key-id string The access key ID of the OSS. + --oss.access-key-secret string The access key secret of the OSS. + --oss.uri string The OSS URI in oss:/// format. Required when cloud storage is OSS. + --rotation-interval-minutes int32 The rotation interval in minutes, range [10, 1440]. + --rotation-size-mib int32 The rotation size in MiB, range [1, 1024]. + --s3.access-key-id string The access key ID of the S3. You only need to set one of the s3.role-arn and [s3.access-key-id, s3.secret-access-key]. + --s3.role-arn string The role arn of the S3. You only need to set one of the s3.role-arn and [s3.access-key-id, s3.secret-access-key]. + --s3.secret-access-key string The secret access key of the S3. You only need to set one of the s3.role-arn and [s3.access-key-id, s3.secret-access-key]. + --s3.uri string The S3 URI in s3:/// format. Required when cloud storage is S3. + --unredacted unredact or redact the database audit log. +``` + +### 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 audit-log config](ticloud_serverless_audit-log_config.md) - Manage TiDB Cloud Serverless database audit logging configuration + diff --git a/docs/generate_doc/ticloud_serverless_audit-log_download.md b/docs/generate_doc/ticloud_serverless_audit-log_download.md index 35fb32f3..b20a198a 100644 --- a/docs/generate_doc/ticloud_serverless_audit-log_download.md +++ b/docs/generate_doc/ticloud_serverless_audit-log_download.md @@ -1,6 +1,6 @@ ## ticloud serverless audit-log download -Download the database audit logs +Download the database audit log files ``` ticloud serverless audit-log download [flags] diff --git a/docs/generate_doc/ticloud_serverless_audit-log_filter-rule_create.md b/docs/generate_doc/ticloud_serverless_audit-log_filter-rule_create.md index 63f710f6..a70c3a33 100644 --- a/docs/generate_doc/ticloud_serverless_audit-log_filter-rule_create.md +++ b/docs/generate_doc/ticloud_serverless_audit-log_filter-rule_create.md @@ -13,20 +13,20 @@ ticloud serverless audit-log filter-rule create [flags] $ ticloud serverless audit-log filter create Create a filter rule which filters all audit logs in non-interactive mode: - $ ticloud serverless audit-log filter create --cluster-id --name --rule '{"users":["%@%"],"filters":[{}]}' + $ ticloud serverless audit-log filter create --cluster-id --display-name --rule '{"users":["%@%"],"filters":[{}]}' Create a filter rule which filters QUERY and EXECUTE for test.t and filter QUERY for all tables in non-interactive mode: - $ ticloud serverless audit-log filter create --cluster-id --name --rule '{"users":["%@%"],"filters":[{"classes":["QUERY","EXECUTE"],"tables":["test.t"]},{"classes":["QUERY"]}]}' + $ ticloud serverless audit-log filter create --cluster-id --display-name --rule '{"users":["%@%"],"filters":[{"classes":["QUERY","EXECUTE"],"tables":["test.t"]},{"classes":["QUERY"]}]}' ``` ### Options ``` - -c, --cluster-id string The ID of the cluster. - -h, --help help for create - --name string The name of the filter rule. - --rule string Filter rule expressions, use "ticloud serverless audit-log filter template" to see filter templates. + -c, --cluster-id string The ID of the cluster. + --display-name string The display name of the filter rule. + -h, --help help for create + --rule string Filter rule expressions, use "ticloud serverless audit-log filter template" to see filter templates. ``` ### Options inherited from parent commands diff --git a/docs/generate_doc/ticloud_serverless_audit-log_filter-rule_delete.md b/docs/generate_doc/ticloud_serverless_audit-log_filter-rule_delete.md index 98f9f729..b82e127d 100644 --- a/docs/generate_doc/ticloud_serverless_audit-log_filter-rule_delete.md +++ b/docs/generate_doc/ticloud_serverless_audit-log_filter-rule_delete.md @@ -13,17 +13,17 @@ ticloud serverless audit-log filter-rule delete [flags] $ ticloud serverless audit-log filter delete Delete an audit log filter rule in non-interactive mode: - $ ticloud serverless audit-log filter delete --cluster-id --name + $ ticloud serverless audit-log filter delete --cluster-id --filter-rule-id ``` ### Options ``` - -c, --cluster-id string The ID of the cluster. - --force Delete a cluster without confirmation. - -h, --help help for delete - --name string The name of the filter rule. + -c, --cluster-id string The ID of the cluster. + --filter-rule-id string The ID of the filter rule. + --force Delete a cluster without confirmation. + -h, --help help for delete ``` ### Options inherited from parent commands diff --git a/docs/generate_doc/ticloud_serverless_audit-log_filter-rule_describe.md b/docs/generate_doc/ticloud_serverless_audit-log_filter-rule_describe.md index 94483271..1d79e40f 100644 --- a/docs/generate_doc/ticloud_serverless_audit-log_filter-rule_describe.md +++ b/docs/generate_doc/ticloud_serverless_audit-log_filter-rule_describe.md @@ -13,16 +13,16 @@ ticloud serverless audit-log filter-rule describe [flags] $ ticloud serverless audit-log filter describe Describe an audit log filter rule in non-interactive mode: - $ ticloud serverless audit-log filter describe --cluster-id --name + $ ticloud serverless audit-log filter describe --cluster-id --filter-rule-id ``` ### Options ``` - -c, --cluster-id string The ID of the cluster. - -h, --help help for describe - --name string The name of the filter rule. + -c, --cluster-id string The ID of the cluster. + --filter-rule-id string The ID of the filter rule. + -h, --help help for describe ``` ### Options inherited from parent commands diff --git a/docs/generate_doc/ticloud_serverless_audit-log_filter-rule_update.md b/docs/generate_doc/ticloud_serverless_audit-log_filter-rule_update.md index 46d385ff..7ea6ff7f 100644 --- a/docs/generate_doc/ticloud_serverless_audit-log_filter-rule_update.md +++ b/docs/generate_doc/ticloud_serverless_audit-log_filter-rule_update.md @@ -13,24 +13,25 @@ ticloud serverless audit-log filter-rule update [flags] $ ticloud serverless audit-log filter update Enable audit log filter rule in non-interactive mode: - $ ticloud serverless audit-log filter update --cluster-id --name --enabled + $ ticloud serverless audit-log filter update --cluster-id --filter-rule-id --enabled Disable audit log filter rule in non-interactive mode: - $ ticloud serverless audit-log filter update --cluster-id --name --enabled=false + $ ticloud serverless audit-log filter update --cluster-id --filter-rule-id --enabled=false Update filters of an audit log filter rule in non-interactive mode: - $ ticloud serverless audit-log filter update --cluster-id --name --rule '{"users":["%@%"],"filters":[{"classes":["QUERY"],"tables":["test.t"]}]}' + $ ticloud serverless audit-log filter update --cluster-id --filter-rule-id --rule '{"users":["%@%"],"filters":[{"classes":["QUERY"],"tables":["test.t"]}]}' ``` ### Options ``` - -c, --cluster-id string The ID of the cluster. - --enabled Enable or disable the filter rule. - -h, --help help for update - --name string The name of the filter rule to update. - --rule string Complete filter rule expressions, use "ticloud serverless audit-log filter template" to see filter templates. + -c, --cluster-id string The ID of the cluster. + --display-name string The display name of the filter rule. + --enabled Enable or disable the filter rule. + --filter-rule-id string The ID of the filter rule. + -h, --help help for update + --rule string Complete filter rule expressions, use "ticloud serverless audit-log filter template" to see filter templates. ``` ### Options inherited from parent commands diff --git a/docs/generate_doc/ticloud_serverless_sql-user_create.md b/docs/generate_doc/ticloud_serverless_sql-user_create.md index 9950234f..66527aa1 100644 --- a/docs/generate_doc/ticloud_serverless_sql-user_create.md +++ b/docs/generate_doc/ticloud_serverless_sql-user_create.md @@ -22,8 +22,8 @@ ticloud serverless sql-user create [flags] -c, --cluster-id string The ID of the cluster. -h, --help help for create --password string The password of the SQL user. - --role strings The role(s) of the SQL user. - -u, --user string The name of the SQL user. + --role strings The role(s) of the SQL user, supported roles ["role_admin" "role_readwrite" "role_readonly"] + -u, --user string The name of the SQL user, user prefix will be added automatically. ``` ### Options inherited from parent commands diff --git a/docs/generate_doc/ticloud_serverless_sql-user_update.md b/docs/generate_doc/ticloud_serverless_sql-user_update.md index 090eb7c0..c9c46ee8 100644 --- a/docs/generate_doc/ticloud_serverless_sql-user_update.md +++ b/docs/generate_doc/ticloud_serverless_sql-user_update.md @@ -24,7 +24,7 @@ ticloud serverless sql-user update [flags] --delete-role strings The role(s) to be deleted from the SQL user. -h, --help help for update --password string The new password of the SQL user. - --role strings The new role(s) of the SQL user. Passing this flag replaces preexisting data. + --role strings The new role(s) of the SQL user. Passing this flag replaces preexisting data, supported roles ["role_admin" "role_readwrite" "role_readonly"] -u, --user string The name of the SQL user to be updated. ``` From a93207705424d22e551664bd0c36226cd861e662 Mon Sep 17 00:00:00 2001 From: shiyuhang <1136742008@qq.com> Date: Mon, 1 Sep 2025 10:41:47 +0800 Subject: [PATCH 3/3] fix --- docs/generate_doc/ticloud_serverless_sql-user_update.md | 2 +- internal/cli/serverless/sqluser/update.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/generate_doc/ticloud_serverless_sql-user_update.md b/docs/generate_doc/ticloud_serverless_sql-user_update.md index c9c46ee8..98049691 100644 --- a/docs/generate_doc/ticloud_serverless_sql-user_update.md +++ b/docs/generate_doc/ticloud_serverless_sql-user_update.md @@ -25,7 +25,7 @@ ticloud serverless sql-user update [flags] -h, --help help for update --password string The new password of the SQL user. --role strings The new role(s) of the SQL user. Passing this flag replaces preexisting data, supported roles ["role_admin" "role_readwrite" "role_readonly"] - -u, --user string The name of the SQL user to be updated. + -u, --user string The name of the SQL user to be updated, user prefix will be added automatically. ``` ### Options inherited from parent commands diff --git a/internal/cli/serverless/sqluser/update.go b/internal/cli/serverless/sqluser/update.go index a9ef4c91..fe128169 100644 --- a/internal/cli/serverless/sqluser/update.go +++ b/internal/cli/serverless/sqluser/update.go @@ -284,7 +284,7 @@ func UpdateCmd(h *internal.Helper) *cobra.Command { }, } - updateCmd.Flags().StringP(flag.User, flag.UserShort, "", "The name of the SQL user to be updated.") + updateCmd.Flags().StringP(flag.User, flag.UserShort, "", "The name of the SQL user to be updated, user prefix will be added automatically.") updateCmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The cluster ID of the SQL user to be updated.") updateCmd.Flags().StringP(flag.Password, "", "", "The new password of the SQL user.") updateCmd.Flags().StringSliceP(flag.UserRole, "", nil, fmt.Sprintf("The new role(s) of the SQL user. Passing this flag replaces preexisting data, supported roles %q", supportedRoles))