Add Download Configuration API
This commit is contained in:
parent
de0de43157
commit
08bc5e89c9
|
@ -36,6 +36,7 @@ Jusqu'a présent, les fonctionalités suivantes ont été implémentées :
|
||||||
- Download (core)
|
- Download (core)
|
||||||
- Download Stats
|
- Download Stats
|
||||||
- Download Files
|
- Download Files
|
||||||
|
- Download Configuration
|
||||||
- Configuration
|
- Configuration
|
||||||
- Connection
|
- Connection
|
||||||
- Connection (Core)
|
- Connection (Core)
|
||||||
|
@ -134,6 +135,7 @@ Les exemples sont disponibles dans le repertoire `exemple`. Ils sont classés pa
|
||||||
- `UPnP` : Affichage des configuration UPnP
|
- `UPnP` : Affichage des configuration UPnP
|
||||||
- `download`
|
- `download`
|
||||||
- `Download` : Listage des téléchargement en cours, liste des fichiers d'un téléchargement et mise a jour de la priorité de téléchargement
|
- `Download` : Listage des téléchargement en cours, liste des fichiers d'un téléchargement et mise a jour de la priorité de téléchargement
|
||||||
|
- `DlConfig` : Affichage des configurations de téléchargement (bt, nntp...)
|
||||||
- `dl_rss` : Un script qui parse les flux RSS et qui rajoute en téléchagement les items correspondant a une expression réguliere
|
- `dl_rss` : Un script qui parse les flux RSS et qui rajoute en téléchagement les items correspondant a une expression réguliere
|
||||||
|
|
||||||
|
|
2
TODO.md
2
TODO.md
|
@ -6,7 +6,7 @@
|
||||||
- Download Peers [UNSTABLE]
|
- Download Peers [UNSTABLE]
|
||||||
- Download Blacklist [UNSTABLE]
|
- Download Blacklist [UNSTABLE]
|
||||||
- Download Feeds
|
- Download Feeds
|
||||||
- Download Configuration
|
- ~~Download Configuration~~
|
||||||
- ~~File System Api~~
|
- ~~File System Api~~
|
||||||
- ~~File System~~
|
- ~~File System~~
|
||||||
- ~~File Sharing Link~~
|
- ~~File Sharing Link~~
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/// Require Composer AutoLoader
|
||||||
|
require_once '../../vendor/autoload.php';
|
||||||
|
|
||||||
|
/// Define our application
|
||||||
|
$App = new \alphayax\freebox\utils\Application( 'com.alphayax.freebox.download', 'PHP API Example (Download)', '1.0.0');
|
||||||
|
$App->authorize();
|
||||||
|
$App->openSession();
|
||||||
|
|
||||||
|
/// Download configuration
|
||||||
|
$DownloadConfigService = new \alphayax\freebox\api\v3\services\download\Configuration( $App);
|
||||||
|
$DlConfig = $DownloadConfigService->getConfiguration();
|
||||||
|
print_r( $DlConfig);
|
||||||
|
|
||||||
|
$DlConfig = $DownloadConfigService->updateThrottlingMode( 'normal');
|
||||||
|
print_r( $DlConfig);
|
|
@ -14,12 +14,12 @@ class DlThrottlingConfig extends Model {
|
||||||
/** @var DlRate : download rate for normal slow slot (in B/s) */
|
/** @var DlRate : download rate for normal slow slot (in B/s) */
|
||||||
protected $slow;
|
protected $slow;
|
||||||
|
|
||||||
/** @var string
|
/** @var string[168]
|
||||||
* The schedule array represent the list of week hours timeslot, starting on monday a midnight.
|
* The schedule array represent the list of week hours timeslot, starting on monday a midnight.
|
||||||
* Therefore the complete week is represented in a array of 168 elements (24 * 7)
|
* Therefore the complete week is represented in a array of 168 elements (24 * 7)
|
||||||
* @see alphayax\freebox\api\v3\symbols\Download\Config\DlThrottlingConfig\Schedule
|
* @see alphayax\freebox\api\v3\symbols\Download\Config\DlThrottlingConfig\Schedule
|
||||||
*/
|
*/
|
||||||
protected $schedule;
|
protected $schedule = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -27,6 +27,16 @@ class DlThrottlingConfig extends Model {
|
||||||
*/
|
*/
|
||||||
protected $mode;
|
protected $mode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DlThrottlingConfig constructor.
|
||||||
|
* @param array $properties_x
|
||||||
|
*/
|
||||||
|
public function __construct( array $properties_x){
|
||||||
|
parent::__construct( $properties_x);
|
||||||
|
$this->initProperty( '$normal' , DlRate::class);
|
||||||
|
$this->initProperty( 'slow' , DlRate::class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return DlRate
|
* @return DlRate
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
namespace alphayax\freebox\api\v3\services\download;
|
||||||
|
use alphayax\freebox\api\v3\Service;
|
||||||
|
use alphayax\freebox\api\v3\models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Configuration
|
||||||
|
* @package alphayax\freebox\api\v3\services\download
|
||||||
|
*/
|
||||||
|
class Configuration extends Service {
|
||||||
|
|
||||||
|
const API_DOWNLOAD_CONFIG = '/api/v3/downloads/config/';
|
||||||
|
const API_DOWNLOAD_THROTTLING = '/api/v3/downloads/throttling';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current Download configuration
|
||||||
|
* @return models\Download\Config\DownloadConfig
|
||||||
|
*/
|
||||||
|
public function getConfiguration(){
|
||||||
|
$rest = $this->getAuthService( self::API_DOWNLOAD_CONFIG);
|
||||||
|
$rest->GET();
|
||||||
|
|
||||||
|
return new models\Download\Config\DownloadConfig( $rest->getCurlResponse()['result']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the Download configuration
|
||||||
|
* @param models\Download\Config\DownloadConfig $downloadConfig
|
||||||
|
* @return models\Download\Config\DownloadConfig
|
||||||
|
*/
|
||||||
|
public function setConfiguration( models\Download\Config\DownloadConfig $downloadConfig){
|
||||||
|
$rest = $this->getAuthService( self::API_DOWNLOAD_CONFIG);
|
||||||
|
$rest->PUT( $downloadConfig->toArray());
|
||||||
|
|
||||||
|
return new models\Download\Config\DownloadConfig( $rest->getCurlResponse()['result']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* You can force the throttling mode using this method.
|
||||||
|
* You can use any of the throttling modes defined in DlThrottlingConfig.
|
||||||
|
* Setting to schedule will automatically set correct throttling mode.
|
||||||
|
* Other values will force the throttling mode until you set it back to schedule.
|
||||||
|
* @param string $throttlingMode
|
||||||
|
* @return array [is_scheduled, throttling]
|
||||||
|
*/
|
||||||
|
public function updateThrottlingMode( $throttlingMode = 'normal'){
|
||||||
|
$rest = $this->getAuthService( self::API_DOWNLOAD_THROTTLING);
|
||||||
|
$rest->PUT([
|
||||||
|
'throttling' => $throttlingMode,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $rest->getCurlResponse()['result'];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue