line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ELab::Client; |
2
|
|
|
|
|
|
|
# ABSTRACT: Access the eLabFTW API with Perl |
3
|
|
|
|
|
|
|
$ELab::Client::VERSION = '0.011'; |
4
|
1
|
|
|
1
|
|
2071
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
70
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
571
|
use Moose; |
|
1
|
|
|
|
|
484041
|
|
|
1
|
|
|
|
|
5
|
|
8
|
1
|
|
|
1
|
|
8201
|
use MooseX::NonMoose; |
|
1
|
|
|
|
|
1058
|
|
|
1
|
|
|
|
|
3
|
|
9
|
1
|
|
|
1
|
|
74058
|
use MooseX::Params::Validate; |
|
1
|
|
|
|
|
90239
|
|
|
1
|
|
|
|
|
8
|
|
10
|
1
|
|
|
1
|
|
1311
|
use JSON; |
|
1
|
|
|
|
|
8863
|
|
|
1
|
|
|
|
|
9
|
|
11
|
1
|
|
|
1
|
|
643
|
use HTTP::Request::Common qw ''; |
|
1
|
|
|
|
|
22688
|
|
|
1
|
|
|
|
|
1993
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
extends 'REST::Client'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has host => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
isa => 'Str', |
18
|
|
|
|
|
|
|
required => 1, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has token => ( |
22
|
|
|
|
|
|
|
is => 'ro', |
23
|
|
|
|
|
|
|
isa => 'Str', |
24
|
|
|
|
|
|
|
required => 1, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has endpoint => ( |
28
|
|
|
|
|
|
|
is => 'ro', |
29
|
|
|
|
|
|
|
isa => 'Str', |
30
|
|
|
|
|
|
|
default => 'api/v1/' |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub BUILD { |
35
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
36
|
0
|
|
|
|
|
|
my $args = shift; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
$self->addHeader('Authorization', $self->token()); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub elab_get { |
42
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
43
|
0
|
|
|
|
|
|
my $url = shift; |
44
|
0
|
|
|
|
|
|
my $result = $self->GET($self->endpoint().$url); |
45
|
0
|
0
|
|
|
|
|
return undef unless $result->responseCode() eq '200'; |
46
|
0
|
|
|
|
|
|
return $result->responseContent(); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub elab_delete { |
50
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
51
|
0
|
|
|
|
|
|
my $url = shift; |
52
|
0
|
|
|
|
|
|
my $result = $self->DELETE($self->endpoint().$url); |
53
|
0
|
0
|
|
|
|
|
return undef unless $result->responseCode() eq '200'; |
54
|
0
|
|
|
|
|
|
return $result->responseContent(); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub elab_post { |
58
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
59
|
0
|
|
|
|
|
|
my $url = shift; |
60
|
0
|
|
|
|
|
|
my $data = shift; |
61
|
0
|
|
|
|
|
|
$data =~ s/^\?//; # buildQuery starts with "?" (makes no sense here) |
62
|
0
|
|
|
|
|
|
my $headers = { 'Content-Type' => 'application/x-www-form-urlencoded' }; |
63
|
0
|
|
|
|
|
|
my $result = $self->POST($self->endpoint().$url, $data, $headers); |
64
|
0
|
0
|
|
|
|
|
return undef unless $result->responseCode() eq '200'; |
65
|
0
|
|
|
|
|
|
return $result->responseContent(); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# from here on we try to follow elabapy in terms of function names |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub create_experiment { |
73
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
74
|
0
|
|
|
|
|
|
return decode_json $self->elab_post("experiments"); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub create_item { |
80
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
81
|
0
|
|
|
|
|
|
my $type = shift; |
82
|
0
|
|
|
|
|
|
return decode_json $self->elab_post("items/$type"); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub create_template { |
88
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
89
|
0
|
|
|
|
|
|
return decode_json $self->elab_post("templates"); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub get_all_experiments { |
95
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
96
|
0
|
|
|
|
|
|
my (%args) = validated_hash( |
97
|
|
|
|
|
|
|
\@_, |
98
|
|
|
|
|
|
|
limit => { isa => 'Int', default => 25 }, |
99
|
|
|
|
|
|
|
offset => { isa => 'Int', default => 0 }, |
100
|
|
|
|
|
|
|
); |
101
|
0
|
|
|
|
|
|
return decode_json $self->elab_get("experiments/?".$self->buildQuery(%args)); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub get_experiment { |
107
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
108
|
0
|
|
|
|
|
|
my $id = shift; |
109
|
0
|
|
|
|
|
|
return decode_json $self->elab_get("experiments/$id"); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub get_all_items { |
115
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
116
|
0
|
|
|
|
|
|
my (%args) = validated_hash( |
117
|
|
|
|
|
|
|
\@_, |
118
|
|
|
|
|
|
|
limit => { isa => 'Int', default => 25 }, |
119
|
|
|
|
|
|
|
offset => { isa => 'Int', default => 0 }, |
120
|
|
|
|
|
|
|
); |
121
|
0
|
|
|
|
|
|
return decode_json $self->elab_get("items/".$self->buildQuery(%args)); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub get_item { |
128
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
129
|
0
|
|
|
|
|
|
my $id = shift; |
130
|
0
|
|
|
|
|
|
return decode_json $self->elab_get("items/$id"); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub get_items_types { |
136
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
137
|
0
|
|
|
|
|
|
return decode_json $self->elab_get("items_types/"); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub get_tags { |
143
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
144
|
0
|
|
|
|
|
|
return decode_json $self->elab_get("tags/"); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub get_upload { |
150
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
151
|
0
|
|
|
|
|
|
my $id = shift; |
152
|
0
|
|
|
|
|
|
return $self->elab_get("uploads/$id"); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub get_status { |
158
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
159
|
0
|
|
|
|
|
|
return decode_json $self->elab_get("status/"); |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub get_all_templates { |
165
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
166
|
0
|
|
|
|
|
|
return decode_json $self->elab_get("templates/"); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub get_template { |
172
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
173
|
0
|
|
|
|
|
|
my $id = shift; |
174
|
0
|
|
|
|
|
|
return decode_json $self->elab_get("templates/$id"); |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub post_experiment { |
180
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
181
|
0
|
|
|
|
|
|
my $id = shift; |
182
|
0
|
|
|
|
|
|
my (%args) = validated_hash( |
183
|
|
|
|
|
|
|
\@_, |
184
|
|
|
|
|
|
|
title => { isa => 'Str', optional => 1 }, |
185
|
|
|
|
|
|
|
date => { isa => 'Str', optional => 1 }, |
186
|
|
|
|
|
|
|
body => { isa => 'Str', optional => 1 }, |
187
|
|
|
|
|
|
|
bodyappend => { isa => 'Str', optional => 1 }, |
188
|
|
|
|
|
|
|
); |
189
|
0
|
|
|
|
|
|
return decode_json $self->elab_post("experiments/$id", $self->buildQuery(%args)); |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub post_item { |
195
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
196
|
0
|
|
|
|
|
|
my $id = shift; |
197
|
0
|
|
|
|
|
|
my (%args) = validated_hash( |
198
|
|
|
|
|
|
|
\@_, |
199
|
|
|
|
|
|
|
title => { isa => 'Str', optional => 1 }, |
200
|
|
|
|
|
|
|
date => { isa => 'Str', optional => 1 }, |
201
|
|
|
|
|
|
|
body => { isa => 'Str', optional => 1 }, |
202
|
|
|
|
|
|
|
bodyappend => { isa => 'Str', optional => 1 }, |
203
|
|
|
|
|
|
|
); |
204
|
0
|
|
|
|
|
|
return decode_json $self->elab_post("items/$id", $self->buildQuery(%args)); |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub post_template { |
210
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
211
|
0
|
|
|
|
|
|
my $id = shift; |
212
|
0
|
|
|
|
|
|
my (%args) = validated_hash( |
213
|
|
|
|
|
|
|
\@_, |
214
|
|
|
|
|
|
|
title => { isa => 'Str', optional => 1 }, |
215
|
|
|
|
|
|
|
date => { isa => 'Str', optional => 1 }, |
216
|
|
|
|
|
|
|
body => { isa => 'Str', optional => 1 }, |
217
|
|
|
|
|
|
|
); |
218
|
0
|
|
|
|
|
|
return decode_json $self->elab_post("templates/$id", $self->buildQuery(%args)); |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
sub add_link_to_experiment { |
224
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
225
|
0
|
|
|
|
|
|
my $id = shift; |
226
|
0
|
|
|
|
|
|
my (%args) = validated_hash( |
227
|
|
|
|
|
|
|
\@_, |
228
|
|
|
|
|
|
|
link => { isa => 'Str' }, |
229
|
|
|
|
|
|
|
); |
230
|
0
|
|
|
|
|
|
return decode_json $self->elab_post("experiments/$id", $self->buildQuery(%args)); |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub add_link_to_item { |
236
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
237
|
0
|
|
|
|
|
|
my $id = shift; |
238
|
0
|
|
|
|
|
|
my (%args) = validated_hash( |
239
|
|
|
|
|
|
|
\@_, |
240
|
|
|
|
|
|
|
link => { isa => 'Str' }, |
241
|
|
|
|
|
|
|
); |
242
|
0
|
|
|
|
|
|
return decode_json $self->elab_post("items/$id", $self->buildQuery(%args)); |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
sub upload_to_experiment { |
248
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
249
|
0
|
|
|
|
|
|
my $id = shift; |
250
|
0
|
|
|
|
|
|
my (%args) = validated_hash( |
251
|
|
|
|
|
|
|
\@_, |
252
|
|
|
|
|
|
|
file => { isa => 'Str' }, |
253
|
|
|
|
|
|
|
); |
254
|
|
|
|
|
|
|
my $request = HTTP::Request::Common::POST( |
255
|
|
|
|
|
|
|
$self->host().$self->endpoint()."experiments/$id", |
256
|
|
|
|
|
|
|
{ |
257
|
0
|
|
|
|
|
|
file => [ $args{file} ] |
258
|
|
|
|
|
|
|
}, |
259
|
|
|
|
|
|
|
Content_Type => 'form-data', |
260
|
|
|
|
|
|
|
Authorization => $self->token(), |
261
|
|
|
|
|
|
|
); |
262
|
0
|
|
|
|
|
|
return decode_json $self->getUseragent()->request($request)->decoded_content(); |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
sub upload_to_item { |
268
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
269
|
0
|
|
|
|
|
|
my $id = shift; |
270
|
0
|
|
|
|
|
|
my (%args) = validated_hash( |
271
|
|
|
|
|
|
|
\@_, |
272
|
|
|
|
|
|
|
file => { isa => 'Str' }, |
273
|
|
|
|
|
|
|
); |
274
|
|
|
|
|
|
|
my $request = HTTP::Request::Common::POST( |
275
|
|
|
|
|
|
|
$self->host().$self->endpoint()."items/$id", |
276
|
|
|
|
|
|
|
{ |
277
|
0
|
|
|
|
|
|
file => [ $args{file} ] |
278
|
|
|
|
|
|
|
}, |
279
|
|
|
|
|
|
|
Content_Type => 'form-data', |
280
|
|
|
|
|
|
|
Authorization => $self->token(), |
281
|
|
|
|
|
|
|
); |
282
|
0
|
|
|
|
|
|
return decode_json $self->getUseragent()->request($request)->decoded_content(); |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
sub add_tag_to_experiment { |
288
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
289
|
0
|
|
|
|
|
|
my $id = shift; |
290
|
0
|
|
|
|
|
|
my (%args) = validated_hash( |
291
|
|
|
|
|
|
|
\@_, |
292
|
|
|
|
|
|
|
tag => { isa => 'Str' }, |
293
|
|
|
|
|
|
|
); |
294
|
0
|
|
|
|
|
|
return decode_json $self->elab_post("experiments/$id", $self->buildQuery(%args)); |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
sub add_tag_to_item { |
300
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
301
|
0
|
|
|
|
|
|
my $id = shift; |
302
|
0
|
|
|
|
|
|
my (%args) = validated_hash( |
303
|
|
|
|
|
|
|
\@_, |
304
|
|
|
|
|
|
|
tag => { isa => 'Str' }, |
305
|
|
|
|
|
|
|
); |
306
|
0
|
|
|
|
|
|
return decode_json $self->elab_post("items/$id", $self->buildQuery(%args)); |
307
|
|
|
|
|
|
|
} |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
sub get_backup_zip { |
312
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
313
|
0
|
|
|
|
|
|
my $datespan = shift; |
314
|
0
|
|
|
|
|
|
return $self->elab_get("backupzip/$datespan"); |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
sub get_bookable { |
320
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
321
|
0
|
|
|
|
|
|
return decode_json $self->elab_get("bookable/"); |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
sub create_event { |
327
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
328
|
0
|
|
|
|
|
|
my $id = shift; |
329
|
0
|
|
|
|
|
|
my (%args) = validated_hash( |
330
|
|
|
|
|
|
|
\@_, |
331
|
|
|
|
|
|
|
start => { isa => 'Str' }, |
332
|
|
|
|
|
|
|
end => { isa => 'Str' }, |
333
|
|
|
|
|
|
|
title => { isa => 'Str' }, |
334
|
|
|
|
|
|
|
); |
335
|
0
|
|
|
|
|
|
return decode_json $self->elab_post("events/$id", $self->buildQuery(%args)); |
336
|
|
|
|
|
|
|
} |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
sub get_event { |
341
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
342
|
0
|
|
|
|
|
|
my $id = shift; |
343
|
0
|
|
|
|
|
|
return decode_json $self->elab_get("events/$id"); |
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
sub get_all_events { |
349
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
350
|
0
|
|
|
|
|
|
return decode_json $self->elab_get("events/"); |
351
|
|
|
|
|
|
|
} |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
sub destroy_event { |
356
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
357
|
0
|
|
|
|
|
|
my $id = shift; |
358
|
0
|
|
|
|
|
|
return decode_json $self->elab_delete("events/$id"); |
359
|
|
|
|
|
|
|
} |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
|
362
|
1
|
|
|
1
|
|
10
|
no Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
363
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
1; |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
__END__ |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
=pod |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
=encoding UTF-8 |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
=head1 NAME |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
ELab::Client - Access the eLabFTW API with Perl |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
=head1 VERSION |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
version 0.011 |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
=head1 SYNOPSYS |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
use ELab::Client; |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
my $elab = ELab::Client->new( |
386
|
|
|
|
|
|
|
host => 'https://elab.somewhere.de/', |
387
|
|
|
|
|
|
|
token => 'ae...d4', |
388
|
|
|
|
|
|
|
); |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
my $e = $elab->post_experiment(4, |
391
|
|
|
|
|
|
|
title => "New experiment title", |
392
|
|
|
|
|
|
|
body => "The new body text" |
393
|
|
|
|
|
|
|
); |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
This module is work in progress, and coverage of the API is by far not complete yet. |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
=head1 METHODS |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
=head2 create_experiment |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
Creates a new experiment: |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
my $e = $elab->create_experiment(); |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
The return value is a hash reference with fields |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
result string 'success' or error message |
408
|
|
|
|
|
|
|
id string id of the new experiment |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
=head2 create_item |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
Creates a new database item of type $type: |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
my $e = $elab->create_item($type); |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
The return value is a hash reference with fields |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
result string 'success' or error message |
419
|
|
|
|
|
|
|
id string id of the new item |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
=head2 create_template |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
Creates a new template: |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
my $t = $elab->create_template(); |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
The return value is a hash reference with fields |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
result string 'success' or error message |
430
|
|
|
|
|
|
|
id string id of the new template |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
=head2 get_all_experiments |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
Lists experiments, with maximum number limit and starting at offset. |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
my $a = $elab->get_all_experiments(limit => 15, offset => 0); |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
The return value is an array reference, where each element is a hash reference |
439
|
|
|
|
|
|
|
describing an experiment (not fully, but abbreviated). |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
=head2 get_experiment |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
Returns an experiment. |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
my $e = $elab->get_experiment($id); |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
The return value is a hash reference with the full experiment information. |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
=head2 get_all_items |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
Lists database items, with maximum number limit and starting at offset. |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
my $a = $elab->get_all_items(limit => 25, offset => 0); |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
The return value is an array reference, where each element is a hash reference |
456
|
|
|
|
|
|
|
corresponding to a database item. |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
=head2 get_item |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
Returns a database item. |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
my $i = $elab->get_item($id); |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
=head2 get_items_types |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
Returns a list of database item types. |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
my $t = $elab->get_items_types(); |
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
The return value is an array reference ... |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
=head2 get_tags |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
Returns the tags of the team. |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
my $t = $elab->get_tags(); |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
=head2 get_upload |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
Get an uploaded file from its id |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
my $data = $elab->get_upload($id); |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
The result is the raw binary data of the uploaded file. |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
=head2 get_status |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
Get a list of possible experiment states (statuses?)... |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
my $s = $elab->get_status(); |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
=head2 get_all_templates |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
my $t = $elab->get_all_templates(); |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
=head2 get_template |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
my $t = $elab->get_template($id); |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
=head2 post_experiment |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
my $e = $elab->post_experiment(13, |
503
|
|
|
|
|
|
|
title => "Updated experiment title", |
504
|
|
|
|
|
|
|
body => "Updated experiment body text" |
505
|
|
|
|
|
|
|
); |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
=head2 post_item |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
my $i = $elab->post_item(4, |
510
|
|
|
|
|
|
|
title => "Database item", |
511
|
|
|
|
|
|
|
body => "here are the bodies" |
512
|
|
|
|
|
|
|
); |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
=head2 post_template |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
=head2 add_link_to_experiment |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
=head2 add_link_to_item |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
=head2 upload_to_experiment |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
my $e = $elab->upload_to_experiment(13, file => "mauterndorf.jpg"); |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
=head2 upload_to_item |
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
my $e = $elab->upload_to_item(13, file => "mauterndorf.jpg"); |
527
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
=head2 add_tag_to_experiment |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
=head2 add_tag_to_item |
531
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
=head2 get_backup_zip |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
=head2 get_bookable |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
=head2 create_event |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
=head2 get_event |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
=head2 get_all_events |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
=head2 destroy_event |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
=head1 AUTHOR |
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
Andreas K. Huettel <dilfridge@gentoo.org> |
547
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Andreas K. Huettel. |
551
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
553
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
=cut |