diff --git a/src/HPCloud/Services/DBaaS.php b/src/HPCloud/Services/DBaaS.php index f56681d..35ca8a5 100644 --- a/src/HPCloud/Services/DBaaS.php +++ b/src/HPCloud/Services/DBaaS.php @@ -27,20 +27,89 @@ SOFTWARE. namespace HPCloud\Services; +use \HPCloud\Services\DBaaS\Instance; +use \HPCloud\Services\DBaaS\Snapshot; + class DBaaS { - public static function newFromServiceCatalog($catalog, $token) { + /** + * The auth token for the current session. + */ + protected $token; + /** + * The base URL to the DBaaS for a given account. + */ + protected $url; + /** + * The tenant name. + * + * Typically, this is an email address. + */ + protected $projectId; + + public static function newFromIdentity($identity) { + + $endpoint = 'https://region-a.geo-1.dbaas-mysql.hpcloudsvc.com:443/v1.0/' . $identity->tenantId(); + $dbaas = new DBaaS($identity->token(), $endpoint, $identity->tenantName()); + + return $dbaas; + /* + return self::newFromServiceCatalog( + $identity->serviceCatalog(), + $identity->token(), + $identity->tenantName() + ); + */ } - public function __construct($token, $endpoint) { - + public static function newFromServiceCatalog($catalog, $token, $projectId) { + // FIXME: Temporary until DBaaS lands in the service catalog. + $endpoint = 'https://region-a.geo-1.dbaas-mysql.hpcloudsvc.com:443/v1.0/'; + return new DBaaS($token, $endpoint, $projectId); + } + /** + * Build a new DBaaS object. + * + * @param string $token + * The auth token from identity services. + * @param string $endpoint + * The endpoint URL, typically from IdentityServices. + * @param string $projectId + * The project ID. Typically, this is the tenant name. + */ + public function __construct($token, $endpoint, $projectId) { + $this->token = $token; + $this->url= $endpoint; + $this->projectId = $projectId; } public function instance() { + return new Instance($this->token, $this->projectId, $this->url); } public function snapshot() { + return new Snapshot($this->token, $this->projectId, $this->url); + } + + /** + * Get the project ID for this session. + * + * @retval string + * The project ID. + */ + public function projectId() { + return $this->projectId; + } + + /** + * Get the endpoint URL to the DBaaS session. + * + * @retval string + * The URL. + */ + public function url() { + return $this->url; } } diff --git a/src/HPCloud/Services/DBaaS/Instance.php b/src/HPCloud/Services/DBaaS/Instance.php new file mode 100644 index 0000000..5e3f6f0 --- /dev/null +++ b/src/HPCloud/Services/DBaaS/Instance.php @@ -0,0 +1,67 @@ +token = $token; + $this->projectId = $projectId; + $this->url = $endpoint; + } + + public function describe($instanceId) { + } + + public function listInstances() { + } + + public function create($name, $flavor = 'medium', $port = NULL, $typeSpec = NULL) { + } + + public function delete($instanceId) { + } + + public function restart($instanceId) { + } + + /** + * Reset the primary password on this instance. + * + * @retval string + * The new (autogenerated) password. + */ + public function resetPassword($instanceId) { + } + + +} diff --git a/src/HPCloud/Services/DBaaS/InstanceDetails.php b/src/HPCloud/Services/DBaaS/InstanceDetails.php new file mode 100644 index 0000000..b36e682 --- /dev/null +++ b/src/HPCloud/Services/DBaaS/InstanceDetails.php @@ -0,0 +1,31 @@ +token = $token; + $this->projectId = $projectId; + $this->url = $endpoint; + } + + public function listSnapshots($instanceId = NULL) { + } + + public function create($instanceId, $name) { + } + + public function delete($snapshotId) { + } + + public function fetch($snapshotId) { + } + +} diff --git a/src/HPCloud/Services/DBaaS/SnapshotDetails.php b/src/HPCloud/Services/DBaaS/SnapshotDetails.php new file mode 100644 index 0000000..5c9d639 --- /dev/null +++ b/src/HPCloud/Services/DBaaS/SnapshotDetails.php @@ -0,0 +1,31 @@ +