Skip to content

Commit

Permalink
Merge branch 'working'
Browse files Browse the repository at this point in the history
Conflicts:
	lib/OpenCloud/Globals.php
  • Loading branch information
gecampbell committed May 10, 2013
2 parents 6eee9d0 + b3eff0b commit fc121d9
Show file tree
Hide file tree
Showing 10 changed files with 181 additions and 88 deletions.
5 changes: 4 additions & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ RELEASE NOTES

### Current branch: master

### 1.5.5
### 05/10/2013 Version 1.5.6
* Support for DNS\Domain::CloneDomain() feature

### 05/07/2013 Version 1.5.5
* PSR-2 implementation (code formatting)
* issue #95 - attempt to fix default timezone to satisfy folks

Expand Down
2 changes: 1 addition & 1 deletion docs/quickref.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ encouraged to contribute theirs).
To use the **php-opencloud** library, use this `require()` statement in your
script:

require '/path/to/php-opencloud.php';
require '/path/to/lib/php-opencloud.php';

Once you've referenced the desired connection class, you can proceed
to establish the connection. For OpenStack clouds, provide the
Expand Down
16 changes: 6 additions & 10 deletions docs/userguide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,10 @@ In the .ZIP or .tar file in which you received the library, everything under
the `lib/` directory should be installed in a location that is accessible. If you're not using a dependency manager like Composer, you will have to register the OpenCloud namespace for your app to use:

// Define the path to the library
$libPath = '/path/to/php-opencloud';
$libPath = '/path/to/php-opencloud/lib';

// Include the autoloader
require_once $libraryPath . '/Autoload.php';

// Register the root OpenCloud namespace
$classLoader = new SplClassLoader('OpenCloud', $libraryPath . '/lib');
$classLoader->register();
require_once $libPath . '/php-opencloud.php';

Once the OpenCloud namespace is registered, you will be able to access all functionality by referencing the class's namespace (in full PSR-0 compliance). For more information about namespaces, check out [PHP's documentation](http://php.net/manual/en/language.namespaces.php).

Expand Down Expand Up @@ -94,11 +90,11 @@ Other Available Documentation

The *php-opencloud API Reference* is auto-generated documentation on the entire
php-opencloud library. Because it is auto-generated, it is kept in sync with the
actual underlying source code (unlike this document, which must be manually
edited).
actual underlying source code (unlike this document, which must be manually
edited).
[@TODO provide links to internal and online versions]

The *php-opencloud Quick Reference* is a simplified reference, providing API
The *php-opencloud Quick Reference* is a simplified reference, providing API
descriptions and syntax for the core features of the library. It is found in
various formats:

Expand Down
52 changes: 28 additions & 24 deletions lib/OpenCloud/AbstractClass/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
*
* @author Glen Campbell <[email protected]>
*/
abstract class Service extends \OpenCloud\Base\Base
abstract class Service extends \OpenCloud\Base\Base
{

private $conn;
private $service_type;
private $service_name;
private $service_region;
private $service_region;
private $service_url;

protected $_namespaces = array();

/**
Expand All @@ -54,10 +54,10 @@ abstract class Service extends \OpenCloud\Base\Base
* (e.g., "publicURL")
*/
public function __construct(
OpenStack $conn,
$type,
$name,
$region,
OpenStack $conn,
$type,
$name,
$region,
$urltype = RAXSDK_URL_PUBLIC
) {
$this->conn = $conn;
Expand All @@ -77,11 +77,11 @@ public function __construct(
public function Url($resource = '', array $param = array())
{
$baseurl = $this->service_url;

if ($resource) {
$baseurl = Lang::noslash($baseurl).'/'.$resource;
}

if (!empty($param)) {
$baseurl .= '?'.$this->MakeQueryString($param);
}
Expand All @@ -95,7 +95,7 @@ public function Url($resource = '', array $param = array())
* @api
* @return array of objects
*/
public function Extensions()
public function Extensions()
{
$ext = $this->GetMetaUrl('extensions');

Expand All @@ -112,10 +112,10 @@ public function Extensions()
* @api
* @return array of limits
*/
public function Limits()
public function Limits()
{
$lim = $this->GetMetaUrl('limits');

if (is_object($lim)) {
return $lim->limits;
} else {
Expand All @@ -137,10 +137,14 @@ public function Limits()
* @param string $body An optional body for POST/PUT requests
* @return \OpenCloud\HttpResult
*/
public function Request($url, $method = 'GET', array $headers = array() ,$body = null)
public function Request(
$url,
$method = 'GET',
array $headers = array(),
$body = null)
{
$headers['X-Auth-Token'] = $this->conn->Token();

if ($tenant = $this->conn->Tenant()) {
$headers['X-Auth-Project-Id'] = $tenant;
}
Expand All @@ -158,7 +162,7 @@ public function Request($url, $method = 'GET', array $headers = array() ,$body =
* query strings
* @return \OpenCloud\Collection
*/
public function Collection($class, $url = null, $parent = null, array $parm = array())
public function Collection($class, $url = null, $parent = null, array $parm = array())
{
// set the element name
$collection = $class::JsonCollectionName();
Expand Down Expand Up @@ -229,7 +233,7 @@ public function Collection($class, $url = null, $parent = null, array $parm = ar
} elseif (isset($obj->$collection)) {
if (!$element) {
$coll_obj = new Collection($parent, $class, $obj->$collection);
} else {
} else {
// handle element levels
$arr = array();
foreach($obj->$collection as $index => $item) {
Expand All @@ -256,7 +260,7 @@ public function Collection($class, $url = null, $parent = null, array $parm = ar
* @api
* @return string
*/
public function Region()
public function Region()
{
return $this->service_region;
}
Expand All @@ -269,7 +273,7 @@ public function Region()
* @api
* @return string
*/
public function Name()
public function Name()
{
return $this->service_name;
}
Expand All @@ -279,7 +283,7 @@ public function Name()
*
* @return array
*/
public function namespaces()
public function namespaces()
{
if (!isset($this->_namespaces)) {
return array();
Expand Down Expand Up @@ -308,7 +312,7 @@ public function namespaces()
* @param string $urltype The URL type; defaults to "publicURL"
* @return string The URL of the service
*/
private function get_endpoint($type, $name, $region, $urltype = 'publicURL')
private function get_endpoint($type, $name, $region, $urltype = 'publicURL')
{
$found = 0;
$catalog = $this->conn->serviceCatalog();
Expand Down Expand Up @@ -354,7 +358,7 @@ private function get_endpoint($type, $name, $region, $urltype = 'publicURL')
* at the beginning or end
* @return \stdClass object
*/
private function GetMetaUrl($resource)
private function GetMetaUrl($resource)
{
$urlbase = $this->get_endpoint(
$this->service_type,
Expand All @@ -380,15 +384,15 @@ private function GetMetaUrl($resource)
if ($response->HttpStatus() >= 300) {
throw new Exceptions\HttpError(sprintf(
Lang::translate('Error accessing [%s] - status [%d], response [%s]'),
$urlbase,
$response->HttpStatus(),
$urlbase,
$response->HttpStatus(),
$response->HttpBody()
));
}

// we're good; proceed
$obj = json_decode($response->HttpBody());

if ($this->CheckJsonError()) {
return false;
}
Expand Down
37 changes: 19 additions & 18 deletions lib/OpenCloud/DNS/AsyncResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@
* The AsyncResponse class encapsulates the data returned by a Cloud DNS
* asynchronous response.
*/
class AsyncResponse extends PersistentObject
class AsyncResponse extends PersistentObject
{

public $jobId;
public $callbackUrl;
public $callbackUrl;
public $status;
public $requestUrl;
public $verb;
public $request;
public $response;
public $error;
public $domains;

protected static $json_name = false;

Expand All @@ -40,7 +41,7 @@ class AsyncResponse extends PersistentObject
* @param \OpenCloud\Service $service the calling service
* @param string $json the json response from the initial request
*/
public function __construct(AbstractService $service, $json = null)
public function __construct(AbstractService $service, $json = null)
{
if (!$json) {
return;
Expand All @@ -61,7 +62,7 @@ public function __construct(AbstractService $service, $json = null)
*
* @return string
*/
public function Url($subresource = null, $qstr = array())
public function Url($subresource = null, $qstr = array())
{
return $this->callbackUrl . '?showDetails=True';
}
Expand All @@ -71,32 +72,32 @@ public function Url($subresource = null, $qstr = array())
*
* @return string
*/
public function Name()
public function Name()
{
return $this->jobId;
}

/**
* overrides for methods
*/
public function Create($parm = array())
{
return $this->NoCreate();
public function Create($parm = array())
{
return $this->NoCreate();
}

public function Update($parm = array())
{
return $this->NoUpdate();
public function Update($parm = array())
{
return $this->NoUpdate();
}

public function Delete()
{
return $this->NoDelete();
public function Delete()
{
return $this->NoDelete();
}

public function PrimaryKeyField()
{
return 'jobId';
public function PrimaryKeyField()
{
return 'jobId';
}

}
}
Loading

0 comments on commit fc121d9

Please sign in to comment.