Package: torque-cli
Quali Torque CLIIntroTorque CLI is the command-line tool for interacting withTorque, the EaaS platform.
To learn more about Torque, visithttps://qtorque.io.Why use Torque CLIWhen developing Blueprints for Torque, it can be very helpful to immediately check your work for errors.Let's assume you are currently working indevelopmentbranch, and you also have a main branch which is connected
to a Torque space. You would like to be sure that your latest local changes haven't broken anything before committing to current branch and pushing to remote or before merging changes to main branch.This is where this tool might be handy for you. Instead of reconnecting Torque to your development branch in the UI or going with "merge and pray" you can
use Torque CLI to validate your current Blueprints state and even launch Environments.NOTE:Please note that the latest stable version with spec1 support is1.5.2.
Some features described in this manual (like blueprint validation or temporary branch workflow)
are not implemented yet in the>1.6.xversion with spec2 support, but they are coming soon.InstallingYou can install Torque CLI withpip:$ python -m pip install torque-cliOr if you want to install it for your user:$ python -m pip install --user torque-cliConfigurationIn order to allow the CLI tool to authenticate with Torque you must provide several parameters:TokenThe easiest way to generate a token is via the Torque UI. Navigate toSettings (in your space) -> Integrations ->
click “Connect” under any of the CI tools -> click “New Token”to get an API token. Alternatively, a token can be generated usingtorque configure set --logincommandSpaceThe space in the Torque to use which is mapped to the Git repo you are usingAccount(optional) providing the account nameTheToken,SpaceandAccountparameters can be provided via special command line flags (--token,--space,and--accountrespectively) but can be conveniently placed in a config file relative to your user folder,
so they don't need to be provided each time.The config file can be easily created and managed using the interactivetorque configurecommand.
The CLI supports multiple profiles and we recommend setting up a default profile for ease of use. To use a non-default profile the--profilecommand line flag needs to be used to specify the profile name.To add a new profile or update an existing one runtorque configure setand follow the on-screen directions. First you will be able to choose the profile name. Hit enter to add/update the default profile or enter a custom profile name. If the profile exists it will be update and if it doesn't exist then a new profile will be configured.
If you want to generate token by Torque CLI then use the--login|-loption (does not work for SSO). You will be requested to enter email and password instead of tokenTo see all profiles runtorque configure listand the command will output a table of all the profiles that are currently configured. Example output:ProfileNameTorqueAccountSpaceNameToken
--------------------------------------------------------------
defaulttorque-demopromotions-manager*********jhtU
custom-profilemy-torquemy-space*********igEwIf a profile is no longer needed it can be easily removed by runningtorque configure remove [profile-name]Thetorque configurecommand will save the config file relative to your home user directory ('~/.torque/config' on Mac and Linux or in '%UserProfile%\.torque\config' on Windows).
If you wish to place the config file in a different location, you can specify that location via an environment variable:$ export TORQUE_CONFIG_PATH=/path/to/fileThe different parameters may also be provided as environment variables instead of using the config file:exportTORQUE_TOKEN=xxxzzzyyyexportTORQUE_SPACE=demo_space# OptionalexportTORQUE_ACCOUNT=MYACCOUNTAdditional environment variablesIt is possible to switch the client to different Torque instance setting custom API endpoint:exportTORQUE_HOSTNAME="torque.example.com"Basic UsageThere are several basic actions Torque CLI currently allows you to perform:Validate a Blueprint (using thetorque bp validatecommand)Get a list of blueprints (viatorque bp list)Start an Environment (viatorque env start)In order to get help run:$ torque --helpIt will give you detailed output with usage:$torque--help
Usage:torque[--space=<space>][--token=<token>][--account=<account>][--profile=<profile>][--help][--debug][--disable-version-check]<command>[<args>...]Options:-h--helpShowthisscreen.--versionShowcurrentversion--space=<space>UseaspecificTorqueSpace,thiswilloverrideanydefaultsetintheconfigfile--token=<token>Useaspecifictokenforauthentication,thiswilloverrideanydefaultsetintheconfigfile--account=<account>[Optional]YourTorqueaccountname.--profile=<profile>UseaspecificProfilesectionintheconfigfileYoustillcanoverrideconfigwith--token/--spaceoptions.

Commands:bp,blueprintvalidatetorqueblueprintsenv,environmentstartenvironment,endenvironmentandgetitsstatusconfigureset,listandremoveconnectionprofilestotorqueYou can get additional help information for a particular command by specifying--helpflag after command name, like:usage:
        torque (env | environment) start <blueprint_name> [options]
        torque (env | environment) status <environment_id>
        torque (env | environment) end <environment_id>
        torque (env | environment) list [--filter={all|my|auto}] [--show-ended] [--count=<N>]
        torque (env | environment) [--help]

    options:
       -h --help                        Show this message

       -d, --duration <minutes>         The Environment will automatically de-provision at the end of the provided
                                        duration.

       -n, --name <environment_name>    Provide a name for the Environment. If not set, the name will be generated
                                        automatically using the source branch (or local changes) and current time.

       -i, --inputs <input_params>      The Blueprints inputs can be provided as a comma-separated list of key=value
                                        pairs. For example: key1=value1,key2=value2.
                                        By default Torque CLI will try to take the default values for these inputs
                                        from the Blueprint definition yaml file.

       -b, --branch <branch>            Run the Blueprint version from a remote Git branch. If not provided,
                                        the CLI will attempt to automatically detect the current working branch.
                                        The CLI will automatically run any local uncommitted or untracked changes in a
                                        temporary branch created for the validation or for the development Environment.

       -c, --commit <commitId>          Specify a specific Commit ID. This is used in order to run an Environment from a
                                        specific Blueprint historic version. If this parameter is used, the
                                        Branch parameter must also be specified.

       -t, --timeout <minutes>          Set how long (default timeout is 30 minutes) to block and wait before releasing
                                        control back to shell prompt. If timeout is reached before the desired status
                                        the wait loop will be interrupted.
                                        If "wait_active" flag is not set and a temp branch is created for local changes,
                                        the CLI will block and wait until the Environment Infrastructure is ready. Then 
                                        the temp branch can be safely deleted and the wait loop will end. 
                                        If "wait_active" flag is set, the CLI will block and wait until the Environment
                                        is Active regardless if temp branch is created or not.

       -w, --wait_active                Block shell prompt and wait for the Environment to be Active (or deployment
                                        ended with an error) while the timeout is not reached. Default timeout
                                        is 30 minutes. The default timeout can be changed using the "timeout" flag.Blueprint validationSpecify a file containing the declaration of your blueprint using the following command:$ torque bp validate MyBlueprint.yamlIf blueprint has any errors you will see them printed:messagenamecode
------------------------------------------------------------------------------------------------------------------
Value'{{.grains.OracleInstance.outputs.instance_id}}'can'tberesolvedValuedoesnotexistVALUE_CANT_BE_RESOLVEDThe Torque CLI can also read the a blueprint content from stdin. In this case, you need to provide a dash "-" instead
of a path to the file.Testing local changesThe Torque CLI can validate your Blueprints and test your Environments even before you commit and push your code to a
remote branch. It does so by creating a temporary branch on the remote repository with your local staged and even
untracked changes which gets deleted automatically after the Environment is created or the Blueprint validation is
complete. The CLI will automatically detect if you have some local changes and use them unless you explicitly
set the --branch flag.Please notice that in order to create an Environment from your local changes, the CLI must make sure they are
picked up by the Environment setup process before completing the action and deleting the temporary branch. This means
that when you launch a local Environment the CLI command will not return immediately. You'll also receive a warning
not to abort the wait as that might not give Torque enough time to pull your changes and the Environment may fail.
Feel free to launch the CLI command asynchronously or continue working in a new tab.NOTEIf you are not it git-enabled folder of your Blueprint repo and haven't set --branch/--commit arguments tool will
validate Blueprint with name "MyBlueprint" from branch currently attached to your Torque space.The result will indicate whether the Blueprint is valid. If there are ny issues, you will see them printed out as
a table describing each issue found.Example:$torqueblueprintvalidateJenkins-bmaster

ERROR-torque.commands-Validationfailed
messagename
----------------------------------------------------------------------------------------------------------
Cloudaccount:AWSisnotrecognizedasavalidcloudaccountinthisspaceBlueprintunknowncloudaccountLaunching an EnvironmentSimilar to the previous command you can omit--branch/--commitarguments if you are in a git-enabled folder of your
Blueprint repo:$ torque env start MyBlueprintThis will create an Environment from the specified BlueprintIf you want to start an Environment from a Blueprint in a specific state, specify--branchand--commitarguments:$ torque env start MyBlueprint --branch dev --commit fb88a5e3275q5d54697cff82a160a29885dfed24Additional optional options that you can provide here are:-d, --duration <minutes>- you can specify duration for the Environment in minutes. Default is 120 minutes-n, --name <environment_name>- the name of the Environment you want to create. By default, the cli will generate a name using the Blueprint name, branch or local changes, and the current timestamp-i, --inputs <input_params>- comma-separated list of input parameters for the Environment, For example:"param1=val1, param2=val2"-w, --wait <timeout>-  is a number of minutes. If set, you Torque CLI will wait for the Environment to become active and lock your terminal.NOTEIf you are not it git-enabled folder of your Blueprint repo and haven't set --branch/--commit arguments tool will
start an Environment using the Blueprint "MyBlueprint" from the branch currently attached to your Torque space.If you omit inputs options, you are inside a git enabled folder and the local is in sync with remote,
then Torque Cli will try to get default values for inputs from the Blueprint YAML file.Result of the command is an Environment ID.Example:$torqueenvstartMyBlueprint--inputs"CS_TORQUE_TOKEN=ABCD, IAM_ROLE=s3access-profile, BUCKET_NAME=abc"ybufpamyok03c11Other functionalityYou can also end a Torque Environment by using the "end" command and specifying its Id:$ torque env end <environment_id>To get the current status of an Environment status run:$ torque env status <environment_id>In order to list all Environments in your space use the following command:$ torque env listBy default, this command will show only Environments launched by the CLI user which are not in an ended status.You can include historic completed Environments by setting--show-endedflagDefault output length is 25. You can override with option--count=Nwhere N < 1000You can also list Environments created by other users or filter only automation Environments by setting option--filter={all|my|auto}. Default ismy.Troubleshooting and HelpTo troubleshoot what Torque CLI is doing you can add--debugto get additional information.For questions, bug reports or feature requests, please refer to theIssue Tracker.ContributingAll your contributions are welcomed and encouraged. We've compiled detailed information about:ContributingLicenseApache License 2.0