Overview
- Byteplus CLI Tool
- Minimum Go version required: 1.5+, recommended: 1.12+
Installing bp
Get the Client via Release
- Download the latest version from: https://github.com/byteplus/byteplus-cli/releases
- Select the version for your OS, extract and use directly
Build the Client Yourself
- Use
build.sh to compile the client
# For macOS
sh build.sh darwin
# For Windows
sh build.sh windows
# For Linux
sh build.sh linux
Configuring bp
Add bp to your system PATH
- Check if
$PATH includes /usr/local/bin. If not, add it accordingly.
- Run the following command to copy
bp to /usr/local/bin:
sudo cp bp /usr/local/bin
To call services, you need AK, SK, and region. You can configure them in two ways:
- Use
bp configure set:
bp configure set --profile test --region cn-beijing --access-key ak --secret-key sk --endpoint endpoint
Supported Parameters:
profile: Configuration name. If it exists, it will be updated; otherwise, a new one will be created.
access-key: Your AK
secret-key: Your SK
region: Region, e.g., cn-beijing
session-token: Required for role-based access
disable-ssl: Whether to disable SSL, default is false
- Use Environment Variables:
export BYTEPLUS_ACCESS_KEY=AK
export BYTEPLUS_SECRET_KEY=SK
export BYTEPLUS_REGION=cn-beijing
export BYTEPLUS_DISABLE_SSL=false
export BYTEPLUS_SESSION_TOKEN=sessionToken
bp will prioritize using the credentials in the active profile.
- After adding or modifying a profile, it becomes the active profile.
- If multiple profiles exist, switch using:
bp configure profile --profile [profile_name]
View a Specific Profile
bp configure get --profile [profile_name]
If omitted, current profile is shown. If profile doesn't exist, default values are returned.
List All Profiles
bp configure list
Switch Active Profile (>= v1.0.16)
bp configure profile --profile [profile_name]
If profile doesn't exist, the switch fails with an error message.
Add/Modify Profile
bp configure set --profile [name] --region [region] --access-key [AK] --secret-key [SK] --endpoint [endpoint]
Additional Fields:
- access-key
- secret-key
- region
- session-token
- disable-ssl
- endpoint
Delete Profile
bp configure delete --profile [profile_name]
If the deleted profile is the current one, bp will randomly pick another available profile.
Run bp completion --help to check how to enable shell auto-completion.
Bash
- View bash script:
bp completion bash
- Install bash-completion:
yum install bash-completion
# or
apt-get install bash-completion
- Enable it:
source /usr/share/bash-completion/bash_completion
Add it to ~/.bashrc for persistence.
- Configure auto-completion:
echo 'source <(bp completion bash)' >> ~/.bashrc
bp completion bash > /etc/bash_completion.d/bp
Then reload shell or run source ~/.bashrc
Zsh
- Enable
compinit:
echo "autoload -U compinit; compinit" >> ~/.zshrc
- Configure:
bp completion zsh > "${fpath[1]}/_bp"
Then reload shell or run source ~/.zshrc
Enable color:
bp enable-color
Disable color:
bp disable-color
Using bp
List Services and Actions
- View available services:
bp [-h|--help]
- View service's supported actions:
bp ecs [-h|--help]
Calling APIs
Basic structure:
bp <service> <action> [--param1 val1 --param2 val2 ...]
Example:
bp ecs DescribeInstances
bp rds_mysql ListDBInstanceIPLists --InstanceId "xxxxxx"
Support JSON input:
bp rds_mysql ModifyDBInstanceIPList --InstanceId "xxxxxx" --GroupName "xxxxxx" --IPList '["10.20.30.40", "50.60.70.80"]'
Support --body for application/json:
bp rds_mysql ModifyDBInstanceIPList --body '{"InstanceId":"xxxxxx", "GroupName": "xxxxxx", "IPList": ["10.20.30.40", "50.60.70.80"]}'