ADD FreePlug API
This commit is contained in:
parent
dc433d95e0
commit
8cff7f8a6f
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
/// Require Composer AutoLoader
|
||||
require_once '../../vendor/autoload.php';
|
||||
|
||||
/// Define our application
|
||||
$App = new \alphayax\freebox\utils\Application( 'com.alphayax.freebox.freeplug', 'PHP API Example (Freeplug)', '1.0.0');
|
||||
$App->authorize();
|
||||
$App->openSession();
|
||||
|
||||
// Freeplug
|
||||
$FreeplugService = new \alphayax\freebox\api\v3\services\config\Freeplug( $App);
|
||||
$a = $FreeplugService->getNetworks();
|
||||
print_r( $a);
|
||||
|
||||
$b = $FreeplugService->getFromId( '14:0C:76:27:12:19');
|
||||
print_r( $b);
|
||||
|
||||
$c = $FreeplugService->resetFromId( '14:0C:76:27:12:19');
|
||||
print_r( $c);
|
|
@ -0,0 +1,137 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\models\Freeplug;
|
||||
use alphayax\freebox\api\v3\Model;
|
||||
|
||||
/**
|
||||
* Class Freeplug
|
||||
* @package alphayax\freebox\api\v3\models\Freeplug
|
||||
*/
|
||||
class Freeplug extends Model {
|
||||
|
||||
/** @var string (Read-only) : Freeplug unique id */
|
||||
protected $id;
|
||||
|
||||
/** @var bool (Read-only) : if true the Freeplug is connected directly to the Freebox */
|
||||
protected $local;
|
||||
|
||||
/**
|
||||
* @var string (Read-only) : Freeplug network role
|
||||
* @see alphayax\freebox\api\v3\symbols\Freeplug\FreeplugNetRole
|
||||
*/
|
||||
protected $net_role;
|
||||
|
||||
/** @var string (Read-only) : Freebox Server netbios name */
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* @var string (Read-only)
|
||||
* @see alphayax\freebox\api\v3\symbols\Freeplug\FreeplugEthPortStatus
|
||||
*/
|
||||
protected $eth_port_status;
|
||||
|
||||
/** @var bool (Read-only) : ethernet link is full duplex */
|
||||
protected $eth_full_duplex;
|
||||
|
||||
/** @var bool (Read-only) : is connected to the network */
|
||||
protected $has_network;
|
||||
|
||||
/** @var int (Read-only) : ethernet port speed */
|
||||
protected $eth_speed;
|
||||
|
||||
/** @var int (Read-only) : seconds since last activity */
|
||||
protected $inactive;
|
||||
|
||||
/** @var string (Read-only) : network id */
|
||||
protected $net_id;
|
||||
|
||||
/** @var int (Read-only) : rx rate (from the freeplugs to the “cco” freeplug) (in Mb/s) -1 if not available */
|
||||
protected $rx_rate;
|
||||
|
||||
/** @var int (Read-only) : tx rate (from the “cco” freeplug to the freeplugs) (in Mb/s) -1 if not available */
|
||||
protected $tx_rate;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isLocal(){
|
||||
return $this->local;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNetRole(){
|
||||
return $this->net_role;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(){
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEthPortStatus(){
|
||||
return $this->eth_port_status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isEthFullDuplex(){
|
||||
return $this->eth_full_duplex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isHasNetwork(){
|
||||
return $this->has_network;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getEthSpeed(){
|
||||
return $this->eth_speed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getInactive(){
|
||||
return $this->inactive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNetId(){
|
||||
return $this->net_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxRate(){
|
||||
return $this->rx_rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxRate(){
|
||||
return $this->tx_rate;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\models\Freeplug;
|
||||
use alphayax\freebox\api\v3\Model;
|
||||
|
||||
/**
|
||||
* Class FreeplugNetwork
|
||||
* @package alphayax\freebox\api\v3\models\Freeplug
|
||||
*/
|
||||
class FreeplugNetwork extends Model {
|
||||
|
||||
/** @var string (Read-only) Network unique id */
|
||||
protected $id;
|
||||
|
||||
/** @var Freeplug[] (Read-only) List of freeplugs member of this network */
|
||||
protected $members;
|
||||
|
||||
public function __construct(array $properties_x){
|
||||
parent::__construct( $properties_x);
|
||||
$this->initPropertyArray( 'members', Freeplug::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getId(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Freeplug[]
|
||||
*/
|
||||
public function getMembers(){
|
||||
return $this->members;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\services\config;
|
||||
use alphayax\freebox\api\v3\Service;
|
||||
use alphayax\freebox\api\v3\models;
|
||||
|
||||
|
||||
/**
|
||||
* Class System
|
||||
* @package alphayax\freebox\api\v3\services\config
|
||||
*/
|
||||
class Freeplug extends Service {
|
||||
|
||||
const API_FREEPLUG = '/api/v3/freeplug/';
|
||||
const API_FREEPLUG_RESET = '/api/v3/freeplug/%s/reset/';
|
||||
|
||||
/**
|
||||
* Get the current system info
|
||||
* @throws \Exception
|
||||
* @return models\Freeplug\FreeplugNetwork[]
|
||||
*/
|
||||
public function getNetworks(){
|
||||
$rest = $this->getAuthService( self::API_FREEPLUG);
|
||||
$rest->GET();
|
||||
|
||||
$Network_xs = $rest->getCurlResponse()['result'];
|
||||
$Networks = [];
|
||||
foreach( $Network_xs as $Network_x) {
|
||||
$Networks[] = new models\Freeplug\FreeplugNetwork( $Network_x);
|
||||
}
|
||||
return $Networks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a particular Freeplug information
|
||||
* @param $FreeplugId
|
||||
* @return models\Freeplug\Freeplug
|
||||
*/
|
||||
public function getFromId( $FreeplugId){
|
||||
$rest = $this->getAuthService( self::API_FREEPLUG . $FreeplugId . DIRECTORY_SEPARATOR);
|
||||
$rest->GET();
|
||||
|
||||
return new models\Freeplug\Freeplug( $rest->getCurlResponse()['result']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset a Freeplug
|
||||
* @param $FreeplugId
|
||||
* @return models\Freeplug\FreeplugNetwork
|
||||
*/
|
||||
public function resetFromId( $FreeplugId){
|
||||
$Service = sprintf( self::API_FREEPLUG_RESET, $FreeplugId);
|
||||
$rest = $this->getAuthService( $Service);
|
||||
$rest->POST();
|
||||
|
||||
return $rest->getCurlResponse()['success'];
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\symbols\Freeplug;
|
||||
|
||||
/**
|
||||
* Symbol FreeplugEthPortStatus
|
||||
* @package alphayax\freebox\api\v3\symbols\Freeplug
|
||||
*/
|
||||
interface FreeplugEthPortStatus {
|
||||
const UP = 'up'; // The ethernet port is up
|
||||
const DOWN = 'down'; // The ethernet port is down
|
||||
const UNKNOWN = 'unknown'; // The ethernet port state is unknown
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\symbols\Freeplug;
|
||||
|
||||
/**
|
||||
* Symbol FreeplugNetRole
|
||||
* @package alphayax\freebox\api\v3\symbols\Freeplug
|
||||
*/
|
||||
interface FreeplugNetRole {
|
||||
const STATION = 'sta'; // Freeplug Station
|
||||
const COORDINATOR_PROXY = 'pco'; // Freeplug proxy coordinator
|
||||
const COORDINATOR_CENTRAL = 'cco'; // Central coordinator
|
||||
}
|
Loading…
Reference in New Issue