diff --git a/lib/REST/Neo4p/Agent/Neo4j/Driver.pm b/lib/REST/Neo4p/Agent/Neo4j/Driver.pm index 152c428..6c3fc30 100644 --- a/lib/REST/Neo4p/Agent/Neo4j/Driver.pm +++ b/lib/REST/Neo4p/Agent/Neo4j/Driver.pm @@ -21,6 +21,21 @@ my $WARN_ON_ERROR; BEGIN { } +my %REST_ACTIONS = ( + all_relationships => 'relationships/all', + all_typed_relationships => 'relationships/all/{-list|&|types}', + create_relationship => 'relationships', + incoming_relationships => 'relationships/in', + incoming_typed_relationships => 'relationships/in/{-list|&|types}', + labels => 'labels', + outgoing_relationships => 'relationships/out', + outgoing_typed_relationships => 'relationships/out/{-list|&|types}', + paged_traverse => 'paged/traverse/{returnType}{?pageSize,leaseTime}', + properties => 'properties', + property => 'properties/{key}', + traverse => 'traverse/{returnType}', +); + sub new { my ($class, @args) = @_; my $self = { @@ -177,21 +192,7 @@ sub connect { last if $f; } # set actions - try { - my $tx = $self->session->begin_transaction; - my $n = $tx->run('create (n) return n')->single; - my $actions = $n->{rest}[0]; - $tx->rollback; - foreach (keys %$actions) { - next if /^extensions|metadata|self$/; - # strip any trailing slash - $actions->{$_} =~ s|/+$||; - my ($suffix) = $actions->{$_} =~ m|.*node/[0-9]+/(.*)|; - $self->{_actions}{$_} = $suffix; - } - } catch { - REST::Neo4p::LocalException->throw("While determining actions: $_"); - }; + $self->{_actions}{$_} = $REST_ACTIONS{$_} for keys %REST_ACTIONS; return 1; }