Begin work on DBaaS classes.

This commit is contained in:
Matt Butcher
2012-05-14 21:12:53 -05:00
parent 3e07cf4686
commit 169528cad5
5 changed files with 255 additions and 3 deletions

View File

@@ -27,20 +27,89 @@ SOFTWARE.
namespace HPCloud\Services; namespace HPCloud\Services;
use \HPCloud\Services\DBaaS\Instance;
use \HPCloud\Services\DBaaS\Snapshot;
class DBaaS { 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() { public function instance() {
return new Instance($this->token, $this->projectId, $this->url);
} }
public function snapshot() { 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;
} }
} }

View File

@@ -0,0 +1,67 @@
<?php
/* ============================================================================
(c) Copyright 2012 Hewlett-Packard Development Company, L.P.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge,publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
============================================================================ */
/**
* @file
*
* This file contains the DBaaS Instance class.
*/
namespace HPCloud\Services\DBaaS;
class Instance {
protected $token;
protected $projectId;
protected $url;
public function __construct($token, $projectId, $endpoint) {
$this->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) {
}
}

View File

@@ -0,0 +1,31 @@
<?php
/* ============================================================================
(c) Copyright 2012 Hewlett-Packard Development Company, L.P.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge,publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
============================================================================ */
/**
* @file
*
* This file contains the HPCloud::DBaaS::InstanceDetails class.
*/
namespace HPCloud\Services\DBaaS;
class InstanceDetails {
}

View File

@@ -0,0 +1,54 @@
<?php
/* ============================================================================
(c) Copyright 2012 Hewlett-Packard Development Company, L.P.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge,publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
============================================================================ */
/**
* @file
*
* This file contains the DBaaS Snapshot class.
*/
namespace HPCloud\Services\DBaaS;
class Snapshot {
protected $token;
protected $projectId;
protected $url;
public function __construct($token, $projectId, $endpoint) {
$this->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) {
}
}

View File

@@ -0,0 +1,31 @@
<?php
/* ============================================================================
(c) Copyright 2012 Hewlett-Packard Development Company, L.P.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge,publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
============================================================================ */
/**
* @file
*
* This file contains the HPCloud::DBaaS::SnapshotDetails class.
*/
namespace HPCloud\Services\DBaaS;
class SnapshotDetails {
}