A CakePHP Library for interacting with the DigitalOcean API.
Spin up and destroy servers for fun & profit from your web app or the shell.
- CakePHP 2.x
- A DigitalOcean account (http://www.digitalocean.com).
- Your DigitalOcean Client ID and API Key.
In your app directory type:
git submodule add -b master https://github.com/timstermatic/cakephp-digitalocean Plugin/DigitalOcean
git submodule init
git submodule update
In your app
directory type:
git clone -b master https://github.com/timstermatic/cakephp-digitalocean Plugin/DigitalOcean
Ensure you are loading it in your APP/Config/bootstrap.php
Either by loading all plugins:
CakePlugin::loadAll()
or explicitly:
CakePlugin::load('DigitalOcean')
Then initialize it:
App::uses('DigitalOcean', 'DigitalOcean.Lib');
$do = new DigitalOcean('YOURCLIENTID','YOURAPIKEY');
$droplet = array(
'name' => 'example.com',
'image_id'=>1601,
'region_id' => 2,
'size_id'=>66
);
$do->droplets('new',null,$droplet)
$do->droplets(12345)
Pass with an id and action to perform the requested action on that droplet. You can pass a 3rd argument which is an array of $params if they are required by the api call.
A full list of available actions is here (https://developers.digitalocean.com/)
$do->droplets(12345, 'reboot')
$do->regions()
$do->images()
$do->images(12345)
Pass with an id and action to perform the requested action on that image. You can pass a 3rd argument which is an array of $params if they are required by the api call.
A full list of available actions is here (https://developers.digitalocean.com/)
$do->images(12345, 'destroy')
$params = array(
'name'=>'my key',
'ssh_pub_key'=>'xxxxxx'
);
$do->sshKeys('new', null, $params);
$do->sshKeys()
$do->sshKeys(12345)
Pass with an id and action to perform the requested action on that ssh key. You can pass a 3rd argument which is an array of $params if they are required by the api call.
A full list of available actions is here (https://developers.digitalocean.com/)
$do->sshKeys(12345, 'destroy')
$params = array(
'name'=>'example.com',
'ip_address'=>'0.0.0.0.0'
);
$do->domains('new', null, $params);
$do->domains()
$do->domains(12345)
Pass with an id and action to perform the requested action on that domain. You can pass a 3rd argument which is an array of $params if they are required by the api call.
A full list of available actions is here (https://developers.digitalocean.com/)
$do->domains(12345, 'destroy')
The first argument must always be the id
of a domain
$params = array(
'name'=>'zone.example.com',
'record_type'=>'CNAME',
'data'=>'@',
);
print_r($do->domainRecords(12345,'new',null, $params));
$do->domainRecords(12345)
$do->domainRecords(12345, 54321)
Pass with an id and action to perform the requested action on that domain record. You can pass a 3rd argument which is an array of $params if they are required by the api call.
A full list of available actions is here (https://developers.digitalocean.com/)
$do->domainRecords(12345,54321, 'destroy')