Element Unify command line tool
Project description
Element Unify CLI
The Unify CLI is a command line interface to Element Unify. It aims to supports all major APIs in Element Unify, and all common OSes (Mac, Windows, Linux).
It uses the command line tool library Click. https://click.palletsprojects.com/en/7.x/
Installation
The Unify CLI needs Python as a prerequisite. Therefore the installation instructions are divided in two main sections:
Python Installation
The best way to get a Python environment up is using a Python virtual environment:
-
brew install pyenv -
brew install pyenv-virtualenv -
Initialize virtual environment, this can be accomplish in two ways:
Option 1: Edit your Terminal profile (persistent)
3.1.1 If you're using bash, append the following to the end of
~/.bashrceval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)"3.1.2 If you're using ZSH, append the following to the end of
~/.zshrceval "$(pyenv init -)"Option 2: Initialize virtualenv for your current session (temporary)
3.2 Or, run this command to initialize the virtualenv
pyenv init -
source ~/.bashrc -
pyenv install 3.8.0 -
pyenv virtualenv 3.8.0 unify-cli
Unify CLI Installation
-
activate the virtualenv
pyenv activate unify-cli -
pip install unify-cli -
Run a test command to ensure things are working!
unify cluster add --help
Configuration
To get started with Unify CLI, first add your instance of Unify. Note that a cluster represents a deployment of Element Unify.
unify cluster add
- Remote is the URL of Unify. For example, https://app001-aws.elementanalytics.com/.
- Username is your Unify username (email).
- Password is your Unify password.
- Name is a name for this instance. For subsequent examples,
unifyis used
You will be prompted to save your credentials to keyring.
Next log in to this instance
unify cluster login --remote=unify
You may be prompted to access your credentials from keyring.
Basic Commands
An Unify CLI command has the following structure
unify <command group> <command> [options and parameters]
For example, to list all orgs in Unify:
unify org list --remote=unify
Main Command Groups
Each of these has a set of commands that goes with it.
Cluster
- Get
- List
- Delete
- Set defaults (org, cluster, user)
Org
- Get
- Upcert
- List
- Delete
- Grant
User
- Get
- Upcert
- List
- Delete
Template
- Get
- Upcert
- List
- Delete
Dataset
- Get
- Upcert
- List
- Delete
Datastream
- Simulate
Pipeline (include map-attributes)
- Get
- Upcert
- List
- Delete
- Run
- Evergreen (turn on and off, Maybe part of the upcert?)
Access
- Databases
- Execute
Configure CLI
Follow the steps below to set up the Unify CLI:
-
Add a new cluster
- Help
unify cluster add --help
- Client will prompt for parameters
unify cluster add
- All parameters inline
unify cluster add --remote "https://app001-aws.elementanalytics.com/" --username "yourusername" --password "yourpassword" --name "unify"
- Help
-
Set cluster as default
- Help
unify cluster default --help
- Client will prompt for parameters
unify cluster default
- All commands inline
unify cluster default --remote unify
- Help
-
Log in to cluster
- Help
unify cluster login --help
- Client will prompt for parameters
- Help
Workflow activities
Workflows commands perform bulk operations to help facilitate common operations such as copying pipelines or templates from one organization to another.
-
Element Unify Instance Management
-
Delete existing cluster
- Help
unify cluster disconnect --help
- All parameters inline
unify cluster disconnect --remote unify
- Client will prompt for parameters
unify cluster disconnect
- Help
-
List all Unify instances
- Help
unify cluster list --help
unify cluster list
- Help
-
-
Organization Management
-
Create Organization
-
All Parameters inline to default cluster
unify org add --name "New Organization Name"
-
All Parameters inline to different cluster
unify org add --name "New Organization Name" --remote "cluster_name"
-
Client will prompt for parameters ot default cluster
unify org add
-
Client will prompt to different cluster
unify org add --remote "cluster_name"
-
-
List all org available for current in user
-
List from default cluster
unify org list
-
List from different cluster
unify org list --remote "cluster name"
-
-
Delete org from cluster
-
Delete org from default cluster
unify org delete --orgid ######
-
Delete org from different cluster
unify org delete --orgid ###### --remote cluster_name
-
-
Create Users
-
Add Admin user to an existing org in default cluster
unify user add --orgid ###### --email "user_email@email.com" --name "User Name" --role Admin --remote unify
-
Add Contributor user to an existing org in default cluster
unify user add --orgid ###### --email "user_email@email.com" --name "User Name" --role Contributor --remote unify
-
Add user to an existing org to different cluster
unify user add --orgid ###### --email "user_email@email.com" --name "User Name" --role Admin --remote cluster_name
-
Add Contributor user to an existing org in default cluster
unify user add --orgid ###### --email "user_email@email.com" --name "User Name" --role Contributor --remote cluster_name
-
-
Data Workflow
-
This group gives the user the ability to export and import various types of data from templates, sources and pipelines
-
Templates
-
Export: This gives the functionality to export all templates from a given ORG, the output will be in standard output.
-
unify wf export-template --org ##### --remote cluster_name -
Export output into file
unify wf export-template --org ##### --remote cluster_name
-
-
Import: This will import templates contents into a given org of a cluster
unify wf import-template --org ##### --remote cluster_name templates.csv
-
Combine import and export into a single line
unify wf export-template --org ##### --remote origin_cluster_name | unify wf import-template --org ##### --remote destination_cluster_name
-
-
Pipelines
-
Export: this gives the functionality of exporting all necessary data (except sources) to export a pipelien structure. This command will even include map templates and map attributes
unify wf export-pipeline --remote origin_cluster_name --org ##### --pipeline ####
-
Export could also accept multiple pipelines:
unify wf export-pipeline --remote origin_cluster_name --org ##### --pipeline #### --pipeline ####
-
Import: This will import pipeline(s) into a given organization of the cluster. This will need a big file as input that can be generated with
unify wf export-pipelineunify wf import-pipeline --remote destination_cluster_name --org #####
-
Import and Export combined using command line pipe
unify wf export-pipeline --remote origin_cluster_name --org org_origin_id --pipeline pipeline_id_to_be_copied | unify wf import-pipeline --remote destination_cluster_name --org destination_org_id
-
-
Graphs
-
List: this gives you the list of all graphs on a given org
unify graph list --remote origin_cluster_name --org #####
-
Query: This will give you the ability to create cypher queries to a given graph
unify graph query --org ### --remote origin_cluster_name --graph "GRAPH ID" "Cypher Query" -junify graph query --org #### --remote platad --graph ##### "MATCH (n)-[r]->(g) RETURN *" -j
-
-
-
Example: Migrate an organization
The simplest way to fully migrate an org is to chain together several commands in a single bash script, the following .sh script can do the job.
#!/bin/sh
ORIGIN_ORG="5024"
ORIGIN_ENV="unify"
DESTINATION_ORG="10824"
DESTINATION_ENV="unify"
# Login to the origin unify cluster
unify cluster login --remote $ORIGIN_ENV
# Login to the destination unify cluster
unify cluster login --remote $DESTINATION_ENV
# Export the templates from the origin env and imported to the destination env
unify wf export-template --remote $ORIGIN_ENV --org $ORIGIN_ORG | unify wf import-template --remote $DESTINATION_ENV --org $DESTINATION_ORG
echo "Templates were migrated"
# Retrieves the datasets lists into a json array
DATASETS=$(unify dataset list --org $ORIGIN_ORG --remote $ORIGIN_ENV)
# Iterates over the current datasets
jq -c '.[]' <<< $DATASETS | while read js; do
code_val=$(jq -r '.id' <<< "$js")
# Export each dataset from the origin env and imported to the destination env
unify wf export-dataset --remote $ORIGIN_ENV --org $ORIGIN_ORG --id $code_val | unify wf import-dataset --remote $DESTINATION_ENV --org $DESTINATION_ORG
done
# Retrieves the pipeline lists into a json array
PIPELINES=$(unify pipeline list --org $ORIGIN_ORG --remote $ORIGIN_ENV)
# Iterates over the current Pipelines
jq -c '.[]' <<< $PIPELINES | while read jss; do
code_val=$(jq -r '.id' <<< "$jss")
# Export each pipeline from the origin env and imported to the destination env
unify wf export-pipeline --remote $ORIGIN_ENV --org $ORIGIN_ORG --pipeline $code_val --skip datasets --skip templates | unify wf import-pipeline --remote $DESTINATION_ENV --org $DESTINATION_ORG --skip datasets --skip templates
done
Developers Section
Info for people developing against the CLI
Running the tests
- Initialize your virtual environment, either using virtualenv, pyenv & pyvenv-virtualenv, or however you have it set up.
- Install the test requirements:
pip install -r tests/requirements.txt - Set the environment variables with cluster credentials (note, this should be a testing cluster for tests as it may not clean up after itself). These env var names may be edited in
tests/local.iniif you like (don't check in the changes of course). Values for these can be found in 1password in the Engineering vault.- LOCAL_API_URL
- LOCAL_ADMIN_NAME
- LOCAL_ADMIN_PASSWORD
- Run the tests:
nosetests --tc-file tests/local.ini --nocapture -v tests/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unify-cli-3.6.2.tar.gz.
File metadata
- Download URL: unify-cli-3.6.2.tar.gz
- Upload date:
- Size: 84.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43771cf22cb022dab69bbe60c4ecc3f6bad25f2de394fed9159d46d2f1e1d300
|
|
| MD5 |
f33bc96b655294d5bbeba81773208771
|
|
| BLAKE2b-256 |
145eabd99b0d668122ea0d2560cb1e597cf3209aa67e3db72282651294cebaa4
|
File details
Details for the file unify_cli-3.6.2-py3-none-any.whl.
File metadata
- Download URL: unify_cli-3.6.2-py3-none-any.whl
- Upload date:
- Size: 106.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d044227051223ff45d8c08764a5dfcb878179dd496017263a5ac9dfae682c897
|
|
| MD5 |
38b3438090a3ea57aac41b29026203c5
|
|
| BLAKE2b-256 |
850ca2a9da9cf031c1bf7f4af3640000026baccbbca426bd8a8de87ae64ef1c2
|