NAME
Net::GraphSpace - API bindings for GraphSpace
VERSION
version 0.0007
SYNOPSIS
use Net::GraphSpace;
use JSON qw(decode_json);
use Try::Tiny;
my $client = Net::GraphSpace->new(
user => 'bob',
password => 'secret',
host => 'graphspace.org'
);
my $graph = Net::GraphSpace::Graph->new(description => 'yeast ppi');
my $node1 = Net::GraphSpace::Node->new(id => 'node-a', label => 'A');
my $node2 = Net::GraphSpace::Node->new(id => 'node-b', label => 'B');
my $edge = Net::GraphSpace::Edge->new(
id => 'a-b', source => 'node-a', target => 'node-b');
$graph->add_nodes([$node1, $node2]);
$graph->add_edge($edge);
$graph->add_node(Net::GraphSpace::Node->new(id => 3, label => 'C'));
# Upload graph to server and set the graph id
my $graph_id = 'graph-id-1';
my $data = $client->add_graph($graph, $graph_id);
my $url = $data->{url};
# Upload graph to server and have server autogenerate the graph id
$data = $client->add_graph($graph);
$graph_id = $data->{id};
$url = $data->{url};
print "Your graph (id: $graph_id) can be viewed at $url\n";
# Get and update a graph
$graph = $clent->get_graph($graph_id)
or die "Could not find graph $graph_id";
$graph->tags(['foo', 'bar']);
$client->update_graph($graph, $graph_id);
# Delete a graph
try {
$client->delete_graph($graph_id);
print "Deleted graph $graph_id: $_\n";
} catch {
print "Could not delete graph $graph_id: $_\n";
};
DESCRIPTION
Net::GraphSpace provides bindings for the GraphSpace API. GraphSpace is
a web based graph/network visualization tool and data store. See
<
http://graphspace.org> for more information.
ATTRIBUTES
Required:
user
password
Optional:
host
Defaults to 'graphspace.org'.
port
Defaults to 80.
prefix
Defaults to ''. Set this if GraphSpace is not hosted at the root of
your server. For example, if GraphSpace is hosted at
http://myserver.com/gs, then set "prefix => '/gs'".
METHODS
new
$client = Net::GraphSpace->new(user => 'bob', password => 'secret');
Takes key/value arguments corresponding to the attributes above.
get_graph
$graph = $clent->get_graph($graph_id)
Returns a Net::GraphSpace::Graph object for the given $graph_id. Returns
undef if the graph could not be found.
add_graph
$data = $client->add_graph($graph);
$data = $client->add_graph($graph, $graph_id);
$data = $client->add_graph($graph, $graph_id, check => 0);
Takes a Net::GraphSpace::Graph object and uploads it. If $graph_id is
not provided, an id is autogenerated for you by the server. An optional
named paramter $check defaults to 1. This means that an extra check is
made to see if the graph with the given $graph_id already exists on the
server. An exception is thrown if it is found. Set $check => 0 if you
don't want this check. This will result in greater efficiency, since one
less http request is made to the server. Also, if the graph already
exists, it will get overwritten as if update_graph() was called. Returns
a hashref of the form:
{
id => 1,
url => 'http://...',
}
The url is the location where the graph can be viewed. Dies on server
error.
update_graph
$data = $client->update_graph($graph, $graph_id);
Updates the graph on the server with id $graph_id. Returns a hashref
just like add_graph(). Dies on server error.
delete_graph($graph_id)
$success = $client->delete_graph($graph, $graph_id);
Deletes the graph with id $graph_id. Returns a true value on success.
Dies on failure or if the graph didn't exist.
SEE ALSO
<
http://graphspace.org>
AUTHOR
Naveed Massjouni <
[email protected]>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Naveed Massjouni.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.