line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::MediaMosa; |
2
|
3
|
|
|
3
|
|
72148
|
use Catmandu::Sane; |
|
3
|
|
|
|
|
273016
|
|
|
3
|
|
|
|
|
19
|
|
3
|
3
|
|
|
3
|
|
739
|
use Carp qw(confess); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
170
|
|
4
|
3
|
|
|
3
|
|
17
|
use Moo; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
17
|
|
5
|
3
|
|
|
3
|
|
4589
|
use LWP::UserAgent; |
|
3
|
|
|
|
|
170785
|
|
|
3
|
|
|
|
|
101
|
|
6
|
3
|
|
|
3
|
|
2312
|
use Data::UUID; |
|
3
|
|
|
|
|
2558
|
|
|
3
|
|
|
|
|
207
|
|
7
|
3
|
|
|
3
|
|
2235
|
use Data::Util qw(:check :validate); |
|
3
|
|
|
|
|
8358
|
|
|
3
|
|
|
|
|
835
|
|
8
|
3
|
|
|
3
|
|
2239
|
use Digest::SHA1 qw(sha1_hex); |
|
3
|
|
|
|
|
2260
|
|
|
3
|
|
|
|
|
189
|
|
9
|
3
|
|
|
3
|
|
2107
|
use Catmandu::MediaMosa::XPath::Helper qw(xpath); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Catmandu::MediaMosa::Response; |
11
|
|
|
|
|
|
|
use URI::Escape; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use all qw( |
14
|
|
|
|
|
|
|
Catmandu::MediaMosa::Items::* |
15
|
|
|
|
|
|
|
Catmandu::MediaMosa::Response::* |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = "0.279"; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#zie http://www.mediamosa.org/sites/default/files/Webservices-MediaMosa-1.5.3.pdf |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has base_url => ( |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
required => 1 |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
has user => ( |
27
|
|
|
|
|
|
|
is => 'ro', |
28
|
|
|
|
|
|
|
required => 1 |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
has password => ( |
31
|
|
|
|
|
|
|
is => 'ro', |
32
|
|
|
|
|
|
|
required => 1 |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _parse_header { |
36
|
|
|
|
|
|
|
my($self,$xpath) = @_; |
37
|
|
|
|
|
|
|
Catmandu::MediaMosa::Response::Header->parse_xpath($xpath); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
sub _make_items { |
40
|
|
|
|
|
|
|
my($self,$items)=@_; |
41
|
|
|
|
|
|
|
Catmandu::MediaMosa::Response::Items->new(items => $items); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
sub _make_response { |
44
|
|
|
|
|
|
|
my($self,$header,$items)=@_; |
45
|
|
|
|
|
|
|
Catmandu::MediaMosa::Response->new(header => $header,items => $items); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
sub _ua { |
48
|
|
|
|
|
|
|
state $_ua = LWP::UserAgent->new( |
49
|
|
|
|
|
|
|
cookie_jar => {} |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
sub _validate_web_response { |
53
|
|
|
|
|
|
|
my($self,$res) = @_; |
54
|
|
|
|
|
|
|
$res->is_error && confess($res->content."\n"); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
sub vp_request { |
57
|
|
|
|
|
|
|
my($self,@args) = @_; |
58
|
|
|
|
|
|
|
$self->login; |
59
|
|
|
|
|
|
|
$self->_vp_request(@args); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
sub _vp_request { |
62
|
|
|
|
|
|
|
my($self,$path,$params,$method)=@_; |
63
|
|
|
|
|
|
|
$method ||= "GET"; |
64
|
|
|
|
|
|
|
my $res; |
65
|
|
|
|
|
|
|
if(uc($method) eq "GET"){ |
66
|
|
|
|
|
|
|
$res = $self->_get($path,$params); |
67
|
|
|
|
|
|
|
}elsif(uc($method) eq "POST"){ |
68
|
|
|
|
|
|
|
$res = $self->_post($path,$params); |
69
|
|
|
|
|
|
|
}else{ |
70
|
|
|
|
|
|
|
confess "method $method not supported"; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
$self->_validate_web_response($res); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$res; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
sub _construct_params_as_array { |
77
|
|
|
|
|
|
|
my($self,$params) = @_; |
78
|
|
|
|
|
|
|
my @array = (); |
79
|
|
|
|
|
|
|
for my $key(keys %$params){ |
80
|
|
|
|
|
|
|
if(is_array_ref($params->{$key})){ |
81
|
|
|
|
|
|
|
#PHP only recognizes 'arrays' when their keys are appended by '[]' (yuk!) |
82
|
|
|
|
|
|
|
for my $val(@{ $params->{$key} }){ |
83
|
|
|
|
|
|
|
push @array,$key."[]" => $val; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
}else{ |
86
|
|
|
|
|
|
|
push @array,$key => $params->{$key}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
return \@array; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
sub _post { |
92
|
|
|
|
|
|
|
my($self,$path,$data)=@_; |
93
|
|
|
|
|
|
|
$self->_ua->post($self->base_url.$path,$self->_construct_params_as_array($data)); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
sub _construct_query { |
96
|
|
|
|
|
|
|
my($self,$data) = @_; |
97
|
|
|
|
|
|
|
my @parts = (); |
98
|
|
|
|
|
|
|
for my $key(keys %$data){ |
99
|
|
|
|
|
|
|
if(is_array_ref($data->{$key})){ |
100
|
|
|
|
|
|
|
for my $val(@{ $data->{$key} }){ |
101
|
|
|
|
|
|
|
push @parts,URI::Escape::uri_escape($key)."[]=".URI::Escape::uri_escape($val); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
}else{ |
104
|
|
|
|
|
|
|
push @parts,URI::Escape::uri_escape($key)."=".URI::Escape::uri_escape($data->{$key}); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
join("&",@parts); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
sub _get { |
110
|
|
|
|
|
|
|
my($self,$path,$data)=@_; |
111
|
|
|
|
|
|
|
my $query = $self->_construct_query($data) || ""; |
112
|
|
|
|
|
|
|
$self->_ua->get($self->base_url.$path."?$query"); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
sub _authenticate { |
115
|
|
|
|
|
|
|
my $self = shift; |
116
|
|
|
|
|
|
|
#dbus communication |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
#client: EGA stuurt "AUTH DBUS_COOKIE_SHA1 " naar VP-Core |
119
|
|
|
|
|
|
|
my($challenge_server,$random); |
120
|
|
|
|
|
|
|
{ |
121
|
|
|
|
|
|
|
my $res = $self->_vp_request("/login",{ |
122
|
|
|
|
|
|
|
dbus => "AUTH DBUS_COOKIE_SHA1 ".$self->user |
123
|
|
|
|
|
|
|
},"POST"); |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
my $items = Catmandu::MediaMosa::Items::login->parse($res->content_ref); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
#server: "DATA vpx 0 " |
128
|
|
|
|
|
|
|
my $dbus = $items->[0]->{dbus}; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
if($dbus !~ /^DATA vpx 0 ([a-f0-9]{32})$/o){ |
131
|
|
|
|
|
|
|
confess("invalid dbus response from server: $dbus\n"); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
$challenge_server = $1; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
#client: EGA verzint willekeurige tekst |
137
|
|
|
|
|
|
|
# en berekent response string: |
138
|
|
|
|
|
|
|
# = sha1(::) |
139
|
|
|
|
|
|
|
$random = Data::UUID->new->create_str; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
#client: EGA stuurt "DATA " naar VP-Core |
142
|
|
|
|
|
|
|
my $success = ""; |
143
|
|
|
|
|
|
|
{ |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
my $response_string = sha1_hex("$challenge_server:$random:".$self->password); |
146
|
|
|
|
|
|
|
my $res = $self->_vp_request("/login",{ |
147
|
|
|
|
|
|
|
dbus => "DATA $random $response_string" |
148
|
|
|
|
|
|
|
},"POST"); |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
my $items = Catmandu::MediaMosa::Items::login->parse($res->content_ref); |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
my $dbus = $items->[0]->{dbus}; |
153
|
|
|
|
|
|
|
#server: OK|REJECTED vpx |
154
|
|
|
|
|
|
|
if($dbus !~ /^(OK|REJECTED) (\w+)$/o){ |
155
|
|
|
|
|
|
|
confess("invalid dbus response from server: $dbus\n"); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
$success = $1; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
#ok? |
161
|
|
|
|
|
|
|
return $success eq "OK"; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
sub login { |
164
|
|
|
|
|
|
|
my $self = shift; |
165
|
|
|
|
|
|
|
state $logged_in = 0; |
166
|
|
|
|
|
|
|
$logged_in ||= $self->_authenticate(); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
#assets |
170
|
|
|
|
|
|
|
# |
171
|
|
|
|
|
|
|
# |
172
|
|
|
|
|
|
|
# -
|
173
|
|
|
|
|
|
|
# q1WmtebDr9F8eberUIjKrhTa |
174
|
|
|
|
|
|
|
# |
175
|
|
|
|
|
|
|
# |
176
|
|
|
|
|
|
|
sub asset_create { |
177
|
|
|
|
|
|
|
my($self,$params) = @_; |
178
|
|
|
|
|
|
|
$params ||= {}; |
179
|
|
|
|
|
|
|
my $res = $self->vp_request("/asset/create",$params,"POST"); |
180
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
181
|
|
|
|
|
|
|
$self->_make_response( |
182
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
183
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
184
|
|
|
|
|
|
|
); |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
#asset_delete: rest api does not return response |
187
|
|
|
|
|
|
|
sub asset_delete { |
188
|
|
|
|
|
|
|
my($self,$params) = @_; |
189
|
|
|
|
|
|
|
$params ||= {}; |
190
|
|
|
|
|
|
|
$self->vp_request("/asset/$params->{asset_id}/delete",$params,"POST"); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
sub asset_list { |
193
|
|
|
|
|
|
|
my($self,$params) = @_; |
194
|
|
|
|
|
|
|
$params ||= {}; |
195
|
|
|
|
|
|
|
my $res = $self->vp_request("/asset",$params,"GET"); |
196
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
197
|
|
|
|
|
|
|
$self->_make_response( |
198
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
199
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::asset_list->parse_xpath($xpath)) |
200
|
|
|
|
|
|
|
); |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
sub asset { |
203
|
|
|
|
|
|
|
my($self,$params) = @_; |
204
|
|
|
|
|
|
|
$params ||= {}; |
205
|
|
|
|
|
|
|
my $res = $self->vp_request("/asset/$params->{asset_id}",$params,"GET"); |
206
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
207
|
|
|
|
|
|
|
$self->_make_response( |
208
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
209
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::asset->parse_xpath($xpath)) |
210
|
|
|
|
|
|
|
); |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
#asset_update: rest api does not return response |
214
|
|
|
|
|
|
|
sub asset_update { |
215
|
|
|
|
|
|
|
my($self,$params) = @_; |
216
|
|
|
|
|
|
|
$params ||= {}; |
217
|
|
|
|
|
|
|
$self->vp_request("/asset/$params->{asset_id}",$params,"POST"); |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
sub asset_play { |
220
|
|
|
|
|
|
|
my($self,$params) = @_; |
221
|
|
|
|
|
|
|
$params ||= {}; |
222
|
|
|
|
|
|
|
my $res = $self->vp_request("/asset/$params->{asset_id}/play",$params,"GET"); |
223
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
224
|
|
|
|
|
|
|
$self->_make_response( |
225
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
226
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
227
|
|
|
|
|
|
|
); |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
#asset_stills |
231
|
|
|
|
|
|
|
sub asset_stills { |
232
|
|
|
|
|
|
|
my($self,$params) = @_; |
233
|
|
|
|
|
|
|
$params ||= {}; |
234
|
|
|
|
|
|
|
my $res = $self->vp_request("/asset/$params->{asset_id}/still",$params,"GET"); |
235
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
236
|
|
|
|
|
|
|
$self->_make_response( |
237
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
238
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
239
|
|
|
|
|
|
|
); |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
#asset_still_create: creates jobs |
242
|
|
|
|
|
|
|
# |
243
|
|
|
|
|
|
|
# |
244
|
|
|
|
|
|
|
# -
|
245
|
|
|
|
|
|
|
# 15839 |
246
|
|
|
|
|
|
|
# |
247
|
|
|
|
|
|
|
# |
248
|
|
|
|
|
|
|
sub asset_still_create { |
249
|
|
|
|
|
|
|
my($self,$params) = @_; |
250
|
|
|
|
|
|
|
$params ||= {}; |
251
|
|
|
|
|
|
|
my $res = $self->vp_request("/asset/$params->{asset_id}/still/create",$params,"POST"); |
252
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
253
|
|
|
|
|
|
|
$self->_make_response( |
254
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
255
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
256
|
|
|
|
|
|
|
); |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
sub asset_job_list { |
259
|
|
|
|
|
|
|
my($self,$params) = @_; |
260
|
|
|
|
|
|
|
$params ||= {}; |
261
|
|
|
|
|
|
|
my $res = $self->vp_request("/asset/$params->{asset_id}/joblist",$params,"GET"); |
262
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
263
|
|
|
|
|
|
|
$self->_make_response( |
264
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
265
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
266
|
|
|
|
|
|
|
); |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
sub asset_collection_list { |
270
|
|
|
|
|
|
|
my($self,$params) = @_; |
271
|
|
|
|
|
|
|
$params ||= {}; |
272
|
|
|
|
|
|
|
my $res = $self->vp_request("/asset/$params->{asset_id}/collection",$params,"GET"); |
273
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
274
|
|
|
|
|
|
|
$self->_make_response( |
275
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
276
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
277
|
|
|
|
|
|
|
); |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
#asset_metadata_update: returns posted metadata |
280
|
|
|
|
|
|
|
# |
281
|
|
|
|
|
|
|
# |
282
|
|
|
|
|
|
|
# -
|
283
|
|
|
|
|
|
|
# test description |
284
|
|
|
|
|
|
|
# |
285
|
|
|
|
|
|
|
# |
286
|
|
|
|
|
|
|
sub asset_metadata_update { |
287
|
|
|
|
|
|
|
my($self,$params) = @_; |
288
|
|
|
|
|
|
|
$params ||= {}; |
289
|
|
|
|
|
|
|
my $res = $self->vp_request("/asset/$params->{asset_id}/metadata",$params,"POST"); |
290
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
291
|
|
|
|
|
|
|
$self->_make_response( |
292
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
293
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath)) |
294
|
|
|
|
|
|
|
); |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
sub asset_mediafile_list { |
297
|
|
|
|
|
|
|
my($self,$params) = @_; |
298
|
|
|
|
|
|
|
$params ||= {}; |
299
|
|
|
|
|
|
|
my $res = $self->vp_request("/asset/$params->{asset_id}/mediafile",$params,"GET"); |
300
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
301
|
|
|
|
|
|
|
$self->_make_response( |
302
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
303
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::mediafile->parse_xpath($xpath)) |
304
|
|
|
|
|
|
|
); |
305
|
|
|
|
|
|
|
} |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
#jobs |
308
|
|
|
|
|
|
|
sub job_status { |
309
|
|
|
|
|
|
|
my($self,$params) = @_; |
310
|
|
|
|
|
|
|
$params ||= {}; |
311
|
|
|
|
|
|
|
my $res = $self->vp_request("/job/$params->{job_id}/status",$params,"GET"); |
312
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
313
|
|
|
|
|
|
|
$self->_make_response( |
314
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
315
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
316
|
|
|
|
|
|
|
); |
317
|
|
|
|
|
|
|
} |
318
|
|
|
|
|
|
|
sub job_delete { |
319
|
|
|
|
|
|
|
my($self,$params) = @_; |
320
|
|
|
|
|
|
|
$params ||= {}; |
321
|
|
|
|
|
|
|
$self->vp_request("/job/$params->{job_id}/delete",$params,"POST"); |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
sub job_failures { |
324
|
|
|
|
|
|
|
my($self,$params) = @_; |
325
|
|
|
|
|
|
|
$params ||= {}; |
326
|
|
|
|
|
|
|
my $res = $self->vp_request("/job/failures",$params,"GET"); |
327
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
328
|
|
|
|
|
|
|
$self->_make_response( |
329
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
330
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
331
|
|
|
|
|
|
|
); |
332
|
|
|
|
|
|
|
} |
333
|
|
|
|
|
|
|
#collections |
334
|
|
|
|
|
|
|
sub collection_list { |
335
|
|
|
|
|
|
|
my($self,$params) = @_; |
336
|
|
|
|
|
|
|
$params ||= {}; |
337
|
|
|
|
|
|
|
my $res = $self->vp_request("/collection",$params,"GET"); |
338
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
339
|
|
|
|
|
|
|
$self->_make_response( |
340
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
341
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
342
|
|
|
|
|
|
|
); |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
sub collection { |
345
|
|
|
|
|
|
|
my($self,$params) = @_; |
346
|
|
|
|
|
|
|
$params ||= {}; |
347
|
|
|
|
|
|
|
my $res = $self->vp_request("/collection/$params->{coll_id}",$params,"GET"); |
348
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
349
|
|
|
|
|
|
|
$self->_make_response( |
350
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
351
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
352
|
|
|
|
|
|
|
); |
353
|
|
|
|
|
|
|
} |
354
|
|
|
|
|
|
|
sub collection_asset_list { |
355
|
|
|
|
|
|
|
my($self,$params) = @_; |
356
|
|
|
|
|
|
|
$params ||= {}; |
357
|
|
|
|
|
|
|
my $res = $self->vp_request("/collection/$params->{coll_id}/asset",$params,"GET"); |
358
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
359
|
|
|
|
|
|
|
$self->_make_response( |
360
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
361
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::asset_list->parse_xpath($xpath)) |
362
|
|
|
|
|
|
|
); |
363
|
|
|
|
|
|
|
} |
364
|
|
|
|
|
|
|
# |
365
|
|
|
|
|
|
|
# -
|
366
|
|
|
|
|
|
|
# 3 |
367
|
|
|
|
|
|
|
# |
368
|
|
|
|
|
|
|
# |
369
|
|
|
|
|
|
|
sub collection_create { |
370
|
|
|
|
|
|
|
my($self,$params) = @_; |
371
|
|
|
|
|
|
|
$params ||= {}; |
372
|
|
|
|
|
|
|
my $res = $self->vp_request("/collection/create",$params,"POST"); |
373
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
374
|
|
|
|
|
|
|
$self->_make_response( |
375
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
376
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
377
|
|
|
|
|
|
|
); |
378
|
|
|
|
|
|
|
} |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
##trancode |
381
|
|
|
|
|
|
|
sub transcode_profile_list { |
382
|
|
|
|
|
|
|
my($self,$params) = @_; |
383
|
|
|
|
|
|
|
$params ||= {}; |
384
|
|
|
|
|
|
|
my $res = $self->vp_request("/transcode/profile",$params,"GET"); |
385
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
386
|
|
|
|
|
|
|
$self->_make_response( |
387
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
388
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
389
|
|
|
|
|
|
|
); |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
sub transcode_profile { |
392
|
|
|
|
|
|
|
my($self,$params) = @_; |
393
|
|
|
|
|
|
|
$params ||= {}; |
394
|
|
|
|
|
|
|
my $res = $self->vp_request("/transcode/profile/$params->{profile_id}",$params,"GET"); |
395
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
396
|
|
|
|
|
|
|
$self->_make_response( |
397
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
398
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
399
|
|
|
|
|
|
|
); |
400
|
|
|
|
|
|
|
} |
401
|
|
|
|
|
|
|
#transcode_profile_update: |
402
|
|
|
|
|
|
|
# |
403
|
|
|
|
|
|
|
# |
404
|
|
|
|
|
|
|
# -
|
405
|
|
|
|
|
|
|
# 1 |
406
|
|
|
|
|
|
|
# |
407
|
|
|
|
|
|
|
# |
408
|
|
|
|
|
|
|
sub transcode_profile_update { |
409
|
|
|
|
|
|
|
my($self,$params) = @_; |
410
|
|
|
|
|
|
|
$params ||= {}; |
411
|
|
|
|
|
|
|
my $res = $self->vp_request("/transcode/profile/$params->{profile_id}",$params,"POST"); |
412
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
413
|
|
|
|
|
|
|
$self->_make_response( |
414
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
415
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
416
|
|
|
|
|
|
|
); |
417
|
|
|
|
|
|
|
} |
418
|
|
|
|
|
|
|
#transcode_profile_create |
419
|
|
|
|
|
|
|
# |
420
|
|
|
|
|
|
|
# |
421
|
|
|
|
|
|
|
# -
|
422
|
|
|
|
|
|
|
# 11 |
423
|
|
|
|
|
|
|
# |
424
|
|
|
|
|
|
|
# |
425
|
|
|
|
|
|
|
sub transcode_profile_create { |
426
|
|
|
|
|
|
|
my($self,$params) = @_; |
427
|
|
|
|
|
|
|
$params ||= {}; |
428
|
|
|
|
|
|
|
my $res = $self->vp_request("/transcode/profile/create",$params,"POST"); |
429
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
430
|
|
|
|
|
|
|
$self->_make_response( |
431
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
432
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
433
|
|
|
|
|
|
|
); |
434
|
|
|
|
|
|
|
} |
435
|
|
|
|
|
|
|
#transcode_profile_delete: rest api does not return response |
436
|
|
|
|
|
|
|
sub transcode_profile_delete { |
437
|
|
|
|
|
|
|
my($self,$params) = @_; |
438
|
|
|
|
|
|
|
$params ||= {}; |
439
|
|
|
|
|
|
|
$self->vp_request("/transcode/profile/$params->{profile_id}/delete",$params,"POST"); |
440
|
|
|
|
|
|
|
} |
441
|
|
|
|
|
|
|
#mediafile_create: |
442
|
|
|
|
|
|
|
# |
443
|
|
|
|
|
|
|
# |
444
|
|
|
|
|
|
|
# -
|
445
|
|
|
|
|
|
|
# ERTpgSptYbqvUaYUJGrryyML |
446
|
|
|
|
|
|
|
# |
447
|
|
|
|
|
|
|
# |
448
|
|
|
|
|
|
|
sub mediafile_create { |
449
|
|
|
|
|
|
|
my($self,$params) = @_; |
450
|
|
|
|
|
|
|
$params ||= {}; |
451
|
|
|
|
|
|
|
my $res = $self->vp_request("/mediafile/create",$params,"POST"); |
452
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
453
|
|
|
|
|
|
|
$self->_make_response( |
454
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
455
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
456
|
|
|
|
|
|
|
); |
457
|
|
|
|
|
|
|
} |
458
|
|
|
|
|
|
|
sub mediafile { |
459
|
|
|
|
|
|
|
my($self,$params) = @_; |
460
|
|
|
|
|
|
|
$params ||= {}; |
461
|
|
|
|
|
|
|
my $res = $self->vp_request("/mediafile/$params->{mediafile_id}",$params,"POST"); |
462
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
463
|
|
|
|
|
|
|
$self->_make_response( |
464
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
465
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::mediafile->parse_xpath($xpath)) |
466
|
|
|
|
|
|
|
); |
467
|
|
|
|
|
|
|
} |
468
|
|
|
|
|
|
|
#media_update: rest api does not return response |
469
|
|
|
|
|
|
|
sub mediafile_update { |
470
|
|
|
|
|
|
|
my($self,$params) = @_; |
471
|
|
|
|
|
|
|
$params ||= {}; |
472
|
|
|
|
|
|
|
$self->vp_request("/mediafile/$params->{mediafile_id}",$params,"POST"); |
473
|
|
|
|
|
|
|
} |
474
|
|
|
|
|
|
|
sub mediafile_upload_ticket_create { |
475
|
|
|
|
|
|
|
my($self,$params) = @_; |
476
|
|
|
|
|
|
|
$params ||= {}; |
477
|
|
|
|
|
|
|
my $res = $self->vp_request("/mediafile/$params->{mediafile_id}/uploadticket/create",$params,"POST"); |
478
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
479
|
|
|
|
|
|
|
$self->_make_response( |
480
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
481
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
482
|
|
|
|
|
|
|
); |
483
|
|
|
|
|
|
|
} |
484
|
|
|
|
|
|
|
#user |
485
|
|
|
|
|
|
|
sub user_list { |
486
|
|
|
|
|
|
|
my($self,$params) = @_; |
487
|
|
|
|
|
|
|
$params ||= {}; |
488
|
|
|
|
|
|
|
my $res = $self->vp_request("/user",$params,"GET"); |
489
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
490
|
|
|
|
|
|
|
$self->_make_response( |
491
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
492
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
493
|
|
|
|
|
|
|
); |
494
|
|
|
|
|
|
|
} |
495
|
|
|
|
|
|
|
sub user_detail { |
496
|
|
|
|
|
|
|
my($self,$params) = @_; |
497
|
|
|
|
|
|
|
$params ||= {}; |
498
|
|
|
|
|
|
|
my $res = $self->vp_request("/user/$params->{user_id}",$params,"GET"); |
499
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
500
|
|
|
|
|
|
|
$self->_make_response( |
501
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
502
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
503
|
|
|
|
|
|
|
); |
504
|
|
|
|
|
|
|
} |
505
|
|
|
|
|
|
|
sub user_job_list { |
506
|
|
|
|
|
|
|
my($self,$params) = @_; |
507
|
|
|
|
|
|
|
$params ||= {}; |
508
|
|
|
|
|
|
|
my $res = $self->vp_request("/user/$params->{owner_id}/joblist",$params,"GET"); |
509
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
510
|
|
|
|
|
|
|
$self->_make_response( |
511
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
512
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
513
|
|
|
|
|
|
|
); |
514
|
|
|
|
|
|
|
} |
515
|
|
|
|
|
|
|
sub error_code_list { |
516
|
|
|
|
|
|
|
my($self,$params) = @_; |
517
|
|
|
|
|
|
|
$params ||= {}; |
518
|
|
|
|
|
|
|
my $res = $self->vp_request("/errorcodes",$params,"GET"); |
519
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
520
|
|
|
|
|
|
|
$self->_make_response( |
521
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
522
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
523
|
|
|
|
|
|
|
); |
524
|
|
|
|
|
|
|
} |
525
|
|
|
|
|
|
|
sub error_code { |
526
|
|
|
|
|
|
|
my($self,$params) = @_; |
527
|
|
|
|
|
|
|
$params ||= {}; |
528
|
|
|
|
|
|
|
my $res = $self->vp_request("/errorcodes/$params->{code}",$params,"GET"); |
529
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
530
|
|
|
|
|
|
|
$self->_make_response( |
531
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
532
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
533
|
|
|
|
|
|
|
); |
534
|
|
|
|
|
|
|
} |
535
|
|
|
|
|
|
|
sub version { |
536
|
|
|
|
|
|
|
my($self,$params) = @_; |
537
|
|
|
|
|
|
|
$params ||= {}; |
538
|
|
|
|
|
|
|
my $res = $self->vp_request("/version",$params,"GET"); |
539
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
540
|
|
|
|
|
|
|
$self->_make_response( |
541
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
542
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
543
|
|
|
|
|
|
|
); |
544
|
|
|
|
|
|
|
} |
545
|
|
|
|
|
|
|
sub acl_app { |
546
|
|
|
|
|
|
|
my($self,$params) = @_; |
547
|
|
|
|
|
|
|
$params ||= {}; |
548
|
|
|
|
|
|
|
my $res = $self->vp_request("/acl/app",$params,"GET"); |
549
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
550
|
|
|
|
|
|
|
$self->_make_response( |
551
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
552
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
553
|
|
|
|
|
|
|
); |
554
|
|
|
|
|
|
|
} |
555
|
|
|
|
|
|
|
sub app_quota { |
556
|
|
|
|
|
|
|
my($self,$params) = @_; |
557
|
|
|
|
|
|
|
$params ||= {}; |
558
|
|
|
|
|
|
|
my $res = $self->vp_request("/app/quota",$params,"GET"); |
559
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
560
|
|
|
|
|
|
|
$self->_make_response( |
561
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
562
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::simple_list->parse_xpath($xpath,1)) |
563
|
|
|
|
|
|
|
); |
564
|
|
|
|
|
|
|
} |
565
|
|
|
|
|
|
|
sub status { |
566
|
|
|
|
|
|
|
my($self,$params) = @_; |
567
|
|
|
|
|
|
|
$params ||= {}; |
568
|
|
|
|
|
|
|
my $res = $self->vp_request("/status",$params,"GET"); |
569
|
|
|
|
|
|
|
my $xpath = xpath($res->content_ref); |
570
|
|
|
|
|
|
|
$self->_make_response( |
571
|
|
|
|
|
|
|
$self->_parse_header($xpath), |
572
|
|
|
|
|
|
|
$self->_make_items(Catmandu::MediaMosa::Items::status->parse_xpath($xpath)) |
573
|
|
|
|
|
|
|
); |
574
|
|
|
|
|
|
|
} |
575
|
|
|
|
|
|
|
=head1 NAME |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
MediaMosa - Low level Perl connector for the MediaMosa REST API |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
=head1 SYNOPSIS |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
my $mm = Catmandu::MediaMosa->new( base_url => 'http://localhost/mediamosa' , user => "foo",password => "mysecret" ); |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
#login is handled automatically ;-), and only redone when the session cookie expires |
584
|
|
|
|
|
|
|
#$mm->login; |
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
#equivalent of /asset?offset=0&limit=100 |
587
|
|
|
|
|
|
|
my $vpcore = $mm->asset_list({ offset => 0,limit => 1000}); |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
die($vpcore->header->request_result_description) if($vpcore->header->request_result eq "error"); |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
say "total found:".$vpcore->header->item_count_total; |
592
|
|
|
|
|
|
|
say "total fetched:".$vpcore->header->item_count; |
593
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
#the result list 'items' is iterable! |
595
|
|
|
|
|
|
|
$vpcore->items->each(sub{ |
596
|
|
|
|
|
|
|
my $item = shift; |
597
|
|
|
|
|
|
|
say "asset_id:".$item->{asset_id}; |
598
|
|
|
|
|
|
|
}); |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
=head1 SEE ALSO |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
L |
603
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
=head1 AUTHOR |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
Nicolas Franck , C<< >> |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
=cut |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
1; |