Skip to main content

Python command line interface to CWP's Dash API.

Project description

# CWP Dash CLI

This is a command line interface tool for interacting with the NZ Common Web Platform Dash API. The primary aim of this tool is to be supported easily on linux hosts without additional packages having being installed. While it could be implemented easily in many different frameworks/languages, it's written in Python for the simple reason that **most** linux servers support Python out of the box. This package uses no external libraries and only core Python modules.

## Support

Currently dash-cli supports <= Python 2.7. A version supporting Python >= 3 is actively being worked on.

## Installation

You'll need to navigate to ``https://dash.cwp.govt.nz/naut/profile`` and obtain an `API token` before continuing.

### Using PIP - (Ubuntu based distros)
```
$ sudo pip install dash-cli
Collecting dash-cli
Downloading dash-cli-0.1.1.tar.gz
Installing collected packages: dash-cli
Running setup.py install for dash-cli ... done
Successfully installed dash-cli-0.1.1

$ dash-cli

Executing dash version 0.1.1.
Config file not found, lets get configured

CWP Email Address: [CWP_DASH_EMAIL]
CWP API Token: [CWP_DASH_API_TOKEN]
You are now configured
```

### Using easy_install - (Centos/RHEL based distros)

```
$ sudo easy_install dash-cli

Searching for dash-cli
...
Installed /usr/lib/python2.7/site-packages/dash_cli-0.1.1-py2.7.egg
Processing dependencies for dash-cli
Finished processing dependencies for dash-cli

$ dash-cli

Executing dash version 0.1.1.
Config file not found, lets get configured

CWP Email Address: [CWP_DASH_EMAIL]
CWP API Token: [CWP_DASH_API_TOKEN]
You are now configured
```

## Changelog
```
0.1.4: 21 May 2018
--------------------------
Support for snapshots failing and timeouts during simple mode

0.1.3: 10 April 2018
--------------------------
Support for large file downloads

0.1.2: 3 April 2018
--------------------------
Simple snapshots

0.1.1: 21 March 2018
--------------------------
Packaging changes
Documentation updates

0.1.0: 19 March 2018
--------------------------
Initial release
```

## Roadmap

* Locks
* Git Fetches
* Deployments
* `sspak` integration

## Usage

```
$ dash-cli -h

Executing dash version 0.1.2.
usage: cwp <command> [<sub_cmmand>|<args>]

Top level commands:
stack Perform actions on stacks
snapshot Perform snapshot actions

CLI interface with CWP dash

positional arguments:
command Subcommand to run

optional arguments:
-h, --help show this help message and exit
```

### Listing stacks
```
# List all stacks/projects
$ dash-cli stacks

# List info about a single stack/project
$ dash-cli stack --project=[project_id]
```

### Snapshots

#### List snapshots

Lists all snapshots for a given stack.

```
$ dash-cli snapshot list [project_id]
Executing dash version 0.1.2.

Retrieving snapshots for '[project_id]'

ID TYPE SIZE STATUS ENV DATE
---
12345 all 2.3GB complete uat 2018-03-19 11:44:05
67890 db 90.0MB complete prod 2018-03-13 15:25:05
```

#### Create snapshot

Queues a snapshot creation for a given stack. The request creates a **transfer** which is essentially a queued job, the transfer ID returned can be used with `snapshot status` to query the state of the snapshot transfer.

```
$ dash-cli snapshot create [project_id] [snap_type] [snap_env]
Executing dash version 0.1.2.
Snapshot for 'moeedgazette' queued
TRANSFER ID STATUS PROJECT TYPE ENVIRONMENT
---
12345 n/a [project_id] db prod

```


#### Query snapshot transfer status

```
$ dash-cli snapshot status [project_id] [transfer_id]
Executing dash version 0.1.2.
Snapshot for '[project_id]' queued
TRANSFER ID STATUS PROJECT
---
12345 Started [project_id]

```


#### Delete snapshot

```
$ dash-cli snapshot delete [project_id] [snapshot_id]
Executing dash version 0.1.0.
Deleting '[project_id]' snapshot with the following ID: 12345
OK.
```

#### Download snapshot

```
$ dash-cli snapshot download [project_id] [snapshot_id]
Executing dash version 0.1.2.
Downloading 'moeinside' snapshot with the following ID: 12345
OK.

```

#### Simple snapshot

Request a snapshot, download it, then delete it with one command, useful for automated jobs.

```
$ dash-cli snapshot simple [project_id] [snap_type] [snap_env]
Executing dash version 0.1.2.
Creating snapshot request
Waiting for [project_id] snapshot to complete... elapsed x seconds
Waiting for [project_id] snapshot to complete... elapsed x seconds
Waiting for [project_id] snapshot to complete... elapsed x seconds
Downloading snapshot...
Cleaning up API snapshots
OK.

```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dash-cli-0.1.4.tar.gz (8.2 kB view details)

Uploaded Source

File details

Details for the file dash-cli-0.1.4.tar.gz.

File metadata

  • Download URL: dash-cli-0.1.4.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dash-cli-0.1.4.tar.gz
Algorithm Hash digest
SHA256 43b54c59617f9d1ac3712b6ed1b2b46a472e8d637d443e7a5e5812adbbee712a
MD5 b8d8ea220f17fd44cfb94ddabef43479
BLAKE2b-256 85b4627d07d6bb0b67b5422aaf1b8ad1c0daf1023e00bfd92be5f9cb1cd218e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page