1 | <?php |
||
9 | class DigitalOcean extends Adapter implements ServerAdapterInterface |
||
10 | { |
||
11 | /** |
||
12 | * The endpoint for all API calls to Digital Ocean (currently at v2) |
||
13 | */ |
||
14 | protected $apiEndpoint = 'https://api.digitalocean.com/v2'; |
||
15 | |||
16 | /** |
||
17 | * A set of default params for creating Digital Ocean droplets |
||
18 | * |
||
19 | * @todo add methods to make this more dynamic and controllable by consumers |
||
20 | */ |
||
21 | protected $defaults = [ |
||
22 | "name" => "example.com", |
||
23 | "region" => "lon1", |
||
24 | "size" => "512mb", |
||
25 | "image" => "ubuntu-14-04-x64", |
||
26 | "ssh_keys" => null, |
||
27 | "backups" => false, |
||
28 | "ipv6" => true, |
||
29 | "user_data" => null, |
||
30 | "private_networking" => null |
||
31 | ]; |
||
32 | |||
33 | /** |
||
34 | * List details for an indexed server, or all servers if id is null. |
||
35 | * |
||
36 | * @param integer $id |
||
37 | * @return GuzzleResponse object | array of GuzzleResponse objects |
||
38 | */ |
||
39 | public function read($id = null) |
||
49 | |||
50 | /** |
||
51 | * Create a new server based on parameters received. |
||
52 | * |
||
53 | * @param array $params |
||
54 | * @return array |
||
55 | */ |
||
56 | public function create($params = array()) |
||
72 | |||
73 | /** |
||
74 | * Delete the server corresponding to the given id. |
||
75 | * |
||
76 | * @param integer $id |
||
77 | * @return integer | null |
||
78 | */ |
||
79 | public function delete($id) |
||
96 | |||
97 | /** |
||
98 | * List of available snapshots. |
||
99 | * |
||
100 | * @param array $params |
||
101 | * @return array |
||
102 | */ |
||
103 | public function images($params) |
||
120 | |||
121 | /** |
||
122 | * Construct http client request headers. |
||
123 | * |
||
124 | * @return void |
||
125 | */ |
||
126 | protected function setHeaders() |
||
132 | |||
133 | /** |
||
134 | * Construct http client request headers. |
||
135 | * @todo this isn't the best place for this method - see where it gets used next and find it a better home |
||
136 | * |
||
137 | * @param array | null $in array of parameters to be converted to string for URL |
||
138 | * @return string |
||
139 | */ |
||
140 | private function paramsToString($in) |
||
146 | } |
||
147 |