ugc enables convenient terminal access to Apache Usergrid.
- Multiple connection/login profiles
- Simple syntax to Usergrid data
- Will automatically perform paging on long query results
- Use relative or absolute URLs
- Convenient path reference '@n' to previous list entities
- Easy-to-read tabular output
- Simplified json-generating syntax for data (key: 'value')
- Ruby evaluation within data elements
- Can optionally emits raw output (--verbose switch)
- Extended SQL syntax (adds 'from' and 'limit' clauses to standard Usergrid syntax)
- File upload (-f or --file option) on PUT and POST
- Emit curl equivalent for all REST commands
$ gem install ugc
Note: Requires Ruby 1.9.3+ or Ruby 2.0+. If you have issues, check your version:
$ ruby -v
If necessary, install a new version of Ruby. RVM is recommended:
$ curl -L https://get.rvm.io | bash -s stable --ruby
delete - delete an entity
get, show, ls, list - retrieve and display a collection or entity
help - Shows a list of commands or help for one command
login - Performs a login to the current profile
post, create - non-idempotent create or update (post is usually create)
profile, profiles - set the current profile (creates if it doesn't exist)
put, update - idempotent create or update (put is usually an update)
query - query (uses sql-like syntax)
target - set the base url, org, and app for the current profile
$ ugc profile apigee
$ ugc target base https://api.usergrid.com
base_url = https://api.usergrid.com
$ ugc target organization scottganyo
organization = scottganyo
$ ugc target app messagee
application = messagee
$ ugc target url https://api.usergrid.com/scottganyo/messagee
base_url = https://api.usergrid.com
organization = scottganyo
application = messagee
(Note the user in this case is an admin user)
$ ugc login --admin [email protected]
password: **********
logged in user: [email protected]
$ ugc profile apigee
Set active profile:
*apigee
base_url: https://api.usergrid.com
organization: scottganyo
application: messagee
access_token: YWMtKgZnO1ULEeKKqQLoGuZA3AAAATwesjMsUYmz_ZGk8vkTwp0lh66Cv_CCEM4
$ ugc list collections
title count name type
Assets 0 assets asset
Users 0 users user
Events 0 events event
Roles 3 roles role
Folders 0 folders folder
Activities 0 activities activity
Devices 0 devices device
Groups 0 groups group
What? No dogs? A travesty!
(Note the use of simplified json syntax)
$ ugc create dog "breed: 'Black Mouth Cur', name: 'Old Yeller'"
name value
uuid 91833fd9-56c5-11e2-a6b8-14109fd49581
name Old Yeller
created 1357341732438
modified 1357341732438
breed Black Mouth Cur
(Note use of square brackets to create an array of dogs)
$ ugc create dogs "[{ name: 'Tramp' },{ breed: 'Cocker Spaniel', name: 'Lady' }]"
# uuid name created modified breed
1 79dfb563-56cb-11e2-a6b8-14109fd49581 Tramp 1357344269759 1357344269759
2 79e11500-56cb-11e2-a6b8-14109fd49581 Lady 1357344269768 1357344269768 Cocker Spaniel
All the created dogs were returned as a list.
(Note use of @1 to reference the 1st row from the previous list.)
$ ugc show @1
name value
uuid 79dfb563-56cb-11e2-a6b8-14109fd49581
name Tramp
created 1357344269759
modified 1357344269768
Note synonym commands:
$ ugc show dogs/79dfb563-56cb-11e2-a6b8-14109fd49581
$ ugc show dogs/Tramp
(Note use of standard json data)
$ ugc update @1 '{ "breed" : "Mixed" }'
name value
uuid 79dfb563-56cb-11e2-a6b8-14109fd49581
name Tramp
created 1357344269759
modified 1357344537483
breed Mixed
If you have more than ten dogs, it might be easier to target your specific dog when you update it:
ugc update dogs/79dfb563-56cb-11e2-a6b8-14109fd49581 '{ "breed" : "Mixed" }'
$ ugc query dogs 'select name, breed where modified >= 1357344269768'
# name breed
1 Einstein Mixed
2 Lady Cocker Spaniel
Note: with ugc, you can also use extended sql syntax...
$ ugc query 'select name, breed from dogs where modified >= 1357344269768 limit 1'
# name breed
1 Einstein Mixed
If you specify column names in your query, you will be unable to reference the returned rows by @1 reference in later commands. (The current Usergrid implementation doesn't return any metadata for the entries.) In addition, for your safety the history will be cleared so that you don't inadvertently reference entities from a previous list.
- Bug Fixes
- fix setting profile & target configurations
- Misc
- Add license to gem
- New features
- logout (remove access_token)
- no longer force log in - as it's not always necessary
- get (ls) command now defaults to list collections when no arguments
- Bug fixes
- updated to work with latest gli (> 2.6)
- Bug Fixes
- allow headers to vary during paging
- Bug Fixes
- url encode url for curl
- Bug Fixes
- Allow for complex matrixed queries including spaces
- New features
- Emit curl equivalent commands with -c (--curl) switch
- eg.
$ ugc -c get something
- New features
- file upload function with -f (--file) switch
- eg.
$ ugc post something "property1Name: 'property1Value'" --file property2Name=/path/to/myfile
- New features
- access management functions with -m (--management) global switch
- eg.
$ ugc -m get orgs/my-org
- New features
- allow non-interactive password on login (-p or --password)
- Bug fixes
- fix display issue with assign query (select {user:username} from...)
- New features
- path reference '@n' in commands to previous list entities
- eg.
$ ugc put @1 foo: 'bar'
- eg.
- added --no-border flag
- added rm alias for delete
- path reference '@n' in commands to previous list entities
- Bug fixes
- lock required version of usergrid_iron
- New features
- Ruby eval of data in put and post commands
- eg. may now use
key: 'value'
for json instead of{"key": "value"}
- eg. may now use
- Added alias: 'show' for 'get'
- Made 'list' an alias of 'get' and updated get to include 'list' functionality
- smart column width for entities
- Added aliases 'create' and 'update' for 'post' and 'put' (yes, I am aware this isn't technically correct)
- Ruby eval of data in put and post commands
- New features
- smart column widths for collections
- add "limit" keyword to sql syntax
- Bug fixes
- fixed issue with selecting a single column
- fixed formatting of entities with heterogeneous attributes
- Bug fixes
- include Gemfile.lock to ensure correct version of usergrid_iron is used
- New features
- support for query result paging
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE.txt file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.