This example demonstrates how to use Bytebase API to configure Environment.
You have to call Bytebase API with service account.
export bytebase_url=http://localhost:8080
export [email protected]
export bytebase_password=bbs_***********6FEFl
bytebase_token=$(curl -v ${bytebase_url}/v1/auth/login \
--data-raw '{"email":"'${bytebase_account}'","password":"'${bytebase_password}'","web":true}' \
--compressed 2>&1 | grep token | grep -o 'access-token=[^;]*;' | grep -o '[^;]*' | sed 's/access-token=//g; s/;//g')
echo $bytebase_token
curl --request GET ${bytebase_url}/v1/environments \
--header 'Authorization: Bearer '${bytebase_token}
curl --request GET ${bytebase_url}/v1/environments/test \
--header 'Authorization: Bearer '${bytebase_token}
Note: The order
parameter specifies the execution sequence of DDL/DML commands, while title
corresponds to the Environment Name
in the Bytebase UI.
curl --request POST "${bytebase_url}/v1/environments?environment_id=test1" \
--header 'Authorization: Bearer '${bytebase_token} \
--data '{
"name": "",
"state": "STATE_UNSPECIFIED",
"title": "test1",
"order": 1,
"tier": "ENVIRONMENT_TIER_UNSPECIFIED",
"color": "#008000"
}'
curl --request PATCH "${bytebase_url}/v1/environments/test1?allow_missing=true" \
--header 'Authorization: Bearer '${bytebase_token} \
--data '{
"name": "",
"state": "STATE_UNSPECIFIED",
"title": "test1-sample",
"order": 1,
"tier": "ENVIRONMENT_TIER_UNSPECIFIED",
"color": ""
}'
curl --request DELETE ${bytebase_url}/v1/environments/test1 \
--header 'Authorization: Bearer '${bytebase_token}
Turns the tier
parameter into UNPROTECTED
.
Operates on deleted resources only. Needs calling the DELETE
API first.
curl --request POST "${bytebase_url}/v1/environments/test1:undelete" \
--header 'Authorization: Bearer '${bytebase_token} \
--data '{
"name": ""
}'