BlueNimble CLI - Command Line Tool

keys command

Description

keys command prints out all the keys loaded in the iCli and also will indicate wich keys are current, prefixing the keys by a (C)

Examples
  1. bluenimble:.> keys
  2. o prod
  3. ----------------
  4. Endpoint: https://sys.prod.mycompany.com/mgm
  5. Access Key: 1XNHZWLOOWQLZQP/AXQL
  6. Secret Key: AsE3tCibIVa9FcmaNZ3pWi5H5nS77dJO2fTrDL4y
  7. o (C) uranus
  8. -----------
  9. Endpoint: https://sys.uranus.bluenimble.com/mgm
  10. Access Key: 1XNHZWLOOWQLZQP/AXQL
  11. Secret Key: AsE3tCibIVa9FcmaNZ3pWi5H5nS77dJO2fTrDL4y

load keys command

Description

load keys command loads a valid BlueNimble keys file into the iCli

iCli will reference the keys using file name without the .keys extension. If you load uranus.keys, then the keys name will uranus

The keys file should be a well-formed json object having at least three properties

  • endpoint BlueNimble Instance Management Endpoint
  • accessKey BlueNimble Space Access Key
  • secretKey BlueNimble Space Secret Key

  1. {
  2. "endpoint": "https://sys.uranus.bluenimble.com/mgm",
  3. "accessKey": "9IAHMWWMQMQZAAY/WPSZ",
  4. "secretKey": "JfO6tBicIZa7FcmoNX3qWi3H9nS77dJO7fOziSPa"
  5. }

Arguments
Keys File Path a local file path to a valid keys file

Examples
  1. bluenimble:.> load keys /tmp/uranus.keys

use keys command

Description

use keys command instruct the iCli to use a specific keys

You may have different keys for diffrent BlueNimble spaces

Arguments
Keys Name the name of the keys file without the extension .keys

Examples
  1. bluenimble:.> use keys uranus

workspace (or ws) command

Description

ws command without arguments prints out your workspace folder where the iCli creates your apis structures and where you put your code, within the apis inside the workspace

ws command with a valid folder path will set your workspace. This is recommended because normaly you'd like to set the workspace to a valid local git repository in order to perform 'merge requests' and 'commits'

Arguments
Folder path (Optional) the path to a valid folder in your local machine

Examples
  1. bluenimble:.> ws
  2. o Workspace
  3. -------------
  4. /git/repos/bluenimble/workspace
  5. o Apis
  6. --------
  7. travel
  8. (C) todolist

  1. bluenimble:.> ws /tmp/workspace
  2. o Workspace
  3. -------------
  4. /tmp/workspace

api command

Description

api command without arguments will print out your current api

api command with a namespace argument will change the current api to the one given by the 'namespace' argument

Arguments
namespace (Optional) an existing api anamespace

Examples
  1. bluenimble:.> api
  2. o Current Api
  3. ---------------
  4. namespace: todolist
  5. path: $ws/ todolist

  1. bluenimble:.> api travel
  2. o Current Api
  3. ---------------
  4. namespace: travel
  5. path: $ws/ travel

create api command

Description

create api command creates a new api project structure under the current workspace

This command create the api structure under a folder given by the namespace argument

  1. - workspace
  2. - todolist
  3. - resources
  4. - messages
  5. - scripts
  6. - services
  7. - templates
  8. api.json

This command generates also the following 'identity management' services

Signup to signup application users
Activate to validate a new user email
Login to authenticate users
ChangePassword allow users to change passwords
OAuth to authenticate users through facebook, linkedin, google plus, github and other OAuth providers

Arguments
namespace the api anamespace

Examples
  1. bluenimble:.> create api todolist
  2. o Api 'todolist' created! path: $ws/ todolist
  3. -----------------------------------------------
  4. {
  5. "namespace": "todolist",
  6. "name": "todolist api",
  7. "description": "todolist description",
  8. "runtime": {
  9. "script": "scripts/Api.js"
  10. },
  11. "spi": {
  12. "class": "scripting.javascript:ApiSpi"
  13. }
  14. }
  15. Info | security scheme 'token' added to api 'todolist'
  16. Info | security scheme 'cookie' added to api 'todolist'
  17. o Api 'todolist' updated spec
  18. -------------------------------
  19. {
  20. "namespace": "todolist",
  21. "name": "todolist api",
  22. "description": "todolist description",
  23. "runtime": {
  24. "script": "scripts/Api.js"
  25. },
  26. "spi": {
  27. "class": "scripting.javascript:ApiSpi"
  28. },
  29. "security": {
  30. "schemes": {
  31. "token": {
  32. "auth": {
  33. "secrets": "default"
  34. }
  35. },
  36. "cookie": {
  37. "auth": {
  38. "secrets": "default"
  39. }
  40. }
  41. }
  42. }
  43. }
  44. /--> 'Signup' Service
  45. |
  46. +--+ spec file created 'services/security/Signup.json'
  47. Imporant | An activation email html file was created! 'templates/emails/signup.html' It's used by the Signup service
  48. Make sure that the email feature is added to your space in order to send emails.
  49. Use command 'add feature' to add an smtp server config
  50. /--> 'Activate' Service
  51. |
  52. +--+ spec file created 'services/security/Activate.json'
  53. /--> 'Login' Service
  54. |
  55. +--+ spec file created 'services/security/Login.json'
  56. /--> 'ChangePassword' Service
  57. |
  58. +--+ spec file created 'services/security/ChangePassword.json'
  59. /--> 'OAuth' Service
  60. |
  61. +--+ spec file created 'services/security/OAuth.json'
  62. Imporant | Make sure that your clientId and sercretId are set in your oauth providers.
  63. See service spec file resources/services/security/OAuth.json

create service command

Description

create service command create services for a model, it generates the json spec and javascript files

Arguments
verb *, get, post, put, delete or find

General Syntax
  1. bluenimble:.> create service [*|get|post|put|delete|find] [model]

Examples
  1. # create a get service for model todoitem
  2. bluenimble:.> create service get todoitem
  3. /--> 'get todoitem' Service
  4. |
  5. +--+ spec file created 'services/todoitems/GetTodoitem.json'
  6. |
  7. +--+ script file created 'services/todoitems/GetTodoitem.js'

  1. # create a post service for model todoitem
  2. bluenimble:.> create service post todoitem
  3. /--> 'post todoitem' Service
  4. |
  5. +--+ spec file created 'services/todoitems/CreateTodoitem.json'
  6. |
  7. +--+ script file created 'services/todoitems/CreateTodoitem.js'

  1. # create a find service for model todoitem
  2. bluenimble:.> create service find todoitem
  3. /--> 'find todoitems' Service
  4. |
  5. +--+ spec file created 'services/todoitems/FindTodoitems.json'
  6. |
  7. +--+ script file created 'services/todoitems/FindTodoitems.js'

  1. # create all services for model task
  2. bluenimble:.> create service * task
  3. /--> 'get task' Service
  4. |
  5. +--+ spec file created 'services/tasks/GetTask.json'
  6. |
  7. +--+ script file created 'services/tasks/GetTask.js'
  8. /--> 'post task' Service
  9. |
  10. +--+ spec file created 'services/tasks/CreateTask.json'
  11. |
  12. +--+ script file created 'services/tasks/CreateTask.js'
  13. /--> 'put task' Service
  14. |
  15. +--+ spec file created 'services/tasks/UpdateTask.json'
  16. |
  17. +--+ script file created 'services/tasks/UpdateTask.js'
  18. /--> 'delete task' Service
  19. |
  20. +--+ spec file created 'services/tasks/DeleteTask.json'
  21. |
  22. +--+ script file created 'services/tasks/DeleteTask.js'
  23. /--> 'find tasks' Service
  24. |
  25. +--+ spec file created 'services/tasks/FindTasks.json'
  26. |
  27. +--+ script file created 'services/tasks/FindTasks.js'

push api command

Description

push api command installs/runs the api given by the namespace argument into a BlueNimble instance

Arguments
namespace the namespace of the api to install

Examples
  1. bluenimble:.> push api todolist
  2. Info | {
  3. "namespace": "todolist",
  4. "name": "todolist api",
  5. "description": "todolist description",
  6. "runtime": {
  7. "script": "scripts/Api.js"
  8. },
  9. "spi": {
  10. "class": "scripting.javascript:ApiSpi"
  11. },
  12. "security": {
  13. "schemes": {
  14. "token": {
  15. "auth": {
  16. "secrets": "default"
  17. }
  18. },
  19. "cookie": {
  20. "auth": {
  21. "secrets": "default"
  22. }
  23. }
  24. }
  25. },
  26. "status": "Running"
  27. }

drop api command

Description

drop api command uninstalls the api given by the namespace argument from a BlueNimble instance

This command doesn't delete the api folder from the workspace

Arguments
namespace the namespace of the api to uninstall

Examples
  1. bluenimble:.> drop api todolist
  2. Info | {
  3. "dropped": "true"
  4. }

desc space command

Description

desc space command prints out information about your space in a BlueNimble instance, such as the admin keys, features installed in this space, quotas and the current number of running/completed requests

Examples
  1. bluenimble:.> desc space
  2. Info | {
  3. "role": "ADMIN",
  4. "accessKey": "1XNHZWLOOWQLZQP/AXQL",
  5. "secretKey": "AsE3tCibIVa9FcmaNZ3pWi5H5nS77dJO2fTrDL4y",
  6. "root": "true",
  7. "space": {
  8. "namespace": "ytxdswopwl",
  9. "features": {
  10. "database": {
  11. "default": { "provider": "platform" }
  12. },
  13. "storage": {
  14. "default": { "provider": "platform" }
  15. },
  16. "scripting": {
  17. "default": { "provider": "platform" }
  18. },
  19. "cache": {
  20. "default": { "provider": "platform" }
  21. },
  22. "messenger": {
  23. "email": {
  24. "provider": "smtp",
  25. "spec": {
  26. "server": {
  27. "mail.smtp.host": "smtp.office365.com",
  28. "mail.smtp.port": "587",
  29. "mail.smtp.auth": "true",
  30. "mail.smtp.starttls.enable": "true"
  31. },
  32. "auth": {
  33. "user": "xxxxx@bluenimble.com",
  34. "password": "xxxxxx"
  35. }
  36. }
  37. }
  38. }
  39. },
  40. "secrets": {
  41. "default": {
  42. "key": "xxxxxxxxxxxxxx",
  43. "algorithm": "AES",
  44. "age": "60"
  45. }
  46. },
  47. "quotas": {
  48. "workers": "30",
  49. "database": "20"
  50. },
  51. "requests": {
  52. "running": "0",
  53. "completed": "17",
  54. "scheduled": "17"
  55. },
  56. "apis": [
  57. {
  58. "namespace": "todolist",
  59. "name": "todolist api",
  60. "description": "todolist description",
  61. "runtime": {
  62. "script": "scripts/Api.js"
  63. },
  64. "spi": {
  65. "class": "scripting.javascript:ApiSpi"
  66. },
  67. "security": {
  68. "schemes": {
  69. "token": {
  70. "auth": {
  71. "secrets": "default"
  72. }
  73. },
  74. "cookie": {
  75. "auth": {
  76. "secrets": "default"
  77. }
  78. }
  79. }
  80. },
  81. "status": "Running"
  82. }
  83. ]
  84. },
  85. "timestamp": "2016-06-15T08:07:11Z"
  86. }

json command

Description

json command is a utility command to create, load a json file, save into a file and set/delete object properties

json create Arguments
variable name a variable name where to store the created json object
json string (Optional) a well formed json string such as { "name": "John" }

if no argument is passed to the json create command, it will create an empty json object {}

Examples
  1. bluenimble:.> json create user
  2. {
  3. }

  1. bluenimble:.> json create user { "name": "John" }
  2. {
  3. "name": "John"
  4. }

  1. bluenimble:.> json create user { "name": "John", "phones": ["+1 408 123 4567", "+1 601 123 4567"] }
  2. {
  3. "name": "John",
  4. "phones": [
  5. "+1 408 123 4567",
  6. "+1 601 123 4567"
  7. ]
  8. }

you'll get the same output using vars command

  1. bluenimble:.> vars user
  2. {
  3. "name": "John",
  4. "phones": [
  5. "+1 408 123 4567",
  6. "+1 601 123 4567"
  7. ]
  8. }

json set Arguments
variable name a valid variable holding your json object
name the property name
value the property value

Examples
  1. bluenimble:.> json set user city Sunnyvale
  2. {
  3. "name": "John",
  4. "phones": [
  5. "+1 408 123 4567",
  6. "+1 601 123 4567"
  7. ],
  8. "city": "Sunnyvale"
  9. }

you can also provide a json object/array as the value of a property by prefixing the value with a 'j\'

  1. bluenimble:.> json set user address j\{ "street": "100 BlueNimble Dr", "zipCode": "1000" }
  2. {
  3. "name": "John",
  4. "phones": [
  5. "+1 408 123 4567",
  6. "+1 601 123 4567"
  7. ],
  8. "city": "Sunnyvale",
  9. "address": {
  10. "street": "100 BlueNimble Dr",
  11. "zipCode": "1000"
  12. }
  13. }

  1. bluenimble:.> json set user pets j\["Rambo", "Valero"]
  2. {
  3. "name": "John",
  4. "phones": [
  5. "+1 408 123 4567",
  6. "+1 601 123 4567"
  7. ],
  8. "city": "Sunnyvale",
  9. "address": {
  10. "street": "100 BlueNimble Dr",
  11. "zipCode": "1000"
  12. },
  13. "pets": [
  14. "Rambo",
  15. "Valero"
  16. ]
  17. }

  1. bluenimble:.> json set user address.zipCode 2000
  2. {
  3. "name": "John",
  4. "phones": [
  5. "+1 408 123 4567",
  6. "+1 601 123 4567"
  7. ],
  8. "city": "Sunnyvale",
  9. "address": {
  10. "street": "100 BlueNimble Dr",
  11. "zipCode": "2000"
  12. },
  13. "pets": [
  14. "Rambo",
  15. "Valero"
  16. ]
  17. }

json delete Arguments
variable name a valid variable holding your json object
name the name of the property to delete

Examples
  1. bluenimble:.> json delete user address.zipCode
  2. {
  3. "name": "John",
  4. "phones": [
  5. "+1 408 123 4567",
  6. "+1 601 123 4567"
  7. ],
  8. "city": "Sunnyvale",
  9. "address": {
  10. "street": "100 BlueNimble Dr"
  11. },
  12. "pets": [
  13. "Rambo",
  14. "Valero"
  15. ]
  16. }

  1. bluenimble:.> json delete user phones
  2. {
  3. "name": "John",
  4. "city": "Sunnyvale",
  5. "address": {
  6. "street": "100 BlueNimble Dr"
  7. },
  8. "pets": [
  9. "Rambo",
  10. "Valero"
  11. ]
  12. }

  1. bluenimble:.> json delete user pets.0
  2. {
  3. "name": "John",
  4. "city": "Sunnyvale",
  5. "address": {
  6. "street": "100 BlueNimble Dr"
  7. },
  8. "pets": [
  9. "Valero"
  10. ]
  11. }

json save Arguments
variable name a valid variable holding your json object
file path a valid file path

Examples
  1. bluenimble:.> json save user /tmp/user.json
  2. 'user' saved to /tmp/user.json

json load Arguments
variable name a variable name where to store the json content of the file
file path a well formed json file path

Examples
  1. bluenimble:.> json load storedUser /tmp/user.json
  2. {
  3. "name": "John",
  4. "city": "Sunnyvale",
  5. "address": {
  6. "street": "100 BlueNimble Dr"
  7. },
  8. "pets": [
  9. "Valero"
  10. ]
  11. }

features command

Description

features command prints out the fetaures' templates installed in the iCli

This command is useful to load a feature template config in a json object in order to add features to a BlueNimble Space

Arguments
feature name (Optional) a valid feature name

Examples
  1. bluenimble:.> features
  2. o features
  3. ------------
  4. messenger
  5. storage

  1. bluenimble:.> features messenger
  2. o messenger
  3. -------------
  4. push
  5. smtp

  1. bluenimble:.> features messenger/push
  2. o push
  3. --------
  4. default.json

  1. bluenimble:.> features messenger/push/default.json
  2. o Variable push.default
  3. -------------------------
  4. {
  5. "name": "push",
  6. "feature": "messenger",
  7. "provider": "push",
  8. "spec": {
  9. "application": "Application Name",
  10. "platforms": {
  11. "gcm": {
  12. "key": "Application Registration Key/ID"
  13. },
  14. "apns_sandbox": {
  15. "key": "Sandbox Application Registration Key/ID",
  16. "certificate": "Sandbox Application Registration Certificate"
  17. },
  18. "apns": {
  19. "key": "Application Registration Key/ID",
  20. "certificate": "Application Registration Certificate"
  21. }
  22. }
  23. }
  24. }

This command will load the push notification template into a variable called push.default

Use the json command to set the right parameters for your push notification service and use add feature command to enable push notifications for apps in your space

add feature command

Description

add feature command adds features to your space in a running BlueNimble instance

Supported features are the ones supported by the instance. Generally, you can add storage and messenger (smtp & mobile push notification) features

  1. bluenimble:.> ctx spaces
  2. Context changed to [spaces]

Arguments
variable name a variable name holding a json object describing the feature config

Examples
  1. bluenimble:spaces> add feature push.default
  2. Info | {
  3. "added": "true"
  4. }

delete feature command

Description

delete feature command deletes installed features from your space in a running BlueNimble instance

Use desc space to list all installed features in order to find which feature you're whiling to delete

  1. bluenimble:spaces> ctx spaces
  2. Context changed to [spaces]

Arguments
feature feature name: messenger or storage
name the name you gave to the feature config on creation

Examples
  1. bluenimble:spaces> delete feature messenger push
  2. Info | {
  3. "deleted": "true"
  4. }

Database Commands

  1. bluenimble:.> ctx db
  2. Context changed to [db]

put record command

Description

put record command adds or updates a record in a database entity

If the recorod id is provided, an update attempt will be made, if the record with this id is not found, the record will be added with this id

Arguments
entity the database entity/table name
record a variable name holding a valid json object of this record

Examples
  1. bluenimble:db>json create pet { "name": "Rambo" }
  2. {
  3. "name": "Rambo"
  4. }
  5. bluenimble:db>put record Pets pet
  6. Info | {
  7. "id": "8fae3585-4843-4f57-82ba-4ce174b0dfa7",
  8. "timestamp": "2016-06-24T10:34:40Z"
  9. }

get record command

Description

get record command gets a record by id

Arguments
entity the database entity/table name
record id a valid record id in the table/entity given by the entity argument

Examples
  1. bluenimble:db> get record Pets 8fae3585-4843-4f57-82ba-4ce174b0dfa7
  2. Info | {
  3. "name": "Rambo",
  4. "id": "8fae3585-4843-4f57-82ba-4ce174b0dfa7",
  5. "timestamp": "2016-06-24T10:34:40Z"
  6. }

delete record command

Description

delete record command deletes a record by id

Arguments
entity the database entity/table name
record id a valid record id in the table/entity given by the entity argument

Examples
  1. bluenimble:db> delete record Pets 8fae3585-4843-4f57-82ba-4ce174b0dfa7
  2. Info | {
  3. "deleted": "true"
  4. }

find records command

Description

find records command finds records in an atble/entity based on a json query

Arguments
entity the database entity/table name
query a variable name of a valid json query

Examples
  1. # create the record json object
  2. bluenimble:db>json create pet { "name": "Rambo-1" }
  3. # put record
  4. bluenimble:db>put record Pets pet
  5. # change the property name in the pet json object
  6. bluenimble:db>json set pet name Rambo-2
  7. # put another record
  8. bluenimble:db>put record Pets pet
  9. # create a json query (like Rambo)
  10. bluenimble:db>json create query { "where": { "name": { "op": "like", "value": "Rambo%" } } }
  11. {
  12. "where": {
  13. "name": {
  14. "op": "like",
  15. "value": "Rambo%"
  16. }
  17. }
  18. }
  19. # find using query
  20. bluenimble:db>find record Pets query
  21. Info | {
  22. "records": [
  23. {
  24. "name": "Rambo-1",
  25. "id": "ec4f720c-ec8e-4c8c-ad88-f345dc5e3a9b",
  26. "timestamp": "2016-06-24T10:43:10Z"
  27. },
  28. {
  29. "name": "Rambo-2",
  30. "id": "e0b64313-7548-4366-9d8d-e13ac5b642c1",
  31. "timestamp": "2016-06-24T10:43:26Z"
  32. }
  33. ]
  34. }

drop entity command

Description

drop entity command drops a database table/entity with all of its data

Arguments
entity the database entity/table name

Examples
  1. bluenimble:db> drop entity Pets
  2. Info | {
  3. "dropped": "true"
  4. }

Storage Commands

  1. bluenimble:.> ctx storage
  2. Context changed to [storage]

put object command

Description

put object command adds or updates an object in a specific storage defined in the user space

Arguments
path the path of the file or folder. It shouldn't start with /

Examples

The command line bellow creates a new folder in the space root storage

  1. bluenimble:db>put object pictures
  2. Success |
  3. {
  4. "added": "true"
  5. }

get object command

Description

get object command could be used to get a stream object (file) or list a folder

Arguments
path the path of the file or folder. It shouldn't start with /

Example

The command line bellow lists files and folders under the pictures folder

  1. bluenimble:db>get object pictures
  2. Success |
  3. {
  4. "name": "pictures",
  5. "timestamp": "2016-09-01T13:10:50Z",
  6. "count": "1",
  7. "length": "0",
  8. "items": [{
  9. "name": "avatar.png",
  10. "timestamp": "2016-09-01T15:28:32Z",
  11. "length": "320"
  12. }]
  13. }

delete object command

Description

delete object command deletes a stream object (file) or a folder

Arguments
path the path of the file or folder. It shouldn't start with /

Example

The command line bellow deletes a file under the pictures folder

  1. bluenimble:db>delete object pictures/avatar.png
  2. Success |
  3. {
  4. "deleted": "true"
  5. }

General Commands

ctx command

Description

ctx command is used to switch between context.
iCli Commands are groupped by context. Database commands are under the 'db' context, while commands to manage a space are under the 'spaces' context

Arguments
context the context name

Example
  1. bluenimble:db>ctx db
  2. Success | Context changed to [db]

vars command

Description

vars command is used to list variables

Example
  1. bluenimble:db>vars
  2. Success | sec=11
  3. a=b
  4. cache.provider=default
  5. min=39
  6. month=9
  7. hour=6
  8. year=2016
  9. storage.provider=default
  10. database.provider=default
  11. day=1
  12. uuid=Vhq8mvBUWhxy9cCFpyY7

set command

Description

set command is used to create or update a variable

Example
  1. bluenimble:db>set user abc@blunimble.com
  2. o user
  3. --------
  4. abc@blunimble.com