File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Opensaucesystems \Lxd \Endpoint ;
4+
5+ use Opensaucesystems \Lxd \Exception \InvalidEndpointException ;
6+
7+ class IncusOS extends AbstractEndpoint
8+ {
9+ protected function getEndpoint ()
10+ {
11+ return '' ;
12+ }
13+
14+ public function __get ($ endpoint )
15+ {
16+ $ class = __NAMESPACE__ . '\\IncusOS \\' . ucfirst ($ endpoint );
17+
18+ if (class_exists ($ class )) {
19+ return new $ class ($ this ->client );
20+ } else {
21+ throw new InvalidEndpointException (
22+ 'Endpoint ' . $ class . ', not implemented. '
23+ );
24+ }
25+ }
26+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Opensaucesystems \Lxd \Endpoint \IncusOS ;
4+
5+ use Opensaucesystems \Lxd \Endpoint \AbstractEndpoint ;
6+
7+ class Applications extends AbstractEndpoint
8+ {
9+
10+ protected function getEndpoint ()
11+ {
12+ return '/os/1.0/applications ' ;
13+ }
14+
15+ public function all ()
16+ {
17+ $ applications = [];
18+ foreach ($ this ->get ($ this ->getEndpoint ()) as $ application ) {
19+ $ applications [] = str_replace ($ this ->getEndpoint () . "/ " , '' , $ application );
20+ }
21+ return $ applications ;
22+ }
23+
24+ public function info (string $ application )
25+ {
26+ return $ this ->get ($ this ->getEndpoint () . "/ " . $ application );
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Opensaucesystems \Lxd \Endpoint \IncusOS ;
4+
5+ use Opensaucesystems \Lxd \Endpoint \AbstractEndpoint ;
6+
7+ class Services extends AbstractEndpoint
8+ {
9+
10+ protected function getEndpoint ()
11+ {
12+ return '/os/1.0/services ' ;
13+ }
14+
15+ public function all ()
16+ {
17+ $ services = [];
18+ foreach ($ this ->get ($ this ->getEndpoint ()) as $ service ) {
19+ $ services [] = str_replace ($ this ->getEndpoint () . "/ " , '' , $ service );
20+ }
21+ return $ services ;
22+ }
23+
24+ public function info (string $ service )
25+ {
26+ return $ this ->get ($ this ->getEndpoint () . "/ " . $ service );
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Opensaucesystems \Lxd \Endpoint \IncusOS ;
4+
5+ use Opensaucesystems \Lxd \Endpoint \AbstractEndpoint ;
6+ use Opensaucesystems \Lxd \Exception \InvalidEndpointException ;
7+
8+ class System extends AbstractEndpoint
9+ {
10+
11+ protected function getEndpoint ()
12+ {
13+ return '/os/1.0/system ' ;
14+ }
15+
16+ public function endpoints ()
17+ {
18+ $ endpoints = [];
19+ foreach ($ this ->get ($ this ->getEndpoint ()) as $ endpoint ) {
20+ $ endpoints [] = str_replace ($ this ->getEndpoint () . "/ " , '' , $ endpoint );
21+ }
22+ return $ endpoints ;
23+ }
24+
25+ public function factoryReset ()
26+ {
27+ $ this ->post ($ this ->getEndpoint () . "/:factory-reset " );
28+ }
29+
30+ public function powerOff ()
31+ {
32+ $ this ->post ($ this ->getEndpoint () . "/:poweroff " );
33+ }
34+
35+ public function reboot ()
36+ {
37+ $ this ->post ($ this ->getEndpoint () . "/:reboot " );
38+ }
39+
40+ public function __get ($ endpoint )
41+ {
42+ $ class = __NAMESPACE__ . '\\System \\' . ucfirst ($ endpoint );
43+
44+ if (class_exists ($ class )) {
45+ return new $ class ($ this ->client );
46+ } else {
47+ throw new InvalidEndpointException (
48+ 'Endpoint ' . $ class . ', not implemented. '
49+ );
50+ }
51+ }
52+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Opensaucesystems \Lxd \Endpoint \IncusOS \System ;
4+
5+ use Opensaucesystems \Lxd \Endpoint \AbstractEndpoint ;
6+
7+ class Logging extends AbstractEndpoint
8+ {
9+
10+ protected function getEndpoint ()
11+ {
12+ return '/os/1.0/system/logging ' ;
13+ }
14+
15+ public function info ()
16+ {
17+ return $ this ->get ($ this ->getEndpoint ());
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Opensaucesystems \Lxd \Endpoint \IncusOS \System ;
4+
5+ use Opensaucesystems \Lxd \Endpoint \AbstractEndpoint ;
6+
7+ class Network extends AbstractEndpoint
8+ {
9+
10+ protected function getEndpoint ()
11+ {
12+ return '/os/1.0/system/network ' ;
13+ }
14+
15+ public function info ()
16+ {
17+ return $ this ->get ($ this ->getEndpoint ());
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Opensaucesystems \Lxd \Endpoint \IncusOS \System ;
4+
5+ use Opensaucesystems \Lxd \Endpoint \AbstractEndpoint ;
6+
7+ class Provider extends AbstractEndpoint
8+ {
9+
10+ protected function getEndpoint ()
11+ {
12+ return '/os/1.0/system/provider ' ;
13+ }
14+
15+ public function info ()
16+ {
17+ return $ this ->get ($ this ->getEndpoint ());
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Opensaucesystems \Lxd \Endpoint \IncusOS \System ;
4+
5+ use Opensaucesystems \Lxd \Endpoint \AbstractEndpoint ;
6+
7+ class Resources extends AbstractEndpoint
8+ {
9+
10+ protected function getEndpoint ()
11+ {
12+ return '/os/1.0/system/resources ' ;
13+ }
14+
15+ public function info ()
16+ {
17+ return $ this ->get ($ this ->getEndpoint ());
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Opensaucesystems \Lxd \Endpoint \IncusOS \System ;
4+
5+ use Opensaucesystems \Lxd \Endpoint \AbstractEndpoint ;
6+
7+ class Security extends AbstractEndpoint
8+ {
9+
10+ protected function getEndpoint ()
11+ {
12+ return '/os/1.0/system/security ' ;
13+ }
14+
15+ public function info ()
16+ {
17+ return $ this ->get ($ this ->getEndpoint ());
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Opensaucesystems \Lxd \Endpoint \IncusOS \System ;
4+
5+ use Opensaucesystems \Lxd \Endpoint \AbstractEndpoint ;
6+
7+ class Storage extends AbstractEndpoint
8+ {
9+
10+ protected function getEndpoint ()
11+ {
12+ return '/os/1.0/system/storage ' ;
13+ }
14+
15+ public function info ()
16+ {
17+ return $ this ->get ($ this ->getEndpoint ());
18+ }
19+ }
You can’t perform that action at this time.
0 commit comments