Usergrid::Client - Usergrid Perl Client
use Usergrid::Client; my $client = Usergrid::Client->new( organization => 'test-organization', application => 'test-app', api_url => 'http://localhost:8080' ); $client->login('johndoe', 'Johndoe123$'); $client->add_entity("books", { name => "Ulysses" }); $client->add_entity("books", { name => "Neuromancer" }); my $books = $client->get_collection("books"); while ($books->has_next_entity()) { my $book = $books->get_next_entity(); print "Name: " . $book->get('name') . ", "; print "Author: " . $book->get('author') . "\n"; $book->set("in-stock", 0); $client->update_entity($book); }
Usergrid::Client provides an easy to use Perl API for Apache Usergrid.
Usergrid is an open-source Backend-as-a-Service ("BaaS" or "mBaaS") composed of an integrated distributed NoSQL database, application layer and client tier with SDKs for developers looking to rapidly build web and/or mobile applications. It provides elementary services (user registration & management, data storage, file storage, queues) and retrieval features (full text search, geolocation search, joins) to power common app features.
It is a multi-tenant system designed for deployment to public cloud environments (such as Amazon Web Services, Rackspace, etc.) or to run on traditional server infrastructures so that anyone can run their own private BaaS deployment.
For architects and back-end teams, it aims to provide a distributed, easily extendable, operationally predictable and highly scalable solution. For front-end developers, it aims to simplify the development process by enabling them to rapidly build and operate mobile and web applications without requiring backend expertise.
Source: https://usergrid.incubator.apache.org/docs/
For more information, visit http://www.usergrid.org
The following attributes are made available via the Usergrid::Request role:
Organization name
Application name
URL of the Usergrid instance
Enable/disable request and response tracing for debugging and troubleshooting (Optional)
The following methods are provided in this API for interacting with the Apache Usergrid backend.
Performs application user authentication. Returns the user token for the logged in user. The token is also kept in memory and used for subsequent authentication of requests.
Performs admin user authentication. Returns the user token for the logged in user. The token is also kept in memory and used for subsequent authentication of requests.
This section covers some of the entity level methods available in the API. Entities form one of the basic building blocks of Usergrid and is analogous to a row in an RDBMS table.
Creates a new entity within the specified collection. Returns a Usergrid::Entity for the newly added entity.
Saves changes to the given entity. Returns the updated Usergrid::Entity.
Returns a Usergrid::Entity identified by either UUID or name. If the entity does not exist, the method returns FALSE.
Deletes an entity from the collection identified by either UUID or name. Returns a Usergrid::Entity of the deleted entity.
Deletes the specified Usergrid::Entity. Returns an instance of the deleted Usergrid::Entity if successful.
Creates a connection from Entity #1 to Entity #2 signified by the relationship. The first entity in this relationship is identified as the connecting entity and the second as the connected entity. The relationship is a string that signifies the type of connection. This returns a Usergrid::Entity of the connecting entity.
Removes the connection between the two entities signified by the relationship. This does not affect the entities in any other way apart from the removal of the connection that is depicted by the relationship. This returns a Usergrid::Entity of the connecting entity with the given relationship removed.
This section covers the methods related to retrieving and working with collections in the Usergrid API. Collections contains groups of entities and is analogous to a table in an RDBMS.
Returns a Usergrid::Collection with the list of entities up to the maximum specified limit, which is 10 if not provided.
Updates all the entities in the specified collection with the provided attributes. Optionally pass in the SQL-like query to narrow the scope of the objects that are affected. This also supports specifying a limit to restrict the maximum number of records that are updated. If not specified, the limit defaults to 10 entities.
Batch delete entities in the specified collection. Optionally pass in a SQL-like query to narrow the scope of the objects that are affected and a limit to restrict the maximum number of records that are deleted. If not specified, the limit defaults to 10 entities.
Queries all the entities in the specified collection using a SQL-like query string. This also supports specifying a limit to restrict the maximum number of records that are returned. If not specified, the limit defaults to 10 entities.
Returns a collection of entities for the given relationship, optionally filtered by a SQL-like query and limited to the maximum number of records specified. If no limit is provided, a default of 10 entities is assumed.
Usergrid::Collection, Usergrid::Entity, Usergrid::Request
This software is distributed under the Apache 2 license.
Anuradha Weeraman <anuradha@cpan.org>
To install Usergrid::Client, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Usergrid::Client
CPAN shell
perl -MCPAN -e shell install Usergrid::Client
For more information on module installation, please visit the detailed CPAN module installation guide.