Command Line Interface

The Ryax Command Line Interface, or Ryax CLI for short, is the swiss army knife for all your automation needs. Without going through the UI you can do CRUD operations on workflows and modules.

Warning

The CLI is in beta. It may change at any time.

Installation

You will need Ryax CLI to unleash the full power of Ryax. In most cases, you can install Ryax CLI by using pip3 as below.

wget https://docs.ryax.tech/_static/ryax-cli-latest.tar.gz
pip3 install ryax-cli-latest.tar.gz

Virtual Environments

A virtual environment assures you can make changes without risking to populate your global python environment.

  • venv

To create a virtual environment, type:

python3 -m venv ryax-crashcourse

Enter the directory to switch to the virtual environment.

cd ryax-crashcourse
  • nix

If you like nix you can simulate a python venv using nix-shell, just copy the content below to file shell.nix.

with import <nixpkgs> {};
mkShell {
 name = "python-devel";
 venvDir = "venv";
 
 buildInputs = with python37Packages; [ 
  aiohttp
  fire
  pyyaml
  requests
 ];
 postShellHook = ''pip install `curl https://ryax.tech.org/ryax-cli-latest.tgz`''; }

To create a simulated venv with ryax-cli working, run the command below on the same location where the shell.nix file is.

nix-shell

Running

Run Ryax CLI and check the help page.

ryax-cli

If you have a command not found error, the installation did not work.

Options

Option

Description

–help

Print help, can be used with specific command.

–server=`url`

URL to Ryax API, for instance, –server=https://myryax.tech.org/api

–output-format=`json`

Show output in json instead of default human readable. Also accepts yaml.

–verify_ssl=`True`

Default is True, setting it to False will disable ssl verification, unsafe.

–password=`pass`

Send pass string as password to void prompting, requires –username.

–username=`user`

Send user string as username to void prompting, requires –password.

Quick Reference

Commands fit 3 categories: Admin, Modules, and Workflows. We detail each category next. When output examples are present, the issued command line starts with a dollar sign ($) and the output is just below the command.

Admin

Administration commands can be used to login, manage users, or monitor the execution of workflows.

  • login : prompt for username and password, create a session file to avoid asking to login everytime.

$ ryax-cli --server=https://myryax.tech.org/api login
  • user : create, list, update, or delete users

    • Create user, will prompt for password

$ ryax-cli --server=https://myryax.tech.org/api user create username
  • List users

$ ryax-cli --server=https://myryax.tech.org/api user list
|                    id|   user|  role|             email|            comment|
| usr-1601469257-kwvf30| myuser| Admin|   myuser@ryax.org|                   |
| usr-1601449386-cwsl5w|  user1| Admin| contact@ryax.tech| Default admin user|
  • Delete user, need to provide user’s id

$ ryax-cli --server=https://myryax.tech.org/api user delete usr-1601449386-cwsl5w
Are you sure you want to delete user usr-1601469257-kwvf30? [n]|y: y
User usr-1601469257-kwvf30 was deleted!

Modules

  • fd : create, list, build, or delete modules

    • Create a module, automatically trigger module build

$ ryax-cli --server=https://myryax.tech.org/api fd create ./one-run/
Creating function...
Function 'one-run' initialized
Creating an archive for gateway in /run/user/1005/tmp6_9ctly7/gateway...
Uploading function content...
Content uploaded!
Building one-run in version 1.0
Triggered build for function one-run with version 1.0.
Function 'one-run' created from './one-run'!
  • List all modules with status

$ ryax-cli --server=https://myryax.tech.org/api fd list
|      id|     kind|    type| status|                                        reason|
| one-run| Gateways| gateway|     OK| OK: The function definition is well formated.|
  • Delete specific module, it also deletes the associated module build

$ ryax-cli --server=https://myryax.tech.org/api fd delete one-run
* build one-run-1.0: The Function 'one-run-1.0' has been deleted successfully. ()
* draft one-run: Function deleted (The function 'one-run' has been deleted.)
  • fb : read or delete modules’ build

    • List all builds, with their states

$ ryax-cli --server=https://myryax.tech.org/api fb list
|              id| version|                         human_name|    type| function_def_id| status|
| hello-world-1.0|     1.0| Just print Hello World on the logs| python3|     hello-world|  READY|
  • Delete a specific module build, it also deletes the associated module draft

$ ryax-cli --server=https://myryax.tech.org/api fb delete hello-world-1.0
* draft hello-world: Function deleted (The function 'hello-world' has been deleted.)
* build hello-world-1.0: The Function 'hello-world-1.0' has been deleted successfully. ()

Workflows

  • wdraft : create, list, or delete workflow’s drafts

    • Create a workflow draft

$ ryax-cli --server=https://myryax.tech.org/api wdraft create ./workflow.yaml 
Creating workflow...
Workflow wf-draft-1601470240-htpd initialized!
Creating functions...
        Function hello-world created!
        Function one-run created!
Workflow wf-draft-1601470240-htpd created!
  • List workflow draft

$ ryax-cli --server=https://myryax.tech.org/api wdraft list
|                       id| human_name| status|                            reason| last_workflow_deployment_id|
| wf-draft-1601470240-htpd| Test      |     OK| OK: the workflow definition is OK|    wfdeploy-1601470429-n8k4|
  • Delete workflow draft

$ ryax-cli --server=https://myryax.tech.org/api wdraft delete wf-draft-1601470240-htpd
Workflow wf-draft-1601470240-htpd deleted!
  • wdeploy : create, list, monitor, or stop workflow’s deployments

    • Create workflow deployment

$ ryax-cli --server=https://myryax.tech.org/api wdeploy create wf-draft-1601470240-htpd
The workflow deployment 'wfdeploy-1601470429-n8k4' created for the workflow draft 'wf-draft-1601470240-htpd'.
  • List deployments

$ ryax-cli --server=https://myryax.tech.org/api wdeploy list
|                       id|        workflow_draft_id|   status|                  human_name|
| wfdeploy-1601470429-n8k4| wf-draft-1601470240-htpd| DEPLOYED| Test the hello-world module|
  • Monitor executions of a given workflow’s deployment, response in json format

$ ryax-cli --server=https://myryax.tech.org/api --output-format=json wdeploy monitor
[
  {
    "function_deploy_id": "func-deploy-1601470430-yneh",
    "function_instance_id": "hello-world",
    "started_at": 1601470435.887851,
    "next_execs": [],
    "executor_id": "func-deploy-1601470430-yneh-6d48b976f7-nrffx",
    "execution_id": "exec-1601470435-57hg",
    "logs": "Hello World\n\n",
    "submitted_at": 1601470435.75352,
    "prev_execs": [
      "exec-1601470435-6dp7"
    ],
    "workflow_deployment_id": "wfdeploy-1601470429-n8k4",
    "ended_at": 1601470435.964718,
    "error_code": 0,
    "state": "DONE"
  },
  {
    "function_deploy_id": "func-deploy-1601470430-jxs2",
    "function_instance_id": "one-run",
    "started_at": 1601470435.442336,
    "next_execs": [
      "exec-1601470435-57hg"
    ],
    "executor_id": "",
    "execution_id": "exec-1601470435-6dp7",
    "logs": "",
    "submitted_at": 1601470435.442336,
    "prev_execs": [],
    "workflow_deployment_id": "wfdeploy-1601470429-n8k4",
    "ended_at": 1601470435.443336,
    "error_code": 0,
    "state": "DONE"
  }
]
  • Stop a deployment

$ ryax-cli --server=https://myryax.tech.org/api wdeploy stop wfdeploy-1601470429-n8k4
The workflow 'wfdeploy-1601470429-n8k4' undeployment triggered.

Examples

  • Create a module and list its draft and build status:

$ ryax-cli --server=https://myryax.tech.org/api fd create ./one-run/
Creating function...
Function 'one-run' initialized
Creating an archive for gateway in /run/user/1005/tmp6_9ctly7/gateway...
Uploading function content...
Content uploaded!
Building one-run in version 1.0
Triggered build for function one-run with version 1.0.
Function 'one-run' created from './one-run'!

# List newly created module
$ ryax-cli --server=https://myryax.tech.org/api fd list
|      id|     kind|    type| status|                                        reason|
| one-run| Gateways| gateway|     OK| OK: The function definition is well formated.|

$ ryax-cli --server=https://myryax.tech.org/api fb list
|          id| version|             human_name|    type| function_def_id|   status|
| one-run-1.0|     1.0| Run a single execution| gateway|         one-run| BUILDING|

# Wait until module is built
$ ryax-cli --server=https://myryax.tech.org/api fb list
|          id| version|             human_name|    type| function_def_id|   status|
| one-run-1.0|     1.0| Run a single execution| gateway|         one-run|    READY|
  • Create a workflow and list to check status:

$ ryax-cli --server=https://myryax.tech.org/api wdraft create ./workflow.yaml 
Creating workflow...
Workflow wf-draft-1601470240-htpd initialized!
Creating functions...
        Function hello-world created!
        Function one-run created!
Workflow wf-draft-1601470240-htpd created!

# List workflow draft details
$ ryax-cli --server=https://myryax.tech.org/api wdraft list
|                       id| human_name| status|                            reason| last_workflow_deployment_id|
| wf-draft-1601470240-htpd| Test      |     OK| OK: the workflow definition is OK|                            |
  • Deploy a workflow and check deployment status:

$ ryax-cli --server=https://myryax.tech.org/api wdeploy create wf-draft-1601470240-htpd
The workflow deployment 'wfdeploy-1601470429-n8k4' created for the workflow draft 'wf-draft-1601470240-htpd'.

# Check if the workflow status is deployed
$ ryax-cli --server=https://myryax.tech.org/api wdeploy list
|                       id|        workflow_draft_id|   status|                  human_name|
| wfdeploy-1601470429-n8k4| wf-draft-1601470240-htpd| DEPLOYED| Test the hello-world module|
  • Retrieve executions formated as json, use wdeploy monitor --help to check available filters:

$ ryax-cli --server=https://myryax.tech.org/api --output-format=json wdeploy monitor
[
  {
    "function_deploy_id": "func-deploy-1601470430-yneh",
    "function_instance_id": "hello-world",
    "started_at": 1601470435.887851,
    "next_execs": [],
    "executor_id": "func-deploy-1601470430-yneh-6d48b976f7-nrffx",
    "execution_id": "exec-1601470435-57hg",
    "logs": "Hello World\n\n",
    "submitted_at": 1601470435.75352,
    "prev_execs": [
      "exec-1601470435-6dp7"
    ],
    "workflow_deployment_id": "wfdeploy-1601470429-n8k4",
    "ended_at": 1601470435.964718,
    "error_code": 0,
    "state": "DONE"
  },
  {
    "function_deploy_id": "func-deploy-1601470430-jxs2",
    "function_instance_id": "one-run",
    "started_at": 1601470435.442336,
    "next_execs": [
      "exec-1601470435-57hg"
    ],
    "executor_id": "",
    "execution_id": "exec-1601470435-6dp7",
    "logs": "",
    "submitted_at": 1601470435.442336,
    "prev_execs": [],
    "workflow_deployment_id": "wfdeploy-1601470429-n8k4",
    "ended_at": 1601470435.443336,
    "error_code": 0,
    "state": "DONE"
  }
]
  • Stop deployment and list to assert UNDEPLOYED status

$ ryax-cli --server=https://myryax.tech.org/api wdeploy stop wfdeploy-1601470429-n8k4
The workflow 'wfdeploy-1601470429-n8k4' undeployment triggered.

# List deployment to check if it was UNDEPLOYED
$ ryax-cli --server=https://myryax.tech.org/api wdeploy list
|                       id|        workflow_draft_id|     status|                  human_name|
| wfdeploy-1601470429-n8k4| wf-draft-1601470240-htpd| UNDEPLOYED| Test the hello-world module|