Overview

Smart World Cli is the command line interface tool for Smart World Professional. You can perform all the same tasks as you can in the Smart World Professional application, but can script using your favorite command line scripting language.

Download

The Smart World CLI tool can be downloaded by sending an email to [email protected]

Usage

Smart World CLi (swp) adheres to common cli usage:

swp [global options] command [command options][arguments...]

Before using swp, you will need to set the following in your environmental variables:

  • SWP_ORGANIZATION_ID
    export SWP_ORGANIZATION_ID=AKD2e234ASKK23432djb 
  • SWP_PROJECT_ID
    export SWP_PROJECT_ID=MHA4dka589fka845dfa 

Organization ID is provided when you sign up and you can get your Project ID by running:

swp list projects

You can script any of the processes below to automate import as the example below shows:

#! /bin/bash

#Sets your organization
export SWP_ORGANIZATION_ID=AKD2e234ASKK23432djb
#Set your project
export SWP_PROJECT_ID=MHA4dka589fka845dfa
swp create dataset myproject.water_mains --local-file ./water_mains.geojson
swp create dataset myproject.parks --local-file ./parks.geojson

Setup

Authentication for SWP requires access keys.  Access keys consist of an access key ID (for example, AKIAIOSFODNN7EXAMPLE) and a secret access key  (for example, wJalrXUtnFEMI_K7MDENG_bPxRfiCYEXAMPLEKEY).  These are set in your .swp/credentials file which should look like below:

 [[config]]

name = "default"
accessKey = "UjnrL9spqWVvcZ4XWs2djb"
secretKey = "bekqQJzvtCT2tb6ZvCSZr8zkLfoeKFrbFjzejQ9mzTv4"

You may add additional organizations by setting a new name and defining new access and secret keys.

Global Options

  The following global options are available with swp:

--quiet, -q                       

--organizationId value, -o value   Organization Id

--projectId value, -p value       Project ID

--accessId value, -a value         Access ID

--secretId value, -s value       Secret ID

--help, -h                         Show Help

--print-version, -V   Show Version

Commands

NAME: list, ls -- list <resourceType> 

USAGE: swp list <commands>

COMMANDS:

datasource, ds, datasources, dataset -- swp list d.s.
features, feature
file, fs, files -- swp list files (default)
project, projects, p -- swp list p
group, groups
role, roles
permission, permissions
user, users, u
org, organization, o -- swp list o
NAME: create, new -- create <resourceType> 

USAGE: swp create <commands>

COMMANDS:

dataset, dataset -- create dataset  --file <fileName>
datasource, datasource, ds
project, projects, p            
group, groups, g                
role, roles, r                  
organization, organizations, o
NAME: delete, rm, del -- delete <resourceType> 

USAGE:  swp delete <commands>

COMMANDS:

datasource, ds, datasources, dataset  
file, fs, files. --  Delete File
project, projects, p                  
group, groups, g                      
role, roles, r                        
user, users, u  
NAME: invite -- invite <resourceType> 

USAGE: swp invite <commands>

COMMANDS:

user, users, u -- invite u [email protected]
NAME: update -- update <resourceType>

USAGE: swp update <commands>

COMMANDS:

datasource, ds, datasources -- update datasource
dataset, dataset            
swp                          
project, projects, p        
group                        
role, roles, r              
user    
NAME: import, i -- import <resourceType>

USAGE: swp import <commands>

COMMANDS:

dataset, datasource, ds. -  manually runs dataset importer job
NAME: download, down, pull, d -- download <resourceType>

USAGE: swp d <commands>

COMMANDS:

file, fs, files -- file download <fileId>
NAME: convert, conv, c -- convert <resourceType>

USAGE: swp c <commands>

COMMANDS:

file, fs, files -- convert file
NAME: upload, up, push, u -- upload <resourceType>

USAGE: swp u <commands>

COMMANDS:

file, fs, files  
NAME: profile -- List Profile

USAGE: swp profile

COMMANDS:

none
NAME: config -- Show Config

USAGE: swp config

COMMANDS:

none
NAME: token, t -- Get Token

USAGE: swp t

COMMANDS:

none
NAME: file, files, fs -- File Upload

USAGE:  swp file <commands>

COMMANDS:

download, down, pull, d  --  file download <fileId>
types  --  file types
upload, up, push, u      
delete, rm, del -- Delete File
convert, conv, c  --  Convert File
list, ls  --  List Files (default)
NAME: asq, q, query -- asq  <sql-string>

USAGE: swp q <sql-string> <options>

OPTIONS:

--geojson, -g
--output value, -o value -- -o <filename>
NAME: help, h -- Shows a list of commands or help for one command

USAGE: swp <command> -h

Usage

Profiles

To show your own profile:

swp profile

Results:

Below this user is a member of two organizations

Profile:
 |- Email: [email protected]
 |- Name: User Name
 |- Organizations:
      |- Name: Organization Name 1 ID: AWDFSFDdsafslk_892
      |- Name: Organization Name 2 ID: DSasdfa74dlsfa_42-1

Projects

Projects are were data is stored and shared in Smart World Professional.  To see a list of all projects you have access to:

swp list projects

To create a new project:

swp create project "project_name"

Users

List users in an organization:

swp list users

Invite users to an organization:

swp invite user <emailaddress>

Files

To get a list of all files in a project:

swp list files

To upload a file:

swp upload file ./filename.geojson

To version an upload if a previous file already exists:

swp upload file ./filename.geojson -v

To delete a file:

swp delete file [filename]

Create Datasource

Create a datasource to upload datasets into.

swp create ds [dataset_name]

You can use commands --quiet (or -q) to run process in the background and --force (or -f) if you need to rerun an import.

Upload File

Upload a file and add it to datasource

swp upload file [file_name]
swp create dataset [dataset_name] --file [file_name]

Asq Query

To create an Asq query you must have a valid SQL string:

swp q 'select * from datasource.dataset'
Did this answer your question?