| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package ArangoDB2::Database; |
|
2
|
|
|
|
|
|
|
|
|
3
|
21
|
|
|
21
|
|
88
|
use strict; |
|
|
21
|
|
|
|
|
25
|
|
|
|
21
|
|
|
|
|
643
|
|
|
4
|
21
|
|
|
21
|
|
84
|
use warnings; |
|
|
21
|
|
|
|
|
24
|
|
|
|
21
|
|
|
|
|
487
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
21
|
|
|
|
|
1342
|
use base qw( |
|
7
|
|
|
|
|
|
|
ArangoDB2::Base |
|
8
|
21
|
|
|
21
|
|
85
|
); |
|
|
21
|
|
|
|
|
25
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
21
|
|
|
21
|
|
101
|
use Data::Dumper; |
|
|
21
|
|
|
|
|
25
|
|
|
|
21
|
|
|
|
|
974
|
|
|
11
|
21
|
|
|
21
|
|
87
|
use JSON::XS; |
|
|
21
|
|
|
|
|
19
|
|
|
|
21
|
|
|
|
|
946
|
|
|
12
|
21
|
|
|
21
|
|
96
|
use Scalar::Util qw(reftype); |
|
|
21
|
|
|
|
|
32
|
|
|
|
21
|
|
|
|
|
1018
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
21
|
|
|
21
|
|
7406
|
use ArangoDB2::Collection; |
|
|
21
|
|
|
|
|
40
|
|
|
|
21
|
|
|
|
|
567
|
|
|
15
|
21
|
|
|
21
|
|
8025
|
use ArangoDB2::Graph; |
|
|
21
|
|
|
|
|
41
|
|
|
|
21
|
|
|
|
|
543
|
|
|
16
|
21
|
|
|
21
|
|
6966
|
use ArangoDB2::Query; |
|
|
21
|
|
|
|
|
35
|
|
|
|
21
|
|
|
|
|
495
|
|
|
17
|
21
|
|
|
21
|
|
7533
|
use ArangoDB2::Replication; |
|
|
21
|
|
|
|
|
36
|
|
|
|
21
|
|
|
|
|
677
|
|
|
18
|
21
|
|
|
21
|
|
6912
|
use ArangoDB2::Transaction; |
|
|
21
|
|
|
|
|
47
|
|
|
|
21
|
|
|
|
|
475
|
|
|
19
|
21
|
|
|
21
|
|
7260
|
use ArangoDB2::User; |
|
|
21
|
|
|
|
|
38
|
|
|
|
21
|
|
|
|
|
11646
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $JSON = JSON::XS->new->utf8; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# collection |
|
26
|
|
|
|
|
|
|
# |
|
27
|
|
|
|
|
|
|
# get/create ArangoDB2::Collection object |
|
28
|
|
|
|
|
|
|
sub collection |
|
29
|
|
|
|
|
|
|
{ |
|
30
|
8
|
|
|
8
|
1
|
43
|
my($self, $name) = @_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
8
|
50
|
|
|
|
25
|
if (defined $name) { |
|
33
|
|
|
|
|
|
|
# only create one ArangoDB2::Collection instance per name |
|
34
|
8
|
|
33
|
|
|
28
|
return $self->collections->{$name} ||= ArangoDB2::Collection->new( |
|
35
|
|
|
|
|
|
|
$self->arango, |
|
36
|
|
|
|
|
|
|
$self, |
|
37
|
|
|
|
|
|
|
$name, |
|
38
|
|
|
|
|
|
|
); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
else { |
|
41
|
0
|
|
|
|
|
0
|
ArangoDB2::Collection->new( |
|
42
|
|
|
|
|
|
|
$self->arango, |
|
43
|
|
|
|
|
|
|
$self, |
|
44
|
|
|
|
|
|
|
$name, |
|
45
|
|
|
|
|
|
|
); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# collections |
|
50
|
|
|
|
|
|
|
# |
|
51
|
|
|
|
|
|
|
# index of ArangoDB2::Collection objects by name |
|
52
|
8
|
|
50
|
8
|
1
|
117
|
sub collections { $_[0]->{collections} ||= {} } |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# create |
|
55
|
|
|
|
|
|
|
# |
|
56
|
|
|
|
|
|
|
# POST /_api/database |
|
57
|
|
|
|
|
|
|
sub create |
|
58
|
|
|
|
|
|
|
{ |
|
59
|
0
|
|
|
0
|
1
|
0
|
my($self, $args) = @_; |
|
60
|
|
|
|
|
|
|
# process args |
|
61
|
0
|
|
|
|
|
0
|
$args = $self->_build_args($args, ['name','users']); |
|
62
|
|
|
|
|
|
|
# make request |
|
63
|
0
|
0
|
|
|
|
0
|
my $res = $self->arango->http->post( |
|
64
|
|
|
|
|
|
|
'/_api/database', |
|
65
|
|
|
|
|
|
|
undef, |
|
66
|
|
|
|
|
|
|
$JSON->encode($args), |
|
67
|
|
|
|
|
|
|
) or return; |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
0
|
return $self; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# current |
|
73
|
|
|
|
|
|
|
# |
|
74
|
|
|
|
|
|
|
# GET /_api/database/current |
|
75
|
|
|
|
|
|
|
sub current |
|
76
|
|
|
|
|
|
|
{ |
|
77
|
0
|
|
|
0
|
1
|
0
|
my($self) = @_; |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
0
|
return $self->arango->http->get('/_api/database/current'); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# delete |
|
83
|
|
|
|
|
|
|
# |
|
84
|
|
|
|
|
|
|
# DELETE /_api/database/{database-name} |
|
85
|
|
|
|
|
|
|
sub delete |
|
86
|
|
|
|
|
|
|
{ |
|
87
|
0
|
|
|
0
|
1
|
0
|
my($self) = @_; |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
0
|
return $self->arango->http->delete("/_api/database/".$self->name); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# graph |
|
93
|
|
|
|
|
|
|
# |
|
94
|
|
|
|
|
|
|
# get/create ArangoDB2::Graph object |
|
95
|
|
|
|
|
|
|
sub graph |
|
96
|
|
|
|
|
|
|
{ |
|
97
|
6
|
|
|
6
|
1
|
31
|
my($self, $name) = @_; |
|
98
|
|
|
|
|
|
|
|
|
99
|
6
|
50
|
|
|
|
17
|
if (defined $name) { |
|
100
|
0
|
|
0
|
|
|
0
|
return $self->graphs->{$name} ||= ArangoDB2::Graph->new( |
|
101
|
|
|
|
|
|
|
$self->arango, |
|
102
|
|
|
|
|
|
|
$self, |
|
103
|
|
|
|
|
|
|
$name, |
|
104
|
|
|
|
|
|
|
); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
else { |
|
107
|
6
|
|
|
|
|
33
|
return ArangoDB2::Graph->new( |
|
108
|
|
|
|
|
|
|
$self->arango, |
|
109
|
|
|
|
|
|
|
$self, |
|
110
|
|
|
|
|
|
|
); |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# graphs |
|
115
|
|
|
|
|
|
|
# |
|
116
|
|
|
|
|
|
|
# index of ArangoDB2::Graph objects by name |
|
117
|
0
|
|
0
|
0
|
1
|
0
|
sub graphs { $_[0]->{graphs} ||= {} } |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# list |
|
120
|
|
|
|
|
|
|
# |
|
121
|
|
|
|
|
|
|
# GET /_api/database |
|
122
|
|
|
|
|
|
|
# |
|
123
|
|
|
|
|
|
|
# Retrieves the list of all existing databases |
|
124
|
|
|
|
|
|
|
sub list |
|
125
|
|
|
|
|
|
|
{ |
|
126
|
0
|
|
|
0
|
1
|
0
|
my($self) = @_; |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
0
|
return $self->arango->http->get('/_api/database'); |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# query |
|
133
|
|
|
|
|
|
|
# |
|
134
|
|
|
|
|
|
|
# get a new ArangoDB2::Query object |
|
135
|
|
|
|
|
|
|
sub query |
|
136
|
|
|
|
|
|
|
{ |
|
137
|
2
|
|
|
2
|
1
|
8
|
my($self, $query) = @_; |
|
138
|
|
|
|
|
|
|
|
|
139
|
2
|
|
|
|
|
6
|
return ArangoDB2::Query->new( |
|
140
|
|
|
|
|
|
|
$self->arango, |
|
141
|
|
|
|
|
|
|
$self, |
|
142
|
|
|
|
|
|
|
$query |
|
143
|
|
|
|
|
|
|
); |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# replication |
|
147
|
|
|
|
|
|
|
# |
|
148
|
|
|
|
|
|
|
# get a new ArangoDB2::Replication object |
|
149
|
|
|
|
|
|
|
sub replication |
|
150
|
|
|
|
|
|
|
{ |
|
151
|
1
|
|
|
1
|
1
|
7
|
my($self) = @_; |
|
152
|
|
|
|
|
|
|
|
|
153
|
1
|
|
|
|
|
9
|
return ArangoDB2::Replication->new( |
|
154
|
|
|
|
|
|
|
$self->arango, |
|
155
|
|
|
|
|
|
|
$self, |
|
156
|
|
|
|
|
|
|
); |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
# transaction |
|
160
|
|
|
|
|
|
|
# |
|
161
|
|
|
|
|
|
|
# get a new ArangoDB2::Transaction object |
|
162
|
|
|
|
|
|
|
sub transaction |
|
163
|
|
|
|
|
|
|
{ |
|
164
|
1
|
|
|
1
|
1
|
4
|
my($self) = @_; |
|
165
|
|
|
|
|
|
|
|
|
166
|
1
|
|
|
|
|
3
|
return ArangoDB2::Transaction->new( |
|
167
|
|
|
|
|
|
|
$self->arango, |
|
168
|
|
|
|
|
|
|
$self, |
|
169
|
|
|
|
|
|
|
); |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
# user |
|
173
|
|
|
|
|
|
|
# |
|
174
|
|
|
|
|
|
|
# ArangoDB2::User object |
|
175
|
|
|
|
|
|
|
sub user |
|
176
|
|
|
|
|
|
|
{ |
|
177
|
1
|
|
|
1
|
1
|
2
|
my($self, $name) = @_; |
|
178
|
|
|
|
|
|
|
|
|
179
|
1
|
|
|
|
|
6
|
return ArangoDB2::User->new( |
|
180
|
|
|
|
|
|
|
$self->arango, |
|
181
|
|
|
|
|
|
|
$self, |
|
182
|
|
|
|
|
|
|
$name, |
|
183
|
|
|
|
|
|
|
); |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
# userDatabases |
|
187
|
|
|
|
|
|
|
# |
|
188
|
|
|
|
|
|
|
# GET /_api/database/user |
|
189
|
|
|
|
|
|
|
# |
|
190
|
|
|
|
|
|
|
# Retrieves the list of all databases the current user can access without specifying |
|
191
|
|
|
|
|
|
|
# a different username or password. |
|
192
|
|
|
|
|
|
|
sub userDatabases |
|
193
|
|
|
|
|
|
|
{ |
|
194
|
0
|
|
|
0
|
1
|
0
|
my($self) = @_; |
|
195
|
|
|
|
|
|
|
|
|
196
|
0
|
|
|
|
|
0
|
return $self->arango->http->get('/_api/database/user'); |
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
# users |
|
200
|
|
|
|
|
|
|
# |
|
201
|
|
|
|
|
|
|
# get/set users |
|
202
|
0
|
|
|
0
|
1
|
0
|
sub users { shift->_get_set('users', @_) } |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
# _class |
|
205
|
|
|
|
|
|
|
# |
|
206
|
|
|
|
|
|
|
# internal name for class |
|
207
|
32
|
|
|
32
|
|
111
|
sub _class { 'database' } |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
1; |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
__END__ |