Working with CLI command versions
To quickly release new service functionality and provide broader coverage of public API calls, the Yandex Cloud CLI is gradually introducing a new approach to generating command trees directly from the public gRPC API proto specifications
With the new approach in place, new commands and their parameters are not always the same as the previous ones. For backward compatibility, versioning of service command trees has been implemented.
In each group of service commands, e.g., yc compute, the main command branch remains as before: yc compute [ instance | image | disk | ... ], but branches with command version numbers are also added, e.g., yc compute v0 [ instance | image | disk | ... ].
The main branch of commands must match one of the versions. If there is only one version, the main branch completely duplicates it.
The information on adding or removing a command version, as well as on switching the main branch to another version, is published in CLI releases.
Tip
Use the current version of the CLI and the command tree the service has assigned as the main one. If CLI commands are called from scripts, CI/CD, or other automated processes, first check command compatibility when migrating to a new CLI version. While the legacy version of the commands is available, you can explicitly state it in specific commands or set it as the default version.
Getting info on available versions
If the service supports multiple command versions, there is a separate branch with version number available for each one of them.
To learn about available versions and which one is used in the main branch, run this command:
yc <service_name> --help
Here is an example:
yc baremetal --help
Result:
Command tree v1 (new CLI interface) is the default. Run `yc baremetal v1 <command>`.
Legacy command tree v0 is also available: `yc baremetal v0 <command>`.
Set `services.baremetal.version: v0` or `services.baremetal.version: v1` in your profile to change the default.
The same information is also provided on the overview page of the relevant service in the CLI reference, e.g., yc baremetal or yc smartwebsecurity.
Using a specific version
To use a specific version, specify it after the service name in the command:
yc <service_name> v<version_number> <command>
Here is an example:
yc baremetal v0 server list
Changing the main branch version
To override the main branch version for a selected CLI profile, run this command:
yc config set services.<service_name>.version v<version_number>
Here is an example:
yc config set services.smartwebsecurity.version v0