ugc enables convenient terminal access to Apache Usergrid.
$ 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 scott@ganyo.com password: ********** logged in user: scott@ganyo.com
$ 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.
$ ugc -c get something
$ ugc post something "property1Name: 'property1Value'" --file property2Name=/path/to/myfile
$ ugc -m get orgs/my-org
$ ugc put @1 foo: 'bar'
key: 'value'
for json instead of {"key": "value"}
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.