NAME

Usergrid::Client - Usergrid Perl Client

SYNOPSIS

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);
}

DESCRIPTION

Usergrid::Client is the client SDK for Apache Usergrid. It provides a Perl object based wrapper for the Usergrid REST-ful APIs.

METHODS

login ($username, $password)

Logs into Usergrid with the provided username and password using application authentication.

management_login ($username, $password)

Used for obtaining a management token for performing privileged operations.

add_entity ($collection, $entity)

Creates a new entity with the attributes specified in the $entity hash reference in the given collection.

update_entity ($entity)

Saves changes to the entity.

get_entity ($collection, $id)

Returns the entity by either id or name for the given collection. If the entity does not exist, the method returns an undef.

get_collection ($collection, [$limit])

Returns a Usergrid::Collection with the list of entities up to a maximum specified by $limit, which is 10 if not specified.

update_collection ($collection, $properties, [$query], [$limit])

Updates all the entities in the specified collection with attributes in the $properties hash reference. Optionally pass in the $query to narrow the scope of the objects that are affected and the $limit to specify the maximum number of records.

delete_collection ($collection, [$query], [$limit])

Deletes all the entities in the specified collection. Optionally pass in the $query to narrow the scope of the objects that are affected and the $limit to specify the maximum number of records.

query_collection ($collection, $query, [$limit])

Queries all the entities in the specified collection. Optionally pass in the $limit to specify the maximum number of records returned.

delete_entity_by_id ($collection, $id)

Deletes an entity from the collection, specified by either UUID or name.

delete_entity ($entity)

Deletes the specified instance of Usergrid::Entity.

connect_entities ($connecting_entity, $relationship, $connected_entity)

Creates a connection between the two entities signified by the relationship.

query_connections ($entity, $relationship, [$query], [$limit])

Returns a collection of entities for the given relationship, optionally filtered by a query and limited to the maximum number of records specified. If no limit is provided, a default of 10 is assumed.

disconnect_entities ($connecting_entity, $relationship, $connected_entity)

Removes the connection between the two entities signified by the relationship.

SEE ALSO

Usergrid::Collection, Usergrid::Entity, Usergrid::Request

LICENSE

This software is distributed under the Apache 2 license.

AUTHOR

Anuradha Weeraman <anuradha@cpan.org>