|
| 1 | +## Volcengine Command Line Tools |
| 2 | + |
| 3 | +[中文](README.MD) | English |
| 4 | + |
| 5 | +### Special Note |
| 6 | + |
| 7 | +To make it easier for users, starting from version v1.0.20, the command prefix for the Volcengine CLI tool has been changed from 'volcengine-cli' to 've'. Earlier versions are not affected. Users who have upgraded to v1.0.20 or later should promptly update the command prefix (refer to the alias command for unified configuration). |
| 8 | + |
| 9 | +### Overview |
| 10 | + |
| 11 | +1. VolcEngine Command Line Tool |
| 12 | +2. The minimum required Go version is 1.5 or higher; version 1.12 or above is recommended. |
| 13 | + |
| 14 | +### Install VolcEngine CLI |
| 15 | + |
| 16 | +#### Obtain the client from the release package. |
| 17 | + |
| 18 | +1. <https://github.com/volcengine/volcengine-cli/releases> Get the latest version |
| 19 | +2. Download the version corresponding to your operating system and extract it for use. |
| 20 | + |
| 21 | +#### Obtaining the client by compiling from source |
| 22 | + |
| 23 | +1. Compile the client using build.sh. |
| 24 | +```shell |
| 25 | +# If using a Mac |
| 26 | +sh build.sh darwin |
| 27 | +mv ve-darwin ve |
| 28 | +# If Using Windows |
| 29 | +sh build.sh windows |
| 30 | +mv ve-windows ve |
| 31 | +# If using Linux |
| 32 | +sh build.sh linux |
| 33 | +mv ve-linux ve |
| 34 | +``` |
| 35 | + |
| 36 | + |
| 37 | +### Configuring VolcEngine CLI |
| 38 | + |
| 39 | +Add the Volcano Engine CLI to the environment variables. |
| 40 | + |
| 41 | +1. Check whether /usr/local/bin exists in the $PATH system variable. If it does not, please set a usable environment variable for the Volcano Engine CLI according to your actual situation. |
| 42 | + |
| 43 | +2. Execute the following command to copy 've' to the /usr/local/bin directory, after which it will be available for use. |
| 44 | + |
| 45 | + ```shell |
| 46 | + sudo cp ve /usr/local/bin |
| 47 | + ``` |
| 48 | + |
| 49 | +#### Configure Credentials |
| 50 | + |
| 51 | +To invoke the service, you must provide AK, SK, and region. These parameters can be configured using either of the following two methods. |
| 52 | + |
| 53 | +1. Example of configuration using 've configure set' |
| 54 | + |
| 55 | + ```shell |
| 56 | + ve configure set --profile test --region cn-beijing --access-key ak --secret-key sk |
| 57 | + ``` |
| 58 | + |
| 59 | + Supported Parameters and Related Descriptions |
| 60 | + |
| 61 | + ```shell |
| 62 | + profile: Configuration name. If the profile already exists, this command will modify the existing configuration; otherwise, it will create a new configuration and set the currently used profile to the new configuration. |
| 63 | + access-key: Your Access Key |
| 64 | + secret-key: Your SK |
| 65 | + region: Geographic area, such as cn-beijing |
| 66 | + session-token: Required if role-playing is used. |
| 67 | + disable-ssl: Specifies whether to disable SSL. The default value is false. |
| 68 | + endpoint: Optional; the default value is open.volcengineapi.com. |
| 69 | + ``` |
| 70 | +
|
| 71 | +2. If no configuration is specified in the configuration file, an attempt will be made to read the configuration from environment variables set via export. |
| 72 | + ```shell |
| 73 | + export VOLCENGINE_ACCESS_KEY=AK |
| 74 | + export VOLCENGINE_SECRET_KEY=SK |
| 75 | + export VOLCENGINE_REGION=cn-bejing |
| 76 | +
|
| 77 | + # Whether to disable SSL; if not set, the default is false. |
| 78 | + export VOLCENGINE_DISABLE_SSL=false |
| 79 | +
|
| 80 | + # If role-playing is employed, the following must be provided |
| 81 | + export VOLCENGINE_SESSION_TOKEN=sessionToken |
| 82 | + ``` |
| 83 | +
|
| 84 | +#### Other Operations of the configure Command |
| 85 | +
|
| 86 | +1. After configuring a profile using the Volcengine CLI 'configure' command, the CLI will prioritize the authentication information within the profile for API request signing. |
| 87 | +2. After a profile is added or modified, the default profile used in the current configuration will be switched to the newly added or modified profile. |
| 88 | +3. If multiple profiles exist, use 've configure profile --profile [configuration name]' to switch before invoking the interface to ensure correct usage. |
| 89 | +
|
| 90 | +###### Retrieve specified profile configuration information |
| 91 | +
|
| 92 | +```shell |
| 93 | +ve configure get --profile [profile name] |
| 94 | +``` |
| 95 | +
|
| 96 | +The 'profile' field is optional. If the 'profile' field is not specified, the current configuration will be displayed. If the 'profile' field is specified, the Volcano Engine CLI will attempt to retrieve and display the specified configuration. |
| 97 | +
|
| 98 | +If the configuration does not exist, all configuration fields in the returned result will be set to their default values. |
| 99 | +
|
| 100 | +###### Display information for all current configuration profiles. |
| 101 | +
|
| 102 | +```shell |
| 103 | +ve configure list |
| 104 | +``` |
| 105 | +
|
| 106 | +###### Switch the currently used configuration (profile). Please ensure that the version is greater than or equal to 1.0.16. |
| 107 | +
|
| 108 | +```shell |
| 109 | +ve configure profile --profile [profile name] |
| 110 | +``` |
| 111 | +
|
| 112 | +The 'profile' field is required. When a profile is specified, the Volcengine CLI will attempt to switch to the corresponding configuration. |
| 113 | +
|
| 114 | +If the configuration does not exist, the current configuration will not be switched, and an error message will be displayed. |
| 115 | +
|
| 116 | +###### Create/Modify Configuration Profile |
| 117 | +
|
| 118 | +```shell |
| 119 | +ve configure set --profile [Profile Name] --region [Region] --access-key [User's AK] --secret-key [User's SK] --endpoint [Endpoint corresponding to the region] |
| 120 | +``` |
| 121 | +
|
| 122 | +After creating or modifying a configuration, the active configuration will switch to the newly created or modified configuration. |
| 123 | +
|
| 124 | +When creating a new configuration, the profile field and region field must be specified; when modifying an existing configuration, the profile field must be specified. |
| 125 | +
|
| 126 | +Other fields that can be specified: |
| 127 | +
|
| 128 | +- access-key |
| 129 | +- secret-key |
| 130 | +- region |
| 131 | +- session-token |
| 132 | +- disable-ssl |
| 133 | +
|
| 134 | +For information on the function of each field, please refer to the 'Supported Parameters and Related Descriptions' section in the previous section. |
| 135 | +
|
| 136 | +###### Delete Configuration Profile |
| 137 | +
|
| 138 | +```shell |
| 139 | +ve configure delete --profile [profile name] |
| 140 | +``` |
| 141 | +
|
| 142 | +When deleting a configuration, the profile field must be specified to indicate the name of the configuration to be deleted. |
| 143 | +
|
| 144 | +If the configuration to be deleted is currently in use, then after successful deletion, Volcano Engine CLI will attempt to randomly select one of the remaining configurations as the new current configuration. |
| 145 | +
|
| 146 | +#### Configure Auto-Completion |
| 147 | +
|
| 148 | +By executing ve completion --help, users can view the methods for configuring auto-completion in various terminals. Based on the instructions provided, users may choose whether to configure the auto-completion feature. |
| 149 | +
|
| 150 | +<br/> |
| 151 | +
|
| 152 | +##### Bash |
| 153 | +
|
| 154 | +The Bash completion script for Volcano Engine CLI can be viewed using 've completion bash'. To enable the autocompletion feature, import this script into your shell. |
| 155 | +
|
| 156 | +###### 1. Install bash-completion |
| 157 | +
|
| 158 | +The Volcengine CLI completion script depends on the bash-completion tool. Therefore, you must install and enable bash-completion in advance. You can use the command 'type _init_completion' to verify whether bash-completion is installed. |
| 159 | +
|
| 160 | +1. Installation: yum install bash-completion or apt-get install bash-completion |
| 161 | +
|
| 162 | +2. Enable bash-completion: source /usr/share/bash-completion/bash_completion |
| 163 | +
|
| 164 | + It is recommended to add 'source /usr/share/bash-completion/bash_completion' to your ~/.bashrc file. |
| 165 | +
|
| 166 | +3. Verify whether bash-completion is installed successfully: execute type _init_completion to check the installation status of bash-completion. |
| 167 | +
|
| 168 | +###### 2. Configuring Auto-Completion |
| 169 | +
|
| 170 | +Follow these steps to enable the auto-completion feature in Bash: |
| 171 | +
|
| 172 | +1. echo 'source <(ve completion bash)' >> ~/.bashrc |
| 173 | +2. ve completion bash > /etc/bash_completion.d/ve |
| 174 | +
|
| 175 | +The changes will take effect after reloading the Shell or executing 'source ~/.bashrc'. |
| 176 | +
|
| 177 | +If the error '_get_comp_words_by_ref: command not found' occurs, please verify again that bash-completion has been installed and configured correctly. |
| 178 | +
|
| 179 | +<br/> |
| 180 | +
|
| 181 | +##### Zsh |
| 182 | +
|
| 183 | +The Zsh completion script for Volcengine CLI can be viewed by executing 've completion zsh'. To enable the auto-completion feature, import this completion script into your shell. |
| 184 | +
|
| 185 | +Configure the auto-completion feature in Zsh by following these steps: |
| 186 | +
|
| 187 | +1. Enabling compinit in Zsh: |
| 188 | + echo "autoload -U compinit; compinit" >> ~/.zshrc |
| 189 | +2. Configure Auto-Completion |
| 190 | + ve completion zsh > "${fpath[1]}/_ve" |
| 191 | +
|
| 192 | +The changes will take effect after reloading the shell or executing 'source ~/.zshrc'. |
| 193 | +
|
| 194 | +#### Configure Color |
| 195 | +
|
| 196 | +The colored display feature can be enabled by using ve enable-color. |
| 197 | +
|
| 198 | +The ve disable-color command can be used to disable the color display feature. |
| 199 | +
|
| 200 | +### Using Volcengine CLI |
| 201 | +
|
| 202 | +#### Query the list of supported services and the list of supported interfaces under each service |
| 203 | +
|
| 204 | +1. Query the list of supported services |
| 205 | + ```shell |
| 206 | + ve [-h|--help] |
| 207 | + ``` |
| 208 | +2. List of Supported Interfaces under the Query Service |
| 209 | + ```shell |
| 210 | + ve ecs [-h|--help] |
| 211 | + ``` |
| 212 | +
|
| 213 | +#### Call the API |
| 214 | +
|
| 215 | +When using the VolcEngine CLI to invoke an API, the basic command structure is as follows: |
| 216 | +
|
| 217 | +```shell |
| 218 | +ve <service name> <action> [--parameter1 value1 --parameter2 value2 ...] |
| 219 | +``` |
| 220 | +
|
| 221 | +You can use ve <service name> <action> --help to view information such as the parameter list and return results for the API you wish to invoke. For example: ve ecs DescribeInstances --help. |
| 222 | +
|
| 223 | +For more detailed information, you may also refer to <https://www.volcengine.com/docs>. |
| 224 | +
|
| 225 | +<br/> |
| 226 | +
|
| 227 | +The following code examples are provided: |
| 228 | +
|
| 229 | +- Basic Usage |
| 230 | +
|
| 231 | + ```shell |
| 232 | + ve ecs DescribeInstances |
| 233 | + ``` |
| 234 | +
|
| 235 | + ```shell |
| 236 | + ve rds_mysql ListDBInstanceIPLists --InstanceId "xxxxxx" |
| 237 | + ``` |
| 238 | +
|
| 239 | +- Supports JSON input |
| 240 | +
|
| 241 | + ```shell |
| 242 | + ve rds_mysql ModifyDBInstanceIPList --InstanceId "xxxxxx" --GroupName "xxxxxx" --IPList '["10.20.30.40", "50.60.70.80"]' |
| 243 | + ``` |
| 244 | +
|
| 245 | +- For requests with ContentType set to application/json, the Volcengine CLI also supports passing the body directly as JSON data. |
| 246 | +
|
| 247 | + ```shell |
| 248 | + ve rds_mysql ModifyDBInstanceIPList --body '{"InstanceId":"xxxxxx", "GroupName": "xxxxxx", "IPList": ["10.20.30.40", "50.60.70.80"]}' |
| 249 | + ``` |
0 commit comments