Skip to main content

Diagrid CLI

The Diagrid CLI allows you to manage and interact with your Catalyst resources. The CLI can perform most actions available in the Catalyst Console and provides additional utilities you can use to develop your applications using the APIs. For example, use the Diagrid CLI to:

  • Create and manage App IDs, connections, subscriptions,...
  • Invoke the Catalyst APIs and listen for incoming requests on a given App ID
  • Connect Catalyst to your local machine to receive pubsub events, service invocations, input bindings, etc. while developing
  • View App ID logs

Installing the CLI

Once you have created your Diagrid Catalyst account, you can access your organization at https://catalyst.diagrid.io.

Next, download and install the Diagrid CLI using the following command:

curl -o- https://downloads.diagrid.io/cli/install.sh | bash

Move the diagrid binary into your path so you can run it from anywhere. For example:

sudo mv ./diagrid /usr/local/bin 

Using the CLI

The CLI is a static binary that should be executed from the command line. Help pages are available for you to navigate the command tree and see what flags are available on each command.

To login to Diagrid Catalyst:

diagrid login

The Diagrid CLI is compatible with both products: Catalyst and Conductor. If you have access to both products, you can choose which set of commands to use by specifying the product name with the command: you can choose which one to use by specifying the product with the command:

diagrid product use catalyst

To verify the current user identity and organization:

diagrid whoami

To clean up your user data, use the logout command:

diagrid logout

Creating your first project

In order to begin using the Catalyst APIs, you must first create a project. After creating the project, you can begin creating App IDs and connections.

# Create project with Diagrid infrastructure resources and managed workflows
diagrid project create myproject --deploy-managed-pubsub --deploy-managed-kv --enable-managed-workflow

# Create an appid
diagrid appid create my-appid

# Create a subscription to the Diagrid Pub/Sub Broker
diagrid subscription create my-subscription --connection pubsub --topic events --route /events --scopes my-app

# View all resources for the current project and wait until all resources become ready
diagrid project get -a

# Connect a terminal to the App ID and listen for incoming subscription events
diagrid listen --app-id my-app --subscription my-subscription

Now in a different terminal:

# Publish a message to the pub/sub broker on the events topic and observe output in the listening terminal
diagrid call publish events --connection pubsub --app-id my-app --data "hello world"

Other useful commands

List all projects in an organization:

diagrid project list

Set the default project for all subsequent commands:

diagrid project use my-project

View all resources in a project:

diagrid project get -a