Skip to content

Commit 7c3689f

Browse files
committed
docs: update sql review api tutorial
1 parent 51d8e11 commit 7c3689f

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

content/docs/tutorials/api-audit-log.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ estimated_time: '40 mins'
99
description: 'Learn how to use the Bytebase API to fetch audit log in Bytebase'
1010
---
1111

12-
Bytebase is a database DevOps and CI/CD tool designed for developers, DBAs, and platform engineering teams. While it offers an intuitive GUI for managing database schema changes and access control, some teams may want to integrate Bytebase into their existing DevOps platforms using the [Bytebase API](/docs/api/overview/).
12+
Bytebase is a database DevSecOps platform designed for developers, security, DBA, and platform engineering teams. While it offers an intuitive GUI for managing database schema changes and access control, some teams may want to integrate Bytebase into their existing DevOps platforms using the [Bytebase API](/docs/api/overview/).
1313

1414
![before-after](/content/docs/tutorials/api-audit-log/api-audit-log-graph.webp)
1515

content/docs/tutorials/api-sql-review.md

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ estimated_time: '40 mins'
99
description: 'Learn how to use the Bytebase API to configure SQL review rules in Bytebase'
1010
---
1111

12-
Bytebase is a database DevOps and CI/CD tool designed for developers, DBAs, and platform engineering teams. While it offers an intuitive GUI for managing database schema changes and access control, some teams may want to integrate Bytebase into their existing DevOps platforms using the [Bytebase API](/docs/api/overview/).
12+
Bytebase is a database DevSecOps platform designed for developers, security, DBA, and platform engineering teams. While it offers an intuitive GUI for managing database schema changes and access control, some teams may want to integrate Bytebase into their existing DevOps platforms using the [Bytebase API](/docs/api/overview/).
1313

1414
This tutorial will guide you through configuring SQL review rules using the Bytebase API. This approach allows you to manage SQL review rules as code within your repository, enabling DBAs or platform engineering teams to apply them to Bytebase as needed.
1515

@@ -32,35 +32,33 @@ This tutorial code repository is at https://github.com/bytebase/api-example/tree
3232

3333
<IncludeBlock url="/docs/share/tutorials/create-service-account"></IncludeBlock>
3434

35-
## Run Scripts in Terminal
36-
37-
### Generate the Token
35+
## Obtain the Access Token
3836

3937
1. Go to [Bytebase API Example
4038
repo](https://github.com/bytebase/api-example) and clone it.
4139

4240
1. Go to subfolder `sql-review`, and follow the instructions in the `README.md` to run the scripts. replace the `bytebase_url`, `bytebase_account`, `bytebase_password` with your own values. Then you will get a `bytebase_token` looks like `ey....9V8s`.
4341

4442
```bash
45-
export bytebase_url=http://localhost:8080
46-
47-
export bytebase_password=bbs_xxxxxxxxxxxxxilcLVG
48-
bytebase_token=$(curl -v ${bytebase_url}/v1/auth/login \
49-
--data-raw '{"email":"'${bytebase_account}'","password":"'${bytebase_password}'","web":true}' \
50-
--compressed 2>&1 | grep token | grep -o 'access-token=[^;]*;' | grep -o '[^;]*' | sed 's/access-token=//g; s/;//g')
51-
echo $bytebase_token
43+
export bytebase_url=http://localhost:8080
44+
45+
export bytebase_password=bbs_xxxxxxxxxxxxxilcLVG
46+
bytebase_token=$(curl -v ${bytebase_url}/v1/auth/login \
47+
--data-raw '{"email":"'${bytebase_account}'","password":"'${bytebase_password}'","web":true}' \
48+
--compressed 2>&1 | grep token | grep -o 'access-token=[^;]*;' | grep -o '[^;]*' | sed 's/access-token=//g; s/;//g')
49+
echo $bytebase_token
5250
```
5351

54-
### Configure SQL Review Policies
52+
## Configure SQL Review Policies
5553

5654
1. Continue following the `README.md` to run the scripts.
5755

5856
```bash
59-
curl --request PATCH ${bytebase_url}/v1/reviewConfigs/basic \
57+
curl --request PATCH ${bytebase_url}/v1/reviewConfigs/basic \
6058
--header 'Authorization: Bearer '${bytebase_token} \
6159
--data @policy/basic.json
62-
63-
curl --request PATCH ${bytebase_url}/v1/reviewConfigs/advanced \
60+
61+
curl --request PATCH ${bytebase_url}/v1/reviewConfigs/advanced \
6462
--header 'Authorization: Bearer '${bytebase_token} \
6563
--data @policy/advanced.json
6664
```
@@ -71,16 +69,16 @@ This tutorial code repository is at https://github.com/bytebase/api-example/tree
7169
1. To delete the SQL review rules, use the following commands:
7270

7371
```bash
74-
curl --request PATCH "${bytebase_url}/v1/reviewConfigs/basic?allow_missing=true&update_mask=rules" \
72+
curl --request PATCH "${bytebase_url}/v1/reviewConfigs/basic?allow_missing=true&update_mask=rules" \
7573
--header 'Authorization: Bearer '${bytebase_token} \
7674
--data @policy/basic.json
7775

78-
curl --request PATCH "${bytebase_url}/v1/reviewConfigs/advanced?allow_missing=true&update_mask=rules" \
76+
curl --request PATCH "${bytebase_url}/v1/reviewConfigs/advanced?allow_missing=true&update_mask=rules" \
7977
--header 'Authorization: Bearer '${bytebase_token} \
8078
--data @policy/advanced.json
8179
```
8280

83-
### Apply SQL Review Policies to Resources
81+
## Attach SQL Review Policies to Resources
8482

8583
You may notice that the SQL review rules are not applied to any resources yet from the above screenshot. In Bytebase, the SQL review rules can be applied to the `environments` or `projects`. Project-level rules take precedence over environment-level rules.
8684

@@ -113,21 +111,21 @@ You may notice that the SQL review rules are not applied to any resources yet fr
113111
1. Go to `Sample Project` page, click **Setting** on the left sidebar to see the applied the SQL review rules.
114112
![bb-project-setting](/content/docs/tutorials/api-sql-review/bb-project-setting.webp)
115113

116-
1. To delete SQL review rules from environments and projects, use the following commands:
114+
1. To detach SQL review policies from environments and projects, use the following commands:
117115

118116
```bash
119-
curl --request DELETE ${bytebase_url}/v1/environments/test/policies/tag \
117+
curl --request DELETE ${bytebase_url}/v1/environments/test/policies/tag \
120118
--header 'Authorization: Bearer '${bytebase_token}
121119

122-
curl --request DELETE ${bytebase_url}/v1/environments/prod/policies/tag \
120+
curl --request DELETE ${bytebase_url}/v1/environments/prod/policies/tag \
123121
--header 'Authorization: Bearer '${bytebase_token}
124122
```
125123

126124
```bash
127-
curl --request DELETE ${bytebase_url}/v1/projects/project-sample/policies/tag \
128-
--header 'Authorization: Bearer '${bytebase_token}
125+
curl --request DELETE ${bytebase_url}/v1/projects/project-sample/policies/tag \
126+
--header 'Authorization: Bearer '${bytebase_token}
129127
```
130128

131129
## Summary
132130

133-
Congratulations! You can now configure SQL review rules using the Bytebase API, in addition to the Bytebase GUI, making SQL review policy as code a reality.
131+
Congratulations! You can now codify SQL review rules using the Bytebase API, in addition to the Bytebase GUI, making SQL review policy as code a reality.

content/docs/tutorials/api-user-database-permission.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ estimated_time: '40 mins'
99
description: 'Learn how to use the Bytebase API to inspect user and database permissions.'
1010
---
1111

12-
Bytebase is a database DevOps and CI/CD tool designed for developers, DBAs, and platform engineering teams. While it offers an intuitive GUI for managing database schema changes and access control, some teams may want to integrate Bytebase into their existing DevOps platforms using the [Bytebase API](/docs/api/overview/).
12+
Bytebase is a database DevSecOps platform designed for developers, security, DBA, and platform engineering teams. While it offers an intuitive GUI for managing database schema changes and access control, some teams may want to integrate Bytebase into their existing DevOps platforms using the [Bytebase API](/docs/api/overview/).
1313

1414
![before-after](/content/docs/tutorials/api-user-database-permission/api-user-db-permission.webp)
1515

0 commit comments

Comments
 (0)