From 153e6e8b678c912dacf3ac303fbf32ae4f8fe378 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Wed, 23 Apr 2014 19:40:17 -0400 Subject: [PATCH] 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 --- .gitignore | 2 +- composer.json | 5 +- doc/documentation.php | 28 +++--- doc/oo-tutorial-code.php | 6 +- doc/oo-tutorial.md | 32 +++--- doc/streams-tutorial.md | 4 +- phpunit.xml.dist | 2 +- src/OpenStack/Bootstrap.php | 32 +++--- src/OpenStack/{ => Common}/Exception.php | 2 +- .../Transport/ClientInterface.php | 54 +++++------ .../Exception}/AuthorizationException.php | 4 +- .../Exception}/ConflictException.php | 4 +- .../Exception}/FileNotFoundException.php | 4 +- .../Exception}/ForbiddenException.php | 2 +- .../Exception}/LengthRequiredException.php | 4 +- .../Exception}/MethodNotAllowedException.php | 4 +- .../Transport/Exception}/ServerException.php | 4 +- .../Exception}/UnauthorizedException.php | 2 +- .../UnprocessableEntityException.php | 4 +- .../{ => Common}/Transport/GuzzleClient.php | 42 ++++---- .../Transport/ResponseInterface.php | 2 +- .../v2}/IdentityService.php | 52 +++++----- .../Exception}/ContainerNotEmptyException.php | 4 +- .../ContentVerificationException.php | 4 +- .../v1/Exception}/ReadOnlyObjectException.php | 4 +- .../v1}/ObjectStorage.php | 90 ++++++++--------- .../v1/Resource}/ACL.php | 28 +++--- .../v1/Resource}/Container.php | 97 ++++++++++--------- .../v1/Resource}/Object.php | 36 +++---- .../v1/Resource}/RemoteObject.php | 51 +++++----- .../v1/Resource}/StreamWrapper.php | 56 +++++------ .../v1/Resource}/StreamWrapperFS.php | 10 +- .../v1/Resource}/Subdir.php | 2 +- {test => tests}/AuthTest.php | 8 +- {test => tests}/README.md | 8 +- {test => tests}/Tests/AutoloaderTest.php | 10 +- {test => tests}/Tests/BootstrapTest.php | 4 +- .../Common/Transport}/GuzzleClientTest.php | 10 +- .../Identity/v2}/IdentityServicesTest.php | 14 ++- .../Tests/ObjectStore/v1}/ACLTest.php | 6 +- .../Tests/ObjectStore/v1}/ContainerTest.php | 20 ++-- .../ObjectStore/v1}/ObjectStorageTest.php | 38 ++++---- .../Tests/ObjectStore/v1}/ObjectTest.php | 6 +- .../ObjectStore/v1}/RemoteObjectTest.php | 12 +-- .../ObjectStore/v1}/StreamWrapperFSTest.php | 20 ++-- .../ObjectStore/v1}/StreamWrapperTest.php | 20 ++-- {test => tests/Tests}/TestCase.php | 14 +-- {test => tests}/bootstrap_curl.php | 0 {test => tests}/bootstrap_phpstream.php | 0 {test => tests}/example.settings.ini | 2 +- 50 files changed, 428 insertions(+), 441 deletions(-) rename src/OpenStack/{ => Common}/Exception.php (97%) rename src/OpenStack/{ => Common}/Transport/ClientInterface.php (67%) rename src/OpenStack/{Transport => Common/Transport/Exception}/AuthorizationException.php (89%) rename src/OpenStack/{Transport => Common/Transport/Exception}/ConflictException.php (90%) rename src/OpenStack/{Transport => Common/Transport/Exception}/FileNotFoundException.php (88%) rename src/OpenStack/{Transport => Common/Transport/Exception}/ForbiddenException.php (95%) rename src/OpenStack/{Transport => Common/Transport/Exception}/LengthRequiredException.php (88%) rename src/OpenStack/{Transport => Common/Transport/Exception}/MethodNotAllowedException.php (87%) rename src/OpenStack/{Transport => Common/Transport/Exception}/ServerException.php (88%) rename src/OpenStack/{Transport => Common/Transport/Exception}/UnauthorizedException.php (95%) rename src/OpenStack/{Transport => Common/Transport/Exception}/UnprocessableEntityException.php (88%) rename src/OpenStack/{ => Common}/Transport/GuzzleClient.php (78%) rename src/OpenStack/{ => Common}/Transport/ResponseInterface.php (99%) rename src/OpenStack/{Services => Identity/v2}/IdentityService.php (91%) rename src/OpenStack/{Storage/ObjectStorage => ObjectStore/v1/Exception}/ContainerNotEmptyException.php (89%) rename src/OpenStack/{Storage/ObjectStorage => ObjectStore/v1/Exception}/ContentVerificationException.php (89%) rename src/OpenStack/{Storage/ObjectStorage => ObjectStore/v1/Exception}/ReadOnlyObjectException.php (88%) rename src/OpenStack/{Storage => ObjectStore/v1}/ObjectStorage.php (83%) rename src/OpenStack/{Storage/ObjectStorage => ObjectStore/v1/Resource}/ACL.php (93%) rename src/OpenStack/{Storage/ObjectStorage => ObjectStore/v1/Resource}/Container.php (89%) rename src/OpenStack/{Storage/ObjectStorage => ObjectStore/v1/Resource}/Object.php (91%) rename src/OpenStack/{Storage/ObjectStorage => ObjectStore/v1/Resource}/RemoteObject.php (90%) rename src/OpenStack/{Storage/ObjectStorage => ObjectStore/v1/Resource}/StreamWrapper.php (95%) rename src/OpenStack/{Storage/ObjectStorage => ObjectStore/v1/Resource}/StreamWrapperFS.php (96%) rename src/OpenStack/{Storage/ObjectStorage => ObjectStore/v1/Resource}/Subdir.php (97%) rename {test => tests}/AuthTest.php (92%) rename {test => tests}/README.md (93%) rename {test => tests}/Tests/AutoloaderTest.php (86%) rename {test => tests}/Tests/BootstrapTest.php (91%) rename {test/Tests => tests/Tests/Common/Transport}/GuzzleClientTest.php (89%) rename {test/Tests => tests/Tests/Identity/v2}/IdentityServicesTest.php (97%) rename {test/Tests => tests/Tests/ObjectStore/v1}/ACLTest.php (98%) rename {test/Tests => tests/Tests/ObjectStore/v1}/ContainerTest.php (95%) rename {test/Tests => tests/Tests/ObjectStore/v1}/ObjectStorageTest.php (83%) rename {test/Tests => tests/Tests/ObjectStore/v1}/ObjectTest.php (97%) rename {test/Tests => tests/Tests/ObjectStore/v1}/RemoteObjectTest.php (96%) rename {test/Tests => tests/Tests/ObjectStore/v1}/StreamWrapperFSTest.php (96%) rename {test/Tests => tests/Tests/ObjectStore/v1}/StreamWrapperTest.php (95%) rename {test => tests/Tests}/TestCase.php (91%) rename {test => tests}/bootstrap_curl.php (100%) rename {test => tests}/bootstrap_phpstream.php (100%) rename {test => tests}/example.settings.ini (96%) diff --git a/.gitignore b/.gitignore index bfb50db..158e9ce 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ vendor/ .DS_Store composer.lock composer.phar -test/settings.ini* \ No newline at end of file +tests/settings.ini* \ No newline at end of file diff --git a/composer.json b/composer.json index d0c0ad1..1c414c4 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,9 @@ "phpunit/phpunit": "4.*" }, "autoload": { - "psr-4": { "OpenStack\\": "src/OpenStack" } + "psr-4": { + "OpenStack\\": "src/OpenStack", + "OpenStack\\Tests\\": "tests/Tests" + } } } diff --git a/doc/documentation.php b/doc/documentation.php index cc14e6f..2a4e5e1 100644 --- a/doc/documentation.php +++ b/doc/documentation.php @@ -92,7 +92,7 @@ *- And so on * @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 * @@ -109,7 +109,7 @@ * // you might want to use this: * \OpenStack\Autoloader::useAutoloader(); * - * use \OpenStack\Services\IdentityService; + * use \OpenStack\Identity\v1\IdentityService; * * // Create a new identity service object, and tell it where to * // 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. *- 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 - * 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: - * - \OpenStack\Services\IdentityService::__construct() tells the object where to connect. - * - \OpenStack\Services\IdentityService::authenticateAsUser() lets you log + * - \OpenStack\Identity\v1\IdentityService::__construct() tells the object where to connect. + * - \OpenStack\Identity\v1\IdentityService::authenticateAsUser() lets you log * 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. * * Basic Example: Object Storage @@ -157,10 +157,10 @@ * // $objectStorageUrl = storageList[0]['endpoints'][0]['publicURL']; * * // 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: - * $objectStore = \OpenStack\Storage\ObjectStorage::newFromIdentity($identity); + * $objectStore = \OpenStack\ObjectStore\v1\ObjectStorage::newFromIdentity($identity); * * // List containers: * print_r($objectStore->containers()); @@ -182,14 +182,14 @@ * ?> * * 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. * - *- \OpenStack\Storage\ObjectStorage is where you will start. - *- Container services are in \OpenStack\Storage\ObjectStorage\Container + *- \OpenStack\ObjectStore\v1\ObjectStorage is where you will start. + *- Container services are in \OpenStack\ObjectStore\v1\ObjectStorage\Container *- There are two classes for objects: - * - \OpenStack\Storage\ObjectStorage\Object is for creating new objects. - * - \OpenStack\Storage\ObjectStorage\RemoteObject provides better network + * - \OpenStack\ObjectStore\v1\ObjectStorage\Object is for creating new objects. + * - \OpenStack\ObjectStore\v1\ObjectStorage\RemoteObject provides better network * performance when reading objects. * */ @@ -222,7 +222,7 @@ * @package OpenStack.Storage.ObjectStorage * Classes specific to ObjectStorage. * - * The main class is \OpenStack\Storage\ObjectStorage. + * The main class is \OpenStack\ObjectStore\v1\ObjectStorage. */ /** * @package OpenStack.Transport diff --git a/doc/oo-tutorial-code.php b/doc/oo-tutorial-code.php index 360737c..a1b5500 100644 --- a/doc/oo-tutorial-code.php +++ b/doc/oo-tutorial-code.php @@ -2,9 +2,9 @@ require_once __DIR__ . '/../src/OpenStack/Autoloader.php'; use \OpenStack\Autoloader; -use \OpenStack\Services\IdentityService; -use \OpenStack\Storage\ObjectStorage; -use \OpenStack\Storage\ObjectStorage\Object; +use \OpenStack\Identity\v2\IdentityService; +use \OpenStack\ObjectStore\v1\ObjectStorage; +use \OpenStack\ObjectStore\v1\ObjectStorage\Object; Autoloader::useAutoloader(); diff --git a/doc/oo-tutorial.md b/doc/oo-tutorial.md index b1c83a7..3ba8e42 100644 --- a/doc/oo-tutorial.md +++ b/doc/oo-tutorial.md @@ -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: 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 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 easier for you to navigate our code. @@ -97,9 +97,9 @@ and this is done as follows: use \OpenStack\Autoloader; use \OpenStack\Bootstrap; - use \OpenStack\Services\IdentityService; - use \OpenStack\Storage\ObjectStorage; - use \OpenStack\Storage\ObjectStorage\Object; + use \OpenStack\Identity\v2\IdentityService; + use \OpenStack\ObjectStore\v1\ObjectStorage; + use \OpenStack\ObjectStore\v1\Resource\Object; \OpenStack\Autoloader::useAutoloader(); ?> @@ -182,7 +182,7 @@ authenticating. $tenantId = 'ADD TENANT ID 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); ?> @@ -203,9 +203,9 @@ authorization token (`$token`), though we can also get the token from `$idService->token()`. Note that the `IdentityService` object may throw various exceptions -(all subclasses of OpenStack::Exception) during authentication. Failed -authentication results in an \OpenStack\Transport\AuthorizationException, while -a network failure may result in an \OpenStack\Transport\ServerException. +(all subclasses of OpenStack\Common\Exception) during authentication. Failed +authentication results in an \OpenStack\Common\Transport\AuthorizationException, while +a network failure may result in an \OpenStack\Common\Transport\ServerException. Earlier, we talked about the service catalog. Once we've authenticated, we can get the service catalog from `$idService->serviceCatalog()`. It @@ -217,7 +217,7 @@ look at Object Storage. ### IdentityService in a Nutshell -Instances of OpenStack::Services::IdentityService are responsible for: +Instances of `OpenStack\Identity\v2\IdentityService` are responsible for: - Authentication - 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` variable. -Now we can get a new OpenStack::Storage::ObjectStorage instance: +Now we can get a new `\OpenStack\ObjectStore\v1\ObjectStorage` instance: serviceCatalog(); @@ -266,7 +266,7 @@ First we get the service catalog (`$catalog`), and then we use the Object Storage instance. The pattern of using a constructor-like static function is used -throughout the OpenStack PHP-Client library. Inspired by Objective-C constructors +throughout the OpenStack PHP-Client library. Inspired by Objective-C constructors and the Factory design pattern, it makes it possible for a single class to have multiple constructors. @@ -332,7 +332,7 @@ Now that we have a `Container`, we can add an object. (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 - 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 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 @@ -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 -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 remote server. Along with providing the features of the `Object` class we saw earlier, it also provides numerous optimizations for working over @@ -473,7 +473,7 @@ called. ### 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 - A proxying mechanism for lazily loading objects diff --git a/doc/streams-tutorial.md b/doc/streams-tutorial.md index d18b4cf..1db61cb 100644 --- a/doc/streams-tutorial.md +++ b/doc/streams-tutorial.md @@ -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 Swift filename parts as if they were directories. Check out -OpenStack::Storage::ObjectStorage::Container.) +`\OpenStack\ObjectStore\v1\Resource\Container`.) ## Using Stream Contexts for Authentication @@ -241,4 +241,4 @@ more about that. Addidtionally, you may wish to learn more about the internals of the stream wrapper, the main class, -OpenStack::Storage::ObjectStorage::StreamWrapper, is well-documented. +`\OpenStack\ObjectStore\v1\Resource\StreamWrapper`, is well-documented. diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d00c547..95baeef 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,7 +2,7 @@ - test/Tests/ + tests/Tests/ diff --git a/src/OpenStack/Bootstrap.php b/src/OpenStack/Bootstrap.php index 2bc25fc..b18752d 100644 --- a/src/OpenStack/Bootstrap.php +++ b/src/OpenStack/Bootstrap.php @@ -22,7 +22,7 @@ namespace OpenStack; -use OpenStack\Services\IdentityService; +use OpenStack\Identity\v2\IdentityService; /** * Bootstrapping services. @@ -50,7 +50,7 @@ use OpenStack\Services\IdentityService; * '\OpenStack\Transport\GuzzleClient', + * 'transport' => '\OpenStack\Common\Transport\GuzzleClient', * // Set the HTTP max wait time to 500 seconds. * 'transport.timeout' => 500, * ); @@ -83,17 +83,17 @@ class Bootstrap { public static $config = array( // 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. */ 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; @@ -120,13 +120,13 @@ class Bootstrap public static function useStreamWrappers() { $swift = stream_wrapper_register( - \OpenStack\Storage\ObjectStorage\StreamWrapper::DEFAULT_SCHEME, - '\OpenStack\Storage\ObjectStorage\StreamWrapper' + \OpenStack\ObjectStore\v1\ObjectStorage\StreamWrapper::DEFAULT_SCHEME, + '\OpenStack\ObjectStore\v1\ObjectStorage\StreamWrapper' ); $swiftfs = stream_wrapper_register( - \OpenStack\Storage\ObjectStorage\StreamWrapperFS::DEFAULT_SCHEME, - '\OpenStack\Storage\ObjectStorage\StreamWrapperFS' + \OpenStack\ObjectStore\v1\ObjectStorage\StreamWrapperFS::DEFAULT_SCHEME, + '\OpenStack\ObjectStore\v1\ObjectStorage\StreamWrapperFS' ); return ($swift && $swiftfs); @@ -144,7 +144,7 @@ class Bootstrap * Common configuration directives: * * - '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 * disabling. Enabling will turn on verbose debugging output * 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 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 * one is already cached. * - * @return \OpenStack\Services\IdentityService An authenticated ready to use - * \OpenStack\Services\IdentityService object. - * @throws \OpenStack\Exception When the needed configuration to authenticate + * @return \OpenStack\Identity\v2\IdentityService An authenticated ready to use + * \OpenStack\Identity\v2\IdentityService object. + * @throws \OpenStack\Common\Exception When the needed configuration to authenticate * is not available. */ 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. * - * @return \OpenStack\Transport\ClientInterface A transport client. + * @return \OpenStack\Common\Transport\ClientInterface A transport client. */ public static function transport($reset = false) { diff --git a/src/OpenStack/Exception.php b/src/OpenStack/Common/Exception.php similarity index 97% rename from src/OpenStack/Exception.php rename to src/OpenStack/Common/Exception.php index a17613f..d7f694b 100644 --- a/src/OpenStack/Exception.php +++ b/src/OpenStack/Common/Exception.php @@ -17,7 +17,7 @@ /** * The parent exception class for OpenStack. */ -namespace OpenStack; +namespace OpenStack\Common; /** * The top-level OpenStack exception. * diff --git a/src/OpenStack/Transport/ClientInterface.php b/src/OpenStack/Common/Transport/ClientInterface.php similarity index 67% rename from src/OpenStack/Transport/ClientInterface.php rename to src/OpenStack/Common/Transport/ClientInterface.php index cb7c47b..cd2203e 100644 --- a/src/OpenStack/Transport/ClientInterface.php +++ b/src/OpenStack/Common/Transport/ClientInterface.php @@ -18,7 +18,7 @@ * This file contains the interface for transporters. */ -namespace OpenStack\Transport; +namespace OpenStack\Common\Transport; /** * Describes a transport client. @@ -63,20 +63,20 @@ interface ClientInterface * @param array $headers An array of name/value header pairs. * @param string $body The string containing the request body. * - * @return \OpenStack\Transport\ResponseInterface The response. The response - * is implicit rather than explicit. The interface is based on a draft for - * messages from PHP FIG. Individual implementing libraries will have their - * own reference to interfaces. For example, see Guzzle. + * @return \OpenStack\Common\Transport\ResponseInterface The response. The response + * is implicit rather than explicit. The interface is based on a draft for + * messages from PHP FIG. Individual implementing libraries will have their + * own reference to interfaces. For example, see Guzzle. * - * @throws \OpenStack\Transport\ForbiddenException - * @throws \OpenStack\Transport\UnauthorizedException - * @throws \OpenStack\Transport\FileNotFoundException - * @throws \OpenStack\Transport\MethodNotAllowedException - * @throws \OpenStack\Transport\ConflictException - * @throws \OpenStack\Transport\LengthRequiredException - * @throws \OpenStack\Transport\UnprocessableEntityException - * @throws \OpenStack\Transport\ServerException - * @throws \OpenStack\Exception + * @throws \OpenStack\Common\Transport\Exception\ForbiddenException + * @throws \OpenStack\Common\Transport\Exception\UnauthorizedException + * @throws \OpenStack\Common\Transport\Exception\FileNotFoundException + * @throws \OpenStack\Common\Transport\Exception\MethodNotAllowedException + * @throws \OpenStack\Common\Transport\Exception\ConflictException + * @throws \OpenStack\Common\Transport\Exception\LengthRequiredException + * @throws \OpenStack\Common\Transport\Exception\UnprocessableEntityException + * @throws \OpenStack\Common\Transport\Exception\ServerException + * @throws \OpenStack\Common\Exception */ 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 * file elsewhere and pass the resource in here. * - * @return \OpenStack\Transport\ResponseInterface The response. The response - * is implicit rather than explicit. The interface is based on a draft for - * messages from PHP FIG. Individual implementing libraries will have their - * own reference to interfaces. For example, see Guzzle. + * @return \OpenStack\Common\Transport\ResponseInterface The response. The response + * is implicit rather than explicit. The interface is based on a draft for + * messages from PHP FIG. Individual implementing libraries will have their + * own reference to interfaces. For example, see Guzzle. * - * @throws \OpenStack\Transport\ForbiddenException - * @throws \OpenStack\Transport\UnauthorizedException - * @throws \OpenStack\Transport\FileNotFoundException - * @throws \OpenStack\Transport\MethodNotAllowedException - * @throws \OpenStack\Transport\ConflictException - * @throws \OpenStack\Transport\LengthRequiredException - * @throws \OpenStack\Transport\UnprocessableEntityException - * @throws \OpenStack\Transport\ServerException - * @throws \OpenStack\Exception + * @throws \OpenStack\Common\Transport\Exception\ForbiddenException + * @throws \OpenStack\Common\Transport\Exception\UnauthorizedException + * @throws \OpenStack\Common\Transport\Exception\FileNotFoundException + * @throws \OpenStack\Common\Transport\Exception\MethodNotAllowedException + * @throws \OpenStack\Common\Transport\Exception\ConflictException + * @throws \OpenStack\Common\Transport\Exception\LengthRequiredException + * @throws \OpenStack\Common\Transport\Exception\UnprocessableEntityException + * @throws \OpenStack\Common\Transport\Exception\ServerException + * @throws \OpenStack\Common\Exception */ public function doRequestWithResource($uri, $method, array $headers = [], $resource); } diff --git a/src/OpenStack/Transport/AuthorizationException.php b/src/OpenStack/Common/Transport/Exception/AuthorizationException.php similarity index 89% rename from src/OpenStack/Transport/AuthorizationException.php rename to src/OpenStack/Common/Transport/Exception/AuthorizationException.php index 309bdcb..81bf7ad 100644 --- a/src/OpenStack/Transport/AuthorizationException.php +++ b/src/OpenStack/Common/Transport/Exception/AuthorizationException.php @@ -17,10 +17,10 @@ /** * The authorization exception. */ -namespace OpenStack\Transport; +namespace OpenStack\Common\Transport\Exception; /** * Thrown when an access constraint is not met. * * Represents an HTTP 401 or 403 exception. */ -class AuthorizationException extends \OpenStack\Exception {} +class AuthorizationException extends \OpenStack\Common\Exception {} diff --git a/src/OpenStack/Transport/ConflictException.php b/src/OpenStack/Common/Transport/Exception/ConflictException.php similarity index 90% rename from src/OpenStack/Transport/ConflictException.php rename to src/OpenStack/Common/Transport/Exception/ConflictException.php index 8fa459c..a6d8e36 100644 --- a/src/OpenStack/Transport/ConflictException.php +++ b/src/OpenStack/Common/Transport/Exception/ConflictException.php @@ -15,7 +15,7 @@ limitations under the License. ============================================================================ */ -namespace OpenStack\Transport; +namespace OpenStack\Common\Transport\Exception; /** * Represents an HTTP 409 error. * @@ -23,4 +23,4 @@ namespace OpenStack\Transport; * deleted because the resource is not empty or deleteable. (viz. * containers). */ -class ConflictException extends \OpenStack\Exception {} +class ConflictException extends \OpenStack\Common\Exception {} diff --git a/src/OpenStack/Transport/FileNotFoundException.php b/src/OpenStack/Common/Transport/Exception/FileNotFoundException.php similarity index 88% rename from src/OpenStack/Transport/FileNotFoundException.php rename to src/OpenStack/Common/Transport/Exception/FileNotFoundException.php index 7bb5895..0f7e194 100644 --- a/src/OpenStack/Transport/FileNotFoundException.php +++ b/src/OpenStack/Common/Transport/Exception/FileNotFoundException.php @@ -15,8 +15,8 @@ limitations under the License. ============================================================================ */ -namespace OpenStack\Transport; +namespace OpenStack\Common\Transport\Exception; /** * Represents an HTTP File Not Found error. */ -class FileNotFoundException extends \OpenStack\Exception {} +class FileNotFoundException extends \OpenStack\Common\Exception {} diff --git a/src/OpenStack/Transport/ForbiddenException.php b/src/OpenStack/Common/Transport/Exception/ForbiddenException.php similarity index 95% rename from src/OpenStack/Transport/ForbiddenException.php rename to src/OpenStack/Common/Transport/Exception/ForbiddenException.php index 80b5508..87afeb7 100644 --- a/src/OpenStack/Transport/ForbiddenException.php +++ b/src/OpenStack/Common/Transport/Exception/ForbiddenException.php @@ -19,7 +19,7 @@ * * The permission denied exception. */ -namespace OpenStack\Transport; +namespace OpenStack\Common\Transport\Exception; /** * Thrown when an access constraint is not met. * diff --git a/src/OpenStack/Transport/LengthRequiredException.php b/src/OpenStack/Common/Transport/Exception/LengthRequiredException.php similarity index 88% rename from src/OpenStack/Transport/LengthRequiredException.php rename to src/OpenStack/Common/Transport/Exception/LengthRequiredException.php index 3889ef2..46de21d 100644 --- a/src/OpenStack/Transport/LengthRequiredException.php +++ b/src/OpenStack/Common/Transport/Exception/LengthRequiredException.php @@ -15,10 +15,10 @@ limitations under the License. ============================================================================ */ -namespace OpenStack\Transport; +namespace OpenStack\Common\Transport\Exception; /** * Represents an HTTP 412 error. * * During some PUT requests, Content-Length is a required header. */ -class LengthRequiredException extends \OpenStack\Exception {} +class LengthRequiredException extends \OpenStack\Common\Exception {} diff --git a/src/OpenStack/Transport/MethodNotAllowedException.php b/src/OpenStack/Common/Transport/Exception/MethodNotAllowedException.php similarity index 87% rename from src/OpenStack/Transport/MethodNotAllowedException.php rename to src/OpenStack/Common/Transport/Exception/MethodNotAllowedException.php index f155dc5..c233fbb 100644 --- a/src/OpenStack/Transport/MethodNotAllowedException.php +++ b/src/OpenStack/Common/Transport/Exception/MethodNotAllowedException.php @@ -15,8 +15,8 @@ limitations under the License. ============================================================================ */ -namespace OpenStack\Transport; +namespace OpenStack\Common\Transport\Exception; /** * Represents an HTTP 405 error. */ -class MethodNotAllowedException extends \OpenStack\Exception {} +class MethodNotAllowedException extends \OpenStack\Common\Exception {} diff --git a/src/OpenStack/Transport/ServerException.php b/src/OpenStack/Common/Transport/Exception/ServerException.php similarity index 88% rename from src/OpenStack/Transport/ServerException.php rename to src/OpenStack/Common/Transport/Exception/ServerException.php index 04e65fb..848ab6c 100644 --- a/src/OpenStack/Transport/ServerException.php +++ b/src/OpenStack/Common/Transport/Exception/ServerException.php @@ -15,8 +15,8 @@ limitations under the License. ============================================================================ */ -namespace OpenStack\Transport; +namespace OpenStack\Common\Transport\Exception; /** * Represents an HTTP 500 error. */ -class ServerException extends \OpenStack\Exception {} +class ServerException extends \OpenStack\Common\Exception {} diff --git a/src/OpenStack/Transport/UnauthorizedException.php b/src/OpenStack/Common/Transport/Exception/UnauthorizedException.php similarity index 95% rename from src/OpenStack/Transport/UnauthorizedException.php rename to src/OpenStack/Common/Transport/Exception/UnauthorizedException.php index 6d83693..f1306e3 100644 --- a/src/OpenStack/Transport/UnauthorizedException.php +++ b/src/OpenStack/Common/Transport/Exception/UnauthorizedException.php @@ -17,7 +17,7 @@ /** * The authorization exception. */ -namespace OpenStack\Transport; +namespace OpenStack\Common\Transport\Exception; /** * Thrown when authorization fails. * diff --git a/src/OpenStack/Transport/UnprocessableEntityException.php b/src/OpenStack/Common/Transport/Exception/UnprocessableEntityException.php similarity index 88% rename from src/OpenStack/Transport/UnprocessableEntityException.php rename to src/OpenStack/Common/Transport/Exception/UnprocessableEntityException.php index bdc8da2..ecd5c87 100644 --- a/src/OpenStack/Transport/UnprocessableEntityException.php +++ b/src/OpenStack/Common/Transport/Exception/UnprocessableEntityException.php @@ -15,11 +15,11 @@ limitations under the License. ============================================================================ */ -namespace OpenStack\Transport; +namespace OpenStack\Common\Transport\Exception; /** * Represents an HTTP 422 error. * * This often represents a case where a checksum or hash did not match * the generated checksum on the remote end. */ -class UnprocessableEntityException extends \OpenStack\Exception {} +class UnprocessableEntityException extends \OpenStack\Common\Exception {} diff --git a/src/OpenStack/Transport/GuzzleClient.php b/src/OpenStack/Common/Transport/GuzzleClient.php similarity index 78% rename from src/OpenStack/Transport/GuzzleClient.php rename to src/OpenStack/Common/Transport/GuzzleClient.php index a169f6e..b73616d 100644 --- a/src/OpenStack/Transport/GuzzleClient.php +++ b/src/OpenStack/Common/Transport/GuzzleClient.php @@ -18,7 +18,7 @@ * This file contains the interface for transporter clients. */ -namespace OpenStack\Transport; +namespace OpenStack\Common\Transport; class GuzzleClient implements ClientInterface, \Serializable { @@ -161,17 +161,17 @@ class GuzzleClient implements ClientInterface, \Serializable * * @param mixed The Guzzle exception. * - * @return \OpenStack\Transport\ResponseInterface The response. + * @return \OpenStack\Common\Transport\ResponseInterface The response. * - * @throws \OpenStack\Transport\ForbiddenException - * @throws \OpenStack\Transport\UnauthorizedException - * @throws \OpenStack\Transport\FileNotFoundException - * @throws \OpenStack\Transport\MethodNotAllowedException - * @throws \OpenStack\Transport\ConflictException - * @throws \OpenStack\Transport\LengthRequiredException - * @throws \OpenStack\Transport\UnprocessableEntityException - * @throws \OpenStack\Transport\ServerException - * @throws \OpenStack\Exception + * @throws \OpenStack\Common\Transport\Exception\ForbiddenException + * @throws \OpenStack\Common\Transport\Exception\UnauthorizedException + * @throws \OpenStack\Common\Transport\Exception\FileNotFoundException + * @throws \OpenStack\Common\Transport\Exception\MethodNotAllowedException + * @throws \OpenStack\Common\Transport\Exception\ConflictException + * @throws \OpenStack\Common\Transport\Exception\LengthRequiredException + * @throws \OpenStack\Common\Transport\Exception\UnprocessableEntityException + * @throws \OpenStack\Common\Transport\Exception\ServerException + * @throws \OpenStack\Common\Exception */ protected function handleException($exception) { @@ -183,29 +183,29 @@ class GuzzleClient implements ClientInterface, \Serializable switch ($code) { case '403': - throw new \OpenStack\Transport\ForbiddenException($response->getReasonPhrase()); + throw new \OpenStack\Common\Transport\Exception\ForbiddenException($response->getReasonPhrase()); case '401': - throw new \OpenStack\Transport\UnauthorizedException($response->getReasonPhrase()); + throw new \OpenStack\Common\Transport\Exception\UnauthorizedException($response->getReasonPhrase()); case '404': - throw new \OpenStack\Transport\FileNotFoundException($response->getReasonPhrase() . " ({$response->getEffectiveUrl()})"); + throw new \OpenStack\Common\Transport\Exception\FileNotFoundException($response->getReasonPhrase() . " ({$response->getEffectiveUrl()})"); 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': - throw new \OpenStack\Transport\ConflictException($response->getReasonPhrase()); + throw new \OpenStack\Common\Transport\Exception\ConflictException($response->getReasonPhrase()); case '412': - throw new \OpenStack\Transport\LengthRequiredException($response->getReasonPhrase()); + throw new \OpenStack\Common\Transport\Exception\LengthRequiredException($response->getReasonPhrase()); case '422': - throw new \OpenStack\Transport\UnprocessableEntityException($response->getReasonPhrase()); + throw new \OpenStack\Common\Transport\Exception\UnprocessableEntityException($response->getReasonPhrase()); case '500': - throw new \OpenStack\Transport\ServerException($response->getReasonPhrase()); + throw new \OpenStack\Common\Transport\Exception\ServerException($response->getReasonPhrase()); 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 // timeout occurred. else { - throw new \OpenStack\Exception($exception->getMessage()); + throw new \OpenStack\Common\Exception($exception->getMessage()); } return $response; diff --git a/src/OpenStack/Transport/ResponseInterface.php b/src/OpenStack/Common/Transport/ResponseInterface.php similarity index 99% rename from src/OpenStack/Transport/ResponseInterface.php rename to src/OpenStack/Common/Transport/ResponseInterface.php index 230f7a7..7cf061d 100644 --- a/src/OpenStack/Transport/ResponseInterface.php +++ b/src/OpenStack/Common/Transport/ResponseInterface.php @@ -18,7 +18,7 @@ * 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. diff --git a/src/OpenStack/Services/IdentityService.php b/src/OpenStack/Identity/v2/IdentityService.php similarity index 91% rename from src/OpenStack/Services/IdentityService.php rename to src/OpenStack/Identity/v2/IdentityService.php index 71ec79e..03cc973 100644 --- a/src/OpenStack/Services/IdentityService.php +++ b/src/OpenStack/Identity/v2/IdentityService.php @@ -18,9 +18,9 @@ * 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. @@ -80,7 +80,7 @@ use OpenStack\Transport\GuzzleClient; * 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 * information is sent in the HTTP headers rather than in the URL. The URL * 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); @@ -243,7 +243,7 @@ class IdentityService * the authenticate() method: * * array( * 'username' => $username, @@ -263,8 +263,8 @@ class IdentityService * response is used to populate this object's service catalog, etc. The * token is also retrievable with token(). * - * @throws \OpenStack\Transport\AuthorizationException If authentication failed. - * @throws \OpenStack\Exception For abnormal network conditions. The message + * @throws \OpenStack\Common\Transport\Exception\AuthorizationException If authentication failed. + * @throws \OpenStack\Common\Exception For abnormal network conditions. The message * will give an indication as to the underlying problem. */ public function authenticate(array $ops) @@ -315,9 +315,9 @@ class IdentityService * @param string $tenantName The tenant Name. This can be obtained through the * OpenStack console. * - * @throws \OpenStack\Transport\AuthorizationException If authentication failed. - * @throws \OpenStack\Exception For abnormal network conditions. The message - * will give an indication as to the underlying problem. + * @throws \OpenStack\Common\Transport\Exception\AuthorizationException If authentication failed. + * @throws \OpenStack\Common\Exception For abnormal network conditions. The message will give an + * indication as to the underlying problem. */ 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 * associative array containing tenant details. * - * @throws \OpenStack\Transport\AuthorizationException If authentication failed. - * @throws \OpenStack\Exception For abnormal network conditions. The message - * will give an indication as to the underlying problem. + * @throws \OpenStack\Common\Transport\Exception\AuthorizationException If authentication failed. + * @throws \OpenStack\Common\Exception For abnormal network conditions. The message will give an + * indication as to the underlying problem. */ public function tenants($token = null) { @@ -612,7 +612,7 @@ class IdentityService } /** - * @see \OpenStack\Services\IdentityService::rescopeUsingTenantId() + * @see \OpenStack\Identity\v2\IdentityService::rescopeUsingTenantId() * @deprecated */ public function rescope($tenantId) @@ -644,9 +644,9 @@ class IdentityService * * @return string The authentication token. * - * @throws \OpenStack\Transport\AuthorizationException If authentication failed. - * @throws \OpenStack\Exception For abnormal network conditions. The message will give an - * indication as to the underlying problem. + * @throws \OpenStack\Common\Transport\Exception\AuthorizationException If authentication failed. + * @throws \OpenStack\Common\Exception For abnormal network conditions. The message will give an + * indication as to the underlying problem. */ public function rescopeUsingTenantId($tenantId) { @@ -699,9 +699,9 @@ class IdentityService * * @return string The authentication token. * - * @throws \OpenStack\Transport\AuthorizationException If authentication failed. - * @throws \OpenStack\Exception For abnormal network conditions. The message will - * give an indication as to the underlying problem. + * @throws \OpenStack\Common\Transport\Exception\AuthorizationException If authentication failed. + * @throws \OpenStack\Common\Exception For abnormal network conditions. The message will + * give an indication as to the underlying problem. */ public function rescopeUsingTenantName($tenantName) { @@ -736,10 +736,10 @@ class IdentityService * This parses the JSON data and parcels out the data to the appropriate * 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 - * it can be used in chaining. + * @return \OpenStack\Identity\v2\IdentityService $this for the current object so + * it can be used in chaining. */ protected function handleResponse($response) { diff --git a/src/OpenStack/Storage/ObjectStorage/ContainerNotEmptyException.php b/src/OpenStack/ObjectStore/v1/Exception/ContainerNotEmptyException.php similarity index 89% rename from src/OpenStack/Storage/ObjectStorage/ContainerNotEmptyException.php rename to src/OpenStack/ObjectStore/v1/Exception/ContainerNotEmptyException.php index 6991ffb..f2e8c0d 100644 --- a/src/OpenStack/Storage/ObjectStorage/ContainerNotEmptyException.php +++ b/src/OpenStack/ObjectStore/v1/Exception/ContainerNotEmptyException.php @@ -18,7 +18,7 @@ * Contains exception class for ContainerNotEmptyException. */ -namespace OpenStack\Storage\ObjectStorage; +namespace OpenStack\ObjectStore\v1\Exception; /** * 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 * container when it requires an empty one. */ -class ContainerNotEmptyException extends \OpenStack\Transport\ServerException {} +class ContainerNotEmptyException extends \OpenStack\Common\Transport\Exception\ServerException {} diff --git a/src/OpenStack/Storage/ObjectStorage/ContentVerificationException.php b/src/OpenStack/ObjectStore/v1/Exception/ContentVerificationException.php similarity index 89% rename from src/OpenStack/Storage/ObjectStorage/ContentVerificationException.php rename to src/OpenStack/ObjectStore/v1/Exception/ContentVerificationException.php index da24032..c15aa60 100644 --- a/src/OpenStack/Storage/ObjectStorage/ContentVerificationException.php +++ b/src/OpenStack/ObjectStore/v1/Exception/ContentVerificationException.php @@ -17,7 +17,7 @@ /** * Contains the ContentVerificationException object. */ -namespace OpenStack\Storage\ObjectStorage; +namespace OpenStack\ObjectStore\v1\Exception; /** * Content Verification error condition. @@ -26,4 +26,4 @@ namespace OpenStack\Storage\ObjectStorage; * not match the supplied checksum. See * RemoteObject::setContentVerification(). */ -class ContentVerificationException extends \OpenStack\Exception {} +class ContentVerificationException extends \OpenStack\Common\Exception {} diff --git a/src/OpenStack/Storage/ObjectStorage/ReadOnlyObjectException.php b/src/OpenStack/ObjectStore/v1/Exception/ReadOnlyObjectException.php similarity index 88% rename from src/OpenStack/Storage/ObjectStorage/ReadOnlyObjectException.php rename to src/OpenStack/ObjectStore/v1/Exception/ReadOnlyObjectException.php index a15ebba..56a44c5 100644 --- a/src/OpenStack/Storage/ObjectStorage/ReadOnlyObjectException.php +++ b/src/OpenStack/ObjectStore/v1/Exception/ReadOnlyObjectException.php @@ -15,8 +15,8 @@ limitations under the License. ============================================================================ */ -namespace OpenStack\Storage\ObjectStorage; +namespace OpenStack\ObjectStore\v1\Exception; /** * Thrown if an object that is read only is modified. */ -class ReadOnlyObjectException extends \OpenStack\Exception {} +class ReadOnlyObjectException extends \OpenStack\Common\Exception {} diff --git a/src/OpenStack/Storage/ObjectStorage.php b/src/OpenStack/ObjectStore/v1/ObjectStorage.php similarity index 83% rename from src/OpenStack/Storage/ObjectStorage.php rename to src/OpenStack/ObjectStore/v1/ObjectStorage.php index bfb2a79..55296d2 100644 --- a/src/OpenStack/Storage/ObjectStorage.php +++ b/src/OpenStack/ObjectStore/v1/ObjectStorage.php @@ -23,11 +23,11 @@ * a text document, a binary). */ -namespace OpenStack\Storage; +namespace OpenStack\ObjectStore\v1; -use OpenStack\Storage\ObjectStorage\Container; -use OpenStack\Storage\ObjectStorage\ACL; -use OpenStack\Transport\GuzzleClient; +use OpenStack\ObjectStore\v1\Resource\Container; +use OpenStack\ObjectStore\v1\Resource\ACL; +use OpenStack\Common\Transport\GuzzleClient; /** * Access to ObjectStorage (Swift). @@ -46,8 +46,8 @@ use OpenStack\Transport\GuzzleClient; * mechanism for Swift. You can use ObjectStorage::newFromSwiftAuth() to * perform this type of authentication. * - * Newer versions use the IdentityServices authentication mechanism (@see - * \OpenStack\Services\IdentityServices). That method is the preferred + * Newer versions use the IdentityService authentication mechanism (@see + * \OpenStack\Identity\v2\IdentityService). That method is the preferred * method. * * Common Tasks @@ -58,7 +58,7 @@ use OpenStack\Transport\GuzzleClient; * * @todo ObjectStorage is not yet constrained to a particular version * 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 { @@ -91,7 +91,7 @@ class ObjectStorage * Create a new instance after getting an authenitcation token. * * 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. * * This uses the legacy Swift authentication facility to authenticate @@ -110,16 +110,14 @@ class ObjectStorage * @param string $key Your secret key. * @param string $url The URL to the object storage endpoint. * - * @throws \OpenStack\Transport\AuthorizationException if the - * authentication failed. - * @throws \OpenStack\Transport\FileNotFoundException if the URL is - * wrong. - * @throws \OpenStack\Exception if some other exception occurs. + * @throws \OpenStack\Common\Transport\Exception\AuthorizationException if the authentication failed. + * @throws \OpenStack\Common\Transport\Exception\FileNotFoundException if the URL is wrong. + * @throws \OpenStack\Common\Exception if some other exception occurs. * * @deprecated Newer versions of OpenStack use Keystone auth instead * 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( '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 - * 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 - * and a service catalog. + * @param \OpenStack\Identity\v2\IdentityService $identity An identity services object that already + * 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(); $tok = $identity->token(); @@ -171,20 +169,20 @@ class ObjectStorage /** * 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. * * This builder can scan the catalog and generate a new ObjectStorage * 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 * 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); for ($i = 0; $i < $c; ++$i) { @@ -214,7 +212,7 @@ class ObjectStorage * @param string $url The URL to the endpoint. This typically is returned * 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->url = $url; @@ -275,7 +273,7 @@ class ObjectStorage * @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 - * 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 * host puts them in). */ @@ -308,9 +306,10 @@ class ObjectStorage * * @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) { @@ -325,7 +324,7 @@ class ObjectStorage } // 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. * - * @throws \OpenStack\Exception If an unexpected network error occurs. + * @throws \OpenStack\Common\Exception If an unexpected network error occurs. */ public function hasContainer($name) { try { $container = $this->container($name); - } catch (\OpenStack\Transport\FileNotFoundException $fnfe) { + } catch (\OpenStack\Common\Transport\Exception\FileNotFoundException $fnfe) { return false; } @@ -397,14 +396,14 @@ class ObjectStorage * $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 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 * (private). To change this behavior, you can add a * 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 * container. * @@ -440,7 +439,7 @@ class ObjectStorage } // According to the OpenStack docs, there are no other return codes. 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.) * * @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(). * * @return boolean true if the cointainer was created, false otherwise. @@ -486,7 +485,7 @@ class ObjectStorage * the object storage. * * 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. * * @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 * 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 * that results in a non-standard code. */ @@ -506,13 +505,13 @@ class ObjectStorage try { $data = $this->req($url, 'DELETE', false); - } catch (\OpenStack\Transport\FileNotFoundException $e) { + } catch (\OpenStack\Common\Transport\Exception\FileNotFoundException $e) { return false; } // XXX: I'm not terribly sure about this. Why not just throw the // ConflictException? - catch (\OpenStack\Transport\ConflictException $e) { - throw new ObjectStorage\ContainerNotEmptyException("Non-empty container cannot be deleted."); + catch (\OpenStack\Common\Transport\Exception\ConflictException $e) { + throw new Exception\ContainerNotEmptyException("Non-empty container cannot be deleted."); } $status = $data->getStatusCode(); @@ -524,7 +523,7 @@ class ObjectStorage // OpenStacks documentation doesn't suggest any other return // codes. 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. * - 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() { diff --git a/src/OpenStack/Storage/ObjectStorage/ACL.php b/src/OpenStack/ObjectStore/v1/Resource/ACL.php similarity index 93% rename from src/OpenStack/Storage/ObjectStorage/ACL.php rename to src/OpenStack/ObjectStore/v1/Resource/ACL.php index ac6ada8..ddbd502 100644 --- a/src/OpenStack/Storage/ObjectStorage/ACL.php +++ b/src/OpenStack/ObjectStore/v1/Resource/ACL.php @@ -18,7 +18,7 @@ * Contains the class for manipulating ObjectStorage ACL strings. */ -namespace OpenStack\Storage\ObjectStorage; +namespace OpenStack\ObjectStore\v1\Resource; /** * Access control list for object storage. @@ -137,8 +137,8 @@ class ACL * * - READ to any host, with container listings. * - * @return \OpenStack\Storage\ObjectStorage\ACL an ACL object with the - * appopriate permissions set. + * @return \OpenStack\ObjectStore\v1\Resource\ACL an ACL object with the + * appopriate permissions set. */ public static function makePublic() { @@ -158,8 +158,8 @@ class ACL * This does not grant any permissions. OpenStack interprets an object * with no permissions as a private object. * - * @return \OpenStack\Storage\ObjectStorage\ACL an ACL object with the - * appopriate permissions set. + * @return \OpenStack\ObjectStore\v1\Resource\ACL an ACL object with the + * appopriate permissions set. */ public static function makeNonPublic() { @@ -183,7 +183,7 @@ class ACL * * @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) { @@ -302,8 +302,8 @@ class ACL * @param mixed $user The name of the user, or optionally an indexed array of * user names. * - * @return \OpenStack\Storage\ObjectStorage\ACL $this for current object so - * the method can be used in chaining. + * @return \OpenStack\ObjectStore\v1\Resource\ACL $this for current object so + * the method can be used in chaining. */ public function addAccount($perm, $account, $user = null) { @@ -338,8 +338,8 @@ class ACL * ACL::WRITE, or ACL::READ_WRITE. * @param string $host A host specification string as described above. * - * @return \OpenStack\Storage\ObjectStorage\ACL $this for current object so - * the method can be used in chaining. + * @return \OpenStack\ObjectStore\v1\Resource\ACL $this for current object so + * the method can be used in chaining. */ public function addReferrer($perm, $host = '*') { @@ -354,8 +354,8 @@ class ACL * @param int $perm One of the predefined permission constants. * @param array $rule A rule array. * - * @return \OpenStack\Storage\ObjectStorage\ACL $this for current object so - * the method can be used in chaining. + * @return \OpenStack\ObjectStore\v1\Resource\ACL $this for current object so + * the method can be used in chaining. */ protected function addRule($perm, $rule) { @@ -377,8 +377,8 @@ class ACL * In the current Swift implementation, there is no mechanism for * allowing some hosts to get listings, while denying others. * - * @return \OpenStack\Storage\ObjectStorage\ACL $this for current object so - * the method can be used in chaining. + * @return \OpenStack\ObjectStore\v1\Resource\ACL $this for current object so + * the method can be used in chaining. */ public function allowListings() { diff --git a/src/OpenStack/Storage/ObjectStorage/Container.php b/src/OpenStack/ObjectStore/v1/Resource/Container.php similarity index 89% rename from src/OpenStack/Storage/ObjectStorage/Container.php rename to src/OpenStack/ObjectStore/v1/Resource/Container.php index af172c1..296ec4b 100644 --- a/src/OpenStack/Storage/ObjectStorage/Container.php +++ b/src/OpenStack/ObjectStore/v1/Resource/Container.php @@ -18,9 +18,9 @@ * 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. @@ -38,9 +38,9 @@ use OpenStack\Transport\GuzzleClient; * ObjectStorage::containers(). * * bytes = $response->getHeader('X-Container-Bytes-Used', 0); @@ -305,9 +305,9 @@ class Container implements \Countable, \IteratorAggregate * @param string $name The name. * @param string $url The full URL to the container. * @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->url = $url; @@ -390,8 +390,8 @@ class Container implements \Countable, \IteratorAggregate * more than 256. UTF-8 or ASCII characters are allowed, though ASCII * seems to be preferred. * - * @return \OpenStack\Storage\ObjectStorage\Container $this so the method can - * be used in chaining. + * @return \OpenStack\ObjectStore\v1\Resource\Container $this so the method can + * be used in chaining. */ public function setMetadata($metadata) { @@ -424,34 +424,36 @@ class Container implements \Countable, \IteratorAggregate /** * 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 * 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. * @param resource $file An optional file argument that, if set, will be * treated as the contents of the object. * * @return boolean true if the object was saved. * - * @throws \OpenStack\Transport\LengthRequiredException if the Content-Length could not be determined and - * chunked encoding was not enabled. This should not occur - * for this class, which always automatically generates - * Content-Length headers. However, subclasses could - * generate this error. - * @throws \OpenStack\Transport\UnprocessableEntityException if the checksum passed here does not match the checksum - * calculated remotely. - * @throws \OpenStack\Exception when an unexpected (usually network-related) error - * condition arises. + * @throws \OpenStack\Common\Transport\Exception\LengthRequiredException if the Content-Length could not be + * determined and chunked encoding was + * not enabled. This should not occur for + * this class, which always automatically + * generates Content-Length headers. + * However, subclasses could generate + * this error. + * @throws \OpenStack\Common\Transport\Exception\UnprocessableEntityException if the checksum passed here does not + * 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) { 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)) { - 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()); @@ -527,7 +529,7 @@ class Container implements \Countable, \IteratorAggregate } 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; @@ -544,11 +546,12 @@ class Container implements \Countable, \IteratorAggregate * particularly in cases where custom headers have been set. * 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. * - * @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) { @@ -572,7 +575,7 @@ class Container implements \Countable, \IteratorAggregate $response = $this->client->doRequest($url, 'POST', $headers, $obj->content()); 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; @@ -590,7 +593,7 @@ class Container implements \Countable, \IteratorAggregate * Note that there is no MOVE operation. You must copy and then DELETE * 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 * the object is not sent. Instead, the copy operation is performed on the * 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()); 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. @@ -626,7 +629,7 @@ class Container implements \Countable, \IteratorAggregate $response = $this->client->doRequest($sourceUrl, 'COPY', $headers); 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; @@ -653,7 +656,7 @@ class Container implements \Countable, \IteratorAggregate * * @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) { @@ -666,7 +669,7 @@ class Container implements \Countable, \IteratorAggregate $response = $this->client->doRequest($url, 'GET', $headers); 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); @@ -701,7 +704,7 @@ class Container implements \Countable, \IteratorAggregate * * @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) { @@ -713,7 +716,7 @@ class Container implements \Countable, \IteratorAggregate $response = $this->client->doRequest($url, 'HEAD', $headers); 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()); @@ -902,7 +905,7 @@ class Container implements \Countable, \IteratorAggregate * * @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() { @@ -919,7 +922,7 @@ class Container implements \Countable, \IteratorAggregate * Not all containers come fully instantiated. This method is sometimes * called to "fill in" missing fields. * - * @return \OpenStack\Storage\ObjectStorage\Container + * @return \OpenStack\ObjectStore\v1\Resource\Container */ protected function loadExtraData() { @@ -928,7 +931,7 @@ class Container implements \Countable, \IteratorAggregate // created with Container::createContainer(). We treat // this as an error condition. 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. $headers = array( @@ -979,7 +982,7 @@ class Container implements \Countable, \IteratorAggregate // The only codes that should be returned are 200 and the ones // already thrown by doRequest. 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(); @@ -990,7 +993,7 @@ class Container implements \Countable, \IteratorAggregate if (!empty($item['subdir'])) { $list[] = new Subdir($item['subdir'], $params['delimiter']); } elseif (empty($item['name'])) { - throw new \OpenStack\Exception('Unexpected entity returned.'); + throw new \OpenStack\Common\Exception('Unexpected entity returned.'); } else { //$url = $this->url . '/' . rawurlencode($item['name']); $url = self::objectUrl($this->url, $item['name']); @@ -1048,12 +1051,12 @@ class Container implements \Countable, \IteratorAggregate try { $response = $this->client->doRequest($url, 'DELETE', $headers); - } catch (\OpenStack\Transport\FileNotFoundException $fnfe) { + } catch (\OpenStack\Common\Transport\Exception\FileNotFoundException $fnfe) { return false; } 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; diff --git a/src/OpenStack/Storage/ObjectStorage/Object.php b/src/OpenStack/ObjectStore/v1/Resource/Object.php similarity index 91% rename from src/OpenStack/Storage/ObjectStorage/Object.php rename to src/OpenStack/ObjectStore/v1/Resource/Object.php index 5843181..3d8fdb7 100644 --- a/src/OpenStack/Storage/ObjectStorage/Object.php +++ b/src/OpenStack/ObjectStore/v1/Resource/Object.php @@ -18,7 +18,7 @@ * Contains the class Object for ObjectStorage. */ -namespace OpenStack\Storage\ObjectStorage; +namespace OpenStack\ObjectStore\v1\Resource; /** * An object for ObjectStorage. @@ -140,8 +140,8 @@ class Object * * @param array $array An associative array of metadata names to values. * - * @return \OpenStack\Storage\ObjectStorage\Object $this so the method can be - * used in chaining. + * @return \OpenStack\ObjectStore\v1\Resource\Object $this so the method can be + * used in chaining. */ public function setMetadata(array $array) { @@ -171,12 +171,12 @@ class Object * object store. * * 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. * - * @return \OpenStack\Storage\ObjectStorage\Object $this so the method can be - * used in chaining. + * @return \OpenStack\ObjectStore\v1\Resource\Object $this so the method can be + * used in chaining. */ public function setName($name) { @@ -222,8 +222,8 @@ class Object * * @param string $type A valid content type. * - * @return \OpenStack\Storage\ObjectStorage\Object $this so the method can be - * used in chaining. + * @return \OpenStack\ObjectStore\v1\Resource\Object $this so the method can be + * used in chaining. */ public function setContentType($type) { @@ -263,8 +263,8 @@ class Object * @param string $type The content type (MIME type). This can be set here for * convenience, or you can call setContentType() directly. * - * @return \OpenStack\Storage\ObjectStorage\Object $this so the method can be - * used in chaining. + * @return \OpenStack\ObjectStore\v1\Resource\Object $this so the method can be + * used in chaining. */ public function setContent($content, $type = null) { @@ -354,8 +354,8 @@ class Object * * @param string $encoding A valid encoding type. * - * @return \OpenStack\Storage\ObjectStorage\Object $this so the method can be - * used in chaining. + * @return \OpenStack\ObjectStore\v1\Resource\Object $this so the method can be + * used in chaining. */ public function setEncoding($encoding) { @@ -396,8 +396,8 @@ class Object * @param string $disposition A valid disposition declaration. These are * defined in various HTTP specifications. * - * @return \OpenStack\Storage\ObjectStorage\Object $this so the method can be - * used in chaining. + * @return \OpenStack\ObjectStore\v1\Resource\Object $this so the method can be + * used in chaining. */ public function setDisposition($disposition) { @@ -451,8 +451,8 @@ class Object * header name, and each value is the HTTP header value. No encoding or * escaping is done. * - * @return \OpenStack\Storage\ObjectStorage\Object $this so the method can be - * used in chaining. + * @return \OpenStack\ObjectStore\v1\Resource\Object $this so the method can be + * used in chaining. */ public function setAdditionalHeaders($headers) { @@ -486,8 +486,8 @@ class Object * * @param array $keys The header names to be removed. * - * @return \OpenStack\Storage\ObjectStorage\Object $this for the current - * object so it can be used in chaining methods. + * @return \OpenStack\ObjectStore\v1\Resource\Object $this for the current + * object so it can be used in chaining methods. */ public function removeHeaders($keys) { diff --git a/src/OpenStack/Storage/ObjectStorage/RemoteObject.php b/src/OpenStack/ObjectStore/v1/Resource/RemoteObject.php similarity index 90% rename from src/OpenStack/Storage/ObjectStorage/RemoteObject.php rename to src/OpenStack/ObjectStore/v1/Resource/RemoteObject.php index beb4d89..2ea8830 100644 --- a/src/OpenStack/Storage/ObjectStorage/RemoteObject.php +++ b/src/OpenStack/ObjectStore/v1/Resource/RemoteObject.php @@ -18,16 +18,17 @@ * 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 remote object is one whose canonical copy is stored in a remote * 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 * 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 * will not result in those modifications being stored on the remote * 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 * 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 string $token The authentication token. * @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->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 * 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); @@ -163,7 +164,7 @@ class RemoteObject extends Object * * @param OpenStackTransportClientInterface $client The HTTP Client */ - public function setClient(\OpenStack\Transport\ClientInterface $client) + public function setClient(\OpenStack\Common\Transport\ClientInterface $client) { $this->client = $client; } @@ -225,7 +226,7 @@ class RemoteObject extends Object /** * 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. */ public function setHeaders($headers) @@ -282,7 +283,7 @@ class RemoteObject extends Object /** * 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. */ public function filterHeaders(&$headers) @@ -317,7 +318,7 @@ class RemoteObject extends Object * * @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. */ public function removeHeaders($keys) @@ -347,10 +348,10 @@ class RemoteObject extends Object * * @return string The contents of the file as a string. * - * @throws \OpenStack\Transport\FileNotFoundException when the requested content cannot be located on the remote - * server. - * @throws \OpenStack\Exception when an unknown exception (usually an abnormal network - * condition) occurs. + * @throws \OpenStack\Common\Transport\Exception\FileNotFoundException when the requested content cannot be + * located on the remote server. + * @throws \OpenStack\Common\Exception when an unknown exception (usually an + * abnormal network condition) occurs. */ public function content() { @@ -466,7 +467,7 @@ class RemoteObject extends Object * @param boolean $enabled If this is true, caching will be enabled. If this * 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) { @@ -511,7 +512,7 @@ class RemoteObject extends Object * server-supplied MD5 hashcode. If this is false, * 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) { @@ -588,8 +589,8 @@ class RemoteObject extends Object * @param boolean $fetchContent If this is true, the content will be * downloaded as well. * - * @return \OpenStack\Storage\ObjectStorage\RemoteObject $this for the current object so it can be used in chaining - * methods. + * @return \OpenStack\ObjectStore\v1\Resource\RemoteObject $this for the current object so it + * can be used in chaining methods. */ public function refresh($fetchContent = false) { @@ -616,8 +617,8 @@ class RemoteObject extends Object * is set to false, a HEAD request is sent, and * no body is returned. * - * @return \OpenStack\Transport\Response containing the object metadata and (depending on the $fetchContent flag) - * optionally the data. + * @return \OpenStack\Common\Transport\Response containing the object metadata and (depending + * on the $fetchContent flag) optionally the data. */ protected function fetchObject($fetchContent = false) { @@ -630,7 +631,7 @@ class RemoteObject extends Object $response = $this->client->doRequest($this->url, $method, $headers); 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); @@ -643,8 +644,8 @@ class RemoteObject extends Object * * 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 - * methods. + * @return \OpenStack\ObjectStore\v1\Resource\RemoteObject $this for the current object so it + * can be used in chaining methods. */ protected function extractFromHeaders($response) { diff --git a/src/OpenStack/Storage/ObjectStorage/StreamWrapper.php b/src/OpenStack/ObjectStore/v1/Resource/StreamWrapper.php similarity index 95% rename from src/OpenStack/Storage/ObjectStorage/StreamWrapper.php rename to src/OpenStack/ObjectStore/v1/Resource/StreamWrapper.php index cda96d5..67c5138 100644 --- a/src/OpenStack/Storage/ObjectStorage/StreamWrapper.php +++ b/src/OpenStack/ObjectStore/v1/Resource/StreamWrapper.php @@ -18,10 +18,10 @@ * Contains the stream wrapper for `swift://` URLs. */ -namespace OpenStack\Storage\ObjectStorage; +namespace OpenStack\ObjectStore\v1\Resource; use \OpenStack\Bootstrap; -use \OpenStack\Storage\ObjectStorage; +use \OpenStack\ObjectStore\v1\ObjectStorage; /** * 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 * 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. * * SUPPORTED CONTEXT PARAMETERS @@ -397,7 +397,7 @@ class StreamWrapper $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); return false; @@ -438,7 +438,7 @@ class StreamWrapper $curr = $this->dirListing[$this->dirIndex]; $this->dirIndex++; - if ($curr instanceof \OpenStack\Storage\ObjectStorage\Subdir) { + if ($curr instanceof \OpenStack\ObjectStore\v1\Resource\Subdir) { $fullpath = $curr->path(); } else { $fullpath = $curr->name(); @@ -548,7 +548,7 @@ class StreamWrapper if ($ret) { 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); return false; @@ -599,7 +599,7 @@ class StreamWrapper { try { $this->writeRemote(); - } catch (\OpenStack\Exception $e) { + } catch (\OpenStack\Common\Exception $e) { trigger_error('Error while closing: ' . $e->getMessage(), E_USER_NOTICE); return false; @@ -639,7 +639,7 @@ class StreamWrapper { try { $this->writeRemote(); - } catch (\OpenStack\Exception $e) { + } catch (\OpenStack\Common\Exception $e) { syslog(LOG_WARNING, $e); trigger_error('Error while flushing: ' . $e->getMessage(), E_USER_NOTICE); @@ -782,7 +782,7 @@ class StreamWrapper try { $this->initializeObjectStorage(); - } catch (\OpenStack\Exception $e) { + } catch (\OpenStack\Common\Exception $e) { trigger_error('Failed to init object storage: ' . $e->getMessage(), E_USER_WARNING); return false; @@ -796,7 +796,7 @@ class StreamWrapper // server roundtrip? try { $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); return false; @@ -845,7 +845,7 @@ class StreamWrapper // If a 404 is thrown, we need to determine whether // 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. if ($this->createIfNotFound) { @@ -861,7 +861,7 @@ class StreamWrapper } // All other exceptions are fatal. - catch (\OpenStack\Exception $e) { + catch (\OpenStack\Common\Exception $e) { //if ($this->triggerErrors) { trigger_error('Failed to fetch object: ' . $e->getMessage(), E_USER_WARNING); //} @@ -1048,10 +1048,10 @@ class StreamWrapper $token = $this->store->token(); $endpoint_url = $this->store->url() . '/' . rawurlencode($name); $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']); - } catch (\OpenStack\Exception $e) { + } catch (\OpenStack\Common\Exception $e) { trigger_error('Error during unlink: ' . $e->getMessage(), E_USER_WARNING); return false; @@ -1085,9 +1085,9 @@ class StreamWrapper $token = $this->store->token(); $endpoint_url = $this->store->url() . '/' . rawurlencode($name); $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']); - } catch (\OpenStack\Exception $e) { + } catch (\OpenStack\Common\Exception $e) { // Apparently file_exists does not set STREAM_URL_STAT_QUIET. //if ($flags & STREAM_URL_STAT_QUIET) { //trigger_error('Could not stat remote file: ' . $e->getMessage(), E_USER_WARNING); @@ -1098,7 +1098,7 @@ class StreamWrapper if ($flags & STREAM_URL_STAT_QUIET) { try { return @$this->generateStat($obj, $container, $obj->contentLength()); - } catch (\OpenStack\Exception $e) { + } catch (\OpenStack\Common\Exception $e) { return false; } } @@ -1110,7 +1110,7 @@ class StreamWrapper * Get the Object. * * 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. * * Accessing the object's payload (Object::content()) is strongly @@ -1213,7 +1213,7 @@ class StreamWrapper $gid = 0; } - if ($object instanceof \OpenStack\Storage\ObjectStorage\RemoteObject) { + if ($object instanceof \OpenStack\ObjectStore\v1\Resource\RemoteObject) { $modTime = $object->lastModified(); } else { $modTime = 0; @@ -1250,7 +1250,7 @@ class StreamWrapper * * @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. */ protected function setMode($mode) @@ -1450,13 +1450,13 @@ class StreamWrapper // FIXME: If a token is invalidated, we should try to re-authenticate. // If context has the info we need, start from there. 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. 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)) { - 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. else { @@ -1467,13 +1467,13 @@ class StreamWrapper $serviceCatalog = $ident->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); 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\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.' . print_r($catalog, true)); + throw new \OpenStack\Common\Exception('No object storage services could be found for this tenant ID.'); } $serviceURL = $catalog[0]['endpoints'][0]['publicURL']; @@ -1496,14 +1496,14 @@ class StreamWrapper $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 if (!empty($username) && !empty($password)) { $token = $ident->authenticateAsUser($username, $password, $tenantId, $tenantName); } else { - throw new \OpenStack\Exception('Username/password must be provided.'); + throw new \OpenStack\Common\Exception('Username/password must be provided.'); } // Cache the service catalog. self::$serviceCatalogCache[$token] = $ident->serviceCatalog(); diff --git a/src/OpenStack/Storage/ObjectStorage/StreamWrapperFS.php b/src/OpenStack/ObjectStore/v1/Resource/StreamWrapperFS.php similarity index 96% rename from src/OpenStack/Storage/ObjectStorage/StreamWrapperFS.php rename to src/OpenStack/ObjectStore/v1/Resource/StreamWrapperFS.php index a6278c6..ed930ad 100644 --- a/src/OpenStack/Storage/ObjectStorage/StreamWrapperFS.php +++ b/src/OpenStack/ObjectStore/v1/Resource/StreamWrapperFS.php @@ -19,7 +19,7 @@ * * 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 * 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 @@ -32,7 +32,7 @@ * Hence the protocol is swiftfs standing for swift file system. * * 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 * @@ -58,10 +58,10 @@ * false. */ -namespace OpenStack\Storage\ObjectStorage; +namespace OpenStack\ObjectStore\v1\Resource; use \OpenStack\Bootstrap; -use \OpenStack\Storage\ObjectStorage; +use \OpenStack\ObjectStore\v1\ObjectStorage; /** * Provides stream wrapping for Swift like a file system. @@ -169,7 +169,7 @@ class StreamWrapperFS extends StreamWrapper $dirListing = $container->objectsWithPrefix($this->dirPrefix, $sep); return !empty($dirListing); - } catch (\OpenStack\Exception $e) { + } catch (\OpenStack\Common\Exception $e) { trigger_error('Path could not be opened: ' . $e->getMessage(), E_USER_WARNING); return false; diff --git a/src/OpenStack/Storage/ObjectStorage/Subdir.php b/src/OpenStack/ObjectStore/v1/Resource/Subdir.php similarity index 97% rename from src/OpenStack/Storage/ObjectStorage/Subdir.php rename to src/OpenStack/ObjectStore/v1/Resource/Subdir.php index bb210b7..63c2439 100644 --- a/src/OpenStack/Storage/ObjectStorage/Subdir.php +++ b/src/OpenStack/ObjectStore/v1/Resource/Subdir.php @@ -18,7 +18,7 @@ * Contains the Subdir class. */ -namespace OpenStack\Storage\ObjectStorage; +namespace OpenStack\ObjectStore\v1\Resource; /** * Represent a subdirectory (subdir) entry. diff --git a/test/AuthTest.php b/tests/AuthTest.php similarity index 92% rename from test/AuthTest.php rename to tests/AuthTest.php index 0a7f90e..4d9b849 100644 --- a/test/AuthTest.php +++ b/tests/AuthTest.php @@ -17,17 +17,17 @@ /** * 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__); require_once $base . '/src/OpenStack/Autoloader.php'; -use \OpenStack\Storage\ObjectStorage; -use \OpenStack\Services\IdentityService; +use \OpenStack\ObjectStore\v1\ObjectStorage; +use \OpenStack\Identity\v2\IdentityService; $config = array( - 'transport' => '\OpenStack\Transport\PHPStreamTransport', + 'transport' => '\OpenStack\Common\Transport\GuzzleClient', 'transport.timeout' => 240, //'transport.debug' => 1, 'transport.ssl.verify' => 0, diff --git a/test/README.md b/tests/README.md similarity index 93% rename from test/README.md rename to tests/README.md index f06589f..fb011af 100644 --- a/test/README.md +++ b/tests/README.md @@ -22,11 +22,11 @@ verify that your PHP client can successfully connect to OpenStack. To run this test, do the following: 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: ``` -$ php test/AuthTest.php +$ php tests/AuthTest.php ``` 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: ``` -$ 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 then make the necessary changes: - $ cd test/ + $ cd tests/ $ cp example.settings.ini settings.ini $ edit settings.ini diff --git a/test/Tests/AutoloaderTest.php b/tests/Tests/AutoloaderTest.php similarity index 86% rename from test/Tests/AutoloaderTest.php rename to tests/Tests/AutoloaderTest.php index 9cf1353..df01dfe 100644 --- a/test/Tests/AutoloaderTest.php +++ b/tests/Tests/AutoloaderTest.php @@ -19,10 +19,10 @@ */ 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. @@ -41,8 +41,8 @@ class AutoloaderTest extends \OpenStack\Tests\TestCase \OpenStack\Autoloader::useAutoloader(); // 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); } } diff --git a/test/Tests/BootstrapTest.php b/tests/Tests/BootstrapTest.php similarity index 91% rename from test/Tests/BootstrapTest.php rename to tests/Tests/BootstrapTest.php index 65ffd31..b13609d 100644 --- a/test/Tests/BootstrapTest.php +++ b/tests/Tests/BootstrapTest.php @@ -19,9 +19,7 @@ */ namespace OpenStack\Tests; -require_once 'test/TestCase.php'; - -class BootstrapTest extends \OpenStack\Tests\TestCase +class BootstrapTest extends TestCase { /** * Canary test. diff --git a/test/Tests/GuzzleClientTest.php b/tests/Tests/Common/Transport/GuzzleClientTest.php similarity index 89% rename from test/Tests/GuzzleClientTest.php rename to tests/Tests/Common/Transport/GuzzleClientTest.php index 92ca175..38f597e 100644 --- a/test/Tests/GuzzleClientTest.php +++ b/tests/Tests/Common/Transport/GuzzleClientTest.php @@ -15,11 +15,9 @@ limitations under the License. ============================================================================ */ -namespace OpenStack\Tests; +namespace OpenStack\Tests\Common\Transport; -use OpenStack\Transport\GuzzleClient; - -require_once 'test/TestCase.php'; +use OpenStack\Common\Transport\GuzzleClient; class GuzzleClientTest extends \OpenStack\Tests\TestCase { @@ -52,7 +50,7 @@ class GuzzleClientTest extends \OpenStack\Tests\TestCase $client = $this->buildClient(); - $this->assertInstanceOf('\OpenStack\Transport\GuzzleClient', $client); + $this->assertInstanceOf('\OpenStack\Common\Transport\GuzzleClient', $client); $response = $client->doRequest($url, $method); $this->assertInstanceOf('\GuzzleHttp\Message\Response', $response); @@ -61,7 +59,7 @@ class GuzzleClientTest extends \OpenStack\Tests\TestCase /** * @depends testDoRequest - * @expectedException \OpenStack\Transport\FileNotFoundException + * @expectedException \OpenStack\Common\Transport\Exception\FileNotFoundException */ public function testDoRequestException() { diff --git a/test/Tests/IdentityServicesTest.php b/tests/Tests/Identity/v2/IdentityServicesTest.php similarity index 97% rename from test/Tests/IdentityServicesTest.php rename to tests/Tests/Identity/v2/IdentityServicesTest.php index 3eb21c8..781c8e8 100644 --- a/test/Tests/IdentityServicesTest.php +++ b/tests/Tests/Identity/v2/IdentityServicesTest.php @@ -17,11 +17,9 @@ /** * Unit tests for IdentityService. */ -namespace OpenStack\Tests\Services; +namespace OpenStack\Tests\Identity\v2; -require_once 'test/TestCase.php'; - -use \OpenStack\Services\IdentityService; +use \OpenStack\Identity\v2\IdentityService; use \OpenStack\Bootstrap; class IdentityServicesTest extends \OpenStack\Tests\TestCase @@ -33,7 +31,7 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase $service = new IdentityService($endpoint, $this->getTransportClient()); - $this->assertInstanceOf('\OpenStack\Services\IdentityService', $service); + $this->assertInstanceOf('\OpenStack\Identity\v2\IdentityService', $service); return $service; } @@ -279,7 +277,7 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase $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->serviceCatalog(), $again->serviceCatalog()); @@ -410,7 +408,7 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase Bootstrap::setConfiguration($settings); $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. $is2 = Bootstrap::identity(); @@ -441,6 +439,6 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase Bootstrap::setConfiguration($settings); $is = Bootstrap::identity(true); - $this->assertInstanceOf('\OpenStack\Services\IdentityService', $is); + $this->assertInstanceOf('\OpenStack\Identity\v2\IdentityService', $is); } } diff --git a/test/Tests/ACLTest.php b/tests/Tests/ObjectStore/v1/ACLTest.php similarity index 98% rename from test/Tests/ACLTest.php rename to tests/Tests/ObjectStore/v1/ACLTest.php index bb5b0c4..19d6e6f 100644 --- a/test/Tests/ACLTest.php +++ b/tests/Tests/ObjectStore/v1/ACLTest.php @@ -17,11 +17,9 @@ /** * Unit tests for ObjectStorage ACLs. */ -namespace OpenStack\Tests\Storage\ObjectStorage; +namespace OpenStack\Tests\ObjectStore\v1\Resource; -require_once 'test/TestCase.php'; - -use \OpenStack\Storage\ObjectStorage\ACL; +use \OpenStack\ObjectStore\v1\Resource\ACL; /** * @ingroup Tests */ diff --git a/test/Tests/ContainerTest.php b/tests/Tests/ObjectStore/v1/ContainerTest.php similarity index 95% rename from test/Tests/ContainerTest.php rename to tests/Tests/ObjectStore/v1/ContainerTest.php index 9ab3f8b..db54182 100644 --- a/test/Tests/ContainerTest.php +++ b/tests/Tests/ObjectStore/v1/ContainerTest.php @@ -17,13 +17,11 @@ /** * Unit tests for Containers. */ -namespace OpenStack\Tests\Storage\ObjectStorage; +namespace OpenStack\Tests\ObjectStore\v1\Resource; -require_once 'test/TestCase.php'; - -use \OpenStack\Storage\ObjectStorage\Container; -use \OpenStack\Storage\ObjectStorage\Object; -use \OpenStack\Storage\ObjectStorage\ACL; +use \OpenStack\ObjectStore\v1\Resource\Container; +use \OpenStack\ObjectStore\v1\Resource\Object; +use \OpenStack\ObjectStore\v1\Resource\ACL; 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() { @@ -189,8 +187,8 @@ class ContainerTest extends \OpenStack\Tests\TestCase // Make sure this throws a 404. try { $foo = $container->object('no/such'); - } catch (\OpenStack\Exception $e) { - $this->assertInstanceOf('\OpenStack\Transport\FileNotFoundException', $e); + } catch (\OpenStack\Common\Exception $e) { + $this->assertInstanceOf('\OpenStack\Common\Transport\Exception\FileNotFoundException', $e); } } @@ -260,7 +258,7 @@ class ContainerTest extends \OpenStack\Tests\TestCase $this->assertEquals(2, count($objects)); 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. @@ -437,7 +435,7 @@ class ContainerTest extends \OpenStack\Tests\TestCase $acl = $container->acl(); - $this->assertInstanceOf('\OpenStack\Storage\ObjectStorage\ACL', $acl); + $this->assertInstanceOf('\OpenStack\ObjectStore\v1\Resource\ACL', $acl); $this->assertTrue($acl->isPublic()); $store->deleteContainer($cname); diff --git a/test/Tests/ObjectStorageTest.php b/tests/Tests/ObjectStore/v1/ObjectStorageTest.php similarity index 83% rename from test/Tests/ObjectStorageTest.php rename to tests/Tests/ObjectStore/v1/ObjectStorageTest.php index 8a36463..45221f3 100644 --- a/test/Tests/ObjectStorageTest.php +++ b/tests/Tests/ObjectStore/v1/ObjectStorageTest.php @@ -17,12 +17,10 @@ /** * Unit tests for ObjectStorage. */ -namespace OpenStack\Tests\Storage; +namespace OpenStack\Tests\ObjectStore\v1\Resource; -require_once 'test/TestCase.php'; - -use \OpenStack\Storage\ObjectStorage\Object; -use \OpenStack\Storage\ObjectStorage\ACL; +use \OpenStack\ObjectStore\v1\Resource\Object; +use \OpenStack\ObjectStore\v1\Resource\ACL; class ObjectStorageTest extends \OpenStack\Tests\TestCase { @@ -42,7 +40,7 @@ class ObjectStorageTest extends \OpenStack\Tests\TestCase { $ostore = $this->swiftAuth(); - $this->assertInstanceOf('\OpenStack\Storage\ObjectStorage', $ostore); + $this->assertInstanceOf('\OpenStack\ObjectStore\v1\ObjectStorage', $ostore); $this->assertTrue(strlen($ostore->token()) > 0); } @@ -53,7 +51,7 @@ class ObjectStorageTest extends \OpenStack\Tests\TestCase { $ident = $this->identity(); - $services = $ident->serviceCatalog(\OpenStack\Storage\ObjectStorage::SERVICE_TYPE); + $services = $ident->serviceCatalog(\OpenStack\ObjectStore\v1\ObjectStorage::SERVICE_TYPE); if (empty($services)) { 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]['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); } @@ -74,8 +72,8 @@ class ObjectStorageTest extends \OpenStack\Tests\TestCase $ident = $this->identity(); $tok = $ident->token(); $cat = $ident->serviceCatalog(); - $ostore = \OpenStack\Storage\ObjectStorage::newFromServiceCatalog($cat, $tok, self::$settings['openstack.swift.region'], $this->getTransportClient()); - $this->assertInstanceOf('\OpenStack\Storage\ObjectStorage', $ostore); + $ostore = \OpenStack\ObjectStore\v1\ObjectStorage::newFromServiceCatalog($cat, $tok, self::$settings['openstack.swift.region'], $this->getTransportClient()); + $this->assertInstanceOf('\OpenStack\ObjectStore\v1\ObjectStorage', $ostore); $this->assertTrue(strlen($ostore->token()) > 0); } @@ -84,27 +82,27 @@ class ObjectStorageTest extends \OpenStack\Tests\TestCase $ident = $this->identity(); $tok = $ident->token(); $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); } public function testNewFromIdnetity() { $ident = $this->identity(); - $ostore = \OpenStack\Storage\ObjectStorage::newFromIdentity($ident, self::$settings['openstack.swift.region'], $this->getTransportClient()); - $this->assertInstanceOf('\OpenStack\Storage\ObjectStorage', $ostore); + $ostore = \OpenStack\ObjectStore\v1\ObjectStorage::newFromIdentity($ident, self::$settings['openstack.swift.region'], $this->getTransportClient()); + $this->assertInstanceOf('\OpenStack\ObjectStore\v1\ObjectStorage', $ostore); $this->assertTrue(strlen($ostore->token()) > 0); } public function testNewFromIdentityAltRegion() { $ident = $this->identity(); - $ostore = \OpenStack\Storage\ObjectStorage::newFromIdentity($ident, 'region-b.geo-1', $this->getTransportClient()); - $this->assertInstanceOf('\OpenStack\Storage\ObjectStorage', $ostore); + $ostore = \OpenStack\ObjectStore\v1\ObjectStorage::newFromIdentity($ident, 'region-b.geo-1', $this->getTransportClient()); + $this->assertInstanceOf('\OpenStack\ObjectStore\v1\ObjectStorage', $ostore); $this->assertTrue(strlen($ostore->token()) > 0); // 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); } @@ -168,7 +166,7 @@ class ObjectStorageTest extends \OpenStack\Tests\TestCase $this->assertEquals(0, $testContainer->count()); // 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() { @@ -300,7 +298,7 @@ class ObjectStorageTest extends \OpenStack\Tests\TestCase } $ret = $store->createContainer($testCollection); - $acl = \OpenStack\Storage\ObjectStorage\ACL::makePublic(); + $acl = \OpenStack\ObjectStore\v1\Resource\ACL::makePublic(); $ret = $store->changeContainerACL($testCollection, $acl); $this->assertFalse($ret); diff --git a/test/Tests/ObjectTest.php b/tests/Tests/ObjectStore/v1/ObjectTest.php similarity index 97% rename from test/Tests/ObjectTest.php rename to tests/Tests/ObjectStore/v1/ObjectTest.php index ef7e4d8..2c6868c 100644 --- a/test/Tests/ObjectTest.php +++ b/tests/Tests/ObjectStore/v1/ObjectTest.php @@ -17,11 +17,9 @@ /** * Unit tests for ObjectStorage Object. */ -namespace OpenStack\Tests\Storage; +namespace OpenStack\Tests\ObjectStore\v1\Resource; -require_once 'test/TestCase.php'; - -use \OpenStack\Storage\ObjectStorage\Object; +use \OpenStack\ObjectStore\v1\Resource\Object; class ObjectTest extends \OpenStack\Tests\TestCase { diff --git a/test/Tests/RemoteObjectTest.php b/tests/Tests/ObjectStore/v1/RemoteObjectTest.php similarity index 96% rename from test/Tests/RemoteObjectTest.php rename to tests/Tests/ObjectStore/v1/RemoteObjectTest.php index 61f7cc7..b83468a 100644 --- a/test/Tests/RemoteObjectTest.php +++ b/tests/Tests/ObjectStore/v1/RemoteObjectTest.php @@ -17,13 +17,11 @@ /** * Unit tests for ObjectStorage RemoteObject. */ -namespace OpenStack\Tests\Storage\ObjectStorage; +namespace OpenStack\Tests\ObjectStore\v1\Resource; -require_once 'test/TestCase.php'; - -use \OpenStack\Storage\ObjectStorage\RemoteObject; -use \OpenStack\Storage\ObjectStorage\Object; -use \OpenStack\Storage\ObjectStorage\Container; +use \OpenStack\ObjectStore\v1\Resource\RemoteObject; +use \OpenStack\ObjectStore\v1\Resource\Object; +use \OpenStack\ObjectStore\v1\Resource\Container; class RemoteObjectTest extends \OpenStack\Tests\TestCase { @@ -68,7 +66,7 @@ class RemoteObjectTest extends \OpenStack\Tests\TestCase $obj = $container->remoteObject(self::FNAME); - $this->assertInstanceOf('\OpenStack\Storage\ObjectStorage\RemoteObject', $obj); + $this->assertInstanceOf('\OpenStack\ObjectStore\v1\Resource\RemoteObject', $obj); return $obj; } diff --git a/test/Tests/StreamWrapperFSTest.php b/tests/Tests/ObjectStore/v1/StreamWrapperFSTest.php similarity index 96% rename from test/Tests/StreamWrapperFSTest.php rename to tests/Tests/ObjectStore/v1/StreamWrapperFSTest.php index 22809ce..1f23345 100644 --- a/test/Tests/StreamWrapperFSTest.php +++ b/tests/Tests/ObjectStore/v1/StreamWrapperFSTest.php @@ -17,13 +17,11 @@ /** * 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\Storage\ObjectStorage\StreamWrapperFS; -use \OpenStack\Storage\ObjectStorage\Container; -use \OpenStack\Storage\ObjectStorage\Object; +use \OpenStack\ObjectStore\v1\Resource\StreamWrapperFS; +use \OpenStack\ObjectStore\v1\Resource\Container; +use \OpenStack\ObjectStore\v1\Resource\Object; /** * @group streamWrapper @@ -47,12 +45,12 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase $tenantId = self::conf('openstack.identity.tenantId'); $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); // 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. $cname = self::$settings['openstack.swift.container']; @@ -61,7 +59,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase $container = $store->container($cname); } // The container was never created. - catch (\OpenStack\Transport\FileNotFoundException $e) { + catch (\OpenStack\Common\Transport\Exception\FileNotFoundException $e) { return; } @@ -196,7 +194,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase // Canary $this->assertNotEmpty(StreamWrapperFS::DEFAULT_SCHEME); - $klass = '\OpenStack\Storage\ObjectStorage\StreamWrapperFS'; + $klass = '\OpenStack\ObjectStore\v1\Resource\StreamWrapperFS'; stream_wrapper_register(StreamWrapperFS::DEFAULT_SCHEME, $klass); $wrappers = stream_get_wrappers(); @@ -389,7 +387,7 @@ class StreamWrapperFSTest extends \OpenStack\Tests\TestCase //throw new \Exception(print_r($md, true)); $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()); diff --git a/test/Tests/StreamWrapperTest.php b/tests/Tests/ObjectStore/v1/StreamWrapperTest.php similarity index 95% rename from test/Tests/StreamWrapperTest.php rename to tests/Tests/ObjectStore/v1/StreamWrapperTest.php index 07e4c7d..61c4422 100644 --- a/test/Tests/StreamWrapperTest.php +++ b/tests/Tests/ObjectStore/v1/StreamWrapperTest.php @@ -17,13 +17,11 @@ /** * Unit tests for the stream wrapper. */ -namespace OpenStack\Tests\Storage\ObjectStorage; +namespace OpenStack\Tests\ObjectStore\v1\Resource; -require_once 'test/TestCase.php'; - -use \OpenStack\Storage\ObjectStorage\StreamWrapper; -use \OpenStack\Storage\ObjectStorage\Container; -use \OpenStack\Storage\ObjectStorage\Object; +use \OpenStack\ObjectStore\v1\Resource\StreamWrapper; +use \OpenStack\ObjectStore\v1\Resource\Container; +use \OpenStack\ObjectStore\v1\Resource\Object; /** * @group streamWrapper @@ -44,12 +42,12 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase $tenantId = self::conf('openstack.identity.tenantId'); $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); // 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. $cname = self::$settings['openstack.swift.container']; @@ -58,7 +56,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase $container = $store->container($cname); } // The container was never created. - catch (\OpenStack\Transport\FileNotFoundException $e) { + catch (\OpenStack\Common\Transport\Exception\FileNotFoundException $e) { return; } @@ -190,7 +188,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase // Canary $this->assertNotEmpty(StreamWrapper::DEFAULT_SCHEME); - $klass = '\OpenStack\Storage\ObjectStorage\StreamWrapper'; + $klass = '\OpenStack\ObjectStore\v1\Resource\StreamWrapper'; stream_wrapper_register(StreamWrapper::DEFAULT_SCHEME, $klass); $wrappers = stream_get_wrappers(); @@ -388,7 +386,7 @@ class StreamWrapperTest extends \OpenStack\Tests\TestCase //throw new \Exception(print_r($md, true)); $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()); diff --git a/test/TestCase.php b/tests/Tests/TestCase.php similarity index 91% rename from test/TestCase.php rename to tests/Tests/TestCase.php index b2a085f..4cba420 100644 --- a/test/TestCase.php +++ b/tests/Tests/TestCase.php @@ -54,8 +54,8 @@ class TestCase extends \PHPUnit_Framework_TestCase self::$settings = $bootstrap_settings; //$this->setTestNamespace('Tests\Units'); - if (file_exists('test/settings.ini')) { - self::$settings += parse_ini_file('test/settings.ini'); + if (file_exists('tests/settings.ini')) { + self::$settings += parse_ini_file('tests/settings.ini'); } else { 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']; $url = self::$settings['openstack.swift.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'); $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); @@ -131,7 +131,7 @@ class TestCase extends \PHPUnit_Framework_TestCase if ($reset || empty(self::$ostore)) { $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; @@ -183,7 +183,7 @@ class TestCase extends \PHPUnit_Framework_TestCase $container = $store->container($cname); } // The container was never created. - catch (\OpenStack\Transport\FileNotFoundException $e) { + catch (\OpenStack\Common\Transport\Exception\FileNotFoundException $e) { return; } @@ -239,7 +239,7 @@ class TestCase extends \PHPUnit_Framework_TestCase $container = $store->container($cname); } // The container was never created. - catch (\OpenStack\Transport\FileNotFoundException $e) { + catch (\OpenStack\Common\Transport\Exception\FileNotFoundException $e) { return; } diff --git a/test/bootstrap_curl.php b/tests/bootstrap_curl.php similarity index 100% rename from test/bootstrap_curl.php rename to tests/bootstrap_curl.php diff --git a/test/bootstrap_phpstream.php b/tests/bootstrap_phpstream.php similarity index 100% rename from test/bootstrap_phpstream.php rename to tests/bootstrap_phpstream.php diff --git a/test/example.settings.ini b/tests/example.settings.ini similarity index 96% rename from test/example.settings.ini rename to tests/example.settings.ini index f53a305..27b87a3 100644 --- a/test/example.settings.ini +++ b/tests/example.settings.ini @@ -37,7 +37,7 @@ openstack.swift.region = "region-a.geo-1" ;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; 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 ; to pass through.