Add Switch API
This commit is contained in:
parent
029f6b5a43
commit
07e096af6c
|
@ -58,6 +58,10 @@ Jusqu'a présent, les fonctionalités suivantes ont été implémentées :
|
|||
- Network Share
|
||||
- Samba
|
||||
- Afp
|
||||
- Switch
|
||||
- Statistics
|
||||
- Status
|
||||
- Config
|
||||
- System
|
||||
- LCD
|
||||
- NAT
|
||||
|
|
2
TODO.md
2
TODO.md
|
@ -32,7 +32,7 @@
|
|||
- ~~LCD~~
|
||||
- ~~Network Share~~
|
||||
- ~~UPnP AV~~
|
||||
- Switch
|
||||
- ~~Switch~~
|
||||
- Wi-Fi
|
||||
- ~~System~~
|
||||
- VPN Server [UNSTABLE]
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\models\SwitchPort;
|
||||
use alphayax\freebox\api\v3\Model;
|
||||
use alphayax\freebox\api\v3\symbols;
|
||||
|
||||
/**
|
||||
* Class Config
|
||||
* @package alphayax\freebox\api\v3\models\SwitchPort
|
||||
*/
|
||||
class Config extends Model {
|
||||
|
||||
/** @var int (Read-only) : switch port id */
|
||||
protected $id;
|
||||
|
||||
/** @var string */
|
||||
protected $duplex;
|
||||
|
||||
/** @var string|int */
|
||||
protected $speed;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @see symbols\SwitchPort\Config\Duplex
|
||||
*/
|
||||
public function getDuplex() {
|
||||
return $this->duplex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $duplex
|
||||
* @see symbols\SwitchPort\Config\Duplex
|
||||
*/
|
||||
public function setDuplex($duplex) {
|
||||
$this->duplex = $duplex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|string
|
||||
* @see symbols\SwitchPort\Config\Speed
|
||||
*/
|
||||
public function getSpeed() {
|
||||
return $this->speed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|string $speed
|
||||
* @see symbols\SwitchPort\Config\Speed
|
||||
*/
|
||||
public function setSpeed($speed) {
|
||||
$this->speed = $speed;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,311 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\models\SwitchPort;
|
||||
use alphayax\freebox\api\v3\Model;
|
||||
|
||||
/**
|
||||
* Class Stats
|
||||
* @package alphayax\freebox\api\v3\models\SwitchPort
|
||||
*/
|
||||
class Stats extends Model {
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $rx_bad_bytes;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $rx_broadcast_packets;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $rx_bytes_rate;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $rx_err_packets;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $rx_fcs_packets;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $rx_fragments_packets;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $rx_good_bytes;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $rx_good_packets;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $rx_jabber_packets;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $rx_multicast_packets;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $rx_oversize_packets;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $rx_packets_rate;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $rx_pause;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $rx_undersize_packets;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $rx_unicast_packets;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $tx_broadcast_packets;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $tx_bytes;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $tx_bytes_rate;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $tx_collisions;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $tx_deferred;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $tx_excessive;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $tx_fcs;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $tx_late;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $tx_multicast_packets;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $tx_multiple;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $tx_packets;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $tx_packets_rate;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $tx_pause;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $tx_single;
|
||||
|
||||
/** @var int (Read-only) */
|
||||
protected $tx_unicast_packets;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxBadBytes() {
|
||||
return $this->rx_bad_bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxBroadcastPackets() {
|
||||
return $this->rx_broadcast_packets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxBytesRate() {
|
||||
return $this->rx_bytes_rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxErrPackets() {
|
||||
return $this->rx_err_packets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxFcsPackets() {
|
||||
return $this->rx_fcs_packets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxFragmentsPackets() {
|
||||
return $this->rx_fragments_packets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxGoodBytes() {
|
||||
return $this->rx_good_bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxGoodPackets() {
|
||||
return $this->rx_good_packets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxJabberPackets() {
|
||||
return $this->rx_jabber_packets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxMulticastPackets() {
|
||||
return $this->rx_multicast_packets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxOversizePackets() {
|
||||
return $this->rx_oversize_packets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxPacketsRate() {
|
||||
return $this->rx_packets_rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxPause() {
|
||||
return $this->rx_pause;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxUndersizePackets() {
|
||||
return $this->rx_undersize_packets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxUnicastPackets() {
|
||||
return $this->rx_unicast_packets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxBroadcastPackets() {
|
||||
return $this->tx_broadcast_packets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxBytes() {
|
||||
return $this->tx_bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxBytesRate() {
|
||||
return $this->tx_bytes_rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxCollisions() {
|
||||
return $this->tx_collisions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxDeferred() {
|
||||
return $this->tx_deferred;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxExcessive() {
|
||||
return $this->tx_excessive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxFcs() {
|
||||
return $this->tx_fcs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxLate() {
|
||||
return $this->tx_late;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxMulticastPackets() {
|
||||
return $this->tx_multicast_packets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxMultiple() {
|
||||
return $this->tx_multiple;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxPackets() {
|
||||
return $this->tx_packets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxPacketsRate() {
|
||||
return $this->tx_packets_rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxPause() {
|
||||
return $this->tx_pause;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxSingle() {
|
||||
return $this->tx_single;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxUnicastPackets() {
|
||||
return $this->tx_unicast_packets;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\models\SwitchPort;
|
||||
use alphayax\freebox\api\v3\Model;
|
||||
use alphayax\freebox\api\v3\symbols;
|
||||
|
||||
/**
|
||||
* Class Status
|
||||
* @package alphayax\freebox\api\v3\models\SwitchPort
|
||||
*/
|
||||
class Status extends Model {
|
||||
|
||||
/** @var int (Read-only) : switch port id */
|
||||
protected $id;
|
||||
|
||||
/** @var string (Read-only) */
|
||||
protected $link;
|
||||
|
||||
/** @var string */
|
||||
protected $duplex;
|
||||
|
||||
/** @var int */
|
||||
protected $speed;
|
||||
|
||||
/** @var string (Read-only) : display form of speed and duplex mode */
|
||||
protected $mode;
|
||||
|
||||
/** @var array (Read-only) : list of { mac, name } of hosts connected to this port */
|
||||
protected $mac_list;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @see symbols\SwitchPort\Status\Link
|
||||
*/
|
||||
public function getLink() {
|
||||
return $this->link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @see symbols\SwitchPort\Status\Duplex
|
||||
*/
|
||||
public function getDuplex() {
|
||||
return $this->duplex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $duplex
|
||||
* @see symbols\SwitchPort\Status\Duplex
|
||||
*/
|
||||
public function setDuplex( $duplex) {
|
||||
$this->duplex = $duplex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @see symbols\SwitchPort\Status\Speed
|
||||
*/
|
||||
public function getSpeed() {
|
||||
return $this->speed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $speed
|
||||
* @see symbols\SwitchPort\Status\Speed
|
||||
*/
|
||||
public function setSpeed( $speed) {
|
||||
$this->speed = $speed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMode() {
|
||||
return $this->mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getMacList() {
|
||||
return $this->mac_list;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\services\config\SwitchPort;
|
||||
use alphayax\freebox\api\v3\Service;
|
||||
use alphayax\freebox\api\v3\models;
|
||||
|
||||
/**
|
||||
* Class Config
|
||||
* @package alphayax\freebox\api\v3\services\config\SwitchPort
|
||||
*/
|
||||
class Config extends Service {
|
||||
|
||||
const API_SWITCH_PORT_CONFIG = '/api/v3/switch/port/%u';
|
||||
|
||||
/**
|
||||
* Get a port configuration
|
||||
* @param int $portId
|
||||
* @return \alphayax\freebox\api\v3\models\SwitchPort\Config
|
||||
*/
|
||||
public function getFromPortId( $portId){
|
||||
$service = sprintf( static::API_SWITCH_PORT_CONFIG, $portId);
|
||||
$rest = $this->getAuthService( $service);
|
||||
$rest->GET();
|
||||
|
||||
return new models\SwitchPort\Config( $rest->getCurlResponse()['result']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a port configuration
|
||||
* @param \alphayax\freebox\api\v3\models\SwitchPort\Config $config
|
||||
* @return \alphayax\freebox\api\v3\models\SwitchPort\Config
|
||||
*/
|
||||
public function update( models\SwitchPort\Config $config){
|
||||
$service = sprintf( static::API_SWITCH_PORT_CONFIG, $config->getId());
|
||||
$rest = $this->getAuthService( $service);
|
||||
$rest->PUT( $config->toArray());
|
||||
|
||||
return new models\SwitchPort\Config( $rest->getCurlResponse()['result']);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\services\config\SwitchPort;
|
||||
use alphayax\freebox\api\v3\Service;
|
||||
use alphayax\freebox\api\v3\models;
|
||||
|
||||
/**
|
||||
* Class Stats
|
||||
* @package alphayax\freebox\api\v3\services\config\SwitchPort
|
||||
*/
|
||||
class Stats extends Service {
|
||||
|
||||
const API_SWITCH_PORT_STATS = '/api/v3/switch/port/%u/stats';
|
||||
|
||||
/**
|
||||
* Get a port configuration
|
||||
* @param int $portId
|
||||
* @return \alphayax\freebox\api\v3\models\SwitchPort\Stats
|
||||
*/
|
||||
public function getFromPortId( $portId){
|
||||
$service = sprintf( static::API_SWITCH_PORT_STATS, $portId);
|
||||
$rest = $this->getAuthService( $service);
|
||||
$rest->GET();
|
||||
|
||||
return new models\SwitchPort\Stats( $rest->getCurlResponse()['result']);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\services\config\SwitchPort;
|
||||
use alphayax\freebox\api\v3\Service;
|
||||
use alphayax\freebox\api\v3\models;
|
||||
|
||||
/**
|
||||
* Class Status
|
||||
* @package alphayax\freebox\api\v3\services\config\SwitchPort
|
||||
*/
|
||||
class Status extends Service {
|
||||
|
||||
const API_SWITCH_STATUS = '/api/v3/switch/status/';
|
||||
|
||||
/**
|
||||
* Get the current switch status
|
||||
* @return \alphayax\freebox\api\v3\models\SwitchPort\Status
|
||||
*/
|
||||
public function getStatus() {
|
||||
$rest = $this->getAuthService( self::API_SWITCH_STATUS);
|
||||
$rest->GET();
|
||||
|
||||
return new models\SwitchPort\Status( $rest->getCurlResponse()['result']);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\symbols\SwitchPort\Config;
|
||||
|
||||
/**
|
||||
* Symbol Duplex
|
||||
* @package alphayax\freebox\api\v3\symbols\SwitchPort\Config
|
||||
* @see alphayax\freebox\api\v3\models\SwitchPort\Config
|
||||
*/
|
||||
interface Duplex {
|
||||
|
||||
/** auto negotiate duplex mode */
|
||||
const AUTO = 'auto';
|
||||
|
||||
/** force in half duplex mode */
|
||||
const HALF = 'half';
|
||||
|
||||
/** force in full duplex mode */
|
||||
const FULL = 'full';
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\symbols\SwitchPort\Config;
|
||||
|
||||
/**
|
||||
* Symbol Speed
|
||||
* @package alphayax\freebox\api\v3\symbols\SwitchPort\Config
|
||||
* @see alphayax\freebox\api\v3\models\SwitchPort\Config
|
||||
*/
|
||||
interface Speed {
|
||||
|
||||
/** auto negotiate speed */
|
||||
const AUTO = 'auto';
|
||||
|
||||
/** 10Base-T */
|
||||
const BASE_10 = 10;
|
||||
|
||||
/** 100Base-TX */
|
||||
const BASE_100 = 100;
|
||||
|
||||
/** 1000Base-T */
|
||||
const BASE_1000 = 1000;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\symbols\SwitchPort\Status;
|
||||
|
||||
/**
|
||||
* Symbol Duplex
|
||||
* @package alphayax\freebox\api\v3\symbols\SwitchPort\Status
|
||||
* @see alphayax\freebox\api\v3\models\SwitchPort\Stats
|
||||
*/
|
||||
interface Duplex {
|
||||
|
||||
/** force in half duplex mode */
|
||||
const HALF = 'half';
|
||||
|
||||
/** force in full duplex mode */
|
||||
const FULL = 'full';
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\symbols\SwitchPort\Status;
|
||||
|
||||
/**
|
||||
* Symbol Link
|
||||
* @package alphayax\freebox\api\v3\symbols\SwitchPort\Status
|
||||
* @see alphayax\freebox\api\v3\models\SwitchPort\Stats
|
||||
*/
|
||||
interface Link {
|
||||
|
||||
/** port is up */
|
||||
const UP = 'up';
|
||||
|
||||
/** port is down */
|
||||
const DOWN = 'down';
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\symbols\SwitchPort\Status;
|
||||
|
||||
/**
|
||||
* Symbol Speed
|
||||
* @package alphayax\freebox\api\v3\symbols\SwitchPort\Status
|
||||
* @see alphayax\freebox\api\v3\models\SwitchPort\Stats
|
||||
*/
|
||||
interface Speed {
|
||||
|
||||
/** 10Base-T */
|
||||
const BASE_10 = 10;
|
||||
|
||||
/** 100Base-TX */
|
||||
const BASE_100 = 100;
|
||||
|
||||
/** 1000Base-T */
|
||||
const BASE_1000 = 1000;
|
||||
}
|
Loading…
Reference in New Issue