Add Storage Partition API + exemple
This commit is contained in:
parent
11432ae276
commit
479d6dc048
|
@ -48,6 +48,9 @@ Jusqu'a présent, les fonctionalités suivantes ont été implémentées :
|
|||
- Peers
|
||||
- BlackList
|
||||
- RRD
|
||||
- Storage
|
||||
- Disk
|
||||
- Partition
|
||||
- Configuration
|
||||
- Connection
|
||||
- Connection (Core)
|
||||
|
|
4
TODO.md
4
TODO.md
|
@ -37,7 +37,7 @@
|
|||
- ~~System~~
|
||||
- ~~VPN Server [UNSTABLE]~~
|
||||
- ~~VPN Client [UNSTABLE]~~
|
||||
- Storage
|
||||
- Storage API [UNSTABLE]
|
||||
- ~~Storage~~
|
||||
- ~~Storage API [UNSTABLE]~~
|
||||
- Parental filter
|
||||
- Parental Control
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
/// Require Composer AutoLoader
|
||||
require_once '../../vendor/autoload.php';
|
||||
|
||||
/// Define our application
|
||||
$App = new \alphayax\freebox\utils\Application( 'com.alphayax.freebox.storage', 'PHP API Example (storage)', '1.0.0');
|
||||
$App->authorize();
|
||||
$App->openSession();
|
||||
|
||||
$StoragePartitionService = new \alphayax\freebox\api\v3\services\Storage\Partition( $App);
|
||||
$Partitions = $StoragePartitionService->getAll();
|
||||
print_r( $Partitions);
|
||||
|
|
@ -72,5 +72,4 @@ class Disk extends Service {
|
|||
return $rest->getSuccess();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\services\Storage;
|
||||
use alphayax\freebox\api\v3\models;
|
||||
use alphayax\freebox\api\v3\Service;
|
||||
use alphayax\freebox\api\v3\symbols;
|
||||
|
||||
/**
|
||||
* Class Partition
|
||||
* @package alphayax\freebox\api\v3\services\Storage
|
||||
*/
|
||||
class Partition extends Service {
|
||||
|
||||
const API_STORAGE_PARTITION = '/api/v3/storage/partition/';
|
||||
const API_STORAGE_PARTITION_CHECK = '/api/v3/storage/partition/%u/check/';
|
||||
|
||||
/**
|
||||
* Get the list of partitions
|
||||
* @throws \Exception
|
||||
* @return models\Storage\DiskPartition[]
|
||||
*/
|
||||
public function getAll(){
|
||||
$rest = $this->getAuthService( self::API_STORAGE_PARTITION);
|
||||
$rest->GET();
|
||||
|
||||
return $rest->getResultAsArray( models\Storage\DiskPartition::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a given partition info
|
||||
* @param $diskId
|
||||
* @return \alphayax\freebox\api\v3\models\Storage\DiskPartition
|
||||
*/
|
||||
public function getFromId( $diskId){
|
||||
$rest = $this->getAuthService( self::API_STORAGE_PARTITION . $diskId);
|
||||
$rest->GET();
|
||||
|
||||
return $rest->getResult( models\Storage\DiskPartition::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the partition with the given id
|
||||
* *NOTE* once started you can monitor the fsck process getting the partition information
|
||||
* @see DiskPartition operation_pct field
|
||||
* @param \alphayax\freebox\api\v3\models\Storage\DiskPartition $diskPartition
|
||||
* @param string $checkMode "ro" for read only check, "rw" to attempt to repair errors
|
||||
* @return bool
|
||||
* @see symbols\Storage\DiskPartition\FsType
|
||||
* @see symbols\Storage\StorageDisk\TableType
|
||||
*/
|
||||
public function check( models\Storage\DiskPartition $diskPartition, $checkMode = 'ro'){
|
||||
$rest = $this->getAuthService( self::API_STORAGE_PARTITION_CHECK . $diskPartition->getId());
|
||||
$rest->PUT([
|
||||
'checkmode' => $checkMode,
|
||||
]);
|
||||
|
||||
return $rest->getSuccess();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue