| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package ArangoDB2::Endpoint; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 20 |  |  | 20 |  | 89 | use strict; | 
|  | 20 |  |  |  |  | 23 |  | 
|  | 20 |  |  |  |  | 687 |  | 
| 4 | 20 |  |  | 20 |  | 82 | use warnings; | 
|  | 20 |  |  |  |  | 32 |  | 
|  | 20 |  |  |  |  | 517 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 20 |  |  |  |  | 1321 | use base qw( | 
| 7 |  |  |  |  |  |  | ArangoDB2::Base | 
| 8 | 20 |  |  | 20 |  | 81 | ); | 
|  | 20 |  |  |  |  | 23 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 20 |  |  | 20 |  | 102 | use Data::Dumper; | 
|  | 20 |  |  |  |  | 23 |  | 
|  | 20 |  |  |  |  | 850 |  | 
| 11 | 20 |  |  | 20 |  | 93 | use JSON::XS; | 
|  | 20 |  |  |  |  | 27 |  | 
|  | 20 |  |  |  |  | 840 |  | 
| 12 | 20 |  |  | 20 |  | 93 | use URI::Escape qw(uri_escape); | 
|  | 20 |  |  |  |  | 21 |  | 
|  | 20 |  |  |  |  | 5111 |  | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | my $JSON = JSON::XS->new->utf8; | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | ############### | 
| 19 |  |  |  |  |  |  | # API METHODS # | 
| 20 |  |  |  |  |  |  | ############### | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | # create | 
| 23 |  |  |  |  |  |  | # | 
| 24 |  |  |  |  |  |  | # POST /_api/endpoint | 
| 25 |  |  |  |  |  |  | sub create | 
| 26 |  |  |  |  |  |  | { | 
| 27 | 0 |  |  | 0 | 1 |  | my($self, $args) = @_; | 
| 28 |  |  |  |  |  |  | # process request args | 
| 29 | 0 |  |  |  |  |  | $args = $self->_build_args($args, ['name', 'databases']); | 
| 30 |  |  |  |  |  |  | # use name for endpoint param | 
| 31 | 0 |  |  |  |  |  | $args->{endpoint} = $args->{name}; | 
| 32 |  |  |  |  |  |  | # make request | 
| 33 | 0 | 0 |  |  |  |  | my $res = $self->arango->http->post( | 
| 34 |  |  |  |  |  |  | '/_api/endpoint', | 
| 35 |  |  |  |  |  |  | undef, | 
| 36 |  |  |  |  |  |  | $JSON->encode($args), | 
| 37 |  |  |  |  |  |  | ) or return; | 
| 38 |  |  |  |  |  |  | # if request was success copy args to self | 
| 39 | 0 |  |  |  |  |  | $self->_build_self($args, ['name', 'databases']); | 
| 40 |  |  |  |  |  |  |  | 
| 41 | 0 |  |  |  |  |  | return $self; | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | # delete | 
| 45 |  |  |  |  |  |  | # | 
| 46 |  |  |  |  |  |  | # DELETE /_api/endpoint/{name} | 
| 47 |  |  |  |  |  |  | sub delete | 
| 48 |  |  |  |  |  |  | { | 
| 49 | 0 |  |  | 0 | 1 |  | my($self, $args) = @_; | 
| 50 |  |  |  |  |  |  | # process request args | 
| 51 | 0 |  |  |  |  |  | $args = $self->_build_args($args, ['name']); | 
| 52 |  |  |  |  |  |  | # make request | 
| 53 | 0 |  |  |  |  |  | return $self->arango->http->delete( | 
| 54 |  |  |  |  |  |  | '/_api/endpoint/'.uri_escape( $args->{name} ) | 
| 55 |  |  |  |  |  |  | ); | 
| 56 |  |  |  |  |  |  | } | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | # list | 
| 59 |  |  |  |  |  |  | # | 
| 60 |  |  |  |  |  |  | # GET /_api/endpoint | 
| 61 |  |  |  |  |  |  | sub list | 
| 62 |  |  |  |  |  |  | { | 
| 63 | 0 |  |  | 0 | 1 |  | my($self) = @_; | 
| 64 |  |  |  |  |  |  |  | 
| 65 | 0 |  |  |  |  |  | return $self->arango->http->get('/_api/endpoint'); | 
| 66 |  |  |  |  |  |  | } | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | #################### | 
| 69 |  |  |  |  |  |  | # PROPERTY METHODS # | 
| 70 |  |  |  |  |  |  | #################### | 
| 71 |  |  |  |  |  |  |  | 
| 72 | 0 |  |  | 0 | 1 |  | sub databases { shift->_get_set('databases', @_) } | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | 1; | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | __END__ |