| 1 | package WWW::FBX::Role::API::APIv3; | ||
| 2 | use 5.008001; | ||
| 3 | use Moose::Role; | ||
| 4 | use WWW::FBX::API; | ||
| 5 | use MIME::Base64 qw/encode_base64 decode_base64/; | ||
| 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_prority 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 prority/ ], | ||
| 143 | required => [ qw/suff prority/ ], | ||
| 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/ ], | ||
| 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->{result}{$_} = decode_base64( $params->{result}{$_} ) if exists $params->{result}{$_} and $params->{result}{$_}; | ||
| 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 | |||
| 312 | if (@_) { | ||
| 313 | my $params = $_[0]; | ||
| 314 | $params->{suff} = encode_base64( $params->{suff}, "") if exists $params->{suff} and $params->{suff}; | ||
| 315 | } | ||
| 316 | |||
| 317 | my $res = $self->$orig(@_); | ||
| 318 | for my $i ( 0.. $#{$res->{result}} ) { | ||
| 319 | $res->{result}->[$i]{path} = decode_base64( $res->{result}[$i]{path} ); | ||
| 320 | } | ||
| 321 | |||
| 322 | $res; | ||
| 323 | }; | ||
| 324 | |||
| 325 | fbx_api_method file_info => ( | ||
| 326 | description => <<'', | ||
| 327 | Get file information. | ||
| 328 | |||
| 329 | path => "fs/info/", | ||
| 330 | method => 'GET', | ||
| 331 | params => [ qw/suff/ ], | ||
| 332 | required => [ qw/suff/ ], | ||
| 333 | ); | ||
| 334 | |||
| 335 | around file_info => sub { | ||
| 336 | my $orig = shift; | ||
| 337 | my $self = shift; | ||
| 338 | |||
| 339 | if (@_) { | ||
| 340 | my $params = $_[0]; | ||
| 341 | $params->{suff} = encode_base64( $params->{suff}, "") if exists $params->{suff} and $params->{suff}; | ||
| 342 | } | ||
| 343 | |||
| 344 | my $params = $self->$orig(@_); | ||
| 345 | |||
| 346 | for (qw/parent target path/) { | ||
| 347 | $params->{result}{$_} = decode_base64( $params->{result}{$_} ) if exists $params->{result}{$_} and $params->{result}{$_}; | ||
| 348 | } | ||
| 349 | |||
| 350 | $params; | ||
| 351 | }; | ||
| 352 | |||
| 353 | #TODO mv, cp, rm, cat, archive, extract, repair, hash, mkdir, rename | ||
| 354 | |||
| 355 | fbx_api_method download_file => ( | ||
| 356 | description => <<'', | ||
| 357 | Download a file. | ||
| 358 | |||
| 359 | path => "dl/", | ||
| 360 | method => 'GET', | ||
| 361 | params => [ qw/suff/ ], | ||
| 362 | required => [ qw/suff/ ], | ||
| 363 | ); | ||
| 364 | |||
| 365 | around download_file => sub { | ||
| 366 | my $orig = shift; | ||
| 367 | my $self = shift; | ||
| 368 | |||
| 369 | if (@_) { | ||
| 370 | my $params = $_[0]; | ||
| 371 | $params->{suff} = encode_base64( $params->{suff}, "") if exists $params->{suff} and $params->{suff}; | ||
| 372 | } | ||
| 373 | |||
| 374 | $self->$orig(@_)->{content}; | ||
| 375 | }; | ||
| 376 | |||
| 377 | #Share | ||
| 378 | fbx_api_method s'/'_'gr => ( | ||
| 379 | description => <<'', | ||
| 380 | Global share getters. | ||
| 381 | |||
| 382 | path => $_, | ||
| 383 | method => 'GET', | ||
| 384 | params => [ ], | ||
| 385 | required => [ ], | ||
| 386 | ) for qw(share_link/); | ||
| 387 | |||
| 388 | #Upload | ||
| 389 | fbx_api_method s'/'_'gr => ( | ||
| 390 | description => <<'', | ||
| 391 | Global upload getters. | ||
| 392 | |||
| 393 | path => $_, | ||
| 394 | method => 'GET', | ||
| 395 | params => [ ], | ||
| 396 | required => [ ], | ||
| 397 | ) for qw(upload/); | ||
| 398 | |||
| 399 | #AirMedia | ||
| 400 | fbx_api_method s'/'_'gr => ( | ||
| 401 | description => <<'', | ||
| 402 | Global airmedia getters. | ||
| 403 | |||
| 404 | path => $_, | ||
| 405 | method => 'GET', | ||
| 406 | params => [ ], | ||
| 407 | required => [ ], | ||
| 408 | ) for qw(airmedia/config airmedia/receivers/); | ||
| 409 | |||
| 410 | #RRD | ||
| 411 | |||
| 412 | #CALL | ||
| 413 | fbx_api_method s'/'_'gr => ( | ||
| 414 | description => <<'', | ||
| 415 | Global call getters. | ||
| 416 | |||
| 417 | path => $_, | ||
| 418 | method => 'GET', | ||
| 419 | params => [ ], | ||
| 420 | required => [ ], | ||
| 421 | ) for qw(call/log/); | ||
| 422 | |||
| 423 | #CONTACTS | ||
| 424 | fbx_api_method s'/'_'gr => ( | ||
| 425 | description => <<'', | ||
| 426 | Global contacts getters. | ||
| 427 | |||
| 428 | path => $_, | ||
| 429 | method => 'GET', | ||
| 430 | params => [ ], | ||
| 431 | required => [ ], | ||
| 432 | ) for qw(contact/); | ||
| 433 | |||
| 434 | #CONNECTION | ||
| 435 | fbx_api_method s'/'_'gr => ( | ||
| 436 | description => <<'', | ||
| 437 | Global Connection getters. | ||
| 438 | |||
| 439 | path => $_, | ||
| 440 | method => 'GET', | ||
| 441 | params => [], | ||
| 442 | required => [], | ||
| 443 | ) for qw(connection connection/config connection/ipv6/config connection/xdsl/ connection/ftth); | ||
| 444 | |||
| 445 | fbx_api_method connection_dyndns => ( | ||
| 446 | description => <<'', | ||
| 447 | Get status or config of dyndns provider. | ||
| 448 | |||
| 449 | path => 'connection/ddns/', | ||
| 450 | method => 'GET', | ||
| 451 | params => [qw/suff/], | ||
| 452 | required => [qw/suff/], | ||
| 453 | ); | ||
| 454 | |||
| 455 | #LAN | ||
| 456 | fbx_api_method s'/'_'gr => ( | ||
| 457 | description => <<'', | ||
| 458 | Global Lan getters. | ||
| 459 | |||
| 460 | path => $_, | ||
| 461 | method => 'GET', | ||
| 462 | params => [], | ||
| 463 | required => [], | ||
| 464 | ) for qw(lan/config lan/browser/interfaces); | ||
| 465 | |||
| 466 | fbx_api_method list_hosts => ( | ||
| 467 | description => <<'', | ||
| 468 | Get the list of hosts on a given interface. | ||
| 469 | |||
| 470 | path => 'lan/browser/', | ||
| 471 | method => 'GET', | ||
| 472 | params => [ qw/suff/ ], | ||
| 473 | required => [ qw/suff/ ], | ||
| 474 | ); | ||
| 475 | |||
| 476 | #Freeplugs | ||
| 477 | fbx_api_method freeplugs_net => ( | ||
| 478 | description => <<'', | ||
| 479 | Get freeplugs networks and information. | ||
| 480 | |||
| 481 | path => 'freeplug/', | ||
| 482 | method => 'GET', | ||
| 483 | params => [ qw/suff/ ], | ||
| 484 | required => [ ], | ||
| 485 | ); | ||
| 486 | |||
| 487 | fbx_api_method reset_freeplug => ( | ||
| 488 | description => <<'', | ||
| 489 | Reset a freeplug. | ||
| 490 | |||
| 491 | path => 'freeplug/', | ||
| 492 | method => 'POST', | ||
| 493 | params => [ qw/suff/ ], | ||
| 494 | required => [ qw/suff/ ], | ||
| 495 | ); | ||
| 496 | |||
| 497 | #DHCP | ||
| 498 | fbx_api_method s'/'_'gr => ( | ||
| 499 | description => <<'', | ||
| 500 | Global DHCP getters. | ||
| 501 | |||
| 502 | path => $_, | ||
| 503 | method => 'GET', | ||
| 504 | params => [ ], | ||
| 505 | required => [ ], | ||
| 506 | ) for qw(dhcp/config dhcp/static_lease dhcp/dynamic_lease); | ||
| 507 | |||
| 508 | #FTP | ||
| 509 | |||
| 510 | fbx_api_method ftp_config => ( | ||
| 511 | description => <<'', | ||
| 512 | Get the FTP config. | ||
| 513 | |||
| 514 | path => 'ftp/config/', | ||
| 515 | method => 'GET', | ||
| 516 | params => [ ], | ||
| 517 | required => [ ], | ||
| 518 | ); | ||
| 519 | |||
| 520 | fbx_api_method set_ftp_config => ( | ||
| 521 | description => <<'', | ||
| 522 | Set the FTP config. | ||
| 523 | |||
| 524 | path => 'ftp/config', | ||
| 525 | method => 'PUT', | ||
| 526 | params => [ qw/enabled allow_anonymous allow_anonymous_write password/ ], | ||
| 527 | required => [ ], | ||
| 528 | ); | ||
| 529 | |||
| 530 | #NAT | ||
| 531 | fbx_api_method s'/'_'gr => ( | ||
| 532 | description => <<'', | ||
| 533 | Global NAT getters. | ||
| 534 | |||
| 535 | path => $_, | ||
| 536 | method => 'GET', | ||
| 537 | params => [ ], | ||
| 538 | required => [ ], | ||
| 539 | ) for qw(fw/dmz fw/redir/ fw/incoming/); | ||
| 540 | |||
| 541 | #UPNP | ||
| 542 | fbx_api_method s'/'_'gr => ( | ||
| 543 | description => <<'', | ||
| 544 | Global UPNP getters. | ||
| 545 | |||
| 546 | path => $_, | ||
| 547 | method => 'GET', | ||
| 548 | params => [ ], | ||
| 549 | required => [ ], | ||
| 550 | ) for qw(upnpigd/config upnpigd/redir/); | ||
| 551 | |||
| 552 | #LCD | ||
| 553 | fbx_api_method lcd => ( | ||
| 554 | description => <<'', | ||
| 555 | Get the LCD config. | ||
| 556 | |||
| 557 | path => 'lcd/config/', | ||
| 558 | method => 'GET', | ||
| 559 | params => [ ], | ||
| 560 | required => [ ], | ||
| 561 | ); | ||
| 562 | fbx_api_method set_lcd => ( | ||
| 563 | description => <<'', | ||
| 564 | Set the LCD config. | ||
| 565 | |||
| 566 | path => 'lcd/config/', | ||
| 567 | method => 'PUT', | ||
| 568 | params => [ qw/brightness orientation orientation_forced/ ], | ||
| 569 | required => [ ], | ||
| 570 | ); | ||
| 571 | |||
| 572 | #SHARES | ||
| 573 | fbx_api_method s'/'_'gr => ( | ||
| 574 | description => <<'', | ||
| 575 | Global Network Shares getters. | ||
| 576 | |||
| 577 | path => $_, | ||
| 578 | method => 'GET', | ||
| 579 | params => [ ], | ||
| 580 | required => [ ], | ||
| 581 | ) for qw(netshare/samba netshare/afp); | ||
| 582 | |||
| 583 | #UPNPAV | ||
| 584 | fbx_api_method upnpav => ( | ||
| 585 | description => <<'', | ||
| 586 | Get the UPNPAV config. | ||
| 587 | |||
| 588 | path => 'upnpav/config', | ||
| 589 | method => 'GET', | ||
| 590 | params => [ ], | ||
| 591 | required => [ ], | ||
| 592 | ); | ||
| 593 | fbx_api_method set_upnpav => ( | ||
| 594 | description => <<'', | ||
| 595 | Set the UPNPAV config. | ||
| 596 | |||
| 597 | path => 'upnpav/config', | ||
| 598 | method => 'PUT', | ||
| 599 | params => [ qw/enabled/], | ||
| 600 | required => [ qw/enabled/], | ||
| 601 | ); | ||
| 602 | |||
| 603 | #SWITCH | ||
| 604 | fbx_api_method switch_sts => ( | ||
| 605 | description => <<'', | ||
| 606 | Get the switch status. | ||
| 607 | |||
| 608 | path => 'switch/status/', | ||
| 609 | method => 'GET', | ||
| 610 | params => [ ], | ||
| 611 | required => [ ], | ||
| 612 | ); | ||
| 613 | |||
| 614 | #wifi | ||
| 615 | fbx_api_method s'/'_'gr => ( | ||
| 616 | description => <<'', | ||
| 617 | Global Wifi getters. | ||
| 618 | |||
| 619 | path => $_, | ||
| 620 | method => 'GET', | ||
| 621 | params => [ ], | ||
| 622 | required => [ ], | ||
| 623 | ) for qw(wifi/config wifi/ap wifi/bss wifi/planning wifi/mac_filter); | ||
| 624 | |||
| 625 | #System | ||
| 626 | fbx_api_method system => ( | ||
| 627 | description => <<'', | ||
| 628 | Get the system info. | ||
| 629 | |||
| 630 | path => 'system', | ||
| 631 | method => 'GET', | ||
| 632 | params => [ ], | ||
| 633 | required => [ ], | ||
| 634 | ); | ||
| 635 | |||
| 636 | fbx_api_method reboot => ( | ||
| 637 | description => <<'', | ||
| 638 | Reboot the system. | ||
| 639 | |||
| 640 | path => 'system/reboot', | ||
| 641 | method => 'POST', | ||
| 642 | params => [ ], | ||
| 643 | required => [ ], | ||
| 644 | ); | ||
| 645 | |||
| 646 | #VPN server | ||
| 647 | fbx_api_method s'/'_'gr => ( | ||
| 648 | description => <<'', | ||
| 649 | Global VPN server getters. | ||
| 650 | |||
| 651 | path => $_, | ||
| 652 | method => 'GET', | ||
| 653 | params => [ ], | ||
| 654 | required => [ ], | ||
| 655 | ) for qw(vpn/ vpn/user/ vpn/ip_pool/); | ||
| 656 | |||
| 657 | #VPN client | ||
| 658 | fbx_api_method s'/'_'gr => ( | ||
| 659 | description => <<'', | ||
| 660 | Global VPN client getters. | ||
| 661 | |||
| 662 | path => $_, | ||
| 663 | method => 'GET', | ||
| 664 | params => [ ], | ||
| 665 | required => [ ], | ||
| 666 | ) for qw(vpn_client/config/ vpn_client/status vpn_client/log); | ||
| 667 | |||
| 668 | #Storage | ||
| 669 | fbx_api_method s'/'_'gr => ( | ||
| 670 | description => <<'', | ||
| 671 | Global storage getters. | ||
| 672 | |||
| 673 | path => $_, | ||
| 674 | method => 'GET', | ||
| 675 | params => [ ], | ||
| 676 | required => [ ], | ||
| 677 | ) for qw(storage/disk/ storage/partition/); | ||
| 678 | |||
| 679 | #Parental | ||
| 680 | fbx_api_method s'/'_'gr => ( | ||
| 681 | description => <<'', | ||
| 682 | Global parental getters. | ||
| 683 | |||
| 684 | path => $_, | ||
| 685 | method => 'GET', | ||
| 686 | params => [ ], | ||
| 687 | required => [ ], | ||
| 688 | ) for qw(parental/config/ parental/filter/); | ||
| 689 | |||
| 690 | |||
| 691 | 1; | ||
| 692 | __END__ | ||
| 693 | |||
| 694 | =encoding utf-8 | ||
| 695 | |||
| 696 | =head1 NAME | ||
| 697 | |||
| 698 | WWW::FBX::Role::API::APIv3 - Freebox API v3 | ||
| 699 | |||
| 700 | =head1 SYNOPSIS | ||
| 701 | |||
| 702 | with 'WWW::FBX::Role::API::APIv3'; | ||
| 703 | |||
| 704 | =head1 DESCRIPTION | ||
| 705 | |||
| 706 | WWW::FBX::Role::API::APIv3 is the freebox6 API version 3 as a Moose Role | ||
| 707 | |||
| 708 | =head1 API | ||
| 709 | |||
| 710 | API documentation is given here: L<http://dev.freebox.fr/sdk/os/> | ||
| 711 | The following methods are currently implemented in this library: | ||
| 712 | |||
| 713 | =head2 call | ||
| 714 | |||
| 715 | =head3 call log | ||
| 716 | |||
| 717 | my $res = $fbx->call_log; | ||
| 718 | |||
| 719 | =head3 contact | ||
| 720 | |||
| 721 | my $res = $fbx->contact; | ||
| 722 | |||
| 723 | =head2 connection | ||
| 724 | |||
| 725 | =head3 connection | ||
| 726 | |||
| 727 | my $res = $fbx->connection; | ||
| 728 | |||
| 729 | =head3 connection config | ||
| 730 | |||
| 731 | my $res = $fbx->connection_config; | ||
| 732 | |||
| 733 | =head3 connection ipv6 config | ||
| 734 | |||
| 735 | my $res = $fbx->connection_ipv6_config; | ||
| 736 | |||
| 737 | =head3 connection xdsl | ||
| 738 | |||
| 739 | my $res = $fbx->connection_xdsl; | ||
| 740 | |||
| 741 | =head3 connection ftth | ||
| 742 | |||
| 743 | my $res = $fbx->connection_ftth; | ||
| 744 | |||
| 745 | =head3 connection dyndns noip | ||
| 746 | |||
| 747 | my $res = $fbx->connection_dyndns({suff=>"noip/status"}); | ||
| 748 | |||
| 749 | =head2 dhcp | ||
| 750 | |||
| 751 | =head3 dhcp config | ||
| 752 | |||
| 753 | my $res = $fbx->dhcp_config; | ||
| 754 | |||
| 755 | =head3 dhcp static lease | ||
| 756 | |||
| 757 | my $res = $fbx->dhcp_static_lease; | ||
| 758 | |||
| 759 | =head3 dhcp dynamic lease | ||
| 760 | |||
| 761 | my $res = $fbx->dhcp_dynamic_lease; | ||
| 762 | |||
| 763 | =head2 download | ||
| 764 | |||
| 765 | =head3 downloads | ||
| 766 | |||
| 767 | my $res = $fbx->downloads; | ||
| 768 | |||
| 769 | =head3 download task | ||
| 770 | |||
| 771 | my $res = $fbx->get_download_task( { suff => "0" } ); | ||
| 772 | |||
| 773 | =head3 download task log | ||
| 774 | |||
| 775 | my $res = $fbx->get_download_task( { suff => "0/log" } ); | ||
| 776 | |||
| 777 | =head3 downloads task del | ||
| 778 | |||
| 779 | my $res = $fbx->del_download_task( { suff => "0" } ); | ||
| 780 | |||
| 781 | =head3 downloads task del with file erase | ||
| 782 | |||
| 783 | my $res = $fbx->del_download_task( { suff => "0/erase" } ); | ||
| 784 | |||
| 785 | =head3 downloads update | ||
| 786 | |||
| 787 | my $res = $fbx->upd_download_task( { suff => "0", io_priority => "high" } ); | ||
| 788 | |||
| 789 | =head3 download add | ||
| 790 | |||
| 791 | my $res = $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"} ); | ||
| 792 | |||
| 793 | =head3 download add by local file | ||
| 794 | |||
| 795 | my $res = $res=$fbx->add_download_task_file( {download_file => [ "debian-8.4.0-arm64-netinst.iso.torrent" ] }); | ||
| 796 | |||
| 797 | =head3 update priority of download file | ||
| 798 | |||
| 799 | my $res = $res=$fbx->change_prio_download_file( {suff=>"76/files/76-0", priority=>"high"} ); | ||
| 800 | |||
| 801 | =head3 download tracker | ||
| 802 | |||
| 803 | my $res = $res = $fbx->get_download_task( {suff => "76/trackers"}); | ||
| 804 | |||
| 805 | =head3 download peers | ||
| 806 | |||
| 807 | my $res = $res = $fbx->get_download_task( {suff => "76/peers"}); | ||
| 808 | |||
| 809 | =head3 downloads stats | ||
| 810 | |||
| 811 | my $res = $fbx->downloads_stats; | ||
| 812 | |||
| 813 | =head3 download feeds | ||
| 814 | |||
| 815 | my $res = $fbx->downloads_feeds; | ||
| 816 | |||
| 817 | =head3 download feed | ||
| 818 | |||
| 819 | my $res = $fbx->downloads_feeds( { suff => "1"}; | ||
| 820 | |||
| 821 | =head3 del feed | ||
| 822 | |||
| 823 | my $res = $fbx->del_feed({suff => "1"}); | ||
| 824 | |||
| 825 | =head3 update feed | ||
| 826 | |||
| 827 | my $res = $fbx->upd_feed({suff=>"1", auto_download=> \1}); | ||
| 828 | |||
| 829 | =head3 refresh feed | ||
| 830 | |||
| 831 | my $res = $fbx->refresh_feed({suff=>"1/fetch"}); | ||
| 832 | |||
| 833 | =head3 refresh all feeds | ||
| 834 | |||
| 835 | my $res = $fbx->refresh_feeds; | ||
| 836 | |||
| 837 | =head3 download feed items | ||
| 838 | |||
| 839 | my $res = $fbx->downloads_feeds({suff=>"1/items"}; | ||
| 840 | |||
| 841 | =head3 update a feed item | ||
| 842 | |||
| 843 | my $res = $fbx->upd_feed({suff=>"1/items/6"}; | ||
| 844 | |||
| 845 | =head3 download a feed item | ||
| 846 | |||
| 847 | my $res = $fbx->download_feed_item({suff=>"1/items/6/download"}; | ||
| 848 | |||
| 849 | =head3 mark all items as read | ||
| 850 | |||
| 851 | my $res = $fbx->mark_all_read({suff=>"1/items/mark_all_as_read"}; | ||
| 852 | |||
| 853 | =head3 add feed | ||
| 854 | |||
| 855 | my $res = $res = $fbx->add_feed({url=>"http://www.nzb-rss.com/rss/Debian-unstable.rss"}); | ||
| 856 | |||
| 857 | =head3 update downloads config | ||
| 858 | |||
| 859 | my $res = $res = $fbx->upd_downloads_config({max_downloading_tasks => 6, download_dir=>"/Disque dur/Téléchargements/"}); | ||
| 860 | |||
| 861 | =head3 update throttling | ||
| 862 | |||
| 863 | my $res = $res = $fbx->upd_downloads_throttle({throttling => "schedule"}); | ||
| 864 | |||
| 865 | =head3 downloads config | ||
| 866 | |||
| 867 | my $res = $fbx->downloads_config; | ||
| 868 | |||
| 869 | =head2 freeplugs | ||
| 870 | |||
| 871 | =head3 freeplugs_net | ||
| 872 | |||
| 873 | my $res = $fbx->freeplugs_net; | ||
| 874 | |||
| 875 | =head2 fs | ||
| 876 | |||
| 877 | =head3 fs tasks | ||
| 878 | |||
| 879 | my $res = $fbx->fs_tasks; | ||
| 880 | |||
| 881 | =head3 fs task | ||
| 882 | |||
| 883 | my $res = $fbx->fs_tasks({suff=>"12"}); | ||
| 884 | |||
| 885 | =head3 fs task | ||
| 886 | |||
| 887 | my $res = $fbx->upd_task({suff=>"12", state=>"paused"}); | ||
| 888 | |||
| 889 | =head3 list files | ||
| 890 | |||
| 891 | my $res = $fbx->list_files({suff=>"/Disque dur/Photos/"}); | ||
| 892 | |||
| 893 | =head3 file info | ||
| 894 | |||
| 895 | my $res = $res = $fbx->file_info({suff=>"Disque dur/Photos/Sydney/DSCF4323.JPG"}); | ||
| 896 | |||
| 897 | =head2 ftp | ||
| 898 | |||
| 899 | =head3 ftp config | ||
| 900 | |||
| 901 | my $res = $fbx->ftp_config; | ||
| 902 | |||
| 903 | =head2 lan | ||
| 904 | |||
| 905 | =head3 lan config | ||
| 906 | |||
| 907 | my $res = $fbx->lan_config; | ||
| 908 | |||
| 909 | =head3 lan browser interfaces | ||
| 910 | |||
| 911 | my $res = $res = $fbx->lan_browser_interfaces; | ||
| 912 | |||
| 913 | =head3 lan browser interfaces pub | ||
| 914 | |||
| 915 | my $res = $fbx->list_hosts({ suff => $res->{result}->[0]->{name} }); | ||
| 916 | |||
| 917 | =head2 lcd | ||
| 918 | |||
| 919 | =head3 lcd | ||
| 920 | |||
| 921 | my $res = $res = $fbx->lcd; | ||
| 922 | |||
| 923 | =head3 lcd brightness back | ||
| 924 | |||
| 925 | my $res = $fbx->set_lcd({ brightness => $res->{result}{brightness} }); | ||
| 926 | |||
| 927 | =head2 nat | ||
| 928 | |||
| 929 | =head3 fw dmz | ||
| 930 | |||
| 931 | my $res = $fbx->fw_dmz; | ||
| 932 | |||
| 933 | =head3 fw redir | ||
| 934 | |||
| 935 | my $res = $fbx->fw_redir; | ||
| 936 | |||
| 937 | =head3 fw incoming | ||
| 938 | |||
| 939 | my $res = $fbx->fw_incoming; | ||
| 940 | |||
| 941 | =head2 parental | ||
| 942 | |||
| 943 | =head3 parental config | ||
| 944 | |||
| 945 | my $res = $fbx->parental_config; | ||
| 946 | |||
| 947 | =head3 parental filter | ||
| 948 | |||
| 949 | my $res = $fbx->parental_filter; | ||
| 950 | |||
| 951 | =head2 share | ||
| 952 | |||
| 953 | =head3 share link | ||
| 954 | |||
| 955 | my $res = $fbx->share_link; | ||
| 956 | |||
| 957 | =head3 upload | ||
| 958 | |||
| 959 | my $res = $fbx->upload; | ||
| 960 | |||
| 961 | =head3 airmedia config | ||
| 962 | |||
| 963 | my $res = $fbx->airmedia_config; | ||
| 964 | |||
| 965 | =head3 airmedia receivers | ||
| 966 | |||
| 967 | my $res = $fbx->airmedia_receivers; | ||
| 968 | |||
| 969 | =head2 shares | ||
| 970 | |||
| 971 | =head3 netshare samba | ||
| 972 | |||
| 973 | my $res = $fbx->netshare_samba; | ||
| 974 | |||
| 975 | =head3 netshare afp | ||
| 976 | |||
| 977 | my $res = $fbx->netshare_afp; | ||
| 978 | |||
| 979 | =head2 storage | ||
| 980 | |||
| 981 | =head3 storage disk | ||
| 982 | |||
| 983 | my $res = $fbx->storage_disk; | ||
| 984 | |||
| 985 | =head3 storage partition | ||
| 986 | |||
| 987 | my $res = $fbx->storage_partition; | ||
| 988 | |||
| 989 | =head2 switch | ||
| 990 | |||
| 991 | =head3 switch status | ||
| 992 | |||
| 993 | my $res = $fbx->switch_sts; | ||
| 994 | |||
| 995 | =head2 system | ||
| 996 | |||
| 997 | =head3 system | ||
| 998 | |||
| 999 | my $res = $fbx->system; | ||
| 1000 | |||
| 1001 | =head2 upnp | ||
| 1002 | |||
| 1003 | =head3 upnpigd config | ||
| 1004 | |||
| 1005 | my $res = $fbx->upnpigd_config; | ||
| 1006 | |||
| 1007 | =head3 upnpigd redir | ||
| 1008 | |||
| 1009 | my $res = $fbx->upnpigd_redir; | ||
| 1010 | |||
| 1011 | =head2 upnpav | ||
| 1012 | |||
| 1013 | =head3 upnpav | ||
| 1014 | |||
| 1015 | my $res = $fbx->upnpav; | ||
| 1016 | |||
| 1017 | =head2 vpn | ||
| 1018 | |||
| 1019 | =head3 vpn | ||
| 1020 | |||
| 1021 | my $res = $fbx->vpn; | ||
| 1022 | |||
| 1023 | =head3 vpn user | ||
| 1024 | |||
| 1025 | my $res = $fbx->vpn_user; | ||
| 1026 | |||
| 1027 | =head3 vpn ip_pool | ||
| 1028 | |||
| 1029 | my $res = $fbx->vpn_ip_pool; | ||
| 1030 | |||
| 1031 | =head3 vpn client config | ||
| 1032 | |||
| 1033 | my $res = $fbx->vpn_client_config; | ||
| 1034 | |||
| 1035 | =head3 vpn client status | ||
| 1036 | |||
| 1037 | my $res = $fbx->vpn_client_status; | ||
| 1038 | |||
| 1039 | =head3 vpn client log | ||
| 1040 | |||
| 1041 | my $res = $fbx->vpn_client_log; | ||
| 1042 | |||
| 1043 | =head2 wifi | ||
| 1044 | |||
| 1045 | =head3 wifi config | ||
| 1046 | |||
| 1047 | my $res = $fbx->wifi_config; | ||
| 1048 | |||
| 1049 | =head3 wifi ap | ||
| 1050 | |||
| 1051 | my $res = $fbx->wifi_ap; | ||
| 1052 | |||
| 1053 | =head3 wifi bss | ||
| 1054 | |||
| 1055 | my $res = $fbx->wifi_bss; | ||
| 1056 | |||
| 1057 | =head3 wifi planning | ||
| 1058 | |||
| 1059 | my $res = $fbx->wifi_planning; | ||
| 1060 | |||
| 1061 | =head3 wifi mac filter | ||
| 1062 | |||
| 1063 | my $res = $fbx->wifi_mac_filter; | ||
| 1064 | |||
| 1065 | =head1 LICENSE | ||
| 1066 | |||
| 1067 | Copyright (C) Laurent Kislaire. | ||
| 1068 | |||
| 1069 | This library is free software; you can redistribute it and/or modify | ||
| 1070 | it under the same terms as Perl itself. | ||
| 1071 | |||
| 1072 | =head1 AUTHOR | ||
| 1073 | |||
| 1074 | Laurent Kislaire E<lt>teebeenator@gmail.comE<gt> | ||
| 1075 | |||
| 1076 | =cut | ||
| 1077 |