File Coverage

blib/lib/WWW/FBX/Role/API/APIv3.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 15 15 100.0


line stmt bran cond sub pod time code
1             package WWW::FBX::Role::API::APIv3;
2 23     23   14017 use 5.014001;
  23         57  
3 23     23   9059 use Moose::Role;
  23         70939  
  23         109  
4 23     23   91115 use WWW::FBX::API;
  23         63  
  23         114  
5 23     23   25331 use MIME::Base64 qw/encode_base64 decode_base64/;
  23         12680  
  23         60149  
6              
7             #sub BUILD {
8             # shift->api_version;
9             #}
10              
11             fbx_api_method api_version => (
12             description => <<'',
13             Get API version.
14              
15             path => 'api_version',
16             method => 'GET',
17             params => [],
18             required => [],
19             );
20              
21             around api_version => sub {
22             my $orig = shift;
23             my $self = shift;
24              
25             api_url( "" );
26             $self->$orig;
27             my $uar = $self->uar;
28             my ($maj) = $uar->{api_version} =~ /(\d*)\./;
29             api_url( "$uar->{api_base_url}v$maj" );
30             };
31              
32             fbx_api_method req_auth => (
33             description => <<'',
34             Ask for an App token.
35              
36             path => 'login/authorize',
37             method => 'POST',
38             params => [qw/ app_id app_name app_version device_name /],
39             required => [qw/ app_id app_name app_version device_name /],
40              
41             );
42              
43             fbx_api_method auth_progress => (
44             description => <<'',
45             Monitor token status.
46              
47             path => 'login/authorize/',
48             method => 'GET',
49             params => [qw/suff/],
50             required => [qw/suff/],
51             );
52              
53             fbx_api_method login => (
54             description => <<'',
55             Get login challenge.
56              
57             path => 'login/',
58             method => 'GET',
59             params => [],
60             required => [],
61             );
62              
63             fbx_api_method open_session => (
64             description => <<'',
65             Open a session.
66              
67             path => 'login/session/',
68             method => 'POST',
69             params => [ qw/ app_id app_version password / ],
70             required => [ qw/ app_id password / ],
71             );
72              
73             #Download
74             fbx_api_method s'/'_'gr => (
75             description => <<'',
76             Global download getters.
77              
78             path => $_,
79             method => 'GET',
80             params => [ ],
81             required => [ ],
82             ) for qw(downloads/ downloads/stats);
83              
84             fbx_api_method get_download_task => (
85             description => <<'',
86             Get the download task.
87              
88             path => 'downloads/',
89             method => 'GET',
90             params => [ qw/suff/ ],
91             required => [ qw/suff/ ],
92             );
93              
94             fbx_api_method del_download_task => (
95             description => <<'',
96             Get the download task.
97              
98             path => 'downloads/',
99             method => 'DELETE',
100             params => [ qw/suff/ ],
101             required => [ qw/suff/ ],
102             );
103              
104             fbx_api_method upd_download_task => (
105             description => <<'',
106             Update the download task.
107              
108             path => 'downloads/',
109             method => 'PUT',
110             params => [ qw/suff io_priority status/ ],
111             required => [ qw/suff/ ],
112             );
113              
114             fbx_api_method add_download_task => (
115             description => <<'',
116             Add a download task.
117              
118             path => 'downloads/add',
119             method => 'POST',
120             content_type => 'application/x-www-form-urlencoded',
121             params => [ qw/download_url download_url_list download_dir recursive username password archive_password cookies/],
122             required => [ qw//],
123             );
124              
125             fbx_api_method add_download_task_file => (
126             description => <<'',
127             Add a download task by file.
128              
129             path => 'downloads/add',
130             method => 'POST',
131             content_type => 'form-data',
132             params => [ qw/download_file download_dir archive_password/],
133             required => [ qw/download_file/],
134             );
135              
136             fbx_api_method change_prio_download_file => (
137             description => <<'',
138             Change the priority of a Download File.
139              
140             path => 'downloads/',
141             method => 'PUT',
142             params => [ qw/suff priority/ ],
143             required => [ qw/suff priority/ ],
144             );
145              
146             #TODO: tracker, blacklist
147              
148             #Download feeds
149             fbx_api_method s'/'_'gr => (
150             description => <<'',
151             Get feed(s).
152              
153             path => $_,
154             method => 'GET',
155             params => [ qw/suff/ ],
156             required => [ ],
157             ) for qw(downloads/feeds/);
158              
159             fbx_api_method add_feed => (
160             description => <<'',
161             Add a feed.
162              
163             path => 'downloads/feeds/',
164             method => 'POST',
165             params => [ qw/url/ ],
166             required => [ qw/url/ ],
167             );
168              
169             fbx_api_method del_feed => (
170             description => <<'',
171             Delete download feed.
172              
173             path => "downloads/feeds/",
174             method => 'DELETE',
175             params => [ qw/suff/ ],
176             required => [ qw/suff/ ],
177             );
178              
179             fbx_api_method upd_feed => (
180             description => <<'',
181             Update download feed.
182              
183             path => 'downloads/feeds/',
184             method => 'PUT',
185             params => [ qw/suff auto_download/ ],
186             required => [ qw/suff / ],
187             );
188              
189             fbx_api_method $_ => (
190             description => <<'',
191             Global feed POST.
192              
193             path => 'downloads/feeds/',
194             method => 'POST',
195             params => [ qw/suff/ ],
196             required => [ qw/suff/ ],
197             ) for qw/refresh_feed download_feed_item mark_all_read/;
198              
199             fbx_api_method refresh_feeds => (
200             description => <<'',
201             Refresh all feeds.
202              
203             path => 'downloads/feeds/fetch',
204             method => 'POST',
205             params => [ ],
206             required => [ ],
207             );
208              
209             #Download config
210             fbx_api_method downloads_config => (
211             description => <<'',
212             Get Downloads config.
213              
214             path => "downloads/config",
215             method => 'GET',
216             params => [ ],
217             required => [ ],
218             );
219              
220             fbx_api_method upd_downloads_config => (
221             description => <<'',
222             Update downloads config.
223              
224             path => "downloads/config",
225             method => 'PUT',
226             params => [ qw/throttling max_downloading_tasks download_dir use_watch_dir watch_dir news bt feed/],
227             required => [ ],
228             ) for qw(downloads/config/);
229              
230             around downloads_config => sub {
231             my $orig = shift;
232             my $self = shift;
233              
234             my $params = $self->$orig(@_);
235              
236             for (qw/download_dir watch_dir/) {
237             $params->{$_} = decode_base64( $params->{$_} ) if exists $params->{$_} and $params->{$_};
238             }
239              
240             $params;
241             };
242              
243             around upd_downloads_config => sub {
244             my $orig = shift;
245             my $self = shift;
246              
247             if (@_) {
248             my $params = $_[0];
249             for my $par (qw/download_dir watch_dir/) {
250             $params->{$par} = encode_base64( $params->{$par}, "") if exists $params->{$par} and $params->{$par};
251             }
252             }
253              
254             $self->$orig(@_);
255             };
256              
257             fbx_api_method upd_downloads_throttle => (
258             description => <<'',
259             Update download throttling.
260              
261             path => "downloads/throttling",
262             method => 'PUT',
263             params => [ qw/throttling/],
264             required => [ qw/throttling/ ],
265             );
266              
267             #FS
268             fbx_api_method s'/'_'gr => (
269             description => <<'',
270             Get task(s).
271              
272             path => $_,
273             method => 'GET',
274             params => [ qw/suff/ ],
275             required => [ ],
276             ) for qw(fs/tasks/);
277              
278             fbx_api_method del_task => (
279             description => <<'',
280             Delete task.
281              
282             path => "fs/tasks/",
283             method => 'DELETE',
284             params => [ qw/suff/ ],
285             required => [ ],
286             );
287              
288             fbx_api_method upd_task => (
289             description => <<'',
290             Update task.
291              
292             path => "fs/tasks/",
293             method => 'PUT',
294             params => [ qw/suff state/ ],
295             required => [ qw/suff state/ ],
296             );
297              
298             fbx_api_method list_files => (
299             description => <<'',
300             List files.
301              
302             path => "fs/ls/",
303             method => 'GET',
304             params => [ qw/suff/ ],
305             required => [ qw/suff/ ],
306             );
307              
308             around list_files => sub {
309             my $orig = shift;
310             my $self = shift;
311             my $params = shift;
312              
313             $params = encode_base64( $params, "") if $params;
314             my $res = $self->$orig($params);
315              
316             for my $i ( 0.. $#{$res} ) {
317             $res->[$i]{path} = decode_base64( $res->[$i]{path} );
318             }
319              
320             $res;
321             };
322              
323             fbx_api_method file_info => (
324             description => <<'',
325             Get file information.
326              
327             path => "fs/info/",
328             method => 'GET',
329             params => [ qw/suff/ ],
330             required => [ qw/suff/ ],
331             );
332              
333             around file_info => sub {
334             my $orig = shift;
335             my $self = shift;
336             my $params = shift;
337              
338             $params = encode_base64( $params, "") if $params;
339            
340             my $res = $self->$orig($params);
341              
342             for (qw/parent target path/) {
343             $params->{$_} = decode_base64( $params->{$_} ) if exists $params->{$_} and $params->{$_};
344             }
345              
346             $params;
347             };
348              
349             fbx_api_method mv => (
350             description => <<'',
351             Move files.
352              
353             path => "fs/mv/",
354             method => 'POST',
355             params => [ qw/files dst mode/ ],
356             required => [ qw/files dst mode/ ],
357             );
358              
359             fbx_api_method cp => (
360             description => <<'',
361             Copy files.
362              
363             path => "fs/cp/",
364             method => 'POST',
365             params => [ qw/files dst mode/ ],
366             required => [ qw/files dst mode/ ],
367             );
368              
369             fbx_api_method archive => (
370             description => <<'',
371             Create an archive.
372              
373             path => "fs/archive/",
374             method => 'POST',
375             params => [ qw/files dst/ ],
376             required => [ qw/files dst/ ],
377             );
378              
379             around [qw/cp mv archive/] => sub {
380             my $orig = shift;
381             my $self = shift;
382             my $params = shift;
383              
384             $params->{$_} = encode_base64( $params->{$_},"") for qw/dst/;
385             $params->{files}->[$_] = encode_base64( $params->{files}->[$_],"") for 0..$#{$params->{files}};
386            
387             $self->$orig($params);
388             };
389              
390             fbx_api_method rm => (
391             description => <<'',
392             Delete files.
393              
394             path => "fs/rm/",
395             method => 'POST',
396             params => [ qw/files/ ],
397             required => [ qw/files/ ],
398             );
399              
400             around [qw/rm cat/] => sub {
401             my $orig = shift;
402             my $self = shift;
403             my $params = shift;
404              
405             $params->{files}->[$_] = encode_base64( $params->{files}->[$_],"") for 0..$#{$params->{files}};
406            
407             $self->$orig($params);
408             };
409              
410             fbx_api_method cat => (
411             description => <<'',
412             Cat files.
413              
414             path => "fs/cat/",
415             method => 'POST',
416             params => [ qw/files dst multi_volumes delete_files overwrite append/ ],
417             required => [ qw/files dst/ ],
418             );
419              
420             fbx_api_method extract => (
421             description => <<'',
422             Extract archive.
423              
424             path => "fs/extract/",
425             method => 'POST',
426             params => [ qw/src dst password delete_archive overwrite/ ],
427             required => [ qw/src dst password delete_archive overwrite/ ],
428             );
429              
430             around [qw/extract/] => sub {
431             my $orig = shift;
432             my $self = shift;
433             my $params = shift;
434              
435             $params->{$_} = encode_base64( $params->{$_},"") for qw/src dst/;
436             $self->$orig($params);
437             };
438              
439             fbx_api_method repair => (
440             description => <<'',
441             Repair file.
442              
443             path => "fs/repair/",
444             method => 'POST',
445             params => [ qw/src delete_archive / ],
446             required => [ qw/src delete_archive/ ],
447             );
448              
449             fbx_api_method hash => (
450             description => <<'',
451             Repair file.
452              
453             path => "fs/hash/",
454             method => 'POST',
455             params => [ qw/src hash_type/ ],
456             required => [ qw/src hash_type/ ],
457             );
458              
459             around [qw/repair hash rename/] => sub {
460             my $orig = shift;
461             my $self = shift;
462             my $params = shift;
463              
464             $params->{$_} = encode_base64( $params->{$_},"") for qw/src/;
465             $self->$orig($params);
466             };
467              
468             fbx_api_method mkdir => (
469             description => <<'',
470             Create directory.
471              
472             path => "fs/mkdir/",
473             method => 'POST',
474             params => [ qw/parent dirname/ ],
475             required => [ qw/parent dirname/ ],
476             );
477              
478             around [qw/mkdir/] => sub {
479             my $orig = shift;
480             my $self = shift;
481             my $params = shift;
482              
483             $params->{$_} = encode_base64( $params->{$_},"") for qw/parent/;
484             $self->$orig($params);
485             };
486              
487             fbx_api_method rename => (
488             description => <<'',
489             Rename file or directory.
490              
491             path => "fs/rename/",
492             method => 'POST',
493             params => [ qw/src dst/ ],
494             required => [ qw/src dst/ ],
495             );
496              
497             fbx_api_method download_file => (
498             description => <<'',
499             Download a file.
500              
501             path => "dl/",
502             method => 'GET',
503             params => [ qw/suff/ ],
504             required => [ qw/suff/ ],
505             );
506              
507             around download_file => sub {
508             my $orig = shift;
509             my $self = shift;
510             my $params = shift;
511              
512             $params = encode_base64( $params, "") if $params;
513              
514             my $res = $self->$orig($params);
515             if ($res->{filename} and $res->{content}) {
516             open my $f, ">", $res->{filename} or die "Can't create file $res->{filename} : $!";
517             print $f $res->{content};
518             close $f;
519             }
520              
521             $res;
522             };
523              
524             #Share
525             fbx_api_method s'/'_'gr => (
526             description => <<'',
527             Global share getters.
528              
529             path => $_,
530             method => 'GET',
531             params => [ ],
532             required => [ ],
533             ) for qw(share_link/);
534              
535             #Upload
536             fbx_api_method s'/'_'gr => (
537             description => <<'',
538             Global upload getters.
539              
540             path => $_,
541             method => 'GET',
542             params => [ qw/suff/ ],
543             required => [ ],
544             ) for qw(upload/);
545              
546             fbx_api_method upload_auth => (
547             description => <<'',
548             Upload auth.
549              
550             path => "upload/",
551             method => 'POST',
552             params => [ qw/dirname upload_name/ ],
553             required => [ qw/dirname upload_name/],
554             );
555              
556             around upload_auth => sub {
557             my $orig = shift;
558             my $self = shift;
559              
560             if (@_) {
561             my $params = $_[0];
562             $params->{dirname} = encode_base64( $params->{dirname}, "") if exists $params->{dirname} and $params->{dirname};
563             }
564              
565             $self->$orig(@_);
566             };
567              
568             fbx_api_method upload_file => (
569             description => <<'',
570             Upload file.
571              
572             path => "upload/",
573             method => 'POST',
574             params => [ qw/id suff dirname name/ ],
575             required => [ qw/name suff/],
576             content_type => 'form-data',
577             );
578              
579             #if user provided an id, use this one otherwise request one (in that case dirname and upload_name have to be provided)
580             around upload_file => sub {
581             my $orig = shift;
582             my $self = shift;
583             my $params = $_[0];
584             my $id;
585             my $filename;
586              
587             if ($params and exists $params->{filename} and $params->{filename}) {
588             $filename = delete $params->{filename};
589             if (exists $params->{id}) {
590             $id = delete $params->{id};
591             } else {
592             $params->{upload_name} = $filename
593             unless exists $params->{upload_name};
594             my $res = $self->upload_auth(@_);
595             delete $params->{dirname};
596             delete $params->{upload_name};
597             $id = $res->{id};
598             }
599             $params->{name} = [ $filename ];
600             $params->{suff} = "$id/send";
601             }
602             $self->$orig(@_);
603             };
604              
605             fbx_api_method s'/'_'gr => (
606             description => <<'',
607             Delete downloads.
608              
609             path => $_,
610             method => 'DELETE',
611             params => [ ],
612             required => [ ],
613             ) for qw(upload/clean);
614              
615             #AirMedia
616             fbx_api_method s'/'_'gr => (
617             description => <<'',
618             Global airmedia getters.
619              
620             path => $_,
621             method => 'GET',
622             params => [ ],
623             required => [ ],
624             ) for qw(airmedia/config airmedia/receivers/);
625              
626             #RRD
627             fbx_api_method rrd => (
628             description => <<'',
629             Get the RRD stats.
630              
631             path => 'rrd/',
632             method => 'POST',
633             params => [qw/db date_start date_end precision fields/],
634             required => [qw/db/],
635             );
636              
637             #CALL
638             fbx_api_method s'/'_'gr => (
639             description => <<'',
640             Global call getters.
641              
642             path => $_,
643             method => 'GET',
644             params => [ qw/suff/ ],
645             required => [ ],
646             ) for qw(call/log/);
647              
648             #CONTACTS
649             fbx_api_method s'/'_'gr => (
650             description => <<'',
651             Global contacts getters.
652              
653             path => $_,
654             method => 'GET',
655             params => [ ],
656             required => [ ],
657             ) for qw(contact/);
658              
659             #CONNECTION
660             fbx_api_method s'/'_'gr => (
661             description => <<'',
662             Global Connection getters.
663              
664             path => $_,
665             method => 'GET',
666             params => [],
667             required => [],
668             ) for qw(connection connection/config connection/ipv6/config connection/xdsl/ connection/ftth);
669              
670             fbx_api_method upd_connection => (
671             description => <<'',
672             Update the connection configuration.
673              
674             path => 'connection/config/',
675             method => 'PUT',
676             params => [qw/ping remote_access remote_access_port wol adblock allow_token_request/],
677             required => [qw//],
678             );
679              
680             fbx_api_method upd_ipv6_config => (
681             description => <<'',
682             Update the ipv6 connection configuration.
683              
684             path => 'connection/ipv6/config/',
685             method => 'PUT',
686             params => [qw/ ipv6_enabled delegations/],
687             required => [qw//],
688             );
689              
690             fbx_api_method connection_dyndns => (
691             description => <<'',
692             Get status or config of dyndns provider.
693              
694             path => 'connection/ddns/',
695             method => 'GET',
696             params => [qw/suff/],
697             required => [qw/suff/],
698             );
699              
700             fbx_api_method upd_connection_dyndns => (
701             description => <<'',
702             Set config of dyndns provider.
703              
704             path => 'connection/ddns/',
705             method => 'GET',
706             params => [qw/suff enabled user password hostname/],
707             required => [qw/suff/],
708             );
709              
710             #LAN
711             fbx_api_method s'/'_'gr => (
712             description => <<'',
713             Global Lan getters.
714              
715             path => $_,
716             method => 'GET',
717             params => [],
718             required => [],
719             ) for qw(lan/config lan/browser/interfaces);
720              
721             fbx_api_method upd_lan_config => (
722             description => <<'',
723             Update lan config.
724              
725             path => 'lan/config/',
726             method => 'PUT',
727             params => [ qw/mode ip name name_dns name_mdns name_netbios/ ],
728             required => [ qw// ],
729             );
730              
731             fbx_api_method list_hosts => (
732             description => <<'',
733             Get the list of hosts on a given interface.
734              
735             path => 'lan/browser/',
736             method => 'GET',
737             params => [ qw/suff/ ],
738             required => [ qw/suff/ ],
739             );
740              
741             fbx_api_method upd_host => (
742             description => <<'',
743             Update a host config.
744              
745             path => 'lan/browser/',
746             method => 'PUT',
747             params => [ qw/suff id primary_name host_type persistent / ],
748             required => [ qw/suff id/ ],
749             );
750              
751             fbx_api_method wol_host => (
752             description => <<'',
753             Send a WoL.
754              
755             path => 'lan/wol/',
756             method => 'POST',
757             params => [ qw/suff mac password/ ],
758             required => [ qw/suff mac/ ],
759             );
760              
761             #Freeplugs
762             fbx_api_method freeplugs_net => (
763             description => <<'',
764             Get freeplugs networks and information.
765              
766             path => 'freeplug/',
767             method => 'GET',
768             params => [ qw/suff/ ],
769             required => [ ],
770             );
771              
772             fbx_api_method reset_freeplug => (
773             description => <<'',
774             Reset a freeplug.
775              
776             path => 'freeplug/',
777             method => 'POST',
778             params => [ qw/suff/ ],
779             required => [ qw/suff/ ],
780             );
781              
782             #DHCP
783             fbx_api_method s'/'_'gr => (
784             description => <<'',
785             Global DHCP getters.
786              
787             path => $_,
788             method => 'GET',
789             params => [ ],
790             required => [ ],
791             ) for qw(dhcp/config dhcp/static_lease dhcp/dynamic_lease);
792             #TODO finish
793              
794             #FTP
795              
796             fbx_api_method ftp_config => (
797             description => <<'',
798             Get the FTP config.
799              
800             path => 'ftp/config/',
801             method => 'GET',
802             params => [ ],
803             required => [ ],
804             );
805              
806             fbx_api_method set_ftp_config => (
807             description => <<'',
808             Set the FTP config.
809              
810             path => 'ftp/config',
811             method => 'PUT',
812             params => [ qw/enabled allow_anonymous allow_anonymous_write password/ ],
813             required => [ ],
814             );
815              
816             #NAT
817             fbx_api_method fw_dmz => (
818             description => <<'',
819             Get dmz config.
820              
821             path => "fw/dmz/",
822             method => 'GET',
823             params => [ ],
824             required => [ ],
825             );
826              
827             fbx_api_method s'/'_'gr => (
828             description => <<'',
829             Global NAT getters.
830              
831             path => $_,
832             method => 'GET',
833             params => [ qw/suff/ ],
834             required => [ qw/suff/ ],
835             ) for qw(fw/redir/ fw/incoming/);
836             #TODO rest
837              
838             #UPNP
839             fbx_api_method s'/'_'gr => (
840             description => <<'',
841             Global UPNP getters.
842              
843             path => $_,
844             method => 'GET',
845             params => [ ],
846             required => [ ],
847             ) for qw(upnpigd/config upnpigd/redir/);
848             #TODO rest
849              
850             #LCD
851             fbx_api_method lcd => (
852             description => <<'',
853             Get the LCD config.
854              
855             path => 'lcd/config/',
856             method => 'GET',
857             params => [ ],
858             required => [ ],
859             );
860             fbx_api_method set_lcd => (
861             description => <<'',
862             Set the LCD config.
863              
864             path => 'lcd/config/',
865             method => 'PUT',
866             params => [ qw/brightness orientation orientation_forced/ ],
867             required => [ ],
868             );
869              
870             #SHARES
871             fbx_api_method s'/'_'gr => (
872             description => <<'',
873             Global Network Shares getters.
874              
875             path => $_,
876             method => 'GET',
877             params => [ ],
878             required => [ ],
879             ) for qw(netshare/samba netshare/afp);
880             #TODO rest
881              
882             #UPNPAV
883             fbx_api_method upnpav => (
884             description => <<'',
885             Get the UPNPAV config.
886              
887             path => 'upnpav/config',
888             method => 'GET',
889             params => [ ],
890             required => [ ],
891             );
892             fbx_api_method set_upnpav => (
893             description => <<'',
894             Set the UPNPAV config.
895              
896             path => 'upnpav/config',
897             method => 'PUT',
898             params => [ qw/enabled/],
899             required => [ qw/enabled/],
900             );
901              
902             #SWITCH
903             fbx_api_method switch_sts => (
904             description => <<'',
905             Get the switch status.
906              
907             path => 'switch/status/',
908             method => 'GET',
909             params => [ ],
910             required => [ ],
911             );
912              
913             fbx_api_method switch_port => (
914             description => <<'',
915             Get the switch port config and status.
916              
917             path => 'switch/port/',
918             method => 'GET',
919             params => [ qw/suff/ ],
920             required => [ qw/suff/ ],
921             );
922              
923             fbx_api_method set_switch_port => (
924             description => <<'',
925             Update a port config.
926              
927             path => 'switch/port/',
928             method => 'PUT',
929             params => [ qw/suff duplex speed/ ],
930             required => [ qw/suff/ ],
931             );
932              
933             #wifi
934             fbx_api_method s'/'_'gr => (
935             description => <<'',
936             Global Wifi getters.
937              
938             path => $_,
939             method => 'GET',
940             params => [ ],
941             required => [ ],
942             ) for qw(wifi/config wifi/planning wifi/mac_filter);
943              
944             fbx_api_method s'/'_'gr => (
945             description => <<'',
946             Wifi AP and bss configuration.
947              
948             path => $_,
949             method => 'GET',
950             params => [ qw/suff/ ],
951             required => [ qw/suff/ ],
952             ) for qw( wifi/ap/ wifi/bss/ );
953              
954             #TODO finish
955              
956             #System
957             fbx_api_method system => (
958             description => <<'',
959             Get the system info.
960              
961             path => 'system',
962             method => 'GET',
963             params => [ ],
964             required => [ ],
965             );
966              
967             fbx_api_method reboot => (
968             description => <<'',
969             Reboot the system.
970              
971             path => 'system/reboot',
972             method => 'POST',
973             params => [ ],
974             required => [ ],
975             );
976              
977             #VPN server
978             fbx_api_method s'/'_'gr => (
979             description => <<'',
980             Global VPN server getters.
981              
982             path => $_,
983             method => 'GET',
984             params => [ ],
985             required => [ ],
986             ) for qw(vpn/ vpn/user/ vpn/ip_pool/);
987              
988             #VPN client
989             fbx_api_method s'/'_'gr => (
990             description => <<'',
991             Global VPN client getters.
992              
993             path => $_,
994             method => 'GET',
995             params => [ ],
996             required => [ ],
997             ) for qw(vpn_client/config/ vpn_client/status vpn_client/log);
998             #TODO finish
999              
1000             #Storage
1001             fbx_api_method s'/'_'gr => (
1002             description => <<'',
1003             Global storage getters.
1004              
1005             path => $_,
1006             method => 'GET',
1007             params => [ ],
1008             required => [ ],
1009             ) for qw(storage/disk/ storage/partition/);
1010             #TODO finish
1011              
1012             #Parental
1013             fbx_api_method s'/'_'gr => (
1014             description => <<'',
1015             Global parental getters.
1016              
1017             path => $_,
1018             method => 'GET',
1019             params => [ ],
1020             required => [ ],
1021             ) for qw(parental/config/ parental/filter/);
1022             #TODO finish
1023              
1024             1;
1025             __END__
1026              
1027             =encoding utf-8
1028              
1029             =head1 NAME
1030              
1031             WWW::FBX::Role::API::APIv3 - Freebox API v3
1032              
1033             =head1 SYNOPSIS
1034              
1035             with 'WWW::FBX::Role::API::APIv3';
1036              
1037             =head1 DESCRIPTION
1038              
1039             WWW::FBX::Role::API::APIv3 is the freebox6 API version 3 as a Moose Role
1040              
1041             =head1 API
1042              
1043             API documentation is given here: L<http://dev.freebox.fr/sdk/os/>
1044             The following methods are currently implemented in this library:
1045              
1046             =head2 RRD
1047              
1048             =head3 get rrd stats
1049              
1050             $fbx->rrd( { db => "temp", fields => [ "cpub" ], precision => 1 } );
1051              
1052             =head2 call and contacts
1053              
1054             =head3 call log
1055              
1056             $fbx->call_log;
1057              
1058             =head3 contact
1059              
1060             $fbx->contact;
1061              
1062             =head2 connection
1063              
1064             =head3 connection
1065              
1066             $res = $fbx->connection;
1067              
1068             =head3 connection config
1069              
1070             $res = $fbx->connection_config;
1071              
1072             =head3 connection ipv6 config
1073              
1074             $fbx->connection_ipv6_config;
1075              
1076             =head3 connection xdsl
1077              
1078             $fbx->connection_xdsl;
1079              
1080             =head3 connection ftth
1081              
1082             $fbx->connection_ftth;
1083              
1084             =head3 update connection config
1085              
1086             $res = $fbx->upd_connection({ping=>\1});
1087              
1088             =head3 update connection ipv6 config
1089              
1090             $res = $fbx->upd_ipv6_config({ipv6_enabled=>\0});
1091              
1092             =head3 connection dyndns noip
1093              
1094             $res = $fbx->connection_dyndns("noip/status");
1095              
1096             =head3 connection dyndns noip
1097              
1098             $res = $fbx->upd_connection_dyndns("noip/status", {enabled=>\0});
1099              
1100             =head2 dhcp
1101              
1102             =head3 dhcp config
1103              
1104             $fbx->dhcp_config;
1105              
1106             =head3 dhcp static lease
1107              
1108             $fbx->dhcp_static_lease;
1109              
1110             =head3 dhcp dynamic lease
1111              
1112             $fbx->dhcp_dynamic_lease;
1113              
1114             =head2 download
1115              
1116             =head3 downloads
1117              
1118             $fbx->downloads;
1119              
1120             =head3 downloads config
1121              
1122             $fbx->downloads_config;
1123              
1124             =head3 downloads stats
1125              
1126             $fbx->downloads_stats;
1127              
1128             =head3 download feeds
1129              
1130             $fbx->downloads_feeds;
1131              
1132             =head3 downloads config
1133              
1134             $res = $fbx->downloads_config;
1135              
1136             =head3 download tasks
1137              
1138             $res = $fbx->get_download_task;
1139              
1140             =head3 download add
1141              
1142             $res = $fbx->add_download_task( { download_url => "http://cdimage.debian.org/debian-cd/current/arm64/bt-cd/debian-8.4.0-arm64-CD-1.iso.torrent"} );
1143              
1144             =head3 update downloads config
1145              
1146             $res = $fbx->upd_downloads_config({max_downloading_tasks => $max_dl_tasks});
1147              
1148             =head3 update throttling
1149              
1150             $res = $fbx->upd_downloads_throttle( "schedule" );
1151              
1152             =head3 download tasks
1153              
1154             $res = $fbx->get_download_task;
1155              
1156             =head3 download task
1157              
1158             $res = $fbx->get_download_task( $id );
1159              
1160             =head3 download task log
1161              
1162             $res = $fbx->get_download_task( "$id/log" );
1163              
1164             =head3 downloads update
1165              
1166             $fbx->upd_download_task( $id, { io_priority => "high" } );
1167              
1168             =head3 get download task files
1169              
1170             $res = $fbx->get_download_task("$id/files") ;
1171              
1172             =head3 update priority of download file
1173              
1174             $res = $fbx->change_prio_download_file( "$id/files/$id_file", { priority=>"high"} );
1175              
1176             =head3 downloads task del
1177              
1178             $res = $fbx->del_download_task( $id );
1179              
1180             =head3 download add by local file
1181              
1182             $res = $fbx->add_download_task_file( {download_file => [ "mine/debian-8.4.0-arm64-netinst.iso.torrent" ] });
1183              
1184             =head3 download tracker
1185              
1186             $res = $fbx->get_download_task( "$id/trackers");
1187              
1188             =head3 download peers
1189              
1190             $res = $fbx->get_download_task( "$id/peers");
1191              
1192             =head3 downloads task del with file erase
1193              
1194             $fbx->del_download_task( "$id/erase" );
1195              
1196             =head3 download feed
1197              
1198             $res = $fbx->downloads_feeds;
1199              
1200             =head3 add feed
1201              
1202             $res = $fbx->add_feed( "http://www.esa.int/rssfeed/Our_Activities/Space_News" );
1203              
1204             =head3 update feed
1205              
1206             $fbx->upd_feed( $id , {auto_download=> \1} );
1207              
1208             =head3 download feed
1209              
1210             $res = $fbx->downloads_feeds("$id/items");
1211              
1212             =head3 refresh feed
1213              
1214             $fbx->refresh_feed( "$id/fetch" );
1215              
1216             =head3 refresh all feeds
1217              
1218             $fbx->refresh_feeds;
1219              
1220             =head3 download feed items
1221              
1222             $fbx->downloads_feeds("$id/items");
1223              
1224             =head3 update a feed item
1225              
1226             $fbx->upd_feed("$id/items/$id_file");
1227              
1228             =head3 download a feed item
1229              
1230             $fbx->download_feed_item("$id/items/$id_file/download");
1231              
1232             =head3 mark all items as read
1233              
1234             $fbx->mark_all_read( "$id/items/mark_all_as_read" );
1235              
1236             =head3 del feed
1237              
1238             $fbx->del_feed( $id );
1239              
1240             =head3 download file to disk
1241              
1242             $res = $fbx->download_file( "Disque dur/Photos/cyril/DSCF4322.JPG" );
1243              
1244             =head3 download file to disk
1245              
1246             $res = $fbx->download_file( "Disque dur/Photos/cyril/DSCF4321.JPG" );
1247              
1248             =head3 get upload id
1249              
1250             $res = $fbx->upload_auth( {upload_name => "DSCF4322.JPG", dirname => "/Disque dur/"} );
1251              
1252             =head3 upload file by upload id
1253              
1254             $res = $fbx->upload_file( {id=> $res->{id}, filename=>"DSCF4322.JPG"});
1255              
1256             =head3 upload file directly
1257              
1258             $res = $fbx->upload_file( {filename => "DSCF4321.JPG", dirname => "/Disque dur/"} );
1259              
1260             =head2 freeplugs
1261              
1262             =head3 list freeplugs
1263              
1264             $fbx->freeplugs_net;
1265              
1266             =head3 get a particular freeplugs
1267              
1268             $fbx->freeplugs_net("F4:CA:E5:1D:46:AE");
1269              
1270             =head3 reset freeplug
1271              
1272             $fbx->reset_freeplug("F4:CA:E5:1D:46:AE");
1273              
1274             =head2 fs
1275              
1276             =head3 fs tasks
1277              
1278             $fbx->fs_tasks;
1279              
1280             =head3 fs task
1281              
1282             $fbx->fs_tasks(12);
1283              
1284             =head3 del fs task
1285              
1286             $fbx->del_task(12);
1287              
1288             =head3 update fs task
1289              
1290             $fbx->upd_task(12, state=>"paused"});
1291              
1292             =head3 list files
1293              
1294             $res = $fbx->list_files("Disque dur/");
1295              
1296             =head3 file info
1297              
1298             $res = $fbx->file_info("Disque dur/Photos/Sydney/DSCF4323.JPG");
1299              
1300             =head3 file move
1301              
1302             $res = $fbx->mv( {files=>[ qw/a.txt b.txt/ ], dst => "/Disque dur/directory", mode => "overwrite" } );
1303              
1304             =head3 file cp
1305              
1306             $res = $fbx->cp( {files=>[ qw/a.txt b.txt/ ], dst => "/Disque dur/directory", mode => "overwrite" } );
1307              
1308             =head3 file archive
1309              
1310             $res = $fbx->archive( {files=>[ qw/a.txt b.txt/ ], dst => "/Disque dur/archive.zip", mode => "overwrite" } );
1311              
1312             =head3 file rm
1313              
1314             $res = $fbx->rm( {files=>[ qw/a.txt b.txt/ ] } );
1315              
1316             =head3 file cat
1317              
1318             $res = $fbx->cat( {files=>[ qw/a.txt b.txt/ ], dst=>"/Disque dur/file", multi_volumes=\0, delete_files=>\0, append=>\1, overwrite=>\0 } );
1319              
1320             =head3 file extract
1321              
1322             $res = $fbx->cat( { src => "foo.iso", dst=>"/Disque dur/directory", password =>"", delete_archive=>\0, overwrite=>\0 } );
1323              
1324             =head3 file repair
1325              
1326             $res = $fbx->repair( { src => "foo.iso.par2", delete_archive=>\0 } );
1327              
1328             =head3 file hash
1329              
1330             $res = $fbx->hash( { src => "foo.iso", hash_type=>"md5" } );
1331              
1332             =head3 mkdir
1333              
1334             $res = $fbx->mkdir( { parent => "/Disque dur/", dirname => "directory" } );
1335              
1336             =head3 rename
1337              
1338             $res = $fbx->rename( { src => "/Disque dur/a.txt", dst => "b.txt' } );
1339              
1340             =head3 download RAW file not JSON!
1341              
1342             $res = $fbx->download_file("Disque dur/Photos/cyril/DSCF4322.JPG");
1343              
1344             =head2 ftp
1345              
1346             =head3 ftp config
1347              
1348             $fbx->ftp_config;
1349              
1350             =head2 lan
1351              
1352             =head3 lan config
1353              
1354             $res = $fbx->lan_config;
1355              
1356             =head3 lan browser interfaces
1357              
1358             $res = $fbx->lan_browser_interfaces;
1359              
1360             =head3 lan browser interfaces pub
1361              
1362             $res = $fbx->list_hosts( $net );
1363              
1364             =head3 get host information
1365              
1366             $res = $fbx->list_hosts("$net/$id");
1367              
1368             =head3 update host information
1369              
1370             $res = $fbx->upd_host("$net/$id", { id => $id , host_type => "networking_device" });
1371              
1372             =head3 update lan config
1373              
1374             $res = $fbx->upd_lan_config( {mode=>"router"} );
1375              
1376             =head3 send wol
1377              
1378             $res = $fbx->wol_host( $net, {mac => "B8:27:EB:73:8C:4E"} );
1379              
1380             =head2 lcd
1381              
1382             =head3 lcd
1383              
1384             $res = $fbx->lcd;
1385              
1386             =head3 lcd brightness back
1387              
1388             $fbx->set_lcd({ brightness => $res->{brightness} });
1389              
1390             =head2 nat
1391              
1392             =head3 fw dmz
1393              
1394             $fbx->fw_dmz;
1395              
1396             =head3 fw all redir
1397              
1398             $fbx->fw_redir;
1399              
1400             =head3 fw redir
1401              
1402             $fbx->fw_redir(0);
1403              
1404             =head3 fw all incoming
1405              
1406             $fbx->fw_incoming;
1407              
1408             =head3 fw incoming
1409              
1410             $fbx->fw_incoming("bittorent-main");
1411              
1412             =head2 parental
1413              
1414             =head3 parental config
1415              
1416             $fbx->parental_config;
1417              
1418             =head3 parental filter
1419              
1420             $fbx->parental_filter;
1421              
1422             =head2 share
1423              
1424             =head3 share link
1425              
1426             $fbx->share_link;
1427              
1428             =head3 upload status
1429              
1430             $fbx->upload;
1431              
1432             =head3 upload status of a task
1433              
1434             $fbx->upload(1);
1435              
1436             =head3 airmedia config
1437              
1438             $fbx->airmedia_config;
1439              
1440             =head3 airmedia receivers
1441              
1442             $fbx->airmedia_receivers;
1443              
1444             =head2 shares
1445              
1446             =head3 netshare samba
1447              
1448             $res = $fbx->netshare_samba;
1449              
1450             =head3 netshare afp
1451              
1452             $fbx->netshare_afp;
1453              
1454             =head2 storage
1455              
1456             =head3 storage disk
1457              
1458             $fbx->storage_disk;
1459              
1460             =head3 storage partition
1461              
1462             $fbx->storage_partition;
1463              
1464             =head2 switch
1465              
1466             =head3 switch status
1467              
1468             $res = $fbx->switch_sts;
1469              
1470             =head3 switch port config
1471              
1472             $res = $fbx->switch_port(1);
1473              
1474             =head3 switch port stats
1475              
1476             $res = $fbx->switch_port("1/stats/");
1477              
1478             =head3 set switch port config
1479              
1480             $res = $fbx->set_switch_port(1 , {duplex=>"auto"} );
1481              
1482             =head2 system
1483              
1484             =head3 get system info
1485              
1486             $fbx->system;
1487              
1488             =head3 reboot system
1489              
1490             $fbx->reboot;
1491              
1492             =head2 upnp
1493              
1494             =head3 upnpigd config
1495              
1496             $fbx->upnpigd_config;
1497              
1498             =head3 upnpigd redir
1499              
1500             $fbx->upnpigd_redir;
1501              
1502             =head2 upnpav
1503              
1504             =head3 upnpav
1505              
1506             $res=$fbx->upnpav;
1507              
1508             =head3 set upnpav
1509              
1510             $fbx->set_upnpav($res->{enabled});
1511              
1512             =head2 vpn
1513              
1514             =head3 vpn
1515              
1516             $fbx->vpn;
1517              
1518             =head3 vpn user
1519              
1520             $fbx->vpn_user;
1521              
1522             =head3 vpn ip_pool
1523              
1524             $fbx->vpn_ip_pool;
1525              
1526             =head3 vpn client config
1527              
1528             $fbx->vpn_client_config;
1529              
1530             =head3 vpn client status
1531              
1532             $fbx->vpn_client_status;
1533              
1534             =head3 vpn client log
1535              
1536             $fbx->vpn_client_log;
1537              
1538             =head2 wifi
1539              
1540             =head3 wifi config
1541              
1542             $fbx->wifi_config;
1543              
1544             =head3 wifi ap list
1545              
1546             $fbx->wifi_ap;
1547              
1548             =head3 wifi ap
1549              
1550             $fbx->wifi_ap(0);
1551              
1552             =head3 wifi ap allowed combinations
1553              
1554             $fbx->wifi_ap( "0/allowed_channel_comb" );
1555              
1556             =head3 wifi ap connected stations
1557              
1558             $fbx->wifi_ap( "0/stations" );
1559              
1560             =head3 wifi ap neighbors
1561              
1562             $fbx->wifi_ap( "0/neighbors" );
1563              
1564             =head3 wifi ap channel usage
1565              
1566             $fbx->wifi_ap( "0/channel_usage" );
1567              
1568             =head3 wifi all bss
1569              
1570             $fbx->wifi_bss;
1571              
1572             =head3 wifi of a bss
1573              
1574             $fbx->wifi_bss( "00:24:D4:AA:BB:CC" );
1575              
1576             =head3 wifi planning
1577              
1578             $fbx->wifi_planning;
1579              
1580             =head3 wifi mac filter
1581              
1582             $fbx->wifi_mac_filter;
1583              
1584             =head1 LICENSE
1585              
1586             Copyright (C) Laurent Kislaire.
1587              
1588             This library is free software; you can redistribute it and/or modify
1589             it under the same terms as Perl itself.
1590              
1591             =head1 AUTHOR
1592              
1593             Laurent Kislaire E<lt>teebeenator@gmail.comE<gt>
1594              
1595             =cut
1596