Updated the directory and namespace structure to support

multiple API verstions for each service. This included
updating the directory structure for the tests and moving
the Common files to a Common namespace.

Implements blueprint multiple-api-versions

Change-Id: I9f9dfc4ef8f4172243519772a9af86dd92690fcf
This commit is contained in:
Matt Farina 2014-04-23 19:40:17 -04:00
parent 30713abaa6
commit 153e6e8b67
50 changed files with 428 additions and 441 deletions

2
.gitignore vendored
View File

@ -5,4 +5,4 @@ vendor/
.DS_Store .DS_Store
composer.lock composer.lock
composer.phar composer.phar
test/settings.ini* tests/settings.ini*

View File

@ -13,6 +13,9 @@
"phpunit/phpunit": "4.*" "phpunit/phpunit": "4.*"
}, },
"autoload": { "autoload": {
"psr-4": { "OpenStack\\": "src/OpenStack" } "psr-4": {
"OpenStack\\": "src/OpenStack",
"OpenStack\\Tests\\": "tests/Tests"
}
} }
} }

View File

@ -92,7 +92,7 @@
*- And so on *- And so on
* @see http://us3.php.net/manual/en/ref.filesystem.php * @see http://us3.php.net/manual/en/ref.filesystem.php
* *
* Learn more about this at \OpenStack\Storage\ObjectStorage\StreamWrapper. * Learn more about this at \OpenStack\ObjectStore\v1\Resource\StreamWrapper.
* *
* Basic Example: Identity Service * Basic Example: Identity Service
* *
@ -109,7 +109,7 @@
* // you might want to use this: * // you might want to use this:
* \OpenStack\Autoloader::useAutoloader(); * \OpenStack\Autoloader::useAutoloader();
* *
* use \OpenStack\Services\IdentityService; * use \OpenStack\Identity\v1\IdentityService;
* *
* // Create a new identity service object, and tell it where to * // Create a new identity service object, and tell it where to
* // go to authenticate. This URL can be found in your console. * // go to authenticate. This URL can be found in your console.
@ -137,12 +137,12 @@
* them before, don't worry. They're easy to get the hang of. * them before, don't worry. They're easy to get the hang of.
*- The Bootstrap class handles setting up OpenStack services. Read about it at \OpenStack\Bootstrap. *- The Bootstrap class handles setting up OpenStack services. Read about it at \OpenStack\Bootstrap.
*- The IdentityServices class handles authenticating to OpenStack, discovering services, and providing *- The IdentityServices class handles authenticating to OpenStack, discovering services, and providing
* access to your account. \OpenStack\Services\IdentityService explains the details, but here are * access to your account. \OpenStack\Identity\v1\IdentityService explains the details, but here are
* a few functions you'll want to know: * a few functions you'll want to know:
* - \OpenStack\Services\IdentityService::__construct() tells the object where to connect. * - \OpenStack\Identity\v1\IdentityService::__construct() tells the object where to connect.
* - \OpenStack\Services\IdentityService::authenticateAsUser() lets you log * - \OpenStack\Identity\v1\IdentityService::authenticateAsUser() lets you log
* in with username and password. * in with username and password.
* - \OpenStack\Services\IdentityService::serviceCatalog() tells you about * - \OpenStack\Identity\v1\IdentityService::serviceCatalog() tells you about
* the services you have activated on this account. * the services you have activated on this account.
* *
* Basic Example: Object Storage * Basic Example: Object Storage
@ -157,10 +157,10 @@
* // $objectStorageUrl = storageList[0]['endpoints'][0]['publicURL']; * // $objectStorageUrl = storageList[0]['endpoints'][0]['publicURL'];
* *
* // Create a new ObjectStorage instance: * // Create a new ObjectStorage instance:
* // $objectStore = new \OpenStack\Storage\ObjectStorage($token, $objectStorageUrl); * // $objectStore = new \OpenStack\ObjectStore\v1\ObjectStorage($token, $objectStorageUrl);
* *
* // Or let ObjectStorage figure out which instance to use: * // Or let ObjectStorage figure out which instance to use:
* $objectStore = \OpenStack\Storage\ObjectStorage::newFromIdentity($identity); * $objectStore = \OpenStack\ObjectStore\v1\ObjectStorage::newFromIdentity($identity);
* *
* // List containers: * // List containers:
* print_r($objectStore->containers()); * print_r($objectStore->containers());
@ -182,14 +182,14 @@
* ?> * ?>
* *
* This shows you a few methods for accessing objects and containers on your * This shows you a few methods for accessing objects and containers on your
* \OpenStack\Storage\ObjectStorage account. There are many functions for * \OpenStack\ObjectStore\v1\ObjectStorage account. There are many functions for
* creating and modifying containers and objects, too. * creating and modifying containers and objects, too.
* *
*- \OpenStack\Storage\ObjectStorage is where you will start. *- \OpenStack\ObjectStore\v1\ObjectStorage is where you will start.
*- Container services are in \OpenStack\Storage\ObjectStorage\Container *- Container services are in \OpenStack\ObjectStore\v1\ObjectStorage\Container
*- There are two classes for objects: *- There are two classes for objects:
* - \OpenStack\Storage\ObjectStorage\Object is for creating new objects. * - \OpenStack\ObjectStore\v1\ObjectStorage\Object is for creating new objects.
* - \OpenStack\Storage\ObjectStorage\RemoteObject provides better network * - \OpenStack\ObjectStore\v1\ObjectStorage\RemoteObject provides better network
* performance when reading objects. * performance when reading objects.
* *
*/ */
@ -222,7 +222,7 @@
* @package OpenStack.Storage.ObjectStorage * @package OpenStack.Storage.ObjectStorage
* Classes specific to ObjectStorage. * Classes specific to ObjectStorage.
* *
* The main class is \OpenStack\Storage\ObjectStorage. * The main class is \OpenStack\ObjectStore\v1\ObjectStorage.
*/ */
/** /**
* @package OpenStack.Transport * @package OpenStack.Transport

View File

@ -2,9 +2,9 @@
require_once __DIR__ . '/../src/OpenStack/Autoloader.php'; require_once __DIR__ . '/../src/OpenStack/Autoloader.php';
use \OpenStack\Autoloader; use \OpenStack\Autoloader;
use \OpenStack\Services\IdentityService; use \OpenStack\Identity\v2\IdentityService;
use \OpenStack\Storage\ObjectStorage; use \OpenStack\ObjectStore\v1\ObjectStorage;
use \OpenStack\Storage\ObjectStorage\Object; use \OpenStack\ObjectStore\v1\ObjectStorage\Object;
Autoloader::useAutoloader(); Autoloader::useAutoloader();

View File

@ -37,7 +37,7 @@ The object-oriented library makes ample use of PHP namespaces. If you've
never seen these before, they look like this: never seen these before, they look like this:
<?php <?php
\OpenStack\Storage\ObjectStorage\RemoteObject \OpenStack\ObjectStore\v1\Resource\RemoteObject
?> ?>
The namespace above is read like this: "The RemoteObject class is part The namespace above is read like this: "The RemoteObject class is part
@ -49,7 +49,7 @@ symbol choice).
For our library, we followed the recommendation of SPR-0, which means For our library, we followed the recommendation of SPR-0, which means
that the class above can be found in the file at: that the class above can be found in the file at:
src/OpenStack/Storage/ObjectStorage/RemoteObject.php src/OpenStack/ObjectStore/v1/Resource/RemoteObject.php
The pattern of matching namespace to file name should (we hope) make it The pattern of matching namespace to file name should (we hope) make it
easier for you to navigate our code. easier for you to navigate our code.
@ -97,9 +97,9 @@ and this is done as follows:
use \OpenStack\Autoloader; use \OpenStack\Autoloader;
use \OpenStack\Bootstrap; use \OpenStack\Bootstrap;
use \OpenStack\Services\IdentityService; use \OpenStack\Identity\v2\IdentityService;
use \OpenStack\Storage\ObjectStorage; use \OpenStack\ObjectStore\v1\ObjectStorage;
use \OpenStack\Storage\ObjectStorage\Object; use \OpenStack\ObjectStore\v1\Resource\Object;
\OpenStack\Autoloader::useAutoloader(); \OpenStack\Autoloader::useAutoloader();
?> ?>
@ -182,7 +182,7 @@ authenticating.
$tenantId = 'ADD TENANT ID HERE'; $tenantId = 'ADD TENANT ID HERE';
$endpoint = 'ADD ENDPOINT URL HERE'; $endpoint = 'ADD ENDPOINT URL HERE';
$idService = new \OpenStack\Services\IdentityService($endpoint); $idService = new \OpenStack\Identity\v2\IdentityService($endpoint);
$token = $idService->authenticateAsUser($username, $password, $tenantId); $token = $idService->authenticateAsUser($username, $password, $tenantId);
?> ?>
@ -203,9 +203,9 @@ authorization token (`$token`), though we can also get the token from
`$idService->token()`. `$idService->token()`.
Note that the `IdentityService` object may throw various exceptions Note that the `IdentityService` object may throw various exceptions
(all subclasses of OpenStack::Exception) during authentication. Failed (all subclasses of OpenStack\Common\Exception) during authentication. Failed
authentication results in an \OpenStack\Transport\AuthorizationException, while authentication results in an \OpenStack\Common\Transport\AuthorizationException, while
a network failure may result in an \OpenStack\Transport\ServerException. a network failure may result in an \OpenStack\Common\Transport\ServerException.
Earlier, we talked about the service catalog. Once we've authenticated, Earlier, we talked about the service catalog. Once we've authenticated,
we can get the service catalog from `$idService->serviceCatalog()`. It we can get the service catalog from `$idService->serviceCatalog()`. It
@ -217,7 +217,7 @@ look at Object Storage.
### IdentityService in a Nutshell ### IdentityService in a Nutshell
Instances of OpenStack::Services::IdentityService are responsible for: Instances of `OpenStack\Identity\v2\IdentityService` are responsible for:
- Authentication - Authentication
- Accessing the service catalog - Accessing the service catalog
@ -250,7 +250,7 @@ shows the Object Storage endpoint that we have already authenticated to
Identity Services. Earlier, we captured that value in the `$token` Identity Services. Earlier, we captured that value in the `$token`
variable. variable.
Now we can get a new OpenStack::Storage::ObjectStorage instance: Now we can get a new `\OpenStack\ObjectStore\v1\ObjectStorage` instance:
<?php <?php
$catalog = $idService->serviceCatalog(); $catalog = $idService->serviceCatalog();
@ -332,7 +332,7 @@ Now that we have a `Container`, we can add an object.
(Yes, we realize the irony of that title.) (Yes, we realize the irony of that title.)
A OpenStack::Storage::ObjectStorage::Container instance is responsible for the following: A `\OpenStack\ObjectStore\v1\Resource\Container` instance is responsible for the following:
- Accessing information about the container - Accessing information about the container
- Creating, saving, deleting, and listing objects in the container - Creating, saving, deleting, and listing objects in the container
@ -396,7 +396,7 @@ Next let's turn to loading objects from the remote object storage.
### The Object in a Nutshell ### The Object in a Nutshell
The OpenStack::Storage::ObjectStorage::Object instances are used for: The `\OpenStack\ObjectStore\v1\Resource\Object` instances are used for:
- Creating a local object to be stored remotely - Creating a local object to be stored remotely
@ -423,7 +423,7 @@ loading objects. Thus, we can fetch the object that we just created:
?> ?>
The `$object` variable now references an instance of a The `$object` variable now references an instance of a
OpenStack::Storage::ObjectStorage::RemoteObject that contains the entire `\OpenStack\ObjectStore\v1\Resource\RemoteObject` that contains the entire
object. `RemoteObject` represents an object that was loaded from the object. `RemoteObject` represents an object that was loaded from the
remote server. Along with providing the features of the `Object` class remote server. Along with providing the features of the `Object` class
we saw earlier, it also provides numerous optimizations for working over we saw earlier, it also provides numerous optimizations for working over
@ -473,7 +473,7 @@ called.
### The RemoteObject in a Nutshell ### The RemoteObject in a Nutshell
Instances of a OpenStack::Storage::ObjectStorage::RemoteObject offer the following features: Instances of a `\OpenStack\ObjectStore\v1\Resource\RemoteObject` offer the following features:
- Access to an object stored on the remote object storage - Access to an object stored on the remote object storage
- A proxying mechanism for lazily loading objects - A proxying mechanism for lazily loading objects

View File

@ -156,7 +156,7 @@ names. So `swift://Example/this/is/my/file.png' checks the container
(For power users, there are some fancy operations you can do to treat (For power users, there are some fancy operations you can do to treat
Swift filename parts as if they were directories. Check out Swift filename parts as if they were directories. Check out
OpenStack::Storage::ObjectStorage::Container.) `\OpenStack\ObjectStore\v1\Resource\Container`.)
## Using Stream Contexts for Authentication ## Using Stream Contexts for Authentication
@ -241,4 +241,4 @@ more about that.
Addidtionally, you may wish to learn more about the internals of the Addidtionally, you may wish to learn more about the internals of the
stream wrapper, the main class, stream wrapper, the main class,
OpenStack::Storage::ObjectStorage::StreamWrapper, is well-documented. `\OpenStack\ObjectStore\v1\Resource\StreamWrapper`, is well-documented.

View File

@ -2,7 +2,7 @@
<phpunit colors="true"> <phpunit colors="true">
<testsuites> <testsuites>
<testsuite name="PHPUnit"> <testsuite name="PHPUnit">
<directory>test/Tests/</directory> <directory>tests/Tests/</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<logging> <logging>

View File

@ -22,7 +22,7 @@
namespace OpenStack; namespace OpenStack;
use OpenStack\Services\IdentityService; use OpenStack\Identity\v2\IdentityService;
/** /**
* Bootstrapping services. * Bootstrapping services.
@ -50,7 +50,7 @@ use OpenStack\Services\IdentityService;
* <?php * <?php
* $config = array( * $config = array(
* // We use Guzzle, which defaults to CURL, for a transport layer. * // We use Guzzle, which defaults to CURL, for a transport layer.
* 'transport' => '\OpenStack\Transport\GuzzleClient', * 'transport' => '\OpenStack\Common\Transport\GuzzleClient',
* // Set the HTTP max wait time to 500 seconds. * // Set the HTTP max wait time to 500 seconds.
* 'transport.timeout' => 500, * 'transport.timeout' => 500,
* ); * );
@ -83,17 +83,17 @@ class Bootstrap
{ {
public static $config = array( public static $config = array(
// The transport implementation. By default, we use the Guzzle Client // The transport implementation. By default, we use the Guzzle Client
'transport' => '\OpenStack\Transport\GuzzleClient', 'transport' => '\OpenStack\Common\Transport\GuzzleClient',
); );
/** /**
* @var \OpenStack\Services\IdentityService An identity services object * @var \OpenStack\Identity\v2\IdentityService An identity services object
* created from the global settings. * created from the global settings.
*/ */
public static $identity = null; public static $identity = null;
/** /**
* @var \OpenStack\Transport\ClientInterface A transport client for requests. * @var \OpenStack\Common\Transport\ClientInterface A transport client for requests.
*/ */
public static $transport = null; public static $transport = null;
@ -120,13 +120,13 @@ class Bootstrap
public static function useStreamWrappers() public static function useStreamWrappers()
{ {
$swift = stream_wrapper_register( $swift = stream_wrapper_register(
\OpenStack\Storage\ObjectStorage\StreamWrapper::DEFAULT_SCHEME, \OpenStack\ObjectStore\v1\ObjectStorage\StreamWrapper::DEFAULT_SCHEME,
'\OpenStack\Storage\ObjectStorage\StreamWrapper' '\OpenStack\ObjectStore\v1\ObjectStorage\StreamWrapper'
); );
$swiftfs = stream_wrapper_register( $swiftfs = stream_wrapper_register(
\OpenStack\Storage\ObjectStorage\StreamWrapperFS::DEFAULT_SCHEME, \OpenStack\ObjectStore\v1\ObjectStorage\StreamWrapperFS::DEFAULT_SCHEME,
'\OpenStack\Storage\ObjectStorage\StreamWrapperFS' '\OpenStack\ObjectStore\v1\ObjectStorage\StreamWrapperFS'
); );
return ($swift && $swiftfs); return ($swift && $swiftfs);
@ -144,7 +144,7 @@ class Bootstrap
* Common configuration directives: * Common configuration directives:
* *
* - 'transport': The namespaced classname for the transport that * - 'transport': The namespaced classname for the transport that
* should be used. Example: @code \OpenStack\Transport\CURLTransport @endcode * should be used. Example: \OpenStack\Common\Transport\GuzzleClient
* - 'transport.debug': The integer 1 for enabling debug, 0 for * - 'transport.debug': The integer 1 for enabling debug, 0 for
* disabling. Enabling will turn on verbose debugging output * disabling. Enabling will turn on verbose debugging output
* for any transport that supports it. * for any transport that supports it.
@ -213,17 +213,17 @@ class Bootstrap
} }
/** /**
* Get a \OpenStack\Services\IdentityService object from the bootstrap config. * Get a \OpenStack\Identity\v2\IdentityService object from the bootstrap config.
* *
* A factory helper function that uses the bootstrap configuration to create * A factory helper function that uses the bootstrap configuration to create
* a ready to use \OpenStack\Services\IdentityService object. * a ready to use \OpenStack\Identity\v2\IdentityService object.
* *
* @param bool $force Whether to force the generation of a new object even if * @param bool $force Whether to force the generation of a new object even if
* one is already cached. * one is already cached.
* *
* @return \OpenStack\Services\IdentityService An authenticated ready to use * @return \OpenStack\Identity\v2\IdentityService An authenticated ready to use
* \OpenStack\Services\IdentityService object. * \OpenStack\Identity\v2\IdentityService object.
* @throws \OpenStack\Exception When the needed configuration to authenticate * @throws \OpenStack\Common\Exception When the needed configuration to authenticate
* is not available. * is not available.
*/ */
public static function identity($force = false) public static function identity($force = false)
@ -261,7 +261,7 @@ class Bootstrap
* *
* @param boolean $reset Whether to recreate the transport client if one already exists. * @param boolean $reset Whether to recreate the transport client if one already exists.
* *
* @return \OpenStack\Transport\ClientInterface A transport client. * @return \OpenStack\Common\Transport\ClientInterface A transport client.
*/ */
public static function transport($reset = false) public static function transport($reset = false)
{ {

View File

@ -17,7 +17,7 @@
/** /**
* The parent exception class for OpenStack. * The parent exception class for OpenStack.
*/ */
namespace OpenStack; namespace OpenStack\Common;
/** /**
* The top-level OpenStack exception. * The top-level OpenStack exception.
* *

View File

@ -18,7 +18,7 @@
* This file contains the interface for transporters. * This file contains the interface for transporters.
*/ */
namespace OpenStack\Transport; namespace OpenStack\Common\Transport;
/** /**
* Describes a transport client. * Describes a transport client.
@ -63,20 +63,20 @@ interface ClientInterface
* @param array $headers An array of name/value header pairs. * @param array $headers An array of name/value header pairs.
* @param string $body The string containing the request body. * @param string $body The string containing the request body.
* *
* @return \OpenStack\Transport\ResponseInterface The response. The response * @return \OpenStack\Common\Transport\ResponseInterface The response. The response
* is implicit rather than explicit. The interface is based on a draft for * is implicit rather than explicit. The interface is based on a draft for
* messages from PHP FIG. Individual implementing libraries will have their * messages from PHP FIG. Individual implementing libraries will have their
* own reference to interfaces. For example, see Guzzle. * own reference to interfaces. For example, see Guzzle.
* *
* @throws \OpenStack\Transport\ForbiddenException * @throws \OpenStack\Common\Transport\Exception\ForbiddenException
* @throws \OpenStack\Transport\UnauthorizedException * @throws \OpenStack\Common\Transport\Exception\UnauthorizedException
* @throws \OpenStack\Transport\FileNotFoundException * @throws \OpenStack\Common\Transport\Exception\FileNotFoundException
* @throws \OpenStack\Transport\MethodNotAllowedException * @throws \OpenStack\Common\Transport\Exception\MethodNotAllowedException
* @throws \OpenStack\Transport\ConflictException * @throws \OpenStack\Common\Transport\Exception\ConflictException
* @throws \OpenStack\Transport\LengthRequiredException * @throws \OpenStack\Common\Transport\Exception\LengthRequiredException
* @throws \OpenStack\Transport\UnprocessableEntityException * @throws \OpenStack\Common\Transport\Exception\UnprocessableEntityException
* @throws \OpenStack\Transport\ServerException * @throws \OpenStack\Common\Transport\Exception\ServerException
* @throws \OpenStack\Exception * @throws \OpenStack\Common\Exception
*/ */
public function doRequest($uri, $method = 'GET', array $headers = [], $body = ''); public function doRequest($uri, $method = 'GET', array $headers = [], $body = '');
@ -105,20 +105,20 @@ interface ClientInterface
* default context. So if you need a special context, you should open the * default context. So if you need a special context, you should open the
* file elsewhere and pass the resource in here. * file elsewhere and pass the resource in here.
* *
* @return \OpenStack\Transport\ResponseInterface The response. The response * @return \OpenStack\Common\Transport\ResponseInterface The response. The response
* is implicit rather than explicit. The interface is based on a draft for * is implicit rather than explicit. The interface is based on a draft for
* messages from PHP FIG. Individual implementing libraries will have their * messages from PHP FIG. Individual implementing libraries will have their
* own reference to interfaces. For example, see Guzzle. * own reference to interfaces. For example, see Guzzle.
* *
* @throws \OpenStack\Transport\ForbiddenException * @throws \OpenStack\Common\Transport\Exception\ForbiddenException
* @throws \OpenStack\Transport\UnauthorizedException * @throws \OpenStack\Common\Transport\Exception\UnauthorizedException
* @throws \OpenStack\Transport\FileNotFoundException * @throws \OpenStack\Common\Transport\Exception\FileNotFoundException
* @throws \OpenStack\Transport\MethodNotAllowedException * @throws \OpenStack\Common\Transport\Exception\MethodNotAllowedException
* @throws \OpenStack\Transport\ConflictException * @throws \OpenStack\Common\Transport\Exception\ConflictException
* @throws \OpenStack\Transport\LengthRequiredException * @throws \OpenStack\Common\Transport\Exception\LengthRequiredException
* @throws \OpenStack\Transport\UnprocessableEntityException * @throws \OpenStack\Common\Transport\Exception\UnprocessableEntityException
* @throws \OpenStack\Transport\ServerException * @throws \OpenStack\Common\Transport\Exception\ServerException
* @throws \OpenStack\Exception * @throws \OpenStack\Common\Exception
*/ */
public function doRequestWithResource($uri, $method, array $headers = [], $resource); public function doRequestWithResource($uri, $method, array $headers = [], $resource);
} }

View File

@ -17,10 +17,10 @@
/** /**
* The authorization exception. * The authorization exception.
*/ */
namespace OpenStack\Transport; namespace OpenStack\Common\Transport\Exception;
/** /**
* Thrown when an access constraint is not met. * Thrown when an access constraint is not met.
* *
* Represents an HTTP 401 or 403 exception. * Represents an HTTP 401 or 403 exception.
*/ */
class AuthorizationException extends \OpenStack\Exception {} class AuthorizationException extends \OpenStack\Common\Exception {}

View File

@ -15,7 +15,7 @@
limitations under the License. limitations under the License.
============================================================================ */ ============================================================================ */
namespace OpenStack\Transport; namespace OpenStack\Common\Transport\Exception;
/** /**
* Represents an HTTP 409 error. * Represents an HTTP 409 error.
* *
@ -23,4 +23,4 @@ namespace OpenStack\Transport;
* deleted because the resource is not empty or deleteable. (viz. * deleted because the resource is not empty or deleteable. (viz.
* containers). * containers).
*/ */
class ConflictException extends \OpenStack\Exception {} class ConflictException extends \OpenStack\Common\Exception {}

View File

@ -15,8 +15,8 @@
limitations under the License. limitations under the License.
============================================================================ */ ============================================================================ */
namespace OpenStack\Transport; namespace OpenStack\Common\Transport\Exception;
/** /**
* Represents an HTTP File Not Found error. * Represents an HTTP File Not Found error.
*/ */
class FileNotFoundException extends \OpenStack\Exception {} class FileNotFoundException extends \OpenStack\Common\Exception {}

View File

@ -19,7 +19,7 @@
* *
* The permission denied exception. * The permission denied exception.
*/ */
namespace OpenStack\Transport; namespace OpenStack\Common\Transport\Exception;
/** /**
* Thrown when an access constraint is not met. * Thrown when an access constraint is not met.
* *

View File

@ -15,10 +15,10 @@
limitations under the License. limitations under the License.
============================================================================ */ ============================================================================ */
namespace OpenStack\Transport; namespace OpenStack\Common\Transport\Exception;
/** /**
* Represents an HTTP 412 error. * Represents an HTTP 412 error.
* *
* During some PUT requests, Content-Length is a required header. * During some PUT requests, Content-Length is a required header.
*/ */
class LengthRequiredException extends \OpenStack\Exception {} class LengthRequiredException extends \OpenStack\Common\Exception {}

View File

@ -15,8 +15,8 @@
limitations under the License. limitations under the License.
============================================================================ */ ============================================================================ */
namespace OpenStack\Transport; namespace OpenStack\Common\Transport\Exception;
/** /**
* Represents an HTTP 405 error. * Represents an HTTP 405 error.
*/ */
class MethodNotAllowedException extends \OpenStack\Exception {} class MethodNotAllowedException extends \OpenStack\Common\Exception {}

View File

@ -15,8 +15,8 @@
limitations under the License. limitations under the License.
============================================================================ */ ============================================================================ */
namespace OpenStack\Transport; namespace OpenStack\Common\Transport\Exception;
/** /**
* Represents an HTTP 500 error. * Represents an HTTP 500 error.
*/ */
class ServerException extends \OpenStack\Exception {} class ServerException extends \OpenStack\Common\Exception {}

View File

@ -17,7 +17,7 @@
/** /**
* The authorization exception. * The authorization exception.
*/ */
namespace OpenStack\Transport; namespace OpenStack\Common\Transport\Exception;
/** /**
* Thrown when authorization fails. * Thrown when authorization fails.
* *

View File

@ -15,11 +15,11 @@
limitations under the License. limitations under the License.
============================================================================ */ ============================================================================ */
namespace OpenStack\Transport; namespace OpenStack\Common\Transport\Exception;
/** /**
* Represents an HTTP 422 error. * Represents an HTTP 422 error.
* *
* This often represents a case where a checksum or hash did not match * This often represents a case where a checksum or hash did not match
* the generated checksum on the remote end. * the generated checksum on the remote end.
*/ */
class UnprocessableEntityException extends \OpenStack\Exception {} class UnprocessableEntityException extends \OpenStack\Common\Exception {}

View File

@ -18,7 +18,7 @@
* This file contains the interface for transporter clients. * This file contains the interface for transporter clients.
*/ */
namespace OpenStack\Transport; namespace OpenStack\Common\Transport;
class GuzzleClient implements ClientInterface, \Serializable class GuzzleClient implements ClientInterface, \Serializable
{ {
@ -161,17 +161,17 @@ class GuzzleClient implements ClientInterface, \Serializable
* *
* @param mixed The Guzzle exception. * @param mixed The Guzzle exception.
* *
* @return \OpenStack\Transport\ResponseInterface The response. * @return \OpenStack\Common\Transport\ResponseInterface The response.
* *
* @throws \OpenStack\Transport\ForbiddenException * @throws \OpenStack\Common\Transport\Exception\ForbiddenException
* @throws \OpenStack\Transport\UnauthorizedException * @throws \OpenStack\Common\Transport\Exception\UnauthorizedException
* @throws \OpenStack\Transport\FileNotFoundException * @throws \OpenStack\Common\Transport\Exception\FileNotFoundException
* @throws \OpenStack\Transport\MethodNotAllowedException * @throws \OpenStack\Common\Transport\Exception\MethodNotAllowedException
* @throws \OpenStack\Transport\ConflictException * @throws \OpenStack\Common\Transport\Exception\ConflictException
* @throws \OpenStack\Transport\LengthRequiredException * @throws \OpenStack\Common\Transport\Exception\LengthRequiredException
* @throws \OpenStack\Transport\UnprocessableEntityException * @throws \OpenStack\Common\Transport\Exception\UnprocessableEntityException
* @throws \OpenStack\Transport\ServerException * @throws \OpenStack\Common\Transport\Exception\ServerException
* @throws \OpenStack\Exception * @throws \OpenStack\Common\Exception
*/ */
protected function handleException($exception) protected function handleException($exception)
{ {
@ -183,29 +183,29 @@ class GuzzleClient implements ClientInterface, \Serializable
switch ($code) { switch ($code) {
case '403': case '403':
throw new \OpenStack\Transport\ForbiddenException($response->getReasonPhrase()); throw new \OpenStack\Common\Transport\Exception\ForbiddenException($response->getReasonPhrase());
case '401': case '401':
throw new \OpenStack\Transport\UnauthorizedException($response->getReasonPhrase()); throw new \OpenStack\Common\Transport\Exception\UnauthorizedException($response->getReasonPhrase());
case '404': case '404':
throw new \OpenStack\Transport\FileNotFoundException($response->getReasonPhrase() . " ({$response->getEffectiveUrl()})"); throw new \OpenStack\Common\Transport\Exception\FileNotFoundException($response->getReasonPhrase() . " ({$response->getEffectiveUrl()})");
case '405': case '405':
throw new \OpenStack\Transport\MethodNotAllowedException($response->getReasonPhrase() . " ({$request->getMethod()} {$response->getEffectiveUrl()})"); throw new \OpenStack\Common\Transport\Exception\MethodNotAllowedException($response->getReasonPhrase() . " ({$request->getMethod()} {$response->getEffectiveUrl()})");
case '409': case '409':
throw new \OpenStack\Transport\ConflictException($response->getReasonPhrase()); throw new \OpenStack\Common\Transport\Exception\ConflictException($response->getReasonPhrase());
case '412': case '412':
throw new \OpenStack\Transport\LengthRequiredException($response->getReasonPhrase()); throw new \OpenStack\Common\Transport\Exception\LengthRequiredException($response->getReasonPhrase());
case '422': case '422':
throw new \OpenStack\Transport\UnprocessableEntityException($response->getReasonPhrase()); throw new \OpenStack\Common\Transport\Exception\UnprocessableEntityException($response->getReasonPhrase());
case '500': case '500':
throw new \OpenStack\Transport\ServerException($response->getReasonPhrase()); throw new \OpenStack\Common\Transport\Exception\ServerException($response->getReasonPhrase());
default: default:
throw new \OpenStack\Exception($response->getReasonPhrase()); throw new \OpenStack\Common\Exception($response->getReasonPhrase());
} }
} }
// The exception was one other than a HTTP error. For example, a HTTP layer // The exception was one other than a HTTP error. For example, a HTTP layer
// timeout occurred. // timeout occurred.
else { else {
throw new \OpenStack\Exception($exception->getMessage()); throw new \OpenStack\Common\Exception($exception->getMessage());
} }
return $response; return $response;

View File

@ -18,7 +18,7 @@
* This file contains the response interface for a HTTP request. * This file contains the response interface for a HTTP request.
*/ */
namespace OpenStack\Transport; namespace OpenStack\Common\Transport;
/** /**
* A Response is what comes back from a HTTP Request. * A Response is what comes back from a HTTP Request.

View File

@ -18,9 +18,9 @@
* This file contains the main IdentityService class. * This file contains the main IdentityService class.
*/ */
namespace OpenStack\Services; namespace OpenStack\Identity\v2;
use OpenStack\Transport\GuzzleClient; use OpenStack\Common\Transport\GuzzleClient;
/** /**
* IdentityService provides authentication and authorization. * IdentityService provides authentication and authorization.
@ -80,7 +80,7 @@ use OpenStack\Transport\GuzzleClient;
* <?php * <?php
* // You may need to use \OpenStack\Bootstrap to set things up first. * // You may need to use \OpenStack\Bootstrap to set things up first.
* *
* use \OpenStack\Services\IdentityService; * use \OpenStack\Identity\v2\IdentityService;
* *
* // Create a new object with the endpoint URL (no version number) * // Create a new object with the endpoint URL (no version number)
* $ident = new IdentityService('https://example.com:35357'); * $ident = new IdentityService('https://example.com:35357');
@ -190,18 +190,18 @@ class IdentityService
* that URI. * that URI.
* *
* <?php * <?php
* $cs = new \OpenStack\Services\IdentityService('http://example.com'); * $cs = new \OpenStack\Identity\v2\IdentityService('http://example.com');
* $token = $cs->authenticateAsUser($username, $password); * $token = $cs->authenticateAsUser($username, $password);
* ?> * ?>
* *
* @param string $url An URL pointing to the Identity Services endpoint. * @param string $url An URL pointing to the Identity Service endpoint.
* Note that you do not need the version identifier in the URL, as version * Note that you do not need the version identifier in the URL, as version
* information is sent in the HTTP headers rather than in the URL. The URL * information is sent in the HTTP headers rather than in the URL. The URL
* should always be to an SSL/TLS encrypted endpoint. * should always be to an SSL/TLS encrypted endpoint.
* *
* @param \OpenStack\Transport\ClientInterface $client An optional HTTP client to use when making the requests. * @param \OpenStack\Common\Transport\ClientInterface $client An optional HTTP client to use when making the requests.
*/ */
public function __construct($url, \OpenStack\Transport\ClientInterface $client = null) public function __construct($url, \OpenStack\Common\Transport\ClientInterface $client = null)
{ {
$parts = parse_url($url); $parts = parse_url($url);
@ -243,7 +243,7 @@ class IdentityService
* the authenticate() method: * the authenticate() method:
* *
* <?php * <?php
* $cs = new \OpenStack\Services\IdentityService($url); * $cs = new \OpenStack\Identity\v2\IdentityService($url);
* $ops = array( * $ops = array(
* 'passwordCredentials' => array( * 'passwordCredentials' => array(
* 'username' => $username, * 'username' => $username,
@ -263,8 +263,8 @@ class IdentityService
* response is used to populate this object's service catalog, etc. The * response is used to populate this object's service catalog, etc. The
* token is also retrievable with token(). * token is also retrievable with token().
* *
* @throws \OpenStack\Transport\AuthorizationException If authentication failed. * @throws \OpenStack\Common\Transport\Exception\AuthorizationException If authentication failed.
* @throws \OpenStack\Exception For abnormal network conditions. The message * @throws \OpenStack\Common\Exception For abnormal network conditions. The message
* will give an indication as to the underlying problem. * will give an indication as to the underlying problem.
*/ */
public function authenticate(array $ops) public function authenticate(array $ops)
@ -315,9 +315,9 @@ class IdentityService
* @param string $tenantName The tenant Name. This can be obtained through the * @param string $tenantName The tenant Name. This can be obtained through the
* OpenStack console. * OpenStack console.
* *
* @throws \OpenStack\Transport\AuthorizationException If authentication failed. * @throws \OpenStack\Common\Transport\Exception\AuthorizationException If authentication failed.
* @throws \OpenStack\Exception For abnormal network conditions. The message * @throws \OpenStack\Common\Exception For abnormal network conditions. The message will give an
* will give an indication as to the underlying problem. * indication as to the underlying problem.
*/ */
public function authenticateAsUser($username, $password, $tenantId = null, $tenantName = null) public function authenticateAsUser($username, $password, $tenantId = null, $tenantName = null)
{ {
@ -585,9 +585,9 @@ class IdentityService
* @return array An indexed array of tenant info. Each entry will be an * @return array An indexed array of tenant info. Each entry will be an
* associative array containing tenant details. * associative array containing tenant details.
* *
* @throws \OpenStack\Transport\AuthorizationException If authentication failed. * @throws \OpenStack\Common\Transport\Exception\AuthorizationException If authentication failed.
* @throws \OpenStack\Exception For abnormal network conditions. The message * @throws \OpenStack\Common\Exception For abnormal network conditions. The message will give an
* will give an indication as to the underlying problem. * indication as to the underlying problem.
*/ */
public function tenants($token = null) public function tenants($token = null)
{ {
@ -612,7 +612,7 @@ class IdentityService
} }
/** /**
* @see \OpenStack\Services\IdentityService::rescopeUsingTenantId() * @see \OpenStack\Identity\v2\IdentityService::rescopeUsingTenantId()
* @deprecated * @deprecated
*/ */
public function rescope($tenantId) public function rescope($tenantId)
@ -644,8 +644,8 @@ class IdentityService
* *
* @return string The authentication token. * @return string The authentication token.
* *
* @throws \OpenStack\Transport\AuthorizationException If authentication failed. * @throws \OpenStack\Common\Transport\Exception\AuthorizationException If authentication failed.
* @throws \OpenStack\Exception For abnormal network conditions. The message will give an * @throws \OpenStack\Common\Exception For abnormal network conditions. The message will give an
* indication as to the underlying problem. * indication as to the underlying problem.
*/ */
public function rescopeUsingTenantId($tenantId) public function rescopeUsingTenantId($tenantId)
@ -699,8 +699,8 @@ class IdentityService
* *
* @return string The authentication token. * @return string The authentication token.
* *
* @throws \OpenStack\Transport\AuthorizationException If authentication failed. * @throws \OpenStack\Common\Transport\Exception\AuthorizationException If authentication failed.
* @throws \OpenStack\Exception For abnormal network conditions. The message will * @throws \OpenStack\Common\Exception For abnormal network conditions. The message will
* give an indication as to the underlying problem. * give an indication as to the underlying problem.
*/ */
public function rescopeUsingTenantName($tenantName) public function rescopeUsingTenantName($tenantName)
@ -736,9 +736,9 @@ class IdentityService
* This parses the JSON data and parcels out the data to the appropriate * This parses the JSON data and parcels out the data to the appropriate
* fields. * fields.
* *
* @param \OpenStack\Transport\ResponseInterface $response A response object. * @param \OpenStack\Common\Transport\ResponseInterface $response A response object.
* *
* @return \OpenStack\Services\IdentityService $this for the current object so * @return \OpenStack\Identity\v2\IdentityService $this for the current object so
* it can be used in chaining. * it can be used in chaining.
*/ */
protected function handleResponse($response) protected function handleResponse($response)

View File

@ -18,7 +18,7 @@
* Contains exception class for ContainerNotEmptyException. * Contains exception class for ContainerNotEmptyException.
*/ */
namespace OpenStack\Storage\ObjectStorage; namespace OpenStack\ObjectStore\v1\Exception;
/** /**
* Indicatest that a container is not empty. * Indicatest that a container is not empty.
@ -28,4 +28,4 @@ namespace OpenStack\Storage\ObjectStorage;
* exception is thrown when such an operation encounters an unempty * exception is thrown when such an operation encounters an unempty
* container when it requires an empty one. * container when it requires an empty one.
*/ */
class ContainerNotEmptyException extends \OpenStack\Transport\ServerException {} class ContainerNotEmptyException extends \OpenStack\Common\Transport\Exception\ServerException {}

View File

@ -17,7 +17,7 @@
/** /**
* Contains the ContentVerificationException object. * Contains the ContentVerificationException object.
*/ */
namespace OpenStack\Storage\ObjectStorage; namespace OpenStack\ObjectStore\v1\Exception;
/** /**
* Content Verification error condition. * Content Verification error condition.
@ -26,4 +26,4 @@ namespace OpenStack\Storage\ObjectStorage;
* not match the supplied checksum. See * not match the supplied checksum. See
* RemoteObject::setContentVerification(). * RemoteObject::setContentVerification().
*/ */
class ContentVerificationException extends \OpenStack\Exception {} class ContentVerificationException extends \OpenStack\Common\Exception {}

View File

@ -15,8 +15,8 @@
limitations under the License. limitations under the License.
============================================================================ */ ============================================================================ */
namespace OpenStack\Storage\ObjectStorage; namespace OpenStack\ObjectStore\v1\Exception;
/** /**
* Thrown if an object that is read only is modified. * Thrown if an object that is read only is modified.
*/ */
class ReadOnlyObjectException extends \OpenStack\Exception {} class ReadOnlyObjectException extends \OpenStack\Common\Exception {}

View File

@ -23,11 +23,11 @@
* a text document, a binary). * a text document, a binary).
*/ */
namespace OpenStack\Storage; namespace OpenStack\ObjectStore\v1;
use OpenStack\Storage\ObjectStorage\Container; use OpenStack\ObjectStore\v1\Resource\Container;
use OpenStack\Storage\ObjectStorage\ACL; use OpenStack\ObjectStore\v1\Resource\ACL;
use OpenStack\Transport\GuzzleClient; use OpenStack\Common\Transport\GuzzleClient;
/** /**
* Access to ObjectStorage (Swift). * Access to ObjectStorage (Swift).
@ -46,8 +46,8 @@ use OpenStack\Transport\GuzzleClient;
* mechanism for Swift. You can use ObjectStorage::newFromSwiftAuth() to * mechanism for Swift. You can use ObjectStorage::newFromSwiftAuth() to
* perform this type of authentication. * perform this type of authentication.
* *
* Newer versions use the IdentityServices authentication mechanism (@see * Newer versions use the IdentityService authentication mechanism (@see
* \OpenStack\Services\IdentityServices). That method is the preferred * \OpenStack\Identity\v2\IdentityService). That method is the preferred
* method. * method.
* *
* Common Tasks * Common Tasks
@ -58,7 +58,7 @@ use OpenStack\Transport\GuzzleClient;
* *
* @todo ObjectStorage is not yet constrained to a particular version * @todo ObjectStorage is not yet constrained to a particular version
* of the API. It attempts to use whatever version is passed in to the * of the API. It attempts to use whatever version is passed in to the
* URL. This is different than IdentityServices, which used a fixed version. * URL. This is different than IdentityService, which used a fixed version.
*/ */
class ObjectStorage class ObjectStorage
{ {
@ -91,7 +91,7 @@ class ObjectStorage
* Create a new instance after getting an authenitcation token. * Create a new instance after getting an authenitcation token.
* *
* THIS METHOD IS DEPRECATED. OpenStack now uses Keyston to authenticate. * THIS METHOD IS DEPRECATED. OpenStack now uses Keyston to authenticate.
* You should use \OpenStack\Services\IdentityServices to authenticate. * You should use \OpenStack\Identity\v2\IdentityService to authenticate.
* Then use this class's constructor to create an object. * Then use this class's constructor to create an object.
* *
* This uses the legacy Swift authentication facility to authenticate * This uses the legacy Swift authentication facility to authenticate
@ -110,16 +110,14 @@ class ObjectStorage
* @param string $key Your secret key. * @param string $key Your secret key.
* @param string $url The URL to the object storage endpoint. * @param string $url The URL to the object storage endpoint.
* *
* @throws \OpenStack\Transport\AuthorizationException if the * @throws \OpenStack\Common\Transport\Exception\AuthorizationException if the authentication failed.
* authentication failed. * @throws \OpenStack\Common\Transport\Exception\FileNotFoundException if the URL is wrong.
* @throws \OpenStack\Transport\FileNotFoundException if the URL is * @throws \OpenStack\Common\Exception if some other exception occurs.
* wrong.
* @throws \OpenStack\Exception if some other exception occurs.
* *
* @deprecated Newer versions of OpenStack use Keystone auth instead * @deprecated Newer versions of OpenStack use Keystone auth instead
* of Swift auth. * of Swift auth.
*/ */
public static function newFromSwiftAuth($account, $key, $url, \OpenStack\Transport\ClientInterface $client = null) public static function newFromSwiftAuth($account, $key, $url, \OpenStack\Common\Transport\ClientInterface $client = null)
{ {
$headers = array( $headers = array(
'X-Auth-User' => $account, 'X-Auth-User' => $account,
@ -150,17 +148,17 @@ class ObjectStorage
} }
/** /**
* Given an IdentityServices instance, create an ObjectStorage instance. * Given an IdentityService instance, create an ObjectStorage instance.
* *
* This constructs a new ObjectStorage from an authenticated instance * This constructs a new ObjectStorage from an authenticated instance
* of an \OpenStack\Services\IdentityServices object. * of an \OpenStack\Identity\v2\IdentityService object.
* *
* @param \OpenStack\Services\IdentityServices $identity An identity services object that already has a valid token * @param \OpenStack\Identity\v2\IdentityService $identity An identity services object that already
* and a service catalog. * has a valid token and a service catalog.
* *
* @return \OpenStack\Storage\ObjectStorage A new ObjectStorage instance. * @return \OpenStack\ObjectStore\v1\ObjectStorage A new ObjectStorage instance.
*/ */
public static function newFromIdentity($identity, $region = ObjectStorage::DEFAULT_REGION, \OpenStack\Transport\ClientInterface $client = null) public static function newFromIdentity($identity, $region = ObjectStorage::DEFAULT_REGION, \OpenStack\Common\Transport\ClientInterface $client = null)
{ {
$cat = $identity->serviceCatalog(); $cat = $identity->serviceCatalog();
$tok = $identity->token(); $tok = $identity->token();
@ -171,20 +169,20 @@ class ObjectStorage
/** /**
* Given a service catalog and an token, create an ObjectStorage instance. * Given a service catalog and an token, create an ObjectStorage instance.
* *
* The IdentityServices object contains a service catalog listing all of the * The IdentityService object contains a service catalog listing all of the
* services to which the present user has access. * services to which the present user has access.
* *
* This builder can scan the catalog and generate a new ObjectStorage * This builder can scan the catalog and generate a new ObjectStorage
* instance pointed to the first object storage endpoint in the catalog. * instance pointed to the first object storage endpoint in the catalog.
* *
* @param array $catalog The serice catalog from IdentityServices::serviceCatalog(). * @param array $catalog The serice catalog from IdentityService::serviceCatalog().
* This can be either the entire catalog or a catalog * This can be either the entire catalog or a catalog
* filtered to just ObjectStorage::SERVICE_TYPE. * filtered to just ObjectStorage::SERVICE_TYPE.
* @param string $authToken The auth token returned by IdentityServices. * @param string $authToken The auth token returned by IdentityService.
* *
* @return \OpenStack\Storage\ObjectStorage A new ObjectStorage instance. * @return \OpenStack\ObjectStore\v1\ObjectStorage A new ObjectStorage instance.
*/ */
public static function newFromServiceCatalog($catalog, $authToken, $region = ObjectStorage::DEFAULT_REGION, \OpenStack\Transport\ClientInterface $client = null) public static function newFromServiceCatalog($catalog, $authToken, $region = ObjectStorage::DEFAULT_REGION, \OpenStack\Common\Transport\ClientInterface $client = null)
{ {
$c = count($catalog); $c = count($catalog);
for ($i = 0; $i < $c; ++$i) { for ($i = 0; $i < $c; ++$i) {
@ -214,7 +212,7 @@ class ObjectStorage
* @param string $url The URL to the endpoint. This typically is returned * @param string $url The URL to the endpoint. This typically is returned
* after authentication. * after authentication.
*/ */
public function __construct($authToken, $url, \OpenStack\Transport\ClientInterface $client = null) public function __construct($authToken, $url, \OpenStack\Common\Transport\ClientInterface $client = null)
{ {
$this->token = $authToken; $this->token = $authToken;
$this->url = $url; $this->url = $url;
@ -275,7 +273,7 @@ class ObjectStorage
* @param string $marker The name of the last object seen. Used when paging. * @param string $marker The name of the last object seen. Used when paging.
* *
* @return array An associative array of containers, where the key is the * @return array An associative array of containers, where the key is the
* container's name and the value is an \OpenStack\Storage\ObjectStorage\Container * container's name and the value is an \OpenStack\ObjectStore\v1\ObjectStorage\Container
* object. Results are ordered in server order (the order that the remote * object. Results are ordered in server order (the order that the remote
* host puts them in). * host puts them in).
*/ */
@ -308,9 +306,10 @@ class ObjectStorage
* *
* @param string $name The name of the container to load. * @param string $name The name of the container to load.
* *
* @return \OpenStack\Storage\ObjectStorage\Container A container. * @return \OpenStack\ObjectStore\v1\Resource\Container A container.
* *
* @throws \OpenStack\Transport\FileNotFoundException if the named container is not found on the remote server. * @throws \OpenStack\Common\Transport\Exception\FileNotFoundException if the named container is not
* found on the remote server.
*/ */
public function container($name) public function container($name)
{ {
@ -325,7 +324,7 @@ class ObjectStorage
} }
// If we get here, it's not a 404 and it's not a 204. // If we get here, it's not a 404 and it's not a 204.
throw new \OpenStack\Exception("Unknown status: $status"); throw new \OpenStack\Common\Exception("Unknown status: $status");
} }
/** /**
@ -339,13 +338,13 @@ class ObjectStorage
* *
* @return boolean true if the container exists, false if it does not. * @return boolean true if the container exists, false if it does not.
* *
* @throws \OpenStack\Exception If an unexpected network error occurs. * @throws \OpenStack\Common\Exception If an unexpected network error occurs.
*/ */
public function hasContainer($name) public function hasContainer($name)
{ {
try { try {
$container = $this->container($name); $container = $this->container($name);
} catch (\OpenStack\Transport\FileNotFoundException $fnfe) { } catch (\OpenStack\Common\Transport\Exception\FileNotFoundException $fnfe) {
return false; return false;
} }
@ -397,14 +396,14 @@ class ObjectStorage
* $boolean = $container->acl()->isPublic(); * $boolean = $container->acl()->isPublic();
* ?> * ?>
* *
* For details on ACLs, see \OpenStack\Storage\ObjectStorage\ACL. * For details on ACLs, see \OpenStack\ObjectStore\v1\Resource\ACL.
* *
* @param string $name The name of the container. * @param string $name The name of the container.
* @param object $acl \OpenStack\Storage\ObjectStorage\ACL An access control * @param object $acl \OpenStack\ObjectStore\v1\Resource\ACL An access control
* list object. By default, a container is non-public * list object. By default, a container is non-public
* (private). To change this behavior, you can add a * (private). To change this behavior, you can add a
* custom ACL. To make the container publically * custom ACL. To make the container publically
* readable, you can use this: \OpenStack\Storage\ObjectStorage\ACL::makePublic(). * readable, you can use this: \OpenStack\ObjectStore\v1\Resource\ACL::makePublic().
* @param array $metadata An associative array of metadata to attach to the * @param array $metadata An associative array of metadata to attach to the
* container. * container.
* *
@ -440,7 +439,7 @@ class ObjectStorage
} }
// According to the OpenStack docs, there are no other return codes. // According to the OpenStack docs, there are no other return codes.
else { else {
throw new \OpenStack\Exception('Server returned unexpected code: ' . $status); throw new \OpenStack\Common\Exception('Server returned unexpected code: ' . $status);
} }
} }
@ -467,7 +466,7 @@ class ObjectStorage
* and to set the ACL.) * and to set the ACL.)
* *
* @param string $name The name of the container. * @param string $name The name of the container.
* @param object $acl \OpenStack\Storage\ObjectStorage\ACL An ACL. To make the * @param object $acl \OpenStack\ObjectStore\v1\Resource\ACL An ACL. To make the
* container publically readable, use ACL::makePublic(). * container publically readable, use ACL::makePublic().
* *
* @return boolean true if the cointainer was created, false otherwise. * @return boolean true if the cointainer was created, false otherwise.
@ -486,7 +485,7 @@ class ObjectStorage
* the object storage. * the object storage.
* *
* The container MUST be empty before it can be deleted. If it is not, * The container MUST be empty before it can be deleted. If it is not,
* an \OpenStack\Storage\ObjectStorage\ContainerNotEmptyException will * an \OpenStack\ObjectStore\v1\Exception\ContainerNotEmptyException will
* be thrown. * be thrown.
* *
* @param string $name The name of the container. * @param string $name The name of the container.
@ -494,9 +493,9 @@ class ObjectStorage
* @return boolean true if the container was deleted, false if the container * @return boolean true if the container was deleted, false if the container
* was not found (and hence, was not deleted). * was not found (and hence, was not deleted).
* *
* @throws \OpenStack\Storage\ObjectStorage\ContainerNotEmptyException if the container is not empty. * @throws \OpenStack\ObjectStore\v1\Exception\ContainerNotEmptyException if the container is not empty.
* *
* @throws \OpenStack\Exception if an unexpected response code is returned. While this should never happen on * @throws \OpenStack\Common\Exception if an unexpected response code is returned. While this should never happen on
* OpenStack servers, forks of OpenStack may choose to extend object storage in a way * OpenStack servers, forks of OpenStack may choose to extend object storage in a way
* that results in a non-standard code. * that results in a non-standard code.
*/ */
@ -506,13 +505,13 @@ class ObjectStorage
try { try {
$data = $this->req($url, 'DELETE', false); $data = $this->req($url, 'DELETE', false);
} catch (\OpenStack\Transport\FileNotFoundException $e) { } catch (\OpenStack\Common\Transport\Exception\FileNotFoundException $e) {
return false; return false;
} }
// XXX: I'm not terribly sure about this. Why not just throw the // XXX: I'm not terribly sure about this. Why not just throw the
// ConflictException? // ConflictException?
catch (\OpenStack\Transport\ConflictException $e) { catch (\OpenStack\Common\Transport\Exception\ConflictException $e) {
throw new ObjectStorage\ContainerNotEmptyException("Non-empty container cannot be deleted."); throw new Exception\ContainerNotEmptyException("Non-empty container cannot be deleted.");
} }
$status = $data->getStatusCode(); $status = $data->getStatusCode();
@ -524,7 +523,7 @@ class ObjectStorage
// OpenStacks documentation doesn't suggest any other return // OpenStacks documentation doesn't suggest any other return
// codes. // codes.
else { else {
throw new \OpenStack\Exception('Server returned unexpected code: ' . $status); throw new \OpenStack\Common\Exception('Server returned unexpected code: ' . $status);
} }
} }
@ -541,7 +540,8 @@ class ObjectStorage
* - containers: Number of containers. * - containers: Number of containers.
* - objects: Number of objects. * - objects: Number of objects.
* *
* @throws \OpenStack\Transport\AuthorizationException if the user credentials are invalid or have expired. * @throws \OpenStack\Common\Transport\Exception\AuthorizationException if the user credentials
* are invalid or have expired.
*/ */
public function accountInfo() public function accountInfo()
{ {

View File

@ -18,7 +18,7 @@
* Contains the class for manipulating ObjectStorage ACL strings. * Contains the class for manipulating ObjectStorage ACL strings.
*/ */
namespace OpenStack\Storage\ObjectStorage; namespace OpenStack\ObjectStore\v1\Resource;
/** /**
* Access control list for object storage. * Access control list for object storage.
@ -137,7 +137,7 @@ class ACL
* *
* - READ to any host, with container listings. * - READ to any host, with container listings.
* *
* @return \OpenStack\Storage\ObjectStorage\ACL an ACL object with the * @return \OpenStack\ObjectStore\v1\Resource\ACL an ACL object with the
* appopriate permissions set. * appopriate permissions set.
*/ */
public static function makePublic() public static function makePublic()
@ -158,7 +158,7 @@ class ACL
* This does not grant any permissions. OpenStack interprets an object * This does not grant any permissions. OpenStack interprets an object
* with no permissions as a private object. * with no permissions as a private object.
* *
* @return \OpenStack\Storage\ObjectStorage\ACL an ACL object with the * @return \OpenStack\ObjectStore\v1\Resource\ACL an ACL object with the
* appopriate permissions set. * appopriate permissions set.
*/ */
public static function makeNonPublic() public static function makeNonPublic()
@ -183,7 +183,7 @@ class ACL
* *
* @param array $headers An associative array of headers. * @param array $headers An associative array of headers.
* *
* @return \OpenStack\Storage\ObjectStorage\ACL A new ACL. * @return \OpenStack\ObjectStore\v1\Resource\ACL A new ACL.
*/ */
public static function newFromHeaders($headers) public static function newFromHeaders($headers)
{ {
@ -302,7 +302,7 @@ class ACL
* @param mixed $user The name of the user, or optionally an indexed array of * @param mixed $user The name of the user, or optionally an indexed array of
* user names. * user names.
* *
* @return \OpenStack\Storage\ObjectStorage\ACL $this for current object so * @return \OpenStack\ObjectStore\v1\Resource\ACL $this for current object so
* the method can be used in chaining. * the method can be used in chaining.
*/ */
public function addAccount($perm, $account, $user = null) public function addAccount($perm, $account, $user = null)
@ -338,7 +338,7 @@ class ACL
* ACL::WRITE, or ACL::READ_WRITE. * ACL::WRITE, or ACL::READ_WRITE.
* @param string $host A host specification string as described above. * @param string $host A host specification string as described above.
* *
* @return \OpenStack\Storage\ObjectStorage\ACL $this for current object so * @return \OpenStack\ObjectStore\v1\Resource\ACL $this for current object so
* the method can be used in chaining. * the method can be used in chaining.
*/ */
public function addReferrer($perm, $host = '*') public function addReferrer($perm, $host = '*')
@ -354,7 +354,7 @@ class ACL
* @param int $perm One of the predefined permission constants. * @param int $perm One of the predefined permission constants.
* @param array $rule A rule array. * @param array $rule A rule array.
* *
* @return \OpenStack\Storage\ObjectStorage\ACL $this for current object so * @return \OpenStack\ObjectStore\v1\Resource\ACL $this for current object so
* the method can be used in chaining. * the method can be used in chaining.
*/ */
protected function addRule($perm, $rule) protected function addRule($perm, $rule)
@ -377,7 +377,7 @@ class ACL
* In the current Swift implementation, there is no mechanism for * In the current Swift implementation, there is no mechanism for
* allowing some hosts to get listings, while denying others. * allowing some hosts to get listings, while denying others.
* *
* @return \OpenStack\Storage\ObjectStorage\ACL $this for current object so * @return \OpenStack\ObjectStore\v1\Resource\ACL $this for current object so
* the method can be used in chaining. * the method can be used in chaining.
*/ */
public function allowListings() public function allowListings()

View File

@ -18,9 +18,9 @@
* Contains the class for ObjectStorage Container objects. * Contains the class for ObjectStorage Container objects.
*/ */
namespace OpenStack\Storage\ObjectStorage; namespace OpenStack\ObjectStore\v1\Resource;
use OpenStack\Transport\GuzzleClient; use OpenStack\Common\Transport\GuzzleClient;
/** /**
* A container in an ObjectStorage. * A container in an ObjectStorage.
@ -38,9 +38,9 @@ use OpenStack\Transport\GuzzleClient;
* ObjectStorage::containers(). * ObjectStorage::containers().
* *
* <?php * <?php
* use \OpenStack\Storage\ObjectStorage; * use \OpenStack\ObjectStore\v1\ObjectStorage;
* use \OpenStack\Storage\ObjectStorage\Container; * use \OpenStack\ObjectStore\v1\Resource\Container;
* use \OpenStack\Storage\ObjectStorage\Object; * use \OpenStack\ObjectStore\v1\Resource\Object;
* *
* // Create a new ObjectStorage instance, logging in with older Swift * // Create a new ObjectStorage instance, logging in with older Swift
* // credentials. * // credentials.
@ -202,11 +202,11 @@ class Container implements \Countable, \IteratorAggregate
* @param string $token The auth token. * @param string $token The auth token.
* @param string $url The base URL. The container name is automatically * @param string $url The base URL. The container name is automatically
* appended to this at construction time. * appended to this at construction time.
* @param \OpenStack\Transport\ClientInterface $client A HTTP transport client. * @param \OpenStack\Common\Transport\ClientInterface $client A HTTP transport client.
* *
* @return \OpenStack\Storage\ObjectStorage\Container A new container object. * @return \OpenStack\ObjectStore\v1\Resource\Container A new container object.
*/ */
public static function newFromJSON($jsonArray, $token, $url, \OpenStack\Transport\ClientInterface $client = null) public static function newFromJSON($jsonArray, $token, $url, \OpenStack\Common\Transport\ClientInterface $client = null)
{ {
$container = new Container($jsonArray['name'], null, null, $client); $container = new Container($jsonArray['name'], null, null, $client);
@ -238,15 +238,15 @@ class Container implements \Countable, \IteratorAggregate
* Container initialization. * Container initialization.
* *
* @param string $name The name of the container. * @param string $name The name of the container.
* @param object $response \OpenStack\Transport\Response The HTTP response object from the Transporter layer * @param object $response \OpenStack\Common\Transport\Response The HTTP response object from the Transporter layer
* @param string $token The auth token. * @param string $token The auth token.
* @param string $url The base URL. The container name is automatically * @param string $url The base URL. The container name is automatically
* appended to this at construction time. * appended to this at construction time.
* @param \OpenStack\Transport\ClientInterface $client A HTTP transport client. * @param \OpenStack\Common\Transport\ClientInterface $client A HTTP transport client.
* *
* @return \OpenStack\Storage\ObjectStorage\Container The Container object, initialized and ready for use. * @return \OpenStack\ObjectStore\v1\Resource\Container The Container object, initialized and ready for use.
*/ */
public static function newFromResponse($name, $response, $token, $url, \OpenStack\Transport\ClientInterface $client = null) public static function newFromResponse($name, $response, $token, $url, \OpenStack\Common\Transport\ClientInterface $client = null)
{ {
$container = new Container($name, null, null, $client); $container = new Container($name, null, null, $client);
$container->bytes = $response->getHeader('X-Container-Bytes-Used', 0); $container->bytes = $response->getHeader('X-Container-Bytes-Used', 0);
@ -305,9 +305,9 @@ class Container implements \Countable, \IteratorAggregate
* @param string $name The name. * @param string $name The name.
* @param string $url The full URL to the container. * @param string $url The full URL to the container.
* @param string $token The auth token. * @param string $token The auth token.
* @param \OpenStack\Transport\ClientInterface $client A HTTP transport client. * @param \OpenStack\Common\Transport\ClientInterface $client A HTTP transport client.
*/ */
public function __construct($name , $url = null, $token = null, \OpenStack\Transport\ClientInterface $client = null) public function __construct($name , $url = null, $token = null, \OpenStack\Common\Transport\ClientInterface $client = null)
{ {
$this->name = $name; $this->name = $name;
$this->url = $url; $this->url = $url;
@ -390,7 +390,7 @@ class Container implements \Countable, \IteratorAggregate
* more than 256. UTF-8 or ASCII characters are allowed, though ASCII * more than 256. UTF-8 or ASCII characters are allowed, though ASCII
* seems to be preferred. * seems to be preferred.
* *
* @return \OpenStack\Storage\ObjectStorage\Container $this so the method can * @return \OpenStack\ObjectStore\v1\Resource\Container $this so the method can
* be used in chaining. * be used in chaining.
*/ */
public function setMetadata($metadata) public function setMetadata($metadata)
@ -424,34 +424,36 @@ class Container implements \Countable, \IteratorAggregate
/** /**
* Save an Object into Object Storage. * Save an Object into Object Storage.
* *
* This takes an \OpenStack\Storage\ObjectStorage\Object * This takes an \OpenStack\ObjectStore\v1\Resource\Object
* and stores it in the given container in the present * and stores it in the given container in the present
* container on the remote object store. * container on the remote object store.
* *
* @param object $obj \OpenStack\Storage\ObjectStorage\Object The object to * @param object $obj \OpenStack\ObjectStore\v1\Resource\Object The object to
* store. * store.
* @param resource $file An optional file argument that, if set, will be * @param resource $file An optional file argument that, if set, will be
* treated as the contents of the object. * treated as the contents of the object.
* *
* @return boolean true if the object was saved. * @return boolean true if the object was saved.
* *
* @throws \OpenStack\Transport\LengthRequiredException if the Content-Length could not be determined and * @throws \OpenStack\Common\Transport\Exception\LengthRequiredException if the Content-Length could not be
* chunked encoding was not enabled. This should not occur * determined and chunked encoding was
* for this class, which always automatically generates * not enabled. This should not occur for
* Content-Length headers. However, subclasses could * this class, which always automatically
* generate this error. * generates Content-Length headers.
* @throws \OpenStack\Transport\UnprocessableEntityException if the checksum passed here does not match the checksum * However, subclasses could generate
* calculated remotely. * this error.
* @throws \OpenStack\Exception when an unexpected (usually network-related) error * @throws \OpenStack\Common\Transport\Exception\UnprocessableEntityException if the checksum passed here does not
* condition arises. * match the checksum calculated remotely.
* @throws \OpenStack\Common\Exception when an unexpected (usually
* network-related) error condition arises.
*/ */
public function save(Object $obj, $file = null) public function save(Object $obj, $file = null)
{ {
if (empty($this->token)) { if (empty($this->token)) {
throw new \OpenStack\Exception('Container does not have an auth token.'); throw new \OpenStack\Common\Exception('Container does not have an auth token.');
} }
if (empty($this->url)) { if (empty($this->url)) {
throw new \OpenStack\Exception('Container does not have a URL to send data.'); throw new \OpenStack\Common\Exception('Container does not have a URL to send data.');
} }
//$url = $this->url . '/' . rawurlencode($obj->name()); //$url = $this->url . '/' . rawurlencode($obj->name());
@ -527,7 +529,7 @@ class Container implements \Countable, \IteratorAggregate
} }
if ($response->getStatusCode() != 201) { if ($response->getStatusCode() != 201) {
throw new \OpenStack\Exception('An unknown error occurred while saving: ' . $response->status()); throw new \OpenStack\Common\Exception('An unknown error occurred while saving: ' . $response->status());
} }
return true; return true;
@ -544,11 +546,12 @@ class Container implements \Countable, \IteratorAggregate
* particularly in cases where custom headers have been set. * particularly in cases where custom headers have been set.
* Use with caution. * Use with caution.
* *
* @param object $obj \OpenStack\Storage\ObjectStorage\Object The object to update. * @param object $obj \OpenStack\ObjectStore\v1\Resource\Object The object to update.
* *
* @return boolean true if the metadata was updated. * @return boolean true if the metadata was updated.
* *
* @throws \OpenStack\Transport\FileNotFoundException if the object does not already exist on the object storage. * @throws \OpenStack\Common\Transport\Exception\FileNotFoundException if the object does not already
* exist on the object storage.
*/ */
public function updateMetadata(Object $obj) public function updateMetadata(Object $obj)
{ {
@ -572,7 +575,7 @@ class Container implements \Countable, \IteratorAggregate
$response = $this->client->doRequest($url, 'POST', $headers, $obj->content()); $response = $this->client->doRequest($url, 'POST', $headers, $obj->content());
if ($response->getStatusCode() != 202) { if ($response->getStatusCode() != 202) {
throw new \OpenStack\Exception('An unknown error occurred while saving: ' . $response->status()); throw new \OpenStack\Common\Exception('An unknown error occurred while saving: ' . $response->status());
} }
return true; return true;
@ -590,7 +593,7 @@ class Container implements \Countable, \IteratorAggregate
* Note that there is no MOVE operation. You must copy and then DELETE * Note that there is no MOVE operation. You must copy and then DELETE
* in order to achieve that. * in order to achieve that.
* *
* @param object $obj \OpenStack\Storage\ObjectStorage::Object The object to * @param object $obj \OpenStack\ObjectStore\v1\Resource\Object The object to
* copy. This object MUST already be saved on the remote server. The body of * copy. This object MUST already be saved on the remote server. The body of
* the object is not sent. Instead, the copy operation is performed on the * the object is not sent. Instead, the copy operation is performed on the
* remote server. You can, and probably should, use a RemoteObject here. * remote server. You can, and probably should, use a RemoteObject here.
@ -607,7 +610,7 @@ class Container implements \Countable, \IteratorAggregate
$sourceUrl = self::objectUrl($this->url, $obj->name()); $sourceUrl = self::objectUrl($this->url, $obj->name());
if (empty($newName)) { if (empty($newName)) {
throw new \OpenStack\Exception("An object name is required to copy the object."); throw new \OpenStack\Common\Exception("An object name is required to copy the object.");
} }
// Figure out what container we store in. // Figure out what container we store in.
@ -626,7 +629,7 @@ class Container implements \Countable, \IteratorAggregate
$response = $this->client->doRequest($sourceUrl, 'COPY', $headers); $response = $this->client->doRequest($sourceUrl, 'COPY', $headers);
if ($response->getStatusCode() != 201) { if ($response->getStatusCode() != 201) {
throw new \OpenStack\Exception("An unknown condition occurred during copy. " . $response->getStatusCode()); throw new \OpenStack\Common\Exception("An unknown condition occurred during copy. " . $response->getStatusCode());
} }
return true; return true;
@ -653,7 +656,7 @@ class Container implements \Countable, \IteratorAggregate
* *
* @param string $name The name of the object to load. * @param string $name The name of the object to load.
* *
* @return \OpenStack\Storage\ObjectStorage\RemoteObject A remote object with the content already stored locally. * @return \OpenStack\ObjectStore\v1\Resource\RemoteObject A remote object with the content already stored locally.
*/ */
public function object($name) public function object($name)
{ {
@ -666,7 +669,7 @@ class Container implements \Countable, \IteratorAggregate
$response = $this->client->doRequest($url, 'GET', $headers); $response = $this->client->doRequest($url, 'GET', $headers);
if ($response->getStatusCode() != 200) { if ($response->getStatusCode() != 200) {
throw new \OpenStack\Exception('An unknown error occurred while saving: ' . $response->status()); throw new \OpenStack\Common\Exception('An unknown error occurred while saving: ' . $response->status());
} }
$remoteObject = RemoteObject::newFromHeaders($name, self::reformatHeaders($response->getHeaders()), $this->token, $url, $this->client); $remoteObject = RemoteObject::newFromHeaders($name, self::reformatHeaders($response->getHeaders()), $this->token, $url, $this->client);
@ -701,7 +704,7 @@ class Container implements \Countable, \IteratorAggregate
* *
* @param string $name The name of the object to fetch. * @param string $name The name of the object to fetch.
* *
* @return \OpenStack\Storage\ObjectStorage\RemoteObject A remote object ready for use. * @return \OpenStack\ObjectStore\v1\Resource\RemoteObject A remote object ready for use.
*/ */
public function proxyObject($name) public function proxyObject($name)
{ {
@ -713,7 +716,7 @@ class Container implements \Countable, \IteratorAggregate
$response = $this->client->doRequest($url, 'HEAD', $headers); $response = $this->client->doRequest($url, 'HEAD', $headers);
if ($response->getStatusCode() != 200) { if ($response->getStatusCode() != 200) {
throw new \OpenStack\Exception('An unknown error occurred while saving: ' . $response->status()); throw new \OpenStack\Common\Exception('An unknown error occurred while saving: ' . $response->status());
} }
$headers = self::reformatHeaders($response->getHeaders()); $headers = self::reformatHeaders($response->getHeaders());
@ -902,7 +905,7 @@ class Container implements \Countable, \IteratorAggregate
* *
* @todo Determine how to get the ACL from JSON data. * @todo Determine how to get the ACL from JSON data.
* *
* @return \OpenStack\Storage\ObjectStorage\ACL An ACL, or null if the ACL could not be retrieved. * @return \OpenStack\ObjectStore\v1\Resource\ACL An ACL, or null if the ACL could not be retrieved.
*/ */
public function acl() public function acl()
{ {
@ -919,7 +922,7 @@ class Container implements \Countable, \IteratorAggregate
* Not all containers come fully instantiated. This method is sometimes * Not all containers come fully instantiated. This method is sometimes
* called to "fill in" missing fields. * called to "fill in" missing fields.
* *
* @return \OpenStack\Storage\ObjectStorage\Container * @return \OpenStack\ObjectStore\v1\Resource\Container
*/ */
protected function loadExtraData() protected function loadExtraData()
{ {
@ -928,7 +931,7 @@ class Container implements \Countable, \IteratorAggregate
// created with Container::createContainer(). We treat // created with Container::createContainer(). We treat
// this as an error condition. // this as an error condition.
if (empty($this->url) || empty($this->token)) { if (empty($this->url) || empty($this->token)) {
throw new \OpenStack\Exception('Remote data cannot be fetched. Tokena and endpoint URL are required.'); throw new \OpenStack\Common\Exception('Remote data cannot be fetched. A Token and endpoint URL are required.');
} }
// Do a GET on $url to fetch headers. // Do a GET on $url to fetch headers.
$headers = array( $headers = array(
@ -979,7 +982,7 @@ class Container implements \Countable, \IteratorAggregate
// The only codes that should be returned are 200 and the ones // The only codes that should be returned are 200 and the ones
// already thrown by doRequest. // already thrown by doRequest.
if ($response->getStatusCode() != 200) { if ($response->getStatusCode() != 200) {
throw new \OpenStack\Exception('An unknown exception occurred while processing the request.'); throw new \OpenStack\Common\Exception('An unknown exception occurred while processing the request.');
} }
$json = $response->json(); $json = $response->json();
@ -990,7 +993,7 @@ class Container implements \Countable, \IteratorAggregate
if (!empty($item['subdir'])) { if (!empty($item['subdir'])) {
$list[] = new Subdir($item['subdir'], $params['delimiter']); $list[] = new Subdir($item['subdir'], $params['delimiter']);
} elseif (empty($item['name'])) { } elseif (empty($item['name'])) {
throw new \OpenStack\Exception('Unexpected entity returned.'); throw new \OpenStack\Common\Exception('Unexpected entity returned.');
} else { } else {
//$url = $this->url . '/' . rawurlencode($item['name']); //$url = $this->url . '/' . rawurlencode($item['name']);
$url = self::objectUrl($this->url, $item['name']); $url = self::objectUrl($this->url, $item['name']);
@ -1048,12 +1051,12 @@ class Container implements \Countable, \IteratorAggregate
try { try {
$response = $this->client->doRequest($url, 'DELETE', $headers); $response = $this->client->doRequest($url, 'DELETE', $headers);
} catch (\OpenStack\Transport\FileNotFoundException $fnfe) { } catch (\OpenStack\Common\Transport\Exception\FileNotFoundException $fnfe) {
return false; return false;
} }
if ($response->getStatusCode() != 204) { if ($response->getStatusCode() != 204) {
throw new \OpenStack\Exception("An unknown exception occured while deleting $name."); throw new \OpenStack\Common\Exception("An unknown exception occured while deleting $name.");
} }
return true; return true;

View File

@ -18,7 +18,7 @@
* Contains the class Object for ObjectStorage. * Contains the class Object for ObjectStorage.
*/ */
namespace OpenStack\Storage\ObjectStorage; namespace OpenStack\ObjectStore\v1\Resource;
/** /**
* An object for ObjectStorage. * An object for ObjectStorage.
@ -140,7 +140,7 @@ class Object
* *
* @param array $array An associative array of metadata names to values. * @param array $array An associative array of metadata names to values.
* *
* @return \OpenStack\Storage\ObjectStorage\Object $this so the method can be * @return \OpenStack\ObjectStore\v1\Resource\Object $this so the method can be
* used in chaining. * used in chaining.
*/ */
public function setMetadata(array $array) public function setMetadata(array $array)
@ -171,11 +171,11 @@ class Object
* object store. * object store.
* *
* To copy an object: * To copy an object:
* @see \OpenStack\Storage\ObjectStorage\Container::copyObject(). * @see \OpenStack\ObjectStore\v1\Resource\Container::copyObject().
* *
* @param string $name A file or object name. * @param string $name A file or object name.
* *
* @return \OpenStack\Storage\ObjectStorage\Object $this so the method can be * @return \OpenStack\ObjectStore\v1\Resource\Object $this so the method can be
* used in chaining. * used in chaining.
*/ */
public function setName($name) public function setName($name)
@ -222,7 +222,7 @@ class Object
* *
* @param string $type A valid content type. * @param string $type A valid content type.
* *
* @return \OpenStack\Storage\ObjectStorage\Object $this so the method can be * @return \OpenStack\ObjectStore\v1\Resource\Object $this so the method can be
* used in chaining. * used in chaining.
*/ */
public function setContentType($type) public function setContentType($type)
@ -263,7 +263,7 @@ class Object
* @param string $type The content type (MIME type). This can be set here for * @param string $type The content type (MIME type). This can be set here for
* convenience, or you can call setContentType() directly. * convenience, or you can call setContentType() directly.
* *
* @return \OpenStack\Storage\ObjectStorage\Object $this so the method can be * @return \OpenStack\ObjectStore\v1\Resource\Object $this so the method can be
* used in chaining. * used in chaining.
*/ */
public function setContent($content, $type = null) public function setContent($content, $type = null)
@ -354,7 +354,7 @@ class Object
* *
* @param string $encoding A valid encoding type. * @param string $encoding A valid encoding type.
* *
* @return \OpenStack\Storage\ObjectStorage\Object $this so the method can be * @return \OpenStack\ObjectStore\v1\Resource\Object $this so the method can be
* used in chaining. * used in chaining.
*/ */
public function setEncoding($encoding) public function setEncoding($encoding)
@ -396,7 +396,7 @@ class Object
* @param string $disposition A valid disposition declaration. These are * @param string $disposition A valid disposition declaration. These are
* defined in various HTTP specifications. * defined in various HTTP specifications.
* *
* @return \OpenStack\Storage\ObjectStorage\Object $this so the method can be * @return \OpenStack\ObjectStore\v1\Resource\Object $this so the method can be
* used in chaining. * used in chaining.
*/ */
public function setDisposition($disposition) public function setDisposition($disposition)
@ -451,7 +451,7 @@ class Object
* header name, and each value is the HTTP header value. No encoding or * header name, and each value is the HTTP header value. No encoding or
* escaping is done. * escaping is done.
* *
* @return \OpenStack\Storage\ObjectStorage\Object $this so the method can be * @return \OpenStack\ObjectStore\v1\Resource\Object $this so the method can be
* used in chaining. * used in chaining.
*/ */
public function setAdditionalHeaders($headers) public function setAdditionalHeaders($headers)
@ -486,7 +486,7 @@ class Object
* *
* @param array $keys The header names to be removed. * @param array $keys The header names to be removed.
* *
* @return \OpenStack\Storage\ObjectStorage\Object $this for the current * @return \OpenStack\ObjectStore\v1\Resource\Object $this for the current
* object so it can be used in chaining methods. * object so it can be used in chaining methods.
*/ */
public function removeHeaders($keys) public function removeHeaders($keys)

View File

@ -18,16 +18,17 @@
* Contains the RemoteObject class. * Contains the RemoteObject class.
*/ */
namespace OpenStack\Storage\ObjectStorage; namespace OpenStack\ObjectStore\v1\Resource;
use OpenStack\Transport\GuzzleClient; use OpenStack\Common\Transport\GuzzleClient;
use OpenStack\ObjectStore\v1\Exception;
/** /**
* A representation of an object stored in remote Object Storage. * A representation of an object stored in remote Object Storage.
* *
* A remote object is one whose canonical copy is stored in a remote * A remote object is one whose canonical copy is stored in a remote
* object storage. It represents a local (and possibly partial) copy of * object storage. It represents a local (and possibly partial) copy of
* an object. (Contrast this with \OpenStack\Storage\ObjectStorage\Object) * an object. (Contrast this with \OpenStack\ObjectStore\v1\Resource\Object)
* *
* Depending on how the object was constructed, it may or may not have a * Depending on how the object was constructed, it may or may not have a
* local copy of the entire contents of the file. It may only have the * local copy of the entire contents of the file. It may only have the
@ -38,7 +39,7 @@ use OpenStack\Transport\GuzzleClient;
* Remote objects can be modified locally. Simply modifying an object * Remote objects can be modified locally. Simply modifying an object
* will not result in those modifications being stored on the remote * will not result in those modifications being stored on the remote
* server. The object must be saved (see * server. The object must be saved (see
* \OpenStack\Storage\ObjectStorage\Container::save()). When an * \OpenStack\ObjectStore\v1\Resource\Container::save()). When an
* object is modified so that its local contents differ from the remote * object is modified so that its local contents differ from the remote
* stored copy, it is marked dirty (see isDirty()). * stored copy, it is marked dirty (see isDirty()).
*/ */
@ -73,9 +74,9 @@ class RemoteObject extends Object
* @param array $data The JSON data as an array. * @param array $data The JSON data as an array.
* @param string $token The authentication token. * @param string $token The authentication token.
* @param $url The URL to the object on the remote server * @param $url The URL to the object on the remote server
* @param \OpenStack\Transport\ClientInterface $client A HTTP transport client. * @param \OpenStack\Common\Transport\ClientInterface $client A HTTP transport client.
*/ */
public static function newFromJSON($data, $token, $url, \OpenStack\Transport\ClientInterface $client = null) public static function newFromJSON($data, $token, $url, \OpenStack\Common\Transport\ClientInterface $client = null)
{ {
$object = new RemoteObject($data['name']); $object = new RemoteObject($data['name']);
$object->setContentType($data['content_type']); $object->setContentType($data['content_type']);
@ -112,9 +113,9 @@ class RemoteObject extends Object
* @param string $url The URL to the object in the object storage. Used for * @param string $url The URL to the object in the object storage. Used for
* issuing subsequent requests. * issuing subsequent requests.
* *
* @return \OpenStack\Storage\ObjectStorage\RemoteObject A new RemoteObject. * @return \OpenStack\ObjectStore\v1\Resource\RemoteObject A new RemoteObject.
*/ */
public static function newFromHeaders($name, $headers, $token, $url, \OpenStack\Transport\ClientInterface $client = null) public static function newFromHeaders($name, $headers, $token, $url, \OpenStack\Common\Transport\ClientInterface $client = null)
{ {
$object = new RemoteObject($name); $object = new RemoteObject($name);
@ -163,7 +164,7 @@ class RemoteObject extends Object
* *
* @param OpenStackTransportClientInterface $client The HTTP Client * @param OpenStackTransportClientInterface $client The HTTP Client
*/ */
public function setClient(\OpenStack\Transport\ClientInterface $client) public function setClient(\OpenStack\Common\Transport\ClientInterface $client)
{ {
$this->client = $client; $this->client = $client;
} }
@ -225,7 +226,7 @@ class RemoteObject extends Object
/** /**
* Set the headers * Set the headers
* *
* @return \OpenStack\Storage\ObjectStorage\RemoteObject $this for the current object so it can be used in chaining * @return \OpenStack\ObjectStore\v1\Resource\RemoteObject $this for the current object so it can be used in chaining
* methods. * methods.
*/ */
public function setHeaders($headers) public function setHeaders($headers)
@ -282,7 +283,7 @@ class RemoteObject extends Object
/** /**
* Filter the headers. * Filter the headers.
* *
* @return \OpenStack\Storage\ObjectStorage\RemoteObject $this for the current object so it can be used in chaining * @return \OpenStack\ObjectStore\v1\Resource\RemoteObject $this for the current object so it can be used in chaining
* methods. * methods.
*/ */
public function filterHeaders(&$headers) public function filterHeaders(&$headers)
@ -317,7 +318,7 @@ class RemoteObject extends Object
* *
* @param array $keys The header names to be removed. * @param array $keys The header names to be removed.
* *
* @return \OpenStack\Storage\ObjectStorage\RemoteObject $this for the current object so it can be used in chaining * @return \OpenStack\ObjectStore\v1\Resource\RemoteObject $this for the current object so it can be used in chaining
* methods. * methods.
*/ */
public function removeHeaders($keys) public function removeHeaders($keys)
@ -347,10 +348,10 @@ class RemoteObject extends Object
* *
* @return string The contents of the file as a string. * @return string The contents of the file as a string.
* *
* @throws \OpenStack\Transport\FileNotFoundException when the requested content cannot be located on the remote * @throws \OpenStack\Common\Transport\Exception\FileNotFoundException when the requested content cannot be
* server. * located on the remote server.
* @throws \OpenStack\Exception when an unknown exception (usually an abnormal network * @throws \OpenStack\Common\Exception when an unknown exception (usually an
* condition) occurs. * abnormal network condition) occurs.
*/ */
public function content() public function content()
{ {
@ -466,7 +467,7 @@ class RemoteObject extends Object
* @param boolean $enabled If this is true, caching will be enabled. If this * @param boolean $enabled If this is true, caching will be enabled. If this
* is false, caching will be disabled. * is false, caching will be disabled.
* *
* @return \OpenStack\Storage\ObjectStorage\RemoteObject $this so the method can be used in chaining. * @return \OpenStack\ObjectStore\v1\Resource\RemoteObject $this so the method can be used in chaining.
*/ */
public function setCaching($enabled) public function setCaching($enabled)
{ {
@ -511,7 +512,7 @@ class RemoteObject extends Object
* server-supplied MD5 hashcode. If this is false, * server-supplied MD5 hashcode. If this is false,
* no checking is done. * no checking is done.
* *
* @return \OpenStack\Storage\ObjectStorage\RemoteObject $this so the method can be used in chaining. * @return \OpenStack\ObjectStore\v1\Resource\RemoteObject $this so the method can be used in chaining.
*/ */
public function setContentVerification($enabled) public function setContentVerification($enabled)
{ {
@ -588,8 +589,8 @@ class RemoteObject extends Object
* @param boolean $fetchContent If this is true, the content will be * @param boolean $fetchContent If this is true, the content will be
* downloaded as well. * downloaded as well.
* *
* @return \OpenStack\Storage\ObjectStorage\RemoteObject $this for the current object so it can be used in chaining * @return \OpenStack\ObjectStore\v1\Resource\RemoteObject $this for the current object so it
* methods. * can be used in chaining methods.
*/ */
public function refresh($fetchContent = false) public function refresh($fetchContent = false)
{ {
@ -616,8 +617,8 @@ class RemoteObject extends Object
* is set to false, a HEAD request is sent, and * is set to false, a HEAD request is sent, and
* no body is returned. * no body is returned.
* *
* @return \OpenStack\Transport\Response containing the object metadata and (depending on the $fetchContent flag) * @return \OpenStack\Common\Transport\Response containing the object metadata and (depending
* optionally the data. * on the $fetchContent flag) optionally the data.
*/ */
protected function fetchObject($fetchContent = false) protected function fetchObject($fetchContent = false)
{ {
@ -630,7 +631,7 @@ class RemoteObject extends Object
$response = $this->client->doRequest($this->url, $method, $headers); $response = $this->client->doRequest($this->url, $method, $headers);
if ($response->getStatusCode() != 200) { if ($response->getStatusCode() != 200) {
throw new \OpenStack\Exception('An unknown exception occurred during transmission.'); throw new \OpenStack\Common\Exception('An unknown exception occurred during transmission.');
} }
$this->extractFromHeaders($response); $this->extractFromHeaders($response);
@ -643,8 +644,8 @@ class RemoteObject extends Object
* *
* This is used internally to set object properties from headers. * This is used internally to set object properties from headers.
* *
* @return \OpenStack\Storage\ObjectStorage\RemoteObject $this for the current object so it can be used in chaining * @return \OpenStack\ObjectStore\v1\Resource\RemoteObject $this for the current object so it
* methods. * can be used in chaining methods.
*/ */
protected function extractFromHeaders($response) protected function extractFromHeaders($response)
{ {

View File

@ -18,10 +18,10 @@
* Contains the stream wrapper for `swift://` URLs. * Contains the stream wrapper for `swift://` URLs.
*/ */
namespace OpenStack\Storage\ObjectStorage; namespace OpenStack\ObjectStore\v1\Resource;
use \OpenStack\Bootstrap; use \OpenStack\Bootstrap;
use \OpenStack\Storage\ObjectStorage; use \OpenStack\ObjectStore\v1\ObjectStorage;
/** /**
* Provides stream wrapping for Swift. * Provides stream wrapping for Swift.
@ -190,7 +190,7 @@ use \OpenStack\Storage\ObjectStorage;
* said markers ought to be created, they are not supported by the stream * said markers ought to be created, they are not supported by the stream
* wrapper. * wrapper.
* *
* As usual, the underlying \OpenStack\Storage\ObjectStorage\Container class * As usual, the underlying \OpenStack\ObjectStore\v1\Resource\Container class
* supports the full range of Swift features. * supports the full range of Swift features.
* *
* SUPPORTED CONTEXT PARAMETERS * SUPPORTED CONTEXT PARAMETERS
@ -397,7 +397,7 @@ class StreamWrapper
$sep = '/'; $sep = '/';
$this->dirListing = $container->objectsWithPrefix($this->dirPrefix, $sep); $this->dirListing = $container->objectsWithPrefix($this->dirPrefix, $sep);
} catch (\OpenStack\Exception $e) { } catch (\OpenStack\Common\Exception $e) {
trigger_error('Directory could not be opened: ' . $e->getMessage(), E_USER_WARNING); trigger_error('Directory could not be opened: ' . $e->getMessage(), E_USER_WARNING);
return false; return false;
@ -438,7 +438,7 @@ class StreamWrapper
$curr = $this->dirListing[$this->dirIndex]; $curr = $this->dirListing[$this->dirIndex];
$this->dirIndex++; $this->dirIndex++;
if ($curr instanceof \OpenStack\Storage\ObjectStorage\Subdir) { if ($curr instanceof \OpenStack\ObjectStore\v1\Resource\Subdir) {
$fullpath = $curr->path(); $fullpath = $curr->path();
} else { } else {
$fullpath = $curr->name(); $fullpath = $curr->name();
@ -548,7 +548,7 @@ class StreamWrapper
if ($ret) { if ($ret) {
return $container->delete($src['path']); return $container->delete($src['path']);
} }
} catch (\OpenStack\Exception $e) { } catch (\OpenStack\Common\Exception $e) {
trigger_error('Rename was not completed: ' . $e->getMessage(), E_USER_WARNING); trigger_error('Rename was not completed: ' . $e->getMessage(), E_USER_WARNING);
return false; return false;
@ -599,7 +599,7 @@ class StreamWrapper
{ {
try { try {
$this->writeRemote(); $this->writeRemote();
} catch (\OpenStack\Exception $e) { } catch (\OpenStack\Common\Exception $e) {
trigger_error('Error while closing: ' . $e->getMessage(), E_USER_NOTICE); trigger_error('Error while closing: ' . $e->getMessage(), E_USER_NOTICE);
return false; return false;
@ -639,7 +639,7 @@ class StreamWrapper
{ {
try { try {
$this->writeRemote(); $this->writeRemote();
} catch (\OpenStack\Exception $e) { } catch (\OpenStack\Common\Exception $e) {
syslog(LOG_WARNING, $e); syslog(LOG_WARNING, $e);
trigger_error('Error while flushing: ' . $e->getMessage(), E_USER_NOTICE); trigger_error('Error while flushing: ' . $e->getMessage(), E_USER_NOTICE);
@ -782,7 +782,7 @@ class StreamWrapper
try { try {
$this->initializeObjectStorage(); $this->initializeObjectStorage();
} catch (\OpenStack\Exception $e) { } catch (\OpenStack\Common\Exception $e) {
trigger_error('Failed to init object storage: ' . $e->getMessage(), E_USER_WARNING); trigger_error('Failed to init object storage: ' . $e->getMessage(), E_USER_WARNING);
return false; return false;
@ -796,7 +796,7 @@ class StreamWrapper
// server roundtrip? // server roundtrip?
try { try {
$this->container = $this->store->container($containerName); $this->container = $this->store->container($containerName);
} catch (\OpenStack\Transport\FileNotFoundException $e) { } catch (\OpenStack\Common\Transport\Exception\FileNotFoundException $e) {
trigger_error('Container not found.', E_USER_WARNING); trigger_error('Container not found.', E_USER_WARNING);
return false; return false;
@ -845,7 +845,7 @@ class StreamWrapper
// If a 404 is thrown, we need to determine whether // If a 404 is thrown, we need to determine whether
// or not a new file should be created. // or not a new file should be created.
catch (\OpenStack\Transport\FileNotFoundException $nf) { catch (\OpenStack\Common\Transport\Exception\FileNotFoundException $nf) {
// For many modes, we just go ahead and create. // For many modes, we just go ahead and create.
if ($this->createIfNotFound) { if ($this->createIfNotFound) {
@ -861,7 +861,7 @@ class StreamWrapper
} }
// All other exceptions are fatal. // All other exceptions are fatal.
catch (\OpenStack\Exception $e) { catch (\OpenStack\Common\Exception $e) {
//if ($this->triggerErrors) { //if ($this->triggerErrors) {
trigger_error('Failed to fetch object: ' . $e->getMessage(), E_USER_WARNING); trigger_error('Failed to fetch object: ' . $e->getMessage(), E_USER_WARNING);
//} //}
@ -1048,10 +1048,10 @@ class StreamWrapper
$token = $this->store->token(); $token = $this->store->token();
$endpoint_url = $this->store->url() . '/' . rawurlencode($name); $endpoint_url = $this->store->url() . '/' . rawurlencode($name);
$client = $this->cxt('transport_client', null); $client = $this->cxt('transport_client', null);
$container = new \OpenStack\Storage\ObjectStorage\Container($name, $endpoint_url, $token, $client); $container = new \OpenStack\ObjectStore\v1\Resource\Container($name, $endpoint_url, $token, $client);
return $container->delete($url['path']); return $container->delete($url['path']);
} catch (\OpenStack\Exception $e) { } catch (\OpenStack\Common\Exception $e) {
trigger_error('Error during unlink: ' . $e->getMessage(), E_USER_WARNING); trigger_error('Error during unlink: ' . $e->getMessage(), E_USER_WARNING);
return false; return false;
@ -1085,9 +1085,9 @@ class StreamWrapper
$token = $this->store->token(); $token = $this->store->token();
$endpoint_url = $this->store->url() . '/' . rawurlencode($name); $endpoint_url = $this->store->url() . '/' . rawurlencode($name);
$client = $this->cxt('transport_client', null); $client = $this->cxt('transport_client', null);
$container = new \OpenStack\Storage\ObjectStorage\Container($name, $endpoint_url, $token, $client); $container = new \OpenStack\ObjectStore\v1\Resource\Container($name, $endpoint_url, $token, $client);
$obj = $container->remoteObject($url['path']); $obj = $container->remoteObject($url['path']);
} catch (\OpenStack\Exception $e) { } catch (\OpenStack\Common\Exception $e) {
// Apparently file_exists does not set STREAM_URL_STAT_QUIET. // Apparently file_exists does not set STREAM_URL_STAT_QUIET.
//if ($flags & STREAM_URL_STAT_QUIET) { //if ($flags & STREAM_URL_STAT_QUIET) {
//trigger_error('Could not stat remote file: ' . $e->getMessage(), E_USER_WARNING); //trigger_error('Could not stat remote file: ' . $e->getMessage(), E_USER_WARNING);
@ -1098,7 +1098,7 @@ class StreamWrapper
if ($flags & STREAM_URL_STAT_QUIET) { if ($flags & STREAM_URL_STAT_QUIET) {
try { try {
return @$this->generateStat($obj, $container, $obj->contentLength()); return @$this->generateStat($obj, $container, $obj->contentLength());
} catch (\OpenStack\Exception $e) { } catch (\OpenStack\Common\Exception $e) {
return false; return false;
} }
} }
@ -1110,7 +1110,7 @@ class StreamWrapper
* Get the Object. * Get the Object.
* *
* This provides low-level access to the * This provides low-level access to the
* \OpenStack\Storage\ObjectStorage::Object instance in which the content * \OpenStack\ObjectStore\v1\ObjectStorage::Object instance in which the content
* is stored. * is stored.
* *
* Accessing the object's payload (Object::content()) is strongly * Accessing the object's payload (Object::content()) is strongly
@ -1213,7 +1213,7 @@ class StreamWrapper
$gid = 0; $gid = 0;
} }
if ($object instanceof \OpenStack\Storage\ObjectStorage\RemoteObject) { if ($object instanceof \OpenStack\ObjectStore\v1\Resource\RemoteObject) {
$modTime = $object->lastModified(); $modTime = $object->lastModified();
} else { } else {
$modTime = 0; $modTime = 0;
@ -1250,7 +1250,7 @@ class StreamWrapper
* *
* @param string $mode The mode string, e.g. `r+` or `wb`. * @param string $mode The mode string, e.g. `r+` or `wb`.
* *
* @return \OpenStack\Storage\ObjectStorage\StreamWrapper $this so the method * @return \OpenStack\ObjectStore\v1\Resource\StreamWrapper $this so the method
* can be used in chaining. * can be used in chaining.
*/ */
protected function setMode($mode) protected function setMode($mode)
@ -1450,13 +1450,13 @@ class StreamWrapper
// FIXME: If a token is invalidated, we should try to re-authenticate. // FIXME: If a token is invalidated, we should try to re-authenticate.
// If context has the info we need, start from there. // If context has the info we need, start from there.
if (!empty($token) && !empty($endpoint)) { if (!empty($token) && !empty($endpoint)) {
$this->store = new \OpenStack\Storage\ObjectStorage($token, $endpoint, $client); $this->store = new \OpenStack\ObjectStore\v1\ObjectStorage($token, $endpoint, $client);
} }
// If we get here and tenant ID is not set, we can't get a container. // If we get here and tenant ID is not set, we can't get a container.
elseif (empty($tenantId) && empty($tenantName)) { elseif (empty($tenantId) && empty($tenantName)) {
throw new \OpenStack\Exception('Either Tenant ID (tenantid) or Tenant Name (tenantname) is required.'); throw new \OpenStack\Common\Exception('Either Tenant ID (tenantid) or Tenant Name (tenantname) is required.');
} elseif (empty($authUrl)) { } elseif (empty($authUrl)) {
throw new \OpenStack\Exception('An Identity Service Endpoint (endpoint) is required.'); throw new \OpenStack\Common\Exception('An Identity Service Endpoint (endpoint) is required.');
} }
// Try to authenticate and get a new token. // Try to authenticate and get a new token.
else { else {
@ -1467,13 +1467,13 @@ class StreamWrapper
$serviceCatalog = $ident->serviceCatalog(); $serviceCatalog = $ident->serviceCatalog();
self::$serviceCatalogCache[$token] = $serviceCatalog; self::$serviceCatalogCache[$token] = $serviceCatalog;
$this->store = ObjectStorage::newFromServiceCatalog($serviceCatalog, $token, \OpenStack\Storage\ObjectStorage::DEFAULT_REGION, $client); $this->store = ObjectStorage::newFromServiceCatalog($serviceCatalog, $token, \OpenStack\ObjectStore\v1\ObjectStorage::DEFAULT_REGION, $client);
/* /*
$catalog = $ident->serviceCatalog(ObjectStorage::SERVICE_TYPE); $catalog = $ident->serviceCatalog(ObjectStorage::SERVICE_TYPE);
if (empty($catalog) || empty($catalog[0]['endpoints'][0]['publicURL'])) { if (empty($catalog) || empty($catalog[0]['endpoints'][0]['publicURL'])) {
//throw new \OpenStack\Exception('No object storage services could be found for this tenant ID.' . print_r($catalog, true)); //throw new \OpenStack\Common\Exception('No object storage services could be found for this tenant ID.' . print_r($catalog, true));
throw new \OpenStack\Exception('No object storage services could be found for this tenant ID.'); throw new \OpenStack\Common\Exception('No object storage services could be found for this tenant ID.');
} }
$serviceURL = $catalog[0]['endpoints'][0]['publicURL']; $serviceURL = $catalog[0]['endpoints'][0]['publicURL'];
@ -1496,14 +1496,14 @@ class StreamWrapper
$client = $this->cxt('transport_client', null); $client = $this->cxt('transport_client', null);
$ident = new \OpenStack\Services\IdentityService($authUrl, $client); $ident = new \OpenStack\Identity\v2\IdentityService($authUrl, $client);
// Frustrated? Go burninate. http://www.homestarrunner.com/trogdor.html // Frustrated? Go burninate. http://www.homestarrunner.com/trogdor.html
if (!empty($username) && !empty($password)) { if (!empty($username) && !empty($password)) {
$token = $ident->authenticateAsUser($username, $password, $tenantId, $tenantName); $token = $ident->authenticateAsUser($username, $password, $tenantId, $tenantName);
} else { } else {
throw new \OpenStack\Exception('Username/password must be provided.'); throw new \OpenStack\Common\Exception('Username/password must be provided.');
} }
// Cache the service catalog. // Cache the service catalog.
self::$serviceCatalogCache[$token] = $ident->serviceCatalog(); self::$serviceCatalogCache[$token] = $ident->serviceCatalog();

View File

@ -19,7 +19,7 @@
* *
* Note, this stream wrapper is in early testing. * Note, this stream wrapper is in early testing.
* *
* The stream wrapper implemented in \OpenStack\Storage\ObjectStorage\StreamWrapper * The stream wrapper implemented in \OpenStack\ObjectStore\v1\Resource\StreamWrapper
* only supports the elements of a stream that are implemented by object * only supports the elements of a stream that are implemented by object
* storage. This is how the PHP documentation states a stream wrapper should be * storage. This is how the PHP documentation states a stream wrapper should be
* created. Because some features do not exist, attempting to treat a stream * created. Because some features do not exist, attempting to treat a stream
@ -32,7 +32,7 @@
* Hence the protocol is swiftfs standing for swift file system. * Hence the protocol is swiftfs standing for swift file system.
* *
* To understand how this stream wrapper works start by first reading the * To understand how this stream wrapper works start by first reading the
* documentation on the \OpenStack\Storage\ObjectStorage\StreamWrapper. * documentation on the \OpenStack\ObjectStore\v1\Resource\StreamWrapper.
* *
* DIRECTORIES * DIRECTORIES
* *
@ -58,10 +58,10 @@
* false. * false.
*/ */
namespace OpenStack\Storage\ObjectStorage; namespace OpenStack\ObjectStore\v1\Resource;
use \OpenStack\Bootstrap; use \OpenStack\Bootstrap;
use \OpenStack\Storage\ObjectStorage; use \OpenStack\ObjectStore\v1\ObjectStorage;
/** /**
* Provides stream wrapping for Swift like a file system. * Provides stream wrapping for Swift like a file system.
@ -169,7 +169,7 @@ class StreamWrapperFS extends StreamWrapper
$dirListing = $container->objectsWithPrefix($this->dirPrefix, $sep); $dirListing = $container->objectsWithPrefix($this->dirPrefix, $sep);
return !empty($dirListing); return !empty($dirListing);
} catch (\OpenStack\Exception $e) { } catch (\OpenStack\Common\Exception $e) {
trigger_error('Path could not be opened: ' . $e->getMessage(), E_USER_WARNING); trigger_error('Path could not be opened: ' . $e->getMessage(), E_USER_WARNING);
return false; return false;

View File

@ -18,7 +18,7 @@
* Contains the Subdir class. * Contains the Subdir class.
*/ */
namespace OpenStack\Storage\ObjectStorage; namespace OpenStack\ObjectStore\v1\Resource;
/** /**
* Represent a subdirectory (subdir) entry. * Represent a subdirectory (subdir) entry.

View File

@ -17,17 +17,17 @@
/** /**
* This is a simple command-line test for authentication. * This is a simple command-line test for authentication.
* *
* You can run the test with `php test/AuthTest.php username key`. * You can run the test with `php tests/AuthTest.php username key`.
*/ */
$base = dirname(__DIR__); $base = dirname(__DIR__);
require_once $base . '/src/OpenStack/Autoloader.php'; require_once $base . '/src/OpenStack/Autoloader.php';
use \OpenStack\Storage\ObjectStorage; use \OpenStack\ObjectStore\v1\ObjectStorage;
use \OpenStack\Services\IdentityService; use \OpenStack\Identity\v2\IdentityService;
$config = array( $config = array(
'transport' => '\OpenStack\Transport\PHPStreamTransport', 'transport' => '\OpenStack\Common\Transport\GuzzleClient',
'transport.timeout' => 240, 'transport.timeout' => 240,
//'transport.debug' => 1, //'transport.debug' => 1,
'transport.ssl.verify' => 0, 'transport.ssl.verify' => 0,

View File

@ -22,11 +22,11 @@ verify that your PHP client can successfully connect to OpenStack. To
run this test, do the following: run this test, do the following:
1. Begin from the root directory of this project, where you should see 1. Begin from the root directory of this project, where you should see
the directories `test/` and `src/`, among others. the directories `tests/` and `src/`, among others.
2. Execute the following command on the commandline: 2. Execute the following command on the commandline:
``` ```
$ php test/AuthTest.php $ php tests/AuthTest.php
``` ```
This will instruct you to use a more complete version of the command, This will instruct you to use a more complete version of the command,
@ -41,7 +41,7 @@ All four pieces of information can be found by logging into the
console. From there, you can execute a command like this: console. From there, you can execute a command like this:
``` ```
$ php test/AuthTest.php myusername apassword https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/ 1234567 $ php tests/AuthTest.php myusername apassword https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/ 1234567
``` ```
@ -61,7 +61,7 @@ Cloud credentials, along with your preferred testing parameters.
The easiest way to do this is to copy the example settings file, and The easiest way to do this is to copy the example settings file, and
then make the necessary changes: then make the necessary changes:
$ cd test/ $ cd tests/
$ cp example.settings.ini settings.ini $ cp example.settings.ini settings.ini
$ edit settings.ini $ edit settings.ini

View File

@ -19,10 +19,10 @@
*/ */
namespace OpenStack\Tests; namespace OpenStack\Tests;
require_once 'src/OpenStack/Autoloader.php';
require_once 'test/TestCase.php';
class AutoloaderTest extends \OpenStack\Tests\TestCase require_once 'src/OpenStack/Autoloader.php';
class AutoloaderTest extends TestCase
{ {
/** /**
* Test the BaseDir. * Test the BaseDir.
@ -41,8 +41,8 @@ class AutoloaderTest extends \OpenStack\Tests\TestCase
\OpenStack\Autoloader::useAutoloader(); \OpenStack\Autoloader::useAutoloader();
// If we can construct a class, we are okay. // If we can construct a class, we are okay.
$test = new \OpenStack\Exception("TEST"); $test = new \OpenStack\Common\Exception("TEST");
$this->assertInstanceOf('\OpenStack\Exception', $test); $this->assertInstanceOf('\OpenStack\Common\Exception', $test);
} }
} }

View File

@ -19,9 +19,7 @@
*/ */
namespace OpenStack\Tests; namespace OpenStack\Tests;
require_once 'test/TestCase.php'; class BootstrapTest extends TestCase
class BootstrapTest extends \OpenStack\Tests\TestCase
{ {
/** /**
* Canary test. * Canary test.

View File

@ -15,11 +15,9 @@
limitations under the License. limitations under the License.
============================================================================ */ ============================================================================ */
namespace OpenStack\Tests; namespace OpenStack\Tests\Common\Transport;
use OpenStack\Transport\GuzzleClient; use OpenStack\Common\Transport\GuzzleClient;
require_once 'test/TestCase.php';
class GuzzleClientTest extends \OpenStack\Tests\TestCase class GuzzleClientTest extends \OpenStack\Tests\TestCase
{ {
@ -52,7 +50,7 @@ class GuzzleClientTest extends \OpenStack\Tests\TestCase
$client = $this->buildClient(); $client = $this->buildClient();
$this->assertInstanceOf('\OpenStack\Transport\GuzzleClient', $client); $this->assertInstanceOf('\OpenStack\Common\Transport\GuzzleClient', $client);
$response = $client->doRequest($url, $method); $response = $client->doRequest($url, $method);
$this->assertInstanceOf('\GuzzleHttp\Message\Response', $response); $this->assertInstanceOf('\GuzzleHttp\Message\Response', $response);
@ -61,7 +59,7 @@ class GuzzleClientTest extends \OpenStack\Tests\TestCase
/** /**
* @depends testDoRequest * @depends testDoRequest
* @expectedException \OpenStack\Transport\FileNotFoundException * @expectedException \OpenStack\Common\Transport\Exception\FileNotFoundException
*/ */
public function testDoRequestException() public function testDoRequestException()
{ {

View File

@ -17,11 +17,9 @@
/** /**
* Unit tests for IdentityService. * Unit tests for IdentityService.
*/ */
namespace OpenStack\Tests\Services; namespace OpenStack\Tests\Identity\v2;
require_once 'test/TestCase.php'; use \OpenStack\Identity\v2\IdentityService;
use \OpenStack\Services\IdentityService;
use \OpenStack\Bootstrap; use \OpenStack\Bootstrap;
class IdentityServicesTest extends \OpenStack\Tests\TestCase class IdentityServicesTest extends \OpenStack\Tests\TestCase
@ -33,7 +31,7 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase
$service = new IdentityService($endpoint, $this->getTransportClient()); $service = new IdentityService($endpoint, $this->getTransportClient());
$this->assertInstanceOf('\OpenStack\Services\IdentityService', $service); $this->assertInstanceOf('\OpenStack\Identity\v2\IdentityService', $service);
return $service; return $service;
} }
@ -279,7 +277,7 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase
$again = unserialize($ser); $again = unserialize($ser);
$this->assertInstanceOf('\OpenStack\Services\IdentityService', $again); $this->assertInstanceOf('\OpenStack\Identity\v2\IdentityService', $again);
$this->assertEquals($service->tenantId(), $again->tenantId()); $this->assertEquals($service->tenantId(), $again->tenantId());
$this->assertEquals($service->serviceCatalog(), $again->serviceCatalog()); $this->assertEquals($service->serviceCatalog(), $again->serviceCatalog());
@ -410,7 +408,7 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase
Bootstrap::setConfiguration($settings); Bootstrap::setConfiguration($settings);
$is = Bootstrap::identity(true); $is = Bootstrap::identity(true);
$this->assertInstanceOf('\OpenStack\Services\IdentityService', $is); $this->assertInstanceOf('\OpenStack\Identity\v2\IdentityService', $is);
// Test getting a second instance from the cache. // Test getting a second instance from the cache.
$is2 = Bootstrap::identity(); $is2 = Bootstrap::identity();
@ -441,6 +439,6 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase
Bootstrap::setConfiguration($settings); Bootstrap::setConfiguration($settings);
$is = Bootstrap::identity(true); $is = Bootstrap::identity(true);
$this->assertInstanceOf('\OpenStack\Services\IdentityService', $is); $this->assertInstanceOf('\OpenStack\Identity\v2\IdentityService', $is);
} }
} }

View File

@ -17,11 +17,9 @@
/** /**
* Unit tests for ObjectStorage ACLs. * Unit tests for ObjectStorage ACLs.
*/ */
namespace OpenStack\Tests\Storage\ObjectStorage; namespace OpenStack\Tests\ObjectStore\v1\Resource;
require_once 'test/TestCase.php'; use \OpenStack\ObjectStore\v1\Resource\ACL;
use \OpenStack\Storage\ObjectStorage\ACL;
/** /**
* @ingroup Tests * @ingroup Tests
*/ */

View File

@ -17,13 +17,11 @@
/** /**
* Unit tests for Containers. * Unit tests for Containers.
*/ */
namespace OpenStack\Tests\Storage\ObjectStorage; namespace OpenStack\Tests\ObjectStore\v1\Resource;
require_once 'test/TestCase.php'; use \OpenStack\ObjectStore\v1\Resource\Container;
use \OpenStack\ObjectStore\v1\Resource\Object;
use \OpenStack\Storage\ObjectStorage\Container; use \OpenStack\ObjectStore\v1\Resource\ACL;
use \OpenStack\Storage\ObjectStorage\Object;
use \OpenStack\Storage\ObjectStorage\ACL;
class ContainerTest extends \OpenStack\Tests\TestCase class ContainerTest extends \OpenStack\Tests\TestCase
{ {
@ -47,7 +45,7 @@ class ContainerTest extends \OpenStack\Tests\TestCase
} }
/** /**
* @expectedException \OpenStack\Exception * @expectedException \OpenStack\Common\Exception
*/ */
public function testConstructorFailure() public function testConstructorFailure()
{ {
@ -189,8 +187,8 @@ class ContainerTest extends \OpenStack\Tests\TestCase
// Make sure this throws a 404. // Make sure this throws a 404.
try { try {
$foo = $container->object('no/such'); $foo = $container->object('no/such');
} catch (\OpenStack\Exception $e) { } catch (\OpenStack\Common\Exception $e) {
$this->assertInstanceOf('\OpenStack\Transport\FileNotFoundException', $e); $this->assertInstanceOf('\OpenStack\Common\Transport\Exception\FileNotFoundException', $e);
} }
} }
@ -260,7 +258,7 @@ class ContainerTest extends \OpenStack\Tests\TestCase
$this->assertEquals(2, count($objects)); $this->assertEquals(2, count($objects));
foreach ($objects as $o) { foreach ($objects as $o) {
$this->assertInstanceOf('\OpenStack\Storage\ObjectStorage\Object', $o); $this->assertInstanceOf('\OpenStack\ObjectStore\v1\Resource\Object', $o);
} }
// This should give us one file and one subdir. // This should give us one file and one subdir.
@ -437,7 +435,7 @@ class ContainerTest extends \OpenStack\Tests\TestCase
$acl = $container->acl(); $acl = $container->acl();
$this->assertInstanceOf('\OpenStack\Storage\ObjectStorage\ACL', $acl); $this->assertInstanceOf('\OpenStack\ObjectStore\v1\Resource\ACL', $acl);
$this->assertTrue($acl->isPublic()); $this->assertTrue($acl->isPublic());
$store->deleteContainer($cname); $store->deleteContainer($cname);

View File

@ -17,12 +17,10 @@
/** /**
* Unit tests for ObjectStorage. * Unit tests for ObjectStorage.
*/ */
namespace OpenStack\Tests\Storage; namespace OpenStack\Tests\ObjectStore\v1\Resource;
require_once 'test/TestCase.php'; use \OpenStack\ObjectStore\v1\Resource\Object;
use \OpenStack\ObjectStore\v1\Resource\ACL;
use \OpenStack\Storage\ObjectStorage\Object;
use \OpenStack\Storage\ObjectStorage\ACL;
class ObjectStorageTest extends \OpenStack\Tests\TestCase class ObjectStorageTest extends \OpenStack\Tests\TestCase
{ {
@ -42,7 +40,7 @@ class ObjectStorageTest extends \OpenStack\Tests\TestCase
{ {
$ostore = $this->swiftAuth(); $ostore = $this->swiftAuth();
$this->assertInstanceOf('\OpenStack\Storage\ObjectStorage', $ostore); $this->assertInstanceOf('\OpenStack\ObjectStore\v1\ObjectStorage', $ostore);
$this->assertTrue(strlen($ostore->token()) > 0); $this->assertTrue(strlen($ostore->token()) > 0);
} }
@ -53,7 +51,7 @@ class ObjectStorageTest extends \OpenStack\Tests\TestCase
{ {
$ident = $this->identity(); $ident = $this->identity();
$services = $ident->serviceCatalog(\OpenStack\Storage\ObjectStorage::SERVICE_TYPE); $services = $ident->serviceCatalog(\OpenStack\ObjectStore\v1\ObjectStorage::SERVICE_TYPE);
if (empty($services)) { if (empty($services)) {
throw new \Exception('No object-store service found.'); throw new \Exception('No object-store service found.');
@ -62,9 +60,9 @@ class ObjectStorageTest extends \OpenStack\Tests\TestCase
//$serviceURL = $services[0]['endpoints'][0]['adminURL']; //$serviceURL = $services[0]['endpoints'][0]['adminURL'];
$serviceURL = $services[0]['endpoints'][0]['publicURL']; $serviceURL = $services[0]['endpoints'][0]['publicURL'];
$ostore = new \OpenStack\Storage\ObjectStorage($ident->token(), $serviceURL, $this->getTransportClient()); $ostore = new \OpenStack\ObjectStore\v1\ObjectStorage($ident->token(), $serviceURL, $this->getTransportClient());
$this->assertInstanceOf('\OpenStack\Storage\ObjectStorage', $ostore); $this->assertInstanceOf('\OpenStack\ObjectStore\v1\ObjectStorage', $ostore);
$this->assertTrue(strlen($ostore->token()) > 0); $this->assertTrue(strlen($ostore->token()) > 0);
} }
@ -74,8 +72,8 @@ class ObjectStorageTest extends \OpenStack\Tests\TestCase
$ident = $this->identity(); $ident = $this->identity();
$tok = $ident->token(); $tok = $ident->token();
$cat = $ident->serviceCatalog(); $cat = $ident->serviceCatalog();
$ostore = \OpenStack\Storage\ObjectStorage::newFromServiceCatalog($cat, $tok, self::$settings['openstack.swift.region'], $this->getTransportClient()); $ostore = \OpenStack\ObjectStore\v1\ObjectStorage::newFromServiceCatalog($cat, $tok, self::$settings['openstack.swift.region'], $this->getTransportClient());
$this->assertInstanceOf('\OpenStack\Storage\ObjectStorage', $ostore); $this->assertInstanceOf('\OpenStack\ObjectStore\v1\ObjectStorage', $ostore);
$this->assertTrue(strlen($ostore->token()) > 0); $this->assertTrue(strlen($ostore->token()) > 0);
} }
@ -84,27 +82,27 @@ class ObjectStorageTest extends \OpenStack\Tests\TestCase
$ident = $this->identity(); $ident = $this->identity();
$tok = $ident->token(); $tok = $ident->token();
$cat = $ident->serviceCatalog(); $cat = $ident->serviceCatalog();
$ostore = \OpenStack\Storage\ObjectStorage::newFromServiceCatalog($cat, $tok, 'region-w.geo-99999.fake', $this->getTransportClient()); $ostore = \OpenStack\ObjectStore\v1\ObjectStorage::newFromServiceCatalog($cat, $tok, 'region-w.geo-99999.fake', $this->getTransportClient());
$this->assertEmpty($ostore); $this->assertEmpty($ostore);
} }
public function testNewFromIdnetity() public function testNewFromIdnetity()
{ {
$ident = $this->identity(); $ident = $this->identity();
$ostore = \OpenStack\Storage\ObjectStorage::newFromIdentity($ident, self::$settings['openstack.swift.region'], $this->getTransportClient()); $ostore = \OpenStack\ObjectStore\v1\ObjectStorage::newFromIdentity($ident, self::$settings['openstack.swift.region'], $this->getTransportClient());
$this->assertInstanceOf('\OpenStack\Storage\ObjectStorage', $ostore); $this->assertInstanceOf('\OpenStack\ObjectStore\v1\ObjectStorage', $ostore);
$this->assertTrue(strlen($ostore->token()) > 0); $this->assertTrue(strlen($ostore->token()) > 0);
} }
public function testNewFromIdentityAltRegion() public function testNewFromIdentityAltRegion()
{ {
$ident = $this->identity(); $ident = $this->identity();
$ostore = \OpenStack\Storage\ObjectStorage::newFromIdentity($ident, 'region-b.geo-1', $this->getTransportClient()); $ostore = \OpenStack\ObjectStore\v1\ObjectStorage::newFromIdentity($ident, 'region-b.geo-1', $this->getTransportClient());
$this->assertInstanceOf('\OpenStack\Storage\ObjectStorage', $ostore); $this->assertInstanceOf('\OpenStack\ObjectStore\v1\ObjectStorage', $ostore);
$this->assertTrue(strlen($ostore->token()) > 0); $this->assertTrue(strlen($ostore->token()) > 0);
// Make sure the store is not the same as the default region. // Make sure the store is not the same as the default region.
$ostoreDefault = \OpenStack\Storage\ObjectStorage::newFromIdentity($ident, self::$settings['openstack.swift.region'], $this->getTransportClient()); $ostoreDefault = \OpenStack\ObjectStore\v1\ObjectStorage::newFromIdentity($ident, self::$settings['openstack.swift.region'], $this->getTransportClient());
$this->assertNotEquals($ostore, $ostoreDefault); $this->assertNotEquals($ostore, $ostoreDefault);
} }
@ -168,7 +166,7 @@ class ObjectStorageTest extends \OpenStack\Tests\TestCase
$this->assertEquals(0, $testContainer->count()); $this->assertEquals(0, $testContainer->count());
// Make sure we get back an ACL: // Make sure we get back an ACL:
$this->assertInstanceOf('\OpenStack\Storage\ObjectStorage\ACL', $testContainer->acl()); $this->assertInstanceOf('\OpenStack\ObjectStore\v1\Resource\ACL', $testContainer->acl());
} }
@ -224,7 +222,7 @@ class ObjectStorageTest extends \OpenStack\Tests\TestCase
} }
/** /**
* @expectedException \OpenStack\Storage\ObjectStorage\ContainerNotEmptyException * @expectedException \OpenStack\ObjectStore\v1\Exception\ContainerNotEmptyException
*/ */
public function testDeleteNonEmptyContainer() public function testDeleteNonEmptyContainer()
{ {
@ -300,7 +298,7 @@ class ObjectStorageTest extends \OpenStack\Tests\TestCase
} }
$ret = $store->createContainer($testCollection); $ret = $store->createContainer($testCollection);
$acl = \OpenStack\Storage\ObjectStorage\ACL::makePublic(); $acl = \OpenStack\ObjectStore\v1\Resource\ACL::makePublic();
$ret = $store->changeContainerACL($testCollection, $acl); $ret = $store->changeContainerACL($testCollection, $acl);
$this->assertFalse($ret); $this->assertFalse($ret);

View File

@ -17,11 +17,9 @@
/** /**
* Unit tests for ObjectStorage Object. * Unit tests for ObjectStorage Object.
*/ */
namespace OpenStack\Tests\Storage; namespace OpenStack\Tests\ObjectStore\v1\Resource;
require_once 'test/TestCase.php'; use \OpenStack\ObjectStore\v1\Resource\Object;
use \OpenStack\Storage\ObjectStorage\Object;
class ObjectTest extends \OpenStack\Tests\TestCase class ObjectTest extends \OpenStack\Tests\TestCase
{ {

View File

@ -17,13 +17,11 @@
/** /**
* Unit tests for ObjectStorage RemoteObject. * Unit tests for ObjectStorage RemoteObject.
*/ */
namespace OpenStack\Tests\Storage\ObjectStorage; namespace OpenStack\Tests\ObjectStore\v1\Resource;
require_once 'test/TestCase.php'; use \OpenStack\ObjectStore\v1\Resource\RemoteObject;
use \OpenStack\ObjectStore\v1\Resource\Object;
use \OpenStack\Storage\ObjectStorage\RemoteObject; use \OpenStack\ObjectStore\v1\Resource\Container;
use \OpenStack\Storage\ObjectStorage\Object;
use \OpenStack\Storage\ObjectStorage\Container;
class RemoteObjectTest extends \OpenStack\Tests\TestCase class RemoteObjectTest extends \OpenStack\Tests\TestCase
{ {
@ -68,7 +66,7 @@ class RemoteObjectTest extends \OpenStack\Tests\TestCase
$obj = $container->remoteObject(self::FNAME); $obj = $container->remoteObject(self::FNAME);
$this->assertInstanceOf('\OpenStack\Storage\ObjectStorage\RemoteObject', $obj); $this->assertInstanceOf('\OpenStack\ObjectStore\v1\Resource\RemoteObject', $obj);
return $obj; return $obj;
} }

View File

@ -17,13 +17,11 @@
/** /**
* Unit tests for the stream wrapper file systema. * Unit tests for the stream wrapper file systema.
*/ */
namespace OpenStack\Tests\Storage\ObjectStorage; namespace OpenStack\Tests\ObjectStore\v1\Resource;
require_once 'test/TestCase.php'; use \OpenStack\ObjectStore\v1\Resource\StreamWrapperFS;
use \OpenStack\ObjectStore\v1\Resource\Container;
use \OpenStack\Storage\ObjectStorage\StreamWrapperFS; use \OpenStack\ObjectStore\v1\Resource\Object;
use \OpenStack\Storage\ObjectStorage\Container;
use \OpenStack\Storage\ObjectStorage\Object;
/** /**
* @group streamWrapper * @group streamWrapper
@ -47,12 +45,12 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase
$tenantId = self::conf('openstack.identity.tenantId'); $tenantId = self::conf('openstack.identity.tenantId');
$url = self::conf('openstack.identity.url'); $url = self::conf('openstack.identity.url');
$ident = new \OpenStack\Services\IdentityService($url, self::getTransportClient()); $ident = new \OpenStack\Identity\v2\IdentityService($url, self::getTransportClient());
$token = $ident->authenticateAsUser($user, $pass, $tenantId); $token = $ident->authenticateAsUser($user, $pass, $tenantId);
// Then we need to get an instance of storage // Then we need to get an instance of storage
$store = \OpenStack\Storage\ObjectStorage::newFromIdentity($ident, self::conf('openstack.swift.region'), self::getTransportClient()); $store = \OpenStack\ObjectStore\v1\ObjectStorage::newFromIdentity($ident, self::conf('openstack.swift.region'), self::getTransportClient());
// Delete the container and all the contents. // Delete the container and all the contents.
$cname = self::$settings['openstack.swift.container']; $cname = self::$settings['openstack.swift.container'];
@ -61,7 +59,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase
$container = $store->container($cname); $container = $store->container($cname);
} }
// The container was never created. // The container was never created.
catch (\OpenStack\Transport\FileNotFoundException $e) { catch (\OpenStack\Common\Transport\Exception\FileNotFoundException $e) {
return; return;
} }
@ -196,7 +194,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase
// Canary // Canary
$this->assertNotEmpty(StreamWrapperFS::DEFAULT_SCHEME); $this->assertNotEmpty(StreamWrapperFS::DEFAULT_SCHEME);
$klass = '\OpenStack\Storage\ObjectStorage\StreamWrapperFS'; $klass = '\OpenStack\ObjectStore\v1\Resource\StreamWrapperFS';
stream_wrapper_register(StreamWrapperFS::DEFAULT_SCHEME, $klass); stream_wrapper_register(StreamWrapperFS::DEFAULT_SCHEME, $klass);
$wrappers = stream_get_wrappers(); $wrappers = stream_get_wrappers();
@ -389,7 +387,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase
//throw new \Exception(print_r($md, true)); //throw new \Exception(print_r($md, true));
$obj = $md['wrapper_data']->object(); $obj = $md['wrapper_data']->object();
$this->assertInstanceOf('\OpenStack\Storage\ObjectStorage\RemoteObject', $obj); $this->assertInstanceOf('\OpenStack\ObjectStore\v1\Resource\RemoteObject', $obj);
$this->assertEquals(self::FTYPE, $obj->contentType()); $this->assertEquals(self::FTYPE, $obj->contentType());

View File

@ -17,13 +17,11 @@
/** /**
* Unit tests for the stream wrapper. * Unit tests for the stream wrapper.
*/ */
namespace OpenStack\Tests\Storage\ObjectStorage; namespace OpenStack\Tests\ObjectStore\v1\Resource;
require_once 'test/TestCase.php'; use \OpenStack\ObjectStore\v1\Resource\StreamWrapper;
use \OpenStack\ObjectStore\v1\Resource\Container;
use \OpenStack\Storage\ObjectStorage\StreamWrapper; use \OpenStack\ObjectStore\v1\Resource\Object;
use \OpenStack\Storage\ObjectStorage\Container;
use \OpenStack\Storage\ObjectStorage\Object;
/** /**
* @group streamWrapper * @group streamWrapper
@ -44,12 +42,12 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase
$tenantId = self::conf('openstack.identity.tenantId'); $tenantId = self::conf('openstack.identity.tenantId');
$url = self::conf('openstack.identity.url'); $url = self::conf('openstack.identity.url');
$ident = new \OpenStack\Services\IdentityService($url, self::getTransportClient()); $ident = new \OpenStack\Identity\v2\IdentityService($url, self::getTransportClient());
$token = $ident->authenticateAsUser($user, $pass, $tenantId); $token = $ident->authenticateAsUser($user, $pass, $tenantId);
// Then we need to get an instance of storage // Then we need to get an instance of storage
$store = \OpenStack\Storage\ObjectStorage::newFromIdentity($ident, self::conf('openstack.swift.region'), self::getTransportClient()); $store = \OpenStack\ObjectStore\v1\ObjectStorage::newFromIdentity($ident, self::conf('openstack.swift.region'), self::getTransportClient());
// Delete the container and all the contents. // Delete the container and all the contents.
$cname = self::$settings['openstack.swift.container']; $cname = self::$settings['openstack.swift.container'];
@ -58,7 +56,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase
$container = $store->container($cname); $container = $store->container($cname);
} }
// The container was never created. // The container was never created.
catch (\OpenStack\Transport\FileNotFoundException $e) { catch (\OpenStack\Common\Transport\Exception\FileNotFoundException $e) {
return; return;
} }
@ -190,7 +188,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase
// Canary // Canary
$this->assertNotEmpty(StreamWrapper::DEFAULT_SCHEME); $this->assertNotEmpty(StreamWrapper::DEFAULT_SCHEME);
$klass = '\OpenStack\Storage\ObjectStorage\StreamWrapper'; $klass = '\OpenStack\ObjectStore\v1\Resource\StreamWrapper';
stream_wrapper_register(StreamWrapper::DEFAULT_SCHEME, $klass); stream_wrapper_register(StreamWrapper::DEFAULT_SCHEME, $klass);
$wrappers = stream_get_wrappers(); $wrappers = stream_get_wrappers();
@ -388,7 +386,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase
//throw new \Exception(print_r($md, true)); //throw new \Exception(print_r($md, true));
$obj = $md['wrapper_data']->object(); $obj = $md['wrapper_data']->object();
$this->assertInstanceOf('\OpenStack\Storage\ObjectStorage\RemoteObject', $obj); $this->assertInstanceOf('\OpenStack\ObjectStore\v1\Resource\RemoteObject', $obj);
$this->assertEquals(self::FTYPE, $obj->contentType()); $this->assertEquals(self::FTYPE, $obj->contentType());

View File

@ -54,8 +54,8 @@ class TestCase extends \PHPUnit_Framework_TestCase
self::$settings = $bootstrap_settings; self::$settings = $bootstrap_settings;
//$this->setTestNamespace('Tests\Units'); //$this->setTestNamespace('Tests\Units');
if (file_exists('test/settings.ini')) { if (file_exists('tests/settings.ini')) {
self::$settings += parse_ini_file('test/settings.ini'); self::$settings += parse_ini_file('tests/settings.ini');
} else { } else {
throw new \Exception('Could not access test/settings.ini'); throw new \Exception('Could not access test/settings.ini');
} }
@ -92,7 +92,7 @@ class TestCase extends \PHPUnit_Framework_TestCase
$key = self::$settings['openstack.swift.key']; $key = self::$settings['openstack.swift.key'];
$url = self::$settings['openstack.swift.url']; $url = self::$settings['openstack.swift.url'];
//$url = self::$settings['openstack.identity.url']; //$url = self::$settings['openstack.identity.url'];
return \OpenStack\Storage\ObjectStorage::newFromSwiftAuth($user, $key, $url, $this->getTransportClient()); return \OpenStack\ObjectStore\v1\ObjectStorage::newFromSwiftAuth($user, $key, $url, $this->getTransportClient());
} }
@ -115,7 +115,7 @@ class TestCase extends \PHPUnit_Framework_TestCase
$tenantId = self::conf('openstack.identity.tenantId'); $tenantId = self::conf('openstack.identity.tenantId');
$url = self::conf('openstack.identity.url'); $url = self::conf('openstack.identity.url');
$is = new \OpenStack\Services\IdentityService($url); $is = new \OpenStack\Identity\v2\IdentityService($url);
$token = $is->authenticateAsUser($user, $pass, $tenantId); $token = $is->authenticateAsUser($user, $pass, $tenantId);
@ -131,7 +131,7 @@ class TestCase extends \PHPUnit_Framework_TestCase
if ($reset || empty(self::$ostore)) { if ($reset || empty(self::$ostore)) {
$ident = $this->identity($reset); $ident = $this->identity($reset);
$objStore = \OpenStack\Storage\ObjectStorage::newFromIdentity($ident, self::$settings['openstack.swift.region'], $this->getTransportClient()); $objStore = \OpenStack\ObjectStore\v1\ObjectStorage::newFromIdentity($ident, self::$settings['openstack.swift.region'], $this->getTransportClient());
self::$ostore = $objStore; self::$ostore = $objStore;
@ -183,7 +183,7 @@ class TestCase extends \PHPUnit_Framework_TestCase
$container = $store->container($cname); $container = $store->container($cname);
} }
// The container was never created. // The container was never created.
catch (\OpenStack\Transport\FileNotFoundException $e) { catch (\OpenStack\Common\Transport\Exception\FileNotFoundException $e) {
return; return;
} }
@ -239,7 +239,7 @@ class TestCase extends \PHPUnit_Framework_TestCase
$container = $store->container($cname); $container = $store->container($cname);
} }
// The container was never created. // The container was never created.
catch (\OpenStack\Transport\FileNotFoundException $e) { catch (\OpenStack\Common\Transport\Exception\FileNotFoundException $e) {
return; return;
} }

View File

@ -37,7 +37,7 @@ openstack.swift.region = "region-a.geo-1"
;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; The HTTP Transport Client to use. ; The HTTP Transport Client to use.
transport = "\OpenStack\Transport\GuzzleClient" transport = "\OpenStack\Common\Transport\GuzzleClient"
; If behind a proxy set to the https proxy server communications need ; If behind a proxy set to the https proxy server communications need
; to pass through. ; to pass through.