Set up

Overview

This tutorial explains how to install and set up the Blue Brain Nexus CLI to connect to a Blue Brain Nexus deployment.

Note

Let’s get started.

Install the Blue Brain Nexus CLI

Since the CLI is written in python, you may want to create a virtual environment for a clean set up. To do so, Conda can be used. If you don’t have it installed follow the instructions here.

conda create -n nexus-cli python=3.6
conda activate nexus-cli
pip install git+https://github.com/BlueBrain/nexus-cli

The following command should output a help message if the installation is successful.

Command
nexus --help
Full source at GitHub
Output
Usage: nexus [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  acls       ACLs operations
  auth       Authentication operations
  orgs       Organizations operations
  profiles   Profiles management operations
  projects   Projects operations
  resolvers  Resolvers operations
  resources  Resources operations
  schemas    Schemas operations
  views      Views operations
Full source at GitHub

Connect to a Nexus deployment

Configure the CLI

To ease the usage of the CLI, we will create a profile named ‘tutorial’ storing locally various configurations such as the Nexus deployment url.

Command
nexus profiles create tutorial https://sandbox.bluebrainnexus.io/v1 \
&& nexus profiles select tutorial \
&& nexus profiles list
Full source at GitHub
Output
Profile created.
Selected profile: tutorial

Profile created.
+------------+----------+------------------------------------- +-------+
| Profile    | Selected | URL                                  | Token |
+------------+----------+--------------------------------------+-------+
| tutorial   |   Yes    | https://sandbox.bluebrainnexus.io/v1 |  None |
+------------+----------+------------------------------------- +-------+
Full source at GitHub

Login

A bearer token is needed to authenticate to Nexus. For the purpose of this tutorial, you’ll login using your github account.

The following command will open (after pressing enter button) a browser window from where you can login using your github account.

Command
nexus auth web
Full source at GitHub
Output
A browser window will now open, please login, copy your token and use the 'set-token' command to store it in the CLI
Press ENTER to continue...
Full source at GitHub

From the opened web page, click on the login button on the right corner and follow the instructions.

login-ui

At the end you’ll see a token button on the right corner. Click on it to copy the token.

login-ui

The token can now be added to the tutorial profile. In the output of the following command you should see that the token column has now an expiry date.

Command
nexus auth set-token $TOKEN && nexus profiles list
Full source at GitHub
Output
+--------------+----------+-------------------------------------+-----------------------------+
| Profile      | Selected | URL                                 |            Token            |
+--------------+----------+-------------------------------------+-----------------------------+
| tutorial     |   Yes    | https://sandbox.bluebrainnexus.io/v1         | Expiry: YYYY-MM-DD HH:mm:s |
+--------------+----------+-------------------------------------+-----------------------------+
Full source at GitHub

That’s it!